$(document).ready(function () {

    $('#footerArrowUp').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        return false;
    });

    $('#footerArrowLeft').click(function () {
        window.history.back();
    });

    $('#showProductPageInquiry').click(function (e) {
        e.preventDefault;
        $('#productPageInquiry').slideToggle(function () { });
    });

    setInterval("changeTravelSlider()", 6000);

    $(".postSearchForm").click(function (e) {
        e.preventDefault;
        $("#searchForm").submit();
    });

    $("#searchForm").submit(function () {
        if ($("#searchFormInput").val().length == 0 || $("#searchFormInput").val() == $("#searchFormInput").attr("orginalValue")) {
            $("#searchFormInput").val(" ");
        }
    });


    $("#searchOptionsContainer select").change(function () {
        var searchOptionTravelDate = $("#searchOptionTravelDate").val();
        var searchOptionTravelLength = $("#searchOptionTravelLength").val();
        var searchOptionTravelType = $("#searchOptionTravelType").val();
        var searchOptionTravelCategory = '.' + $("#searchOptionTravelCategory").val() + '|';
        if (searchOptionTravelCategory == '.|') {
            var searchOptionTravelCategory = '';
        }

        $(".searchResultProduct").each(function () {
            var t = $(this);
            var productDate = t.attr("searchResultTravelDate");
            var productType = t.attr("searchResultTravelType");
            var productLength = t.attr("searchResultTravelLength");
            var productCategory = t.attr("searchResultTravelCategory");

            if ((productCategory.indexOf(searchOptionTravelCategory) != -1 || searchOptionTravelCategory.length == 0) && (productDate == searchOptionTravelDate || searchOptionTravelDate.length == 0) && (productType == searchOptionTravelType || searchOptionTravelType.length == 0) && (productLength == searchOptionTravelLength || searchOptionTravelLength.length == 0)) {
                t.show();
            } else {
                t.hide();
            }
        });
    });


    var travelCalenderMonthNamePrevious = "";
    $(".travelCalenderMonthName").each(function () {
        if (!($(this).html() == travelCalenderMonthNamePrevious)) {
            $(this).show();
        }
        travelCalenderMonthNamePrevious = $(this).html();
    });


});
