﻿$(function () {
    chkSE_change();
    $("#accordion").accordion();
    //Hide (Collapse) the toggle containers on load
    $(".toggle_container").hide();
    $(".toggle_container:first").show();
    //   $(".singleUnitBox:first h2").addClass("active");
    $("h2.trigger:first").toggleClass("active");

    //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
    $("h2.trigger").click(function () {
        $(this).toggleClass("active").next().slideToggle("slow");
        return false; //Prevent the browser jump to the link anchor
    });
    // Deals Sliding
    /*$('#dealBox').hover(function(){
    $(".floatDetails", this).stop().animate({top:'0px'},{queue:false,duration:160});
    }, function() {
    $(".floatDetails", this).stop().animate({top:'260px'},{queue:false,duration:160});
    });*/

    $("#textExample").verticaltabs({ speed: 500, slideShow: false, activeIndex: 0 });
    /*$("#imageExample").verticaltabs({speed: 1000,slideShow: true,slideShowSpeed: 3000,activeIndex: 0,playPausePos: "topRight"});*/

    /*$("ul.tabs").tabs("div.panes > div,");*/
});

function showSearchPopup() {
    document.getElementById("searchPopup").style.display = "inline";
//    var point = document.getElementById("SearchPoint");
//    var top = point.style.top;
//    document.getElementById("searchPopup").style.top = 245;
//    document.getElementById("searchPopup").style.left = point.style.left;
    document.getElementById("searchPopup").style.display = "inline";
    document.getElementById("CountryPopup").focus();
    //            var p = $("#serch");
    //            var position = p.position();
    //            $('#searchPopup').css("left: " + position.left + ", top: " + position.top);
    //            $('#searchPopup').css({ 'display': 'inline' });

    //            var pos = $("#serch").offset();
    //            var width = $("#serch").width();
    //            //show the menu directly over the placeholder
    //            $("#searchPopup").css({ "left": (pos.left + width) + "px", "top": pos.top + "px" });
    //            $("#searchPopup").show();

    //$('#searchPopup').css({ 'top': '" + point.style.top +"' });
    //$('#searchPopup').css({ 'display': 'inline' });
}
function popupSelectDes(country, des, DesHe) {
    //   $('#searchPopup').css({ 'display': 'none' });
    document.getElementById("searchPopup").style.display = "none";
    document.getElementById("Country").value = country;
    document.getElementById("Destination").value = des;
    document.getElementById("DestinationHeb").value = DesHe;
}
function closeSEPopup() {
    document.getElementById("searchPopup").style.display = "none";
    document.getElementById("tbFromDate").focus();
}
function chkSE_change() {
    document.getElementById("Country").value = "";
    document.getElementById("Destination").value = "";
    document.getElementById("DestinationHeb").value = "";
    $.post('../../NetServices/GetDestinationsForDepartment.aspx',
            {
                Dep: 'ski'
            },
            function (data) {
                $("#popupDes").html(data);
            }
            );
    $.post('../../NetServices/GetCountrysForDepartment.aspx',
            {
                MainDep: 'ski'
            },
            function (data) {
                $("#divCountryPopup").html(data);
            }
            );
    $("#divDestinationPopup").html("<select ID='DestinationPopup' name='DestinationPopup' class='field' style='Width:130px;Height:20px;' dir='rtl' />");
}
function CountryPopup_change() {
    document.getElementById("DestinationHeb").value = "";
    document.getElementById("Destination").value = "";
    document.getElementById("Country").value = $("#CountryPopup").val();
    $.post('../../NetServices/GetDestinationCmb.aspx',
        {
            Dep: 'ski',
            Country: $("#CountryPopup").val()
        },
        function (data) {
            $("#divDestinationPopup").html(data);
        }
        );
}
function DestinationPopup_change() {
    document.getElementById("Destination").value = $("#DestinationPopup").val();
    var variable = $("#DestinationPopup");
    var actualText = variable.find(":selected").text();
    document.getElementById("DestinationHeb").value = actualText;
    document.getElementById("searchPopup").style.display = "none";
    document.getElementById("tbFromDate").focus();
}
function selectDesPopup() {
    if (document.getElementById("DestinationPopup").value == "") { alert("נא בחר יעד \n יעד - שדה חובה"); document.getElementById("DestinationPopup").focus(); return false; }
    DestinationPopup_change();
}
function showCalendarWin() {
    var chkSE = "SKI";
    var Des = document.getElementById("Destination").value;
    if (Des == "") { alert("נא הקלד יעד לנסיעה \n יעד שדה חובה"); return false; }
    $("#calendarPopup").css("display", "inline");
    var CalUrl = "http://www.netravel.co.il/lib/calendarNet/Calendar.aspx?Des=" + Des + "&flddepDate=frmSE.tbFromDate&CurDate=&fldReturnDate=frmSE.tbReturnDate&ReturnDate=&Dep=" + chkSE;
    var ifr = "<iframe id='ifrmCalendar' name='ifrmCalendar' src='" + CalUrl + "' width='500' height='260' frameborder='0' />"
    $("#frmCalendarPopup").append(ifr);

}
function closeCalendar() {
    $("#calendarPopup").css("display", "none");
    $("#frmCalendarPopup").empty();
}
function btnSubmit() {
    document.getElementById("tbFromDate").value = $("#ifrmCalendar").contents().find("#lblDepartureDate").text();
    document.getElementById("tbReturnDate").value = $("#ifrmCalendar").contents().find("#lblReturnDate").text();
    if (document.getElementById("Destination").value == "") {
        alert("נה בחר יעד"); document.getElementById("Destination").focus(); return false;
    }
    var link = "http://www.netravel.co.il/wait.aspx?dep=ski&Des=" + document.getElementById("Destination").value + "&Country=" + document.getElementById("Country").value + "&depDate=" + document.getElementById("tbFromDate").value + "&ReturnDate=" + document.getElementById("tbReturnDate").value;
    SearchWin = window.open(link, '_self');
}
function CheckData() {
    if ((document.getElementById("Destination").value == "") || (document.getElementById("Destination").value == "0")) {
        alert("אנא בחר יעד"); document.getElementById("Destination").focus(); return false;
    }
    var link = "http://www.netravel.co.il/wait.aspx?dep=ski&Des=" + document.getElementById("Destination").value + "&Country=" + document.getElementById("Country").value + "&depDate=" + document.getElementById("tbFromDate").value + "&ReturnDate=" + document.getElementById("tbReturnDate").value;
    SearchWin = window.open(link, "_self");
}
function testSelectSite() {
    var num = 0;
    if (document.getElementById("SkiSiteID1").value == "") {num = 1;}
    if (document.getElementById("SkiSiteID2").value == "") {num = num + 1;}
    if (document.getElementById("SkiSiteID3").value == "") {num = num + 1;}
    if (num > 1) {alert("נא בחר אתר להשווה");return false;}
}
