﻿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: 'flight'
            },
            function (data) {
                $("#popupDes").html(data);
            }
            );
    $.post('../../NetServices/GetCountrysForDepartment.aspx',
            {
                MainDep: 'flight'
            },
            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: 'flight',
                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 = "flight";
    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=flight&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 Dep ="flight"// document.getElementById("DepartmentID").value;
    //	if(Dep=="0"){Dep="";}
    //	var link ="../../flight/?Des=" + document.getElementById("Destination").value + "&Country=" + document.getElementById("Country").value + "&DepID=" + Dep
    //    link = link + "&depDate=" + document.getElementById("tbFromDate").value + "&ReturnDate=" + document.getElementById("tbReturnDate").value;
    var link = "http://www.netravel.co.il/wait.aspx?dep=flight&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");
}

