 
// Banner cycle
var bannerCounter = 0;
var cycleBanners_timeout;
var waitBanner_clicked = false;
var bannerCycle_linx = []; 
var bannerCycle_obj = [];
var bannerCycle_imgs = new Array('../images/Interactive_banner01.jpg', '../images/Interactive_banner02.jpg', '../images/Interactive_banner03.jpg', '../images/Interactive_banner04.jpg');
var takanonLinkx_arr = new Array('#takanon01', '', '#takanon03', '', '#takanon05');

function set_bannerCycle() {
    
    interactiveLinks = document.getElementById('interactiveMenu').getElementsByTagName('A');
    for (i = 0; i < interactiveLinks.length; i++) {
        bannerCycle_linx[bannerCycle_linx.length] = interactiveLinks[(interactiveLinks.length - 1) - i];
        bannerCycle_obj[bannerCycle_obj.length] = new Image;
        bannerCycle_obj[bannerCycle_obj.length - 1].src = bannerCycle_imgs[i];
    }
    document.getElementById("interactiveBannerLinkx").onmouseover = function () { clearTimeout(cycleBanners_timeout); }
    document.getElementById("interactiveBannerLinkx").onmouseout = function () { clearTimeout(cycleBanners_timeout); cycleBanners_timeout = setTimeout('run_bannerCycle()', 6000000); }
    for (i = 0; i < bannerCycle_linx.length; i++) {
        bannerCycle_linx[i].onmouseover = function() { bannerCycle_choice(this); }
        bannerCycle_linx[i].onmouseout = function () { clearTimeout(cycleBanners_timeout); cycleBanners_timeout = setTimeout('run_bannerCycle()', 6000000); }
    }

    run_bannerCycle();
}

function run_bannerCycle() {
    if (document.getElementById('liteBox').style.display != "block") {
        for (i = 0; i < bannerCycle_linx.length; i++) bannerCycle_linx[i].className = "";
        bannerCycle_linx[bannerCounter].className = "interactiveSelected";
        document.getElementById('interactive_img').src = bannerCycle_obj[bannerCounter].src;

        if (takanonLinkx_arr[bannerCounter] != "") {
            document.getElementById('takanonLinkx').innerHTML = "בכפוף לתקנון";
            document.getElementById('takanonLinkx').href = takanonLinkx_arr[bannerCounter];
        }
        else document.getElementById('takanonLinkx').innerHTML = "";

        document.getElementById("interactiveBannerLinkx").href = bannerCycle_linx[bannerCounter].href;
        document.getElementById("interactiveBannerLinkx").target = bannerCycle_linx[bannerCounter].target;

        if (bannerCycle_imgsCursor[bannerCounter] != "") {
            document.getElementById("interactiveBannerLinkx").style.cursor = 'pointer';
        }
        else
            document.getElementById("interactiveBannerLinkx").style.cursor = 'default';

        if (bannerCounter < bannerCycle_linx.length - 1) bannerCounter++;
        else bannerCounter = 0;

//        if (waitBanner_clicked) cycleBanners_timeout = setTimeout('run_bannerCycle()', 6000);
//        else {
//            waitBanner_clicked = false;
            cycleBanners_timeout = setTimeout('run_bannerCycle()', 6000000);
        //}
    }
}

function bannerCycle_choice(tempObj) {
    clearTimeout(cycleBanners_timeout);
    var xTemp = -1;
    for (i = 0; i < bannerCycle_linx.length; i++) {
        bannerCycle_linx[i].className = "";
        if (bannerCycle_linx[i] == tempObj) xTemp = i;
    }
    tempObj.className = "interactiveSelected";
    bannerCounter = xTemp;
    document.getElementById('interactive_img').src = bannerCycle_obj[bannerCounter].src;

    document.getElementById("interactiveBannerLinkx").href = bannerCycle_linx[bannerCounter].href;
    document.getElementById("interactiveBannerLinkx").target = bannerCycle_linx[bannerCounter].target;
//    interactiveLinks = document.getElementById('interactiveMenu').getElementsByTagName('A');
    //    interactiveLinks[xTemp].href = bannerCycle_linx[xTemp].href;

    if (bannerCycle_imgsCursor[bannerCounter] != "") {
        document.getElementById("interactiveBannerLinkx").style.cursor = 'pointer';
    }
    else
        document.getElementById("interactiveBannerLinkx").style.cursor = 'default';

    if (takanonLinkx_arr[bannerCounter] != "") {
        document.getElementById('takanonLinkx').innerHTML = "בכפוף לתקנון";
        document.getElementById('takanonLinkx').href = takanonLinkx_arr[bannerCounter];
    }
    else document.getElementById('takanonLinkx').innerHTML = "";
    //run_bannerCycle();
}

// search box
function toggleSearchBox_radio(verBox) {
    radioObj = document.getElementById('destinationChoice0' + verBox);
    verBox_li = radioObj.parentNode.parentNode.getElementsByTagName('li');
    for (i = 0; i < verBox_li.length; i++)
        if (verBox_li[i].className.indexOf(' checkedRadio') != -1)
        verBox_li[i].className = verBox_li[i].className.split(' checkedRadio')[0];
    radioObj.parentNode.className += " checkedRadio";

    if (!radioObj.checked) radioObj.checked = "true";

    if (verBox == 1) {
        document.getElementById('backTo_tr').style.display = "none";
        document.getElementById('oneWay_td01').style.display = "";
        document.getElementById('oneWay_td02').style.display = "";
        document.getElementById('oneWay_td03').style.display = "";
        document.getElementById('dateTD01').innerHTML = "מתאריך";
		//document.getElementById('dateTD01').parentNode.getElementsByTagName('A')[0].onclick = function(){openPop('calendarHolder'); return false;};
    }
    else if (verBox == 2) {
        document.getElementById('backTo_tr').style.display = "";
        document.getElementById('oneWay_td01').style.display = "";
        document.getElementById('oneWay_td02').style.display = "";
        document.getElementById('oneWay_td03').style.display = "";
        document.getElementById('dateTD01').innerHTML = "מתאריך";
		//document.getElementById('dateTD01').parentNode.getElementsByTagName('A')[0].onclick = function(){openPop('calendarHolder'); return false;};
    }
    else if (verBox == 3) {
        document.getElementById('backTo_tr').style.display = "none";
        document.getElementById('oneWay_td01').style.display = "none";
        document.getElementById('oneWay_td02').style.display = "none";
        document.getElementById('oneWay_td03').style.display = "none";
        document.getElementById('dateTD01').innerHTML = "בתאריך";
		//document.getElementById('dateTD01').parentNode.getElementsByTagName('A')[0].onclick = function(){openPop('calendarHolder_oneWay'); return false;};
    }
}

// search box slider
function toggleSearchBox(toggle, heightx)
{
	if(toggle)
	{
		maximumHeight = heightx;
		document.getElementById('expandSearch').style.display = "";
		openingDrawer = document.getElementById('bigSearchBox_overflow');
		search_openUp();
	}
	else
	{
		closingdrawer = document.getElementById('bigSearchBox_overflow');
		if(document.getElementById('result_right_form_cal')) document.getElementById('result_right_form_cal').style.display = "none";
		search_closeDown();
	}
}

var minimumHeight = 19;
var maximumHeight = 130;
var openingCount = minimumHeight;
var closingCount = maximumHeight;
var closingdrawer, openingDrawer;
var inprogress = false;
var speed01 = 5;
var speed02 = 10;
var speed03 = 15;
var curSpeed = speed02;
var easeStep01 = 49;
var easeStep02 = 154;
var easeStep03 = 174;
var easeStep04 = maximumHeight;

function search_openUp() {
    inprogress = true;
    if (openingCount < maximumHeight) {
        openingCount += curSpeed;
        openingDrawer.style.height = openingCount + "px";
        if ((openingCount + 14) > 126)
            document.getElementById('searchBox_holder').style.height = (openingCount + 14) + "px";

        if ((openingCount >= easeStep01) && (openingCount < easeStep02)) curSpeed = speed03;
        else if ((openingCount >= easeStep02) && (openingCount < easeStep03)) curSpeed = speed02;
        else if ((openingCount >= easeStep03) && (openingCount < easeStep04)) curSpeed = speed01;
        setTimeout("search_openUp()", 1);
    }
    else {
        openingCount = minimumHeight;
        closingCount = maximumHeight;
        curSpeed = speed02;
        inprogress = false;
		if(document.getElementById('result_right_form_cal')) document.getElementById('result_right_form_cal').style.display = "block";
    }
}

function search_closeDown() {
    inprogress = true;
    if (openingCount < maximumHeight) openingCount += curSpeed;
    if (closingCount > minimumHeight) {
        closingCount -= curSpeed;
        closingdrawer.style.height = closingCount + "px";

        if ((closingCount + 14) < 126)
            document.getElementById('searchBox_holder').style.height = (closingCount + 14) + "px";

        if ((openingCount >= easeStep01) && (openingCount < easeStep02)) curSpeed = speed03;
        else if ((openingCount >= easeStep02) && (openingCount < easeStep03)) curSpeed = speed02;
        else if ((openingCount >= easeStep03) && (openingCount < easeStep04)) curSpeed = speed01;
        setTimeout("search_closeDown()", 5);
    }
    else {
        openingCount = minimumHeight;
        closingCount = maximumHeight;
        curSpeed = speed02;
        inprogress = false;
        document.getElementById('expandSearch').style.display = "none";
    }
}

// dynamic gallery

//var lastMinute_details = new Array(
//new Array("../images/img1_last_deal.gif", "טיסה לרומא", "<img src=\"../images/iberia_logo.gif\" alt=\"\" width=\"78\" height=\"17\"> החל מ-$289"),
//new Array("../images/img1_last_deal.gif", "דלהי", "מבחר טיסות"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "אוסטרליהוחצי"),
//new Array("../images/img1_last_deal.gif", "טיסה ללונדון", "<img src=\"../images/iberia_logo.gif\" alt=\"\" width=\"78\" height=\"17\"> החל מ-$350"),
//new Array("../images/img1_last_deal.gif", "הונג קונג", "מחירים בלעדיים למזמינים היום"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס"),
//new Array("../images/img1_last_deal.gif", "נופש באילת", "טיסה + מלון הרודס")
//);


//var num_of_cards = parseInt(lastMinute_details.length);
//var LinkWidth = 120;
//var scroll_startPosition = 142;
//var cards_onTheLeft = 5;
//var leftMost_card = num_of_cards - 1;
//var original_scrollPosition = ((num_of_cards - cards_onTheLeft) * LinkWidth) + scroll_startPosition;
//var galleryStrip, streamDir;
//var galleryPosition_count = 0;


//function setGallery(cardNum) {
//    galleryStrip = document.getElementById('galleryStrip');
//    //var tableTop = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><img src=\"../images/blank.gif\" width=\"137\" height=\"1\"/></td>";
//    var tableTop = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>";
//    var tableBottom = "<td><img src=\"../images/blank.gif\" width=\"137\" height=\"1\"/></td></tr></table>";
//    var tempSTR = tableTop;

//    for (j = 0; j < 3; j++) {
//        for (i = 0; i < num_of_cards; i++) {
//            altTemp = " " + i;
//            tempSTR += "<td onclick=\"_gaq.push(['_trackPageview','/fp/?Page=Flights_Main&Pos=Last_Moment&Type=Slide_Bar&Label=" + lastMinute_details[i][1].replace('טיסה ל', '') + "_" + lastMinute_details[i][4] + "'])\" align=\"center\"><a href=" + lastMinute_details[i][4] + " title=\"" + lastMinute_details[i][1] + "\">" +
//			    "<img src=\"" + lastMinute_details[i][0] + "\" alt=\"" + lastMinute_details[i][1] + "\" width=\"107\" height=\"70\"/>" + "<strong>" +
//			    lastMinute_details[i][1] + "</strong><span style=\"font-size:0.9em\">" + lastMinute_details[i][3] + "</span><span style=\"color:#003f62;font-size:1.1em\"><b>" + lastMinute_details[i][2] + "<b/></span>" +
//			    "</a></td>";
//        }
//    }
//    tempSTR += tableBottom;
//    document.write(tempSTR);
//    resetTo_position = original_scrollPosition + ((leftMost_card - cardNum) * LinkWidth);
//    lastMinute_chkBTN();
//}



function setGallery(cardNum) {
    galleryStrip = document.getElementById('galleryStrip');
    var tableTop = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>";
    var tableBottom = "</tr></table>"; 
    var tempSTR = tableTop;
    var FlightType = '';
    for (j = 0; j < 3; j++) {
        for (i = 0; i < num_of_cards; i++) {
            altTemp = " " + i;
            if (lastMinute_details[i][6]=='FL')
                FlightType = 'טיסה סדירה';
            else
                FlightType = 'צארטר';
            tempSTR += "<td onclick=\"_gaq.push(['_trackPageview','/fp/?Page=Flights_Main&Pos=Last_Moment&Type=Slide_Bar&Label=" + lastMinute_details[i][1].replace('טיסה ל', '') + ",טיסה," + lastMinute_details[i][2].toString().split('>')[1].toString() + "," + FlightType + "," + lastMinute_details[i][3].toString() + ",מקום " + lastMinute_details[i][5].toString() + "'])\" align=\"center\"><a href=\"" + lastMinute_details[i][4] + "\" title=\"" + lastMinute_details[i][1] + "\">" +
				"<img src=\"" + lastMinute_details[i][0] + "\" alt=\"" + lastMinute_details[i][1] + "\" width=\"107\" height=\"70\"/>" +
				"<strong>" + lastMinute_details[i][1] + "</strong><span>" + lastMinute_details[i][3] + "</span><span style=\"color:#003f62;font-size:1.1em\"><b>" + lastMinute_details[i][2] + "<b/></span>" +
				"</a></td>";
        }
    }
    tempSTR += tableBottom;
    document.write(tempSTR);

    galleryStrip.scrollLeft = original_scrollPosition + ((leftMost_card - cardNum) * LinkWidth);
    resetTo_position = original_scrollPosition + ((leftMost_card - cardNum) * LinkWidth);
    lastMinute_chkBTN();
}



function lastMinute_right() {
    if (!galleryStream_inprogress) {
        if ((galleryStrip.scrollLeft - ((num_of_cards - cards_onTheLeft - 1) * LinkWidth)) == resetTo_position) galleryStrip.scrollLeft = resetTo_position - ((cards_onTheLeft + 1) * LinkWidth);
        streamDir = 1;
        streamGallery();
        galleryPosition_count--;
        lastMinute_chkBTN();
        _gaq.push(['_trackPageview', '/fp/?Page=Flights&Pos=Last_Moment&Type=Slide_Bar&Label=Paging']);
    }
}



function lastMinute_left() {
    if (!galleryStream_inprogress) {
        if ((galleryStrip.scrollLeft + ((num_of_cards - cards_onTheLeft - 1) * LinkWidth)) == resetTo_position) galleryStrip.scrollLeft = resetTo_position + ((cards_onTheLeft + 1) * LinkWidth);
        streamDir = 0;
        streamGallery();
        galleryPosition_count++;
        lastMinute_chkBTN();
        _gaq.push(['_trackPageview', '/fp/?Page=Flights&Pos=Last_Moment&Type=Slide_Bar&Label=Paging']);
    }
}


function lastMinute_chkBTN() {
    if (galleryPosition_count + num_of_cards == 0) galleryPosition_count = 0;
    else if (galleryPosition_count == num_of_cards) galleryPosition_count = 0;

    var smallerNum = galleryPosition_count + 1;
    if (smallerNum == 0) smallerNum = num_of_cards;
    else if (smallerNum < 0) smallerNum = num_of_cards + smallerNum;
    else if (smallerNum > num_of_cards) smallerNum = smallerNum - num_of_cards;

    var biggerNum = galleryPosition_count + 5;
    if (biggerNum == 0) biggerNum = num_of_cards;
    else if (biggerNum < 0) biggerNum = num_of_cards + biggerNum;
    else if (biggerNum > num_of_cards) biggerNum = biggerNum - num_of_cards;

    document.getElementById('lastMinute_counter').innerHTML = smallerNum + " - " + biggerNum + " מתוך " + num_of_cards;
}



//var galleryStream_inprogress = false;
//var galleryMinimumHeight = 0;
//var gallery_streamCount = galleryMinimumHeight;
//var galleryMaximumHeight = LinkWidth;
//var gallerySpeed01 = 5;
//var gallerySpeed02 = 10;
//var gallerySpeed03 = 15;
//var galleryCurSpeed = gallerySpeed02;
//var galleryEaseStep01 = 20;
//var galleryEaseStep02 = 80;
//var galleryEaseStep03 = 110;
//var galleryEaseStep04 = 120;

function streamGallery() {
    galleryStream_inprogress = true;
    if (gallery_streamCount < galleryMaximumHeight) {
        gallery_streamCount += galleryCurSpeed;
        if (streamDir) galleryStrip.scrollLeft += galleryCurSpeed;
        else galleryStrip.scrollLeft -= galleryCurSpeed;
        if ((gallery_streamCount >= galleryEaseStep01) && (gallery_streamCount < galleryEaseStep02)) galleryCurSpeed = gallerySpeed03;
        else if ((gallery_streamCount >= galleryEaseStep02) && (gallery_streamCount < galleryEaseStep03)) galleryCurSpeed = gallerySpeed02;
        else if ((gallery_streamCount >= galleryEaseStep03) && (gallery_streamCount < galleryEaseStep04)) galleryCurSpeed = gallerySpeed01;
        setTimeout("streamGallery()", 1);
    }
    else {
        gallery_streamCount = galleryMinimumHeight;
        galleryCurSpeed = gallerySpeed02;
        galleryStream_inprogress = false;
    }
}

// results functions
function directFlights_over(trObj, whichMO) {
    if (whichMO) {
        trObj.className += " Direct_flights_box_ro";
        getNextSibling(trObj).className += " Direct_flights_box_open_ro";//trObj.nextSibling.className += " Direct_flights_box_open_ro";
    }
    else {
        trObj.parentNode.className += " Direct_flights_box_open_ro";
        getPrevSibling(trObj.parentNode).className += " Direct_flights_box_ro"; //trObj.parentNode.previousSibling.className += " Direct_flights_box_ro";
    }
}

function directFlights_out(trObj, whichMO) {
    if (whichMO) {
        trObj.className = trObj.className.split(" Direct_flights_box_ro")[0];
        getNextSibling(trObj).className = getNextSibling(trObj).className.split(" Direct_flights_box_open_ro")[0]; //trObj.nextSibling.className = trObj.nextSibling.className.split(" Direct_flights_box_open_ro")[0];
    }
    else {
        trObj.parentNode.className = trObj.parentNode.className.split(" Direct_flights_box_open_ro")[0]
        getPrevSibling(trObj.parentNode).className = getPrevSibling(trObj.parentNode).className.split(" Direct_flights_box_ro")[0]; //trObj.parentNode.previousSibling.className = trObj.parentNode.previousSibling.className.split(" Direct_flights_box_ro")[0];
    }
}


function resultBox_tr(trObj, toggle, last) {
    if (toggle) {
        if (last) trObj.className = "resultBox_tRO_lastTR";
        else trObj.className = "resultBox_tRO";
    }
    else {
        if (last) trObj.className = "resultBox_lastTR";
        else trObj.className = "";
    }
}
function OpenLastDiv() {
    //
    if (document.getElementById('LastSubmitDivIdInp').value.length > 0)
    {
        var submitDivObj = document.getElementById(document.getElementById('LastSubmitDivIdInp').value);
        if (submitDivObj != null) 
        {
            window.location.hash = document.getElementById('LastSubmitAnchorForBackIdInp').value; 
            directFlights_open(submitDivObj, 1);          
        }
    }
//    if (document.getElementById('LastSubmitDivMoreIdInp').value.length > 0)
//    {
//        var moreAnchorObj = document.getElementById(document.getElementById('LastSubmitDivMoreIdInp').value);
//        if (moreAnchorObj != null) 
//        {
//            moreInfoOverflow_toggleChrOpenBlock(moreAnchorObj);
//        }
//    }
}
var opinionClicked = false;
function directFlights_open(trObj, whichMO) { 
    if(!outputHeight_inProgress)
	{
		if(whichMO)
		{
			resultBoxx = trObj;
			resultBoxx_link = getNextSibling(trObj);
		}
		else
		{
			resultBoxx = getPrevSibling(trObj.parentNode);
			resultBoxx_link = trObj.parentNode;
		}

		if((!(resultBoxx.getAttribute('clicked')=="true"))&&(!opinionClicked))
		{
			resultBoxx.setAttribute('clicked', 'true');
			resultBoxx.onmouseover = "";
			resultBoxx.onmouseout = "";
			resultBoxx_link.getElementsByTagName('A')[0].onmouseover = "";
			resultBoxx_link.getElementsByTagName('A')[0].onmouseout = "";
			resultBoxx_link.style.display = "none";
			openedDiv = getNextSibling(resultBoxx_link);
			openedDiv.style.display = "block";
			getNextSibling(openedDiv).style.display = "block";

			if(!(openedDiv.getAttribute('opened')=="true"))
			{
				document.getElementById('liteBox').style.display = "block";
				document.getElementById('liteBox').className = "liteBox_trans";
				document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
	
				outputDiv = openedDiv.getElementsByTagName('div')[0];
				outputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;
				
				if(outputDiv.getElementsByTagName('div')[0])
					outputHeight -= outputDiv.getElementsByTagName('div')[0].offsetHeight;
				
				openedDiv.setAttribute('opened', 'true');
				open_resultsTable();
			}
		}
		else
		{
			openedDiv = getNextSibling(resultBoxx_link);
			outputDiv = openedDiv.getElementsByTagName('div')[0];
			outputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;

			document.getElementById('liteBox').style.display = "block";
			document.getElementById('liteBox').className = "liteBox_trans";
			document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";	
			
			close_resultsTable();
		}
		opinionClicked = false;
	}
}

function directFlightsCharter_open(trObj, whichMO) {
    if (!outputHeight_inProgress) {
        if (whichMO) {
            resultBoxx = trObj;
            resultBoxx_link = getNextSibling(trObj);
        }
        else {
            resultBoxx = getPrevSibling(trObj.parentNode);
            resultBoxx_link = trObj.parentNode;
        }

        if ((!(resultBoxx.getAttribute('clicked') == "true")) && (!opinionClicked)) {
            resultBoxx.setAttribute('clicked', 'true');
            resultBoxx.onmouseover = "";
            resultBoxx.onmouseout = "";
            resultBoxx_link.getElementsByTagName('A')[0].onmouseover = "";
            resultBoxx_link.getElementsByTagName('A')[0].onmouseout = "";
            resultBoxx_link.style.display = "none";
            openedDiv = getNextSibling(resultBoxx_link);
            openedDiv.style.display = "block";
            getNextSibling(openedDiv).style.display = "block";

            if (!(openedDiv.getAttribute('opened') == "true")) {
                document.getElementById('liteBox').style.display = "block";
                document.getElementById('liteBox').className = "liteBox_trans";
                document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";

                outputDiv = openedDiv.getElementsByTagName('div')[0];
                outputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;

                if (outputDiv.getElementsByTagName('div')[0])
                    outputHeight -= outputDiv.getElementsByTagName('div')[0].offsetHeight;

                openedDiv.setAttribute('opened', 'true');
                open_resultsTable();
            }
        }
        else {
            openedDiv = getNextSibling(resultBoxx_link);
            outputDiv = openedDiv.getElementsByTagName('div')[0];
            outputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;

            document.getElementById('liteBox').style.display = "block";
            document.getElementById('liteBox').className = "liteBox_trans";
            document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";

            close_resultsTable();
        }
    }
}

function directFlights_close(trObj)
{
	openedDiv = getPrevSibling(trObj.parentNode);
    outputDiv = openedDiv.getElementsByTagName('div')[0];
    outputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;
	document.getElementById('liteBox').style.display = "block";
	document.getElementById('liteBox').className = "liteBox_trans";
	document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";	
    close_resultsTable();
}

var outputHeight, outputDiv;
var outputHeight_count = 0;
var outputHeight_inProgress = false;

function open_resultsTable() {
    outputHeight_inProgress = true;
	if((outputHeight - outputHeight_count) > 12)
	{
	    outputHeight_count += 12;
		outputDiv.style.height = outputHeight_count+"px";
		setTimeout('open_resultsTable()', 1);
	}
	else
	{
		outputDiv.style.height = outputHeight+"px";
		outputHeight_inProgress = false;
		outputHeight_count = 0;
		document.getElementById('liteBox').style.display = "none";
		document.getElementById('liteBox').className = "liteBox";
	}
}

function openCharter_resultsTable() {
    outputHeight_inProgress = true;
    if ((outputHeight - outputHeight_count) > 12) {
        outputHeight_count += 12;
        outputDiv.style.height = outputHeight_count + "px";
        setTimeout('openCharter_resultsTable()', 1);
    }
    else {
        outputDiv.style.height = outputHeight + "px";
        outputHeight_inProgress = false;
        outputHeight_count = 0;
        document.getElementById('liteBox').style.display = "none";
        document.getElementById('liteBox').className = "liteBox";
    }
}

function close_resultsTable()
{
	outputHeight_inProgress = true;
	if ((outputHeight - outputHeight_count) > 10)
	{
	    outputHeight_count += 10;
		outputDiv.style.height = (outputHeight-outputHeight_count)+"px";
		setTimeout('close_resultsTable()', 1);		
	}
	else
	{
		outputHeight_inProgress = false;
		outputHeight_count = 0;

		outputDiv.style.height = "auto";
		outputDiv.parentNode.style.display = "none";
		getNextSibling(outputDiv.parentNode).style.display = "none";
		outputDiv.parentNode.setAttribute('opened', 'false');

		getPrevSibling(outputDiv.parentNode).style.display = "";
		getPrevSibling(outputDiv.parentNode).className = getPrevSibling(outputDiv.parentNode).className.split(" Direct_flights_box_open_ro")[0];
		getPrevSibling(getPrevSibling(outputDiv.parentNode)).className = getPrevSibling(getPrevSibling(outputDiv.parentNode)).className.split(" Direct_flights_box_ro")[0];
		getPrevSibling(getPrevSibling(outputDiv.parentNode)).onmouseover = function(){directFlights_over(this, 1);}		
		getPrevSibling(getPrevSibling(outputDiv.parentNode)).onmouseout = function(){directFlights_out(this, 1);}		
		getPrevSibling(getPrevSibling(outputDiv.parentNode)).setAttribute('clicked', 'false');

		getPrevSibling(outputDiv.parentNode).getElementsByTagName('A')[0].onmouseover = function(){directFlights_over(this, 0);}
		getPrevSibling(outputDiv.parentNode).getElementsByTagName('A')[0].onmouseout = function(){directFlights_out(this, 0);}

        outputLinx = outputDiv.getElementsByTagName('A');
        for (i = 0; i < outputLinx.length; i++)
            if (outputLinx[i].className == "result_box_open_more_info_minus") {
            outputLinx[i].className = "result_box_open_more_info_plus";
            outputLinx[i].innerHTML = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            outputLinx[i].title = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
        }
		document.getElementById('liteBox').style.display = "none";
		document.getElementById('liteBox').className = "liteBox";		
    }
}


var moreInfo_outputHeight, moreInfo_outputDiv, moreInfo_output_holderHeight;
var moreInfo_outputHeight_count = 0;
var moreInfo_outputHeight_inProgress = false;

function moreInfoOverflow_toggle(innerFlow_link) {
    if(!moreInfo_outputHeight_inProgress)
	{
		moreInfo_outputDiv = innerFlow_link.parentNode.parentNode;
		moreInfo_outputHeight = getNextSibling(innerFlow_link.parentNode).offsetHeight;
		moreInfo_output_holderHeight = moreInfo_outputDiv.offsetHeight;

		document.getElementById('liteBox').style.display = "block";
		document.getElementById('liteBox').className = "liteBox_trans";
		
		document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
		if (innerFlow_link.className == "result_box_open_more_info_plus_new") {
		    innerFlow_link.className = "result_box_open_more_info_minus_new";
		    innerFlow_link.innerHTML = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
		    innerFlow_link.title = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
		    moreInfoOverflow_open();
		    if (document.getElementById('DestinationNameInp') != null) {
		        _gaq.push(['_trackPageview', '/fp/?Page= Charter_Results&Pos=&Type=more_Expand_Link&Label=' + document.getElementById('DestinationNameInp').value]);
		    }
        }
        else {
            innerFlow_link.className = "result_box_open_more_info_plus_new";
            innerFlow_link.innerHTML = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            innerFlow_link.title = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            moreInfoOverflow_close();
            if (document.getElementById('DestinationNameInp') != null) {
                _gaq.push(['_trackPageview', '/fp/?Page= Charter_Results&Pos=&Type=close_Expand_Link&Label=' + document.getElementById('DestinationNameInp').value]);
            }
		}
    }
}

function moreInfoOverflow_toggleOpenBlock(innerFlow_link) {
    if (!moreInfo_outputHeight_inProgress) {
        moreInfo_outputDiv = innerFlow_link.parentNode.parentNode;
        moreInfo_outputHeight = document.getElementById('MoreOpenBlockHightInp').value; 
        moreInfo_output_holderHeight = 124;  
        document.getElementById('liteBox').style.display = "block";
        document.getElementById('liteBox').className = "liteBox_trans";

        document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
        if (innerFlow_link.className == "result_box_open_more_info_plus_new") {
            innerFlow_link.className = "result_box_open_more_info_minus_new";
            innerFlow_link.innerHTML = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
            innerFlow_link.title = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
            moreInfoOverflow_open();
        }
        else {
            innerFlow_link.className = "result_box_open_more_info_plus_new";
            innerFlow_link.innerHTML = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            innerFlow_link.title = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            moreInfoOverflow_close();
        }
    }
}


function moreInfoOverflow_toggleChr(innerFlow_link)
{
    if (!moreInfo_outputHeight_inProgress) {
        moreInfo_outputDiv = innerFlow_link.parentNode.parentNode;
        moreInfo_outputHeight = getNextSibling(innerFlow_link.parentNode).offsetHeight;
        moreInfo_output_holderHeight = moreInfo_outputDiv.offsetHeight;

        document.getElementById('liteBox').style.display = "block";
        document.getElementById('liteBox').className = "liteBox_trans";

        document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
        if (innerFlow_link.className == "result_box_open_more_info_plus") {
            innerFlow_link.className = "result_box_open_more_info_minus";
            innerFlow_link.innerHTML = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
            innerFlow_link.title = "הסתר טיסות נוספות, בתאריכים ושעות שונות";
            moreInfoOverflow_open();
        }
        else {
            innerFlow_link.className = "result_box_open_more_info_plus";
            innerFlow_link.innerHTML = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            innerFlow_link.title = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            moreInfoOverflow_close();
        }
    }
}
function moreInfoOverflow_open() {
    moreInfo_outputHeight_inProgress = true;

    if ((moreInfo_outputHeight - moreInfo_outputHeight_count) > 12) {
        moreInfo_outputHeight_count += 12;
        moreInfo_outputDiv.style.height = (Number(moreInfo_output_holderHeight) + Number(moreInfo_outputHeight_count)) + "px";
        setTimeout('moreInfoOverflow_open()', 1);
    }
    else {
        moreInfo_outputDiv.style.height = Number(moreInfo_output_holderHeight) + Number(moreInfo_outputHeight) + "px";
        moreInfo_outputHeight_inProgress = false;
        moreInfo_outputHeight_count = 0;
		document.getElementById('liteBox').style.display = "none";
		document.getElementById('liteBox').className = "liteBox";		
    }
}

function moreInfoOverflow_close() {
    moreInfo_outputHeight_inProgress = true;

    if ((moreInfo_outputHeight - moreInfo_outputHeight_count) > 12) {
        moreInfo_outputHeight_count += 12;
        moreInfo_outputDiv.style.height = (moreInfo_output_holderHeight - moreInfo_outputHeight_count) + "px";
        setTimeout('moreInfoOverflow_close()', 1);
    }
    else {
        moreInfo_outputDiv.style.height = moreInfo_output_holderHeight - moreInfo_outputHeight + "px";
        moreInfo_outputHeight_inProgress = false;
        moreInfo_outputHeight_count = 0;
		document.getElementById('liteBox').style.display = "none";
		document.getElementById('liteBox').className = "liteBox";		
    }
}


function charter_moreResults_open(trObj) {
    getNextSibling(trObj).style.display = "block";
    trObj.style.display = "none";
}

function charter_moreResults_close(trObj) {
    charterObj = trObj.parentNode.parentNode.parentNode;
	getPrevSibling(charterObj).style.display = "block";
    charterObj.style.display = "none";
}

function toggle_destinationTabs(tabLink, tabChoice) {
    if (tabChoice == 0) {
        document.getElementById("ByCountries").style.display = "block";
        document.getElementById("ByABC").style.display = "none";
    }
    else {
        document.getElementById("ByCountries").style.display = "none";
        document.getElementById("ByABC").style.display = "block";
    }

    tabsList = tabLink.parentNode.parentNode.getElementsByTagName("A");
    for (i = 0; i < tabsList.length; i++) tabsList[i].className = "";
    tabLink.className = "activ";
}

var current_votingStar = 0;
function votingStar_click(starNum) {
    document.getElementById('VotingStar').className = "Voting_star Voting_star0" + starNum;
    document.getElementById('Vote_num').innerHTML = "ציון " + "<asp:Label ID='ScoreLiteral' runat='server'" + "></asp:Label>" + "/5";
    document.getElementById('ScoreLiteral').innerHTML = starNum;
    current_votingStar = starNum;
}

function votingStar_out() {
    document.getElementById('ScoreLiteral').innerHTML = current_votingStar;
    document.getElementById('VotingStar').className = "Voting_star Voting_star0" + current_votingStar;
}

function votingStar_over(starNum) {
    document.getElementById('ScoreLiteral').innerHTML = starNum;
    document.getElementById('VotingStar').className = "Voting_star Voting_star0" + starNum;
}
function toggle_moreOpinion(linx, toggle) {
    if (toggle) {
        linx.parentNode.style.display = "none";
        getNextSibling(linx.parentNode).style.display = "";
    }
    else {
        linx.parentNode.parentNode.style.display = "none";
        getPrevSibling(linx.parentNode.parentNode).style.display = "";
    }
}

//////////////////////////Dev JS///////////////////////////
function getNextSibling(startBrother) {
    endBrother = startBrother.nextSibling;
    while (endBrother.nodeType != 1) {
        endBrother = endBrother.nextSibling;
    }
    return endBrother;
}

function getPrevSibling(startBrother) {
    endBrother = startBrother.previousSibling;
    while (endBrother.nodeType != 1) {
        endBrother = endBrother.previousSibling;
    }
    return endBrother;
}

function MoreDestinationClick(){
    document.getElementById('MoreDestinationBtn').click();
    document.getElementById('liteBox').style.display = "block";
    document.getElementById('liteBox').style.height = document.body.offsetHeight + 100 + "px";
}

function charterMoreResultOpen(id) {
    window.location.hash = "CheapestPrice";
    obj = document.getElementById(id)
    getNextSibling(obj).style.display = "block";
    obj.style.display = "none";
    window.location.hash = "CheapestPrice";
}

//function GetCheapestFlight(id) {
//    
//    window.location.hash = "CheapestPrice";
//    obj = document.getElementById(id);
//    if (obj.style.display == 'none') {
//        getNextSibling(obj)
//    }
//    else {

//    }
//    getNextSibling(obj).style.display = "block";
//    obj.style.display = "none";
//    window.location.hash = "CheapestPrice";
//}

function SetDestinationInp() {
    if (document.getElementById('DestinationsDDL').selectedIndex > 0) {
        document.getElementById('DestinationIdInp').value = document.getElementById('DestinationsDDL')[document.getElementById('DestinationsDDL').selectedIndex].value;
    }
    else {
        document.getElementById('DestinationIdInp').value = '';
    }
}

function ClearDate() {
    document.getElementById('fromDate').value = '';
    document.getElementById('fromDateInp').value = '';
    document.getElementById('toDateInp').value = '';
}

function CheckIfSingleCalendarAllowed() {
    if (document.getElementById('DestinationIdInp').value.length > 0) {
        openCalendarPopUP(); 
    }
    else {
        alert('יש לבחור יעד לפני תאריך');
    }
}

function TopOfPage(id) {
    window.location.hash = "TopOfPage";
}

function CheckMailValidation(mail)
{
    return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(mail);
}
function CheckIfCalendarAllowed() {
    if (document.getElementById('ToggleSearchBoxInp').value == '1' || document.getElementById('ToggleSearchBoxInp').value == '2') {
        if (document.getElementById('departureToDestinationInp').value.length > 0) {
            openCalendarPopUP();
        }
        else {
            alert('נא לבחור יעד');
            return false;
        }
    }
    if (document.getElementById('ToggleSearchBoxInp').value == '3') {
        if (document.getElementById('departureToDestinationInp').value.length < 1) {
            alert('נא לבחור יעד');
            return false;
        }
        if (document.getElementById('returnFromDestinationInp').value.length < 1) {
            alert('נא לבחור חזרה מ');
            return false;
        }
        openCalendarPopUP();
    }
}
function GoFlightDetails(flightDealId, depAirport, dep2Airport, destAirport, isSoldOut, submitDivId)
{
    if (isSoldOut == 'False') 
    {
        document.getElementById('LastSubmitDivIdInp').value = "OpenDiv_" + submitDivId;
        document.getElementById('LastSubmitDivMoreIdInp').value = "OpenMore_" + submitDivId;
        document.getElementById('LastSubmitAnchorForBackIdInp').value = submitDivId;
        document.getElementById('flightID').value = flightDealId;
        document.getElementById('depAirport').value = depAirport;
        document.getElementById('dep2Airport').value = dep2Airport;
        document.getElementById('destAirport').value = destAirport;
        document.getElementById('resultSubmit').click();
    }
}
function OpenWriteOpinion() {
    document.getElementById('IsWriteOpinionInp').value = "true";
    document.getElementById('OpenWriteOpinionBtn').click();
    document.getElementById('liteBox').style.display = "block";
    document.getElementById('liteBox').style.height = document.body.offsetHeight + 100 + "px";
}
function OpenReadOpinion() {
    document.getElementById('IsReadOpinionInp').value = "true";
    document.getElementById('OpenReadOpinionBtn').click();
    document.getElementById('liteBox').style.display = "block";
    document.getElementById('liteBox').style.height = document.body.offsetHeight + 100 + "px";
}
function CheckIfWriteOpinionOK() {
    errorMsg = "";
    if (document.getElementById('PromotedAirlinesDDL')[document.getElementById('PromotedAirlinesDDL').selectedIndex].value == "-1") {
        errorMsg = "נא לבחור חברת תעופה";
    }
    if (document.getElementById('WriterNameInp').value.length == 0) {
        errorMsg = errorMsg + "\r\n" + "נא לבחור חברת תעופה";
    }
    if (document.getElementById('CitiesInIsraelDDL')[document.getElementById('CitiesInIsraelDDL').selectedIndex].value == "-1") {
        errorMsg = errorMsg + "\r\n" + "נא לבחור עיר";
    }
    if (document.getElementById('AirLineRecommendationInp').value.length == 0 || document.getElementById('AirLineRecommendationInp').value == "(הזן מלל חופשי (עד 250 תווים") {
        errorMsg = errorMsg + "\r\n" + "נא לכתוב חוות דעת";
    }
    if (document.getElementById('ScoreLiteral').innerHTML == "0") {
        errorMsg = errorMsg + "\r\n" + "נא לדרג";
    }
    document.getElementById('AirLinrRatingInp').value = document.getElementById('ScoreLiteral').innerHTML;
    if (errorMsg.length == 0) {
        current_votingStar = 0;
        document.getElementById('VotingStar').className = "Voting_star";
        document.getElementById('WriteOpinionBtn').click();
    }
    else {
        alert(errorMsg);
        return false;
    }
    _gaq.push(['_trackPageview', "'/fp/?Page=Write_Opinion&Pos=Center&Type=Button&Label=" + document.getElementById('PromotedAirlinesDDL')[document.getElementById('PromotedAirlinesDDL').selectedIndex].value + '_' + document.getElementById('AirLinrRatingInp').value.replace("ציון ", "").replace("/5", "") + "'"]);
}

function CloseWriteOpinionOpenWriterCompletePop(openpopID, closePopId) {
    document.getElementById(closePopId).style.display = 'none';
    document.getElementById(openpopID).style.display = 'block';
}

function OpenReadOpinion() {
    document.getElementById('ReadOpinionsBtn').click();
}

function ShowReadOpinion() {
    if (document.getElementById('OpinionHolder') != null) {
        document.getElementById('OpinionHolder').style.display = 'none';
    }
    openPop('ReadOpinionHolder');
}

var inFirst = true;
function showWaitDiv() {
    if (inFirst) {
        document.getElementById('liteBox').style.display = "block";
        document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
        inFirst = false;
        document.getElementById("pleaseWaitDiv").style.left = ((document.documentElement.clientWidth - 640) / 2) + "px";
        document.getElementById("pleaseWaitDiv").style.top = (document.documentElement.scrollTop + 200) +"px";
        document.getElementById("pleaseWaitDiv").style.display = "block";
        WaitingDivAnimation()

        var desName = "";
        if (document.getElementById('locationFromCombine') != null)
            desName = document.getElementById('locationFromCombine').value;
        if (document.getElementById('locationTo1') != null)
            desName = document.getElementById('locationTo1').value;

        var label = document.getElementById('WaitingBannerHeaderLbl');
        if (typeof label.textContent != 'undefined')
            label.textContent = "ברגע זה גוליבר מבצעת חיפוש טיסות ל-" + desName + ", במערכת ההזמנות של כל חברות התעופה";
        else
            label.innerText = "ברגע זה גוליבר מבצעת חיפוש טיסות ל-" + desName + ", במערכת ההזמנות של כל חברות התעופה";
    }
    window.setTimeout('showWaitDiv();', 2000);
}

function GoToResultPage() {

//    var numberOfAdults = document.getElementById('AdultNumberDDL')[document.getElementById('AdultNumberDDL').selectedIndex].value;
//    var numberOfChilds = document.getElementById('ChildNumberDDL')[document.getElementById('ChildNumberDDL').selectedIndex].value;
//    var numberOfSeniors = document.getElementById('SeniorNumberDDL')[document.getElementById('SeniorNumberDDL').selectedIndex].value;
//    var numberOfYouth = document.getElementById('YouthNumberDDL')[document.getElementById('YouthNumberDDL').selectedIndex].value;
    //    var numberOfInfants = document.getElementById('InfantNumberDDL')[document.getElementById('InfantNumberDDL').selectedIndex].value;
    var numberOfAdults = document.getElementById('adultNumInp').value
    var numberOfChilds = document.getElementById('childNumInp').value
    var numberOfInfants = document.getElementById('babyNumInp').value
    var numberOfSeniors = document.getElementById('seniorNumInp').value
    var numberOfYouth = document.getElementById('youthNumInp').value

    if (document.getElementById('ToggleSearchBoxInp').value == "2") {
        document.getElementById('returnFromDestinationInp').value = document.getElementById('departureToDestinationInp').value;
    }
    else if (document.getElementById('ToggleSearchBoxInp').value == "1") {
        document.getElementById('returnFromDestinationInp').value = "";
    }
    if (document.getElementById('returnFromDestinationInp').value == document.getElementById('departureToDestinationInp').value) {
        document.getElementById('ToggleSearchBoxInp').value = "2"
    }
    var SpecificAirLineCode = "";
    if (typeof document.getElementById('SpecificAirLineCodeInp') != 'undefined' && document.getElementById('SpecificAirLineCodeInp') != null) {
        SpecificAirLineCode = document.getElementById('SpecificAirLineCodeInp').value;
    }
    window.location = "FlightsResults.aspx?from=" + document.getElementById('departureFromDestinationInp').value +
                        "&to=" + document.getElementById('departureToDestinationInp').value +
                        "&from2=" + document.getElementById('returnFromDestinationInp').value +
                        "&dateFrom=" + document.getElementById('fromDateInp').value +
                        "&dateTo=" + document.getElementById('toDateInp').value +
                        "&Type=" + document.getElementById('ToggleSearchBoxInp').value +
                        "&PassengersCode=" + GetPassengersCode(numberOfAdults, numberOfSeniors, numberOfChilds, numberOfYouth, numberOfInfants) +
                        //document.getElementById('AdultNumberDDL')[document.getElementById('AdultNumberDDL').selectedIndex].value + "00" + 
                        //document.getElementById('ChildNumberDDL')[document.getElementById('ChildNumberDDL').selectedIndex].value + "0" + 
                        //document.getElementById('InfantNumberDDL')[document.getElementById('InfantNumberDDL').selectedIndex].value +
                        "&SpecificAirLineCode=" + SpecificAirLineCode +
                        (document.getElementById('GclidInp').value.length > 0 ? "&gclid=" + document.getElementById('GclidInp').value : "");
    showWaitDiv();
}
function GoToResultPage(dateFrom, dateTo) {

    var numberOfAdults = document.getElementById('adultNumInp').value
    var numberOfChilds = document.getElementById('childNumInp').value
    var numberOfInfants = document.getElementById('babyNumInp').value
    var numberOfSeniors = document.getElementById('seniorNumInp').value
    var numberOfYouth = document.getElementById('youthNumInp').value

    if (typeof dateFrom == 'undefined')
        dateFrom = document.getElementById('fromDateInp').value;
    if (typeof dateTo == 'undefined')
        dateTo = document.getElementById('toDateInp').value;
    if (document.getElementById('ToggleSearchBoxInp').value == "2") {
        document.getElementById('returnFromDestinationInp').value = document.getElementById('departureToDestinationInp').value;
    }
    else if (document.getElementById('ToggleSearchBoxInp').value == "1") {
        document.getElementById('returnFromDestinationInp').value = "";
    }
    if (document.getElementById('returnFromDestinationInp').value == document.getElementById('departureToDestinationInp').value) {
        document.getElementById('ToggleSearchBoxInp').value = "2"
    }
    var SpecificAirLineCode = "";
    if (typeof document.getElementById('SpecificAirLineCodeInp') != 'undefined' && document.getElementById('SpecificAirLineCodeInp') != null) {
        SpecificAirLineCode = document.getElementById('SpecificAirLineCodeInp').value;
    }
    window.location = "FlightsResults.aspx?from=" + document.getElementById('departureFromDestinationInp').value +
                        "&to=" + document.getElementById('departureToDestinationInp').value +
                        "&from2=" + document.getElementById('returnFromDestinationInp').value +
                        "&dateFrom=" + dateFrom +
                        "&dateTo=" + dateTo +
                        "&Type=" + document.getElementById('ToggleSearchBoxInp').value +
                        "&PassengersCode=" + GetPassengersCode(numberOfAdults, numberOfSeniors, numberOfChilds, numberOfYouth, numberOfInfants) +
                        //document.getElementById('AdultNumberDDL')[document.getElementById('AdultNumberDDL').selectedIndex].value + "00" + document.getElementById('ChildNumberDDL')[document.getElementById('ChildNumberDDL').selectedIndex].value + "0" + document.getElementById('InfantNumberDDL')[document.getElementById('InfantNumberDDL').selectedIndex].value +
                        "&SpecificAirLineCode=" + SpecificAirLineCode +
                        (document.getElementById('GclidInp').value.length > 0 ? "&gclid=" + document.getElementById('GclidInp').value : "");
    showWaitDiv();
}

function GoToResultPageFromHome() {
    showWaitDiv();
    var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1
    if (isChrome) {
        window.setTimeout('RedirectToResultPage();', 500);
    }
    else {
        RedirectToResultPage()
    }   
}
function RedirectToResultPage() {
    var numberOfAdults = document.getElementById('adultNumInp').value;
    var numberOfChilds = document.getElementById('childNumInp').value;
    var numberOfSeniors = document.getElementById('seniorNumInp').value;
    var numberOfYouth = document.getElementById('youthNumInp').value;
    var numberOfInfants = document.getElementById('babyNumInp').value;
    if (document.getElementById('ToggleSearchBoxInp').value == "2") {
        document.getElementById('returnFromDestinationInp').value = document.getElementById('departureToDestinationInp').value;
    }
    else if (document.getElementById('ToggleSearchBoxInp').value == "1") {
        document.getElementById('returnFromDestinationInp').value = "";
    }
    if (document.getElementById('returnFromDestinationInp').value == document.getElementById('departureToDestinationInp').value) {
        document.getElementById('ToggleSearchBoxInp').value = "2"
    }
    var SpecificAirLineCode = "";
    if (typeof document.getElementById('SpecificAirLineCodeInp') != 'undefined' && document.getElementById('SpecificAirLineCodeInp') != null) {
        SpecificAirLineCode = document.getElementById('SpecificAirLineCodeInp').value;
    }
    window.location = "FlightsResults.aspx?from=" + document.getElementById('departureFromDestinationInp').value +
                        "&to=" + document.getElementById('departureToDestinationInp').value +
                        "&from2=" + document.getElementById('returnFromDestinationInp').value +
                        "&dateFrom=" + document.getElementById('fromDateInp').value +
                        "&dateTo=" + document.getElementById('toDateInp').value +
                        "&Type=" + document.getElementById('ToggleSearchBoxInp').value +
                        "&PassengersCode=" + GetPassengersCode(numberOfAdults, numberOfSeniors, numberOfChilds, numberOfYouth, numberOfInfants) +
                        "&SpecificAirLineCode=" + SpecificAirLineCode +
                        (document.getElementById('GclidInp').value.length > 0 ? "&gclid=" + document.getElementById('GclidInp').value : "");    
}
function GetPassengersCode(adultNumber, seniorsNumber, childNumber,youthNumber, infantNumber) {
    var passengerCode = 0;
    passengerCode = (adultNumber.toString().toString().length > 0 ? adultNumber.toString() : "0")
                    + (seniorsNumber.toString().length > 0 ? seniorsNumber.toString() : "0")
                    + ("0")
                    + (childNumber.toString().length > 0 ? childNumber.toString() : "0")
                    + (youthNumber.toString().length > 0 ? youthNumber.toString() : "0")
                    + (infantNumber.toString().length > 0 ? infantNumber.toString() : "0");
    return passengerCode;
}

function CheckIfResultPageOK() {
    errorMsg = "";
    if (document.getElementById('departureToDestinationInp').value == document.getElementById('departureFromDestinationInp').value) {
        errorMsg = errorMsg + "לא ניתן לבחור יעד יציאה ויעד נחיתה זהים";
    }
    if (document.getElementById('departureToDestinationInp').value.length == 0) {
        errorMsg = "נא לבחור יעד";
    }
    if (document.getElementById('fromDateInp').value.length == 0) {
        errorMsg = errorMsg + "\r\n" + "נא לבחור תאריכים";
    }
    var numberOfAdults = document.getElementById('adultNumInp').value;
    var numberOfSeniors = document.getElementById('seniorNumInp').value;
    var numberOfYouth = document.getElementById('youthNumInp').value;
    if (Number(numberOfAdults) == 0 && Number(numberOfSeniors) == 0 && Number(numberOfYouth) == 0) {
        errorMsg = errorMsg + "\r\n" + "יש לבחור מבוגר או פנסיונר או צעיר אחד לפחות";
    }
    if (errorMsg.length == 0) {
        GoToResultPage();
    }
    else {
        alert(errorMsg);
        return false;
    }

}

function CheckIfHomePageOK() {
    
    errorMsg = "";
    flightType = "הלוך ןשוב מאותו יעד"
    if (document.getElementById('ToggleSearchBoxInp') == "1") {
        flightType = "כיוון אחד"
    }
    if (document.getElementById('ToggleSearchBoxInp') == "3") {
        flightType = "הלוך ושוב, חזרה מיעד שונה"
    }
    if (document.getElementById('departureToDestinationInp').value == document.getElementById('departureFromDestinationInp').value) {
        errorMsg = errorMsg + "לא ניתן לבחור יעד יציאה ויעד נחיתה זהים";
    }
    if (document.getElementById('departureToDestinationInp').value.length == 0) {
        errorMsg = "נא לבחור יעד";
    }
    if (document.getElementById('fromDateInp').value.length == 0) {
        errorMsg = errorMsg + "\r\n" + "נא לבחור תאריכים";
    }
    var numberOfAdults = document.getElementById('adultNumInp').value;
    var numberOfChilds = document.getElementById('childNumInp').value;
    var numberOfSeniors = document.getElementById('seniorNumInp').value;
    var numberOfYouth = document.getElementById('youthNumInp').value;
    var numberOfInfants = document.getElementById('babyNumInp').value;
    if (Number(numberOfAdults) == 0 && Number(numberOfSeniors) == 0 && Number(numberOfYouth) == 0)
    {
        errorMsg = errorMsg + "\r\n" + "יש לבחור מבוגר או פנסיונר או צעיר אחד לפחות";
    }
    if (errorMsg.length == 0) {
        _gaq.push(['_trackPageview', '/fp/?Page=Flights&Pos=Middle&Type=Button&Label=Search&FlightType=' + flightType]);
        GoToResultPageFromHome();
    }
    else 
    {
        alert(errorMsg);
        return false;
    }
}

function SetSearchBoxRadioInp(id) {
    document.getElementById('ToggleSearchBoxInp').value = id;
}

/////////////flights reservation////////////////////////////////
//function document_onkeypress() {
//    if (window.event.keyCode == 13)
//        showDealSummary();
//}
function SetupComboNoScroll(oCombo) {
    document.body.focus();
}
function restrictToEnglish(str) {
    var asciiChr;
    for (i = 0; i < str.length; i++) {
        asciiChr = str.charCodeAt(i);
        if ((asciiChr < 32) || (asciiChr > 32 && asciiChr < 65) ||
                    (asciiChr > 90 && asciiChr < 97) || (asciiChr > 122)) {
            return false;
        }
    }
    return true;
}

function recalculatePrice(obj, personNum) {
    var rentalPrice = 0;
//    if (document.getElementById("rentCarPriceLbl").innerText == "")
//        rentalPrice = 0;
//    else
//        rentalPrice = eval(document.getElementById("rentCarPriceLbl").innerText);
    var hotelPrice = 0;
//    if (document.getElementById("hotelPriceLbl").innerText == "")
//        hotelPrice = 0;
//    else
    //        hotelPrice = eval(document.getElementById("hotelPriceLbl").innerText);
    var totalInsSum = 0;
    if (document.getElementById('isInsurenceLi') != null) {
        document.getElementById('isInsurenceLi').style.display = 'none';
    }
    for (var personNum = 1; personNum <= 7; personNum++) {
        if (document.getElementById("passengerItem1_insurance_" + personNum)) {
            var currInsFee = eval(document.getElementById("passengerItem1_insurance_" + personNum).value);
            if (currInsFee > 0) {
                totalInsSum += currInsFee;
            }
            
        }
        if (document.getElementById("CharterPassenger" + "_insurance_" + personNum)) {
            var currInsFee = eval(document.getElementById("CharterPassenger" + "_insurance_" + personNum).value);
            if (currInsFee > 0) {
                totalInsSum += currInsFee;
            }
        }
    }if ((totalInsSum > 0) && (document.getElementById('isInsurenceLi') != null)) {
        document.getElementById('isInsurenceLi').style.display = 'block';
    }
    //document.getElementById("lblSumInsurance").innerText = Math.round(totalInsSum * 100.0) / 100.0;
    document.getElementById("lblTotalPrice").innerHTML = eval(document.getElementById("lblPrice").innerHTML) + totalInsSum + rentalPrice + hotelPrice;
    if (totalInsSum == 0) {
        document.getElementById('InsurenceTitleLbl').innerHTML = "";
    }
    else {
        document.getElementById('InsurenceTitleLbl').innerHTML = "כולל ביטוח";
    }

    if (document.getElementById("CurrencySignInp") != null) {/*Only for the new reservation pages*/
        document.getElementById('PaymentsDDL').options[0].text = document.getElementById("CurrencySignInp").value + document.getElementById("lblTotalPrice").innerHTML + ' בתשלום אחד';
    }

    if (document.getElementById("TotalInsurancePriceInp") != null) {
        document.getElementById("TotalInsurancePriceInp").value = totalInsSum.toString();
    }
    if (document.getElementById("UpdatePaymentsDropDownListBtn") != null) {
        document.getElementById("UpdatePaymentsDropDownListBtn").click();
    }
}

//function showDealSummary() { 
//    if (checkForm())
//        document.getElementById("OrderDeal").click();
//}

function CheckPassengersDetails() 
{
    var error = "\n";
    var isError = false;
    for (var personNum = 1; personNum <= 7; personNum++) 
    {
        //regular flight
        if (document.getElementById("passengerItem1_firstName_" + personNum)) 
        {
            var tenantLabel = document.getElementById("passengerItem1_tenantLabel_" + personNum).innerHTML;
            if (document.getElementById("passengerItem1_firstName_" + personNum).value == "") 
            {
                error += "יש להזין שם פרטי";
                isError = true;
                document.getElementById("passengerItem1_firstName_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                if (!restrictToEnglish(document.getElementById("passengerItem1_firstName_" + personNum).value)) 
                {
                    if (isError)
                        error += ", שם פרטי באנגלית";
                    else
                        error += "יש להזין שם פרטי באנגלית";
                    isError = true;
                    document.getElementById("passengerItem1_firstName_" + personNum).style.border = "1px solid #f24e22";
                }
                else 
                {
                    document.getElementById("passengerItem1_firstName_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (document.getElementById("passengerItem1_familyName_" + personNum).value == "") 
            {
                if (isError)
                    error += ", שם משפחה";
                else
                    error += "יש להזין שם משפחה";
                isError = true;
                document.getElementById("passengerItem1_familyName_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                if (!restrictToEnglish(document.getElementById("passengerItem1_familyName_" + personNum).value)) 
                {
                    if (isError)
                        error += ", שם משפחה באנגלית";
                    else
                        error += "יש להזין שם משפחה באנגלית";
                    isError = true;
                    document.getElementById("passengerItem1_familyName_" + personNum).style.border = "1px solid #f24e22";
                }
                else 
                {
                    document.getElementById("passengerItem1_familyName_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (document.getElementById("passengerItem1_idNumber_" + personNum).value != "") 
            {
                if (!CheckIDNumber(document.getElementById("passengerItem1_idNumber_" + personNum).value)) 
                {
                    if (isError)
                        error += ", מס' תעודת זהות תקני";
                    else
                        error += "יש להזין מס' תעודת זהות תקני";
                    isError = true;
                    document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #f24e22";
                }
                else 
                {
                    document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            else 
            {
                document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("passengerItem1_yearBirth_" + personNum).value == "-1") 
            {
                if (isError)
                    error += ", שנת לידה";
                else
                    error += "יש להזין שנת לידה";
                isError = true;
                document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("passengerItem1_monthBirth_" + personNum).value == "-1") 
            {
                if (isError)
                    error += ", חודש לידה";
                else
                    error += "יש להזין חודש לידה";
                isError = true;
                document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("passengerItem1_dayBirth_" + personNum).value == "-1") 
            {
                if (isError)
                    error += ", יום לידה";
                else
                    error += "יש להזין יום לידה";
                isError = true;
                document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else
            {
                if (!valiDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value, document.getElementById("passengerItem1_monthBirth_" + personNum).value, document.getElementById("passengerItem1_yearBirth_" + personNum).value)) 
                {
                    if (isError)
                        error += ", תאריך לידה חוקי";
                    else
                        error += "יש להזין תאריך לידה חוקי";
                    isError = true;
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }





            if (document.getElementById("passengerItem1_GenderDDL_" + personNum).value == "-1") {
                if (isError)
                    error += ", מין";
                else
                    error += "יש להזין מין";
                isError = true;
                document.getElementById("passengerItem1_GenderDDL_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                document.getElementById("passengerItem1_GenderDDL_" + personNum).style.border = "1px solid #7F9DB9";
            }




            if (document.getElementById('IsUSAInp').value == 'true') {
                if (document.getElementById("passengerItem1_PassportNumberTB_" + personNum).value.length < 7) {
                    document.getElementById("passengerItem1_PassportNumberTB_" + personNum).style.border = "1px solid #f24e22";
                    if (isError)
                        error += ",  להזין מספר דרכון";
                    else
                        error += "יש להזין מספר דרכון";
                }
                else {
                    document.getElementById("passengerItem1_PassportNumberTB_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            
            if (document.getElementById('IsUSAInp').value == 'true') {
                if (document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value.length < 8) {
                    document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).style.border = "1px solid #f24e22";
                    if (isError)
                        error += ", תוקף דרכון";
                    else
                        error += "יש להזין תוקף דרכון";
                }
                else if (!CheckPassportValidDate(document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[0] + document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[1], document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[3] + document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[4], document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[6] + document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[7] + document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[8] + document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).value[9])) {
                    if (isError)
                        error += ", תוקף דרכון";
                    else
                        error += "יש להזין תוקף דרכון";

                }
                else {
                    document.getElementById("passengerItem1_PassportValidDateTB_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }

                  
            if (document.getElementById("passengerItem1_insurance_" + personNum).value == "-1") {
                if (isError)
                    error += ",  לבחור ביטוח";
                else
                    error += "יש להזין ביטוח";
                isError = true;
                document.getElementById("passengerItem1_insurance_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                if (document.getElementById("passengerItem1_monthBirth_" + personNum).value != "-1"
                       && document.getElementById("passengerItem1_dayBirth_" + personNum).value != "-1"
                       && document.getElementById("passengerItem1_yearBirth_" + personNum).value != "-1"
                       && document.getElementById("passengerItem1_insurance_" + personNum).value != "0"
                       ) {
                    var bornDate = new Date();
                    bornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                    bornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                    bornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                    bornDate.setHours(00, 00, 00, 00);

                    var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                    var adultMinBornDate = new Date();
                    adultMinBornDate.setMonth(arriveDateArr[0] - 1);
                    adultMinBornDate.setDate(arriveDateArr[1]);
                    adultMinBornDate.setFullYear(arriveDateArr[2] - 50);
                    adultMinBornDate.setHours(00, 00, 00, 00);

                    if (bornDate - adultMinBornDate <= 0) {
                        if (isError)
                            error += ", לרכישת ביטוח לנוסעים מעל גיל 60 יש להתקשר ל-03-7137777\n";
                        else
                            error += "לרכישת ביטוח לנוסעים מעל גיל 60 יש להתקשר ל-03-7137777";
                        isError = true;
                        document.getElementById("passengerItem1_insurance_" + personNum).style.border = "1px solid #f24e22";
                    }
                    else {
                        document.getElementById("passengerItem1_insurance_" + personNum).style.border = "1px solid #7F9DB9";
                    }
                }
                else {
                    document.getElementById("passengerItem1_insurance_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (isError) {
                error += " ל" + tenantLabel.replace(":", "") + "\n";
            }
            isError = false;     
            var personType = tenantLabel.substring(0, 1);
            if (personType == "י")//child(age 2-11)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var chdMinBornDate = new Date();
                chdMinBornDate.setMonth(arriveDateArr[0] - 1);
                chdMinBornDate.setDate(arriveDateArr[1]);
                chdMinBornDate.setFullYear(arriveDateArr[2] - 11);
                chdMinBornDate.setHours(00, 00, 00, 00);
                var chdBornDate = new Date();
                chdBornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                chdBornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                chdBornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                chdBornDate.setHours(00, 00, 00, 00);
                if (chdBornDate - chdMinBornDate <= 0)
                {
                    if (error=="\n")
                        error = " ילד, הינו מי שטרם מלאו לו 11 ביום הטיסה.";
                    else
                        error += " ילד, הינו מי שטרם מלאו לו 11 ביום הטיסה.\n";
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "ת")//baby(age 0-2)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var infMinBornDate = new Date();
                infMinBornDate.setMonth(arriveDateArr[0] - 1);
                infMinBornDate.setDate(arriveDateArr[1]);
                infMinBornDate.setFullYear(arriveDateArr[2] - 2);
                infMinBornDate.setHours(00, 00, 00, 00);
                var infBornDate = new Date();
                infBornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                infBornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                infBornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                infBornDate.setHours(00, 00, 00, 00);
                if (infBornDate - infMinBornDate <= 0)
                {
                    if (error=="\n")
                        error = " תינוק, הינו מי שטרם מלאו לו שנתיים ביום הטיסה.";
                    else
                        error += " תינוק, הינו מי שטרם מלאו לו שנתיים ביום הטיסה.\n";
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "ס")//student(age 11-31)
            {

                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var chdMinBornDate = new Date();
                chdMinBornDate.setMonth(arriveDateArr[0] - 1);
                chdMinBornDate.setDate(arriveDateArr[1]);
                chdMinBornDate.setFullYear(arriveDateArr[2] - 31);
                chdMinBornDate.setHours(00, 00, 00, 00);
                var chdBornDate = new Date();
                chdBornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                chdBornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                chdBornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                chdBornDate.setHours(00, 00, 00, 00);
                if (chdBornDate - chdMinBornDate <= 0)
                {
                    if (error=="\n")
                        error = " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.";
                    else
                        error += " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.\n";
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "פ")//senior (older then 65)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var senMinBornDate = new Date();
                senMinBornDate.setMonth(arriveDateArr[0] - 1);
                senMinBornDate.setDate(arriveDateArr[1]);
                senMinBornDate.setFullYear(arriveDateArr[2] - 65);
                senMinBornDate.setHours(00, 00, 00, 00);
                var senBornDate = new Date();
                senBornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                senBornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                senBornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                senBornDate.setHours(00, 00, 00, 00);
                //alert(chdBornDate);
                if (chdBornDate - senMinBornDate >= 0)
                {
                    if (error=="\n")
                        error = " פנסיונר, הינו מי שמלאו לו 65 ביום הטיסה.";
                    else
                        error += " פנסיונר, הינו מי שמלאו לו 65 ביום הטיסה.\n";
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "צ")//youth(age 12-24)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var ythMinBornDate = new Date();
                ythMinBornDate.setMonth(arriveDateArr[0] - 1);
                ythMinBornDate.setDate(arriveDateArr[1]);
                ythMinBornDate.setFullYear(arriveDateArr[2] - 31);
                ythMinBornDate.setHours(00, 00, 00, 00);
                var ythBornDate = new Date();
                ythBornDate.setMonth(eval(document.getElementById("passengerItem1_monthBirth_" + personNum).value) - 1);
                ythBornDate.setDate(document.getElementById("passengerItem1_dayBirth_" + personNum).value);
                ythBornDate.setFullYear(document.getElementById("passengerItem1_yearBirth_" + personNum).value);
                ythBornDate.setHours(00, 00, 00, 00);
                if (ythBornDate - ythMinBornDate <= 0) {
                    if (error == "\n")
                        error = " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.";
                    else
                        error += " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.\n";
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("passengerItem1_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("passengerItem1_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
        }
        //charter
        if (document.getElementById("CharterPassenger_firstName_" + personNum)) {
            var tenantLabel = document.getElementById("CharterPassenger_tenantLabel_" + personNum).innerHTML;
            if (document.getElementById("CharterPassenger_firstName_" + personNum).value == "") {
                error += "יש להזין שם פרטי";
                isError = true;
                document.getElementById("CharterPassenger_firstName_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                if (!restrictToEnglish(document.getElementById("CharterPassenger_firstName_" + personNum).value)) {
                    if (isError)
                        error += ", שם פרטי באנגלית";
                    else
                        error += "יש להזין שם פרטי באנגלית";
                    isError = true;
                    document.getElementById("CharterPassenger_firstName_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_firstName_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (document.getElementById("CharterPassenger_familyName_" + personNum).value == "") 
            {
                if (isError)
                    error += ", שם משפחה";
                else
                    error += "יש להזין שם משפחה";
                isError = true;
                document.getElementById("CharterPassenger_familyName_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                if (!restrictToEnglish(document.getElementById("CharterPassenger_familyName_" + personNum).value)) {
                    if (isError)
                        error += ", שם משפחה באנגלית";
                    else
                        error += "יש להזין שם משפחה באנגלית";
                    isError = true;
                    document.getElementById("CharterPassenger_familyName_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_familyName_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (document.getElementById("CharterPassenger_idNumber_" + personNum).value != "") {
                if (!CheckIDNumber(document.getElementById("CharterPassenger_idNumber_" + personNum).value)) {
                    if (isError)
                        error += ", מס' תעודת זהות תקני";
                    else
                        error += "יש להזין מס' תעודת זהות תקני";
                    isError = true;
                    document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            else {
                document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("CharterPassenger_yearBirth_" + personNum).value == "-1") {
                if (isError)
                    error += ", שנת לידה";
                else
                    error += "יש להזין שנת לידה";
                isError = true;
                document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("CharterPassenger_monthBirth_" + personNum).value == "-1") {
                if (isError)
                    error += ", חודש לידה";
                else
                    error += "יש להזין חודש לידה";
                isError = true;
                document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
            }
            if (document.getElementById("CharterPassenger_dayBirth_" + personNum).value == "-1") {
                if (isError)
                    error += ", יום לידה";
                else
                    error += "יש להזין יום לידה";
                isError = true;
                document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
            }
            else 
            {
                if (!(valiDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value, document.getElementById("CharterPassenger_monthBirth_" + personNum).value, document.getElementById("CharterPassenger_yearBirth_" + personNum).value))) 
                {
                    if (isError)
                        error += ", תאריך לידה חוקי";
                    else
                        error += "יש להזין תאריך לידה חוקי";
                    isError = true;
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (document.getElementById("CharterPassenger_insurance_" + personNum).value == "-1") {
                if (isError)
                    error += ",  לבחור ביטוח";
                else
                    error += "יש להזין ביטוח";
                isError = true;
                document.getElementById("CharterPassenger_insurance_" + personNum).style.border = "1px solid #f24e22";
            }
            else {
                if (document.getElementById("CharterPassenger_monthBirth_" + personNum).value != "-1"
                       && document.getElementById("CharterPassenger_dayBirth_" + personNum).value != "-1"
                       && document.getElementById("CharterPassenger_yearBirth_" + personNum).value != "-1"
                       && document.getElementById("CharterPassenger_insurance_" + personNum).value != "0"
                       ) {
                    var bornDate = new Date();
                    bornDate.setMonth(eval(document.getElementById("CharterPassenger_monthBirth_" + personNum).value) - 1);
                    bornDate.setDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value);
                    bornDate.setFullYear(document.getElementById("CharterPassenger_yearBirth_" + personNum).value);
                    bornDate.setHours(00, 00, 00, 00);

                    var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                    var adultMinBornDate = new Date();
                    adultMinBornDate.setMonth(arriveDateArr[0] - 1);
                    adultMinBornDate.setDate(arriveDateArr[1]);
                    adultMinBornDate.setFullYear(arriveDateArr[2] - 50);
                    adultMinBornDate.setHours(00, 00, 00, 00);

                    if (bornDate - adultMinBornDate <= 0) {
                        if (isError)
                            error += ", לרכישת ביטוח לנוסעים מעל גיל 60 יש להתקשר ל-03-7137777\n";
                        else
                            error += "לרכישת ביטוח לנוסעים מעל גיל 60 יש להתקשר ל-03-7137777";
                        isError = true;
                        document.getElementById("CharterPassenger_insurance_" + personNum).style.border = "1px solid #f24e22";
                    }
                    else {
                        document.getElementById("CharterPassenger_insurance_" + personNum).style.border = "1px solid #7F9DB9";
                    }
                }
                else {
                    document.getElementById("CharterPassenger_insurance_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (isError) {
                error += " ל" + tenantLabel.replace(":", "") + "\n";
            }
            isError = false; 
            var personType = tenantLabel.substring(0, 1);
            if (personType == "י")//child(age 2-11)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var chdMinBornDate = new Date();
                chdMinBornDate.setMonth(arriveDateArr[0] - 1);
                chdMinBornDate.setDate(arriveDateArr[1]);
                chdMinBornDate.setFullYear(arriveDateArr[2] - 12);
                chdMinBornDate.setHours(00, 00, 00, 00);
                var chdBornDate = new Date();
                chdBornDate.setMonth(eval(document.getElementById("CharterPassenger_monthBirth_" + personNum).value) - 1);
                chdBornDate.setDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value);
                chdBornDate.setFullYear(document.getElementById("CharterPassenger_yearBirth_" + personNum).value);
                chdBornDate.setHours(00, 00, 00, 00);
                if (chdBornDate - chdMinBornDate <= 0)
                {
                    if (error == "\n")
                        error = tenantLabel + " ילד, הינו מי שטרם מלאו לו 12 ביום הטיסה.";
                    else
                        error += tenantLabel + " ילד, הינו מי שטרם מלאו לו 12 ביום הטיסה.\n";
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "ת")//baby(age 0-2)
            {
                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var infMinBornDate = new Date();
                infMinBornDate.setMonth(arriveDateArr[0] - 1);
                infMinBornDate.setDate(arriveDateArr[1]);
                infMinBornDate.setFullYear(arriveDateArr[2] - 2);
                infMinBornDate.setHours(00, 00, 00, 00);
                var infBornDate = new Date();
                infBornDate.setMonth(eval(document.getElementById("CharterPassenger_monthBirth_" + personNum).value) - 1);
                infBornDate.setDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value);
                infBornDate.setFullYear(document.getElementById("CharterPassenger_yearBirth_" + personNum).value);
                infBornDate.setHours(00, 00, 00, 00);
                if (infBornDate - infMinBornDate <= 0)
                {
                    if (error == "\n")
                        error = " תינוק, הינו מי שטרם מלאו לו שנתיים ביום הטיסה.";
                    else
                        error += " תינוק, הינו מי שטרם מלאו לו שנתיים ביום הטיסה.\n";
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "ס")//student(age 11-31)
            {

                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var chdMinBornDate = new Date();
                chdMinBornDate.setMonth(arriveDateArr[0] - 1);
                chdMinBornDate.setDate(arriveDateArr[1]);
                chdMinBornDate.setFullYear(arriveDateArr[2] - 31);
                chdMinBornDate.setHours(00, 00, 00, 00);
                var chdBornDate = new Date();
                chdBornDate.setMonth(eval(document.getElementById("CharterPassenger_monthBirth_" + personNum).value) - 1);
                chdBornDate.setDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value);
                chdBornDate.setFullYear(document.getElementById("CharterPassenger_yearBirth_" + personNum).value);
                chdBornDate.setHours(00, 00, 00, 00);
                if (chdBornDate - chdMinBornDate <= 0)
                {
                    if (error == "\n")
                        error = " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.";
                    else
                        error += " סטודנט, הינו מי שטרם מלאו לו 31 ביום הטיסה.\n";
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
            if (personType == "פ")//senior (older then 65)
            {

                var arriveDateArr = document.getElementById("dateArrival").value.split("/");
                var chdMinBornDate = new Date();
                chdMinBornDate.setMonth(arriveDateArr[0] - 1);
                chdMinBornDate.setDate(arriveDateArr[1]);
                chdMinBornDate.setFullYear(arriveDateArr[2] - 65);
                chdMinBornDate.setHours(00, 00, 00, 00);
                var chdBornDate = new Date();
                chdBornDate.setMonth(eval(document.getElementById("CharterPassenger_monthBirth_" + personNum).value) - 1);
                chdBornDate.setDate(document.getElementById("CharterPassenger_dayBirth_" + personNum).value);
                chdBornDate.setFullYear(document.getElementById("CharterPassenger_yearBirth_" + personNum).value);
                chdBornDate.setHours(00, 00, 00, 00);
                //alert(chdBornDate);
                if (chdBornDate - chdMinBornDate >= 0)
                {
                    if (error == "\n")
                        error = " פנסיונר, הינו מי שמלאו לו 65 ביום הטיסה.";
                    else
                        error += " פנסיונר, הינו מי שמלאו לו 65 ביום הטיסה.\n";
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #f24e22";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #f24e22";
                }
                else {
                    document.getElementById("CharterPassenger_monthBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_dayBirth_" + personNum).style.border = "1px solid #7F9DB9";
                    document.getElementById("CharterPassenger_yearBirth_" + personNum).style.border = "1px solid #7F9DB9";
                }
            }
        }
    }
    if (error == "\n")
        return "Valid";
    else
        return error;
}


//function CheckDatesValidity() {
//    var YearNow, MonthNow, MonthChoosen, YearChoosen;
//    YearNow = document.frmReservation.Year.value;
//    MonthNow = document.frmReservation.Month.value;
//    YearChoosen = document.frmReservation.YearExpireDDL.options[document.frmReservation.YearExpireDDL.selectedIndex].text;
//    MonthChoosen = document.frmReservation.MonthExpireDDL.options[document.frmReservation.MonthExpireDDL.selectedIndex].text;
//    if (parseFloat(YearNow) < parseFloat(YearChoosen)) {
//        return true;
//    }
//    else if (parseFloat(YearNow) == parseFloat(YearChoosen) && parseFloat(MonthNow) < parseFloat(MonthChoosen)) {
//        return true;
//    }
//    else {
//        return false;
//    }
//}

//function checkForm() {
//    var flag;
//    var l_error = "";
//    var tenantsDetailsCheck = checkTenantsDetails();
//    if (l_error == "" && !(tenantsDetailsCheck == "Valid"))
//        l_error = tenantsDetailsCheck;

//    if (l_error == "" && !CheckDatesValidity())
//        l_error = "תאריך התוקף שהוזן אינו חוקי, נא להזין שוב";

//    if (l_error == "") {
//        var CreditCardNumber = String(document.frmReservation.CardNumber.value);
//        var CreditCardType = String(document.frmReservation.CardTypeDDL.value);
//        CreditCardType = CreditCardType.substr(0, 1)

//        if (CreditCardNumber != "2610") //In order to enable Developers tests
//        {
//             If block if the card num is ok,check if user mark the chkBox to agree.
//            if (!CheckCreditCardNumber(CreditCardNumber, CreditCardType)) {
//                document.frmReservation.CardNumber.focus();
//                l_error = "מספר כרטיס אשראי שגוי";
//            }
//        }
//        else {
//            creditApproved = true; //In order to enable Developers tests
//        }

//    }
//    if (l_error == "" && !CheckCardLastNumbers())
//        l_error = "יש להזין 3 ספרות אחרונות בגב הכרטיס";

//    if (l_error == "" && !document.frmReservation.chkAgree.checked)
//        l_error = "אנא אשר הסכמתך לתנאים הכלליים";

//    if (l_error == "" && !CheckIDNumber(document.frmReservation.CardOwnerID.value))
//        if (document.frmReservation.CardOwnerID.value.length == 0) {
//            l_error = "יש למלא את שדות החובה";
//        }
//        else {
//            l_error = "מס' ת.ז. המשלם שגוי";
//        }

//    if (l_error == "" && !CheckName())
//        l_error = "יש למלא את שדות החובה";
//    if (l_error == "" && !CheckIfIdIsInDataBase())
//        l_error = "מספר תעודת הזהות אינו תואם את מספר הזהות של אחד הנוסעים";

//    if (l_error == "" && !CheckPhones()) {
//        _gaq.push(['_trackPageview', '/fp/?Page=Payment_Details&Pos=Submit_Order&Type=Button&Label=' + document.getElementById('ReservationIdInp').value + '_' + l_error])
//        return false;
//    }

//    if (l_error == "" && !CheckAddress())
//        l_error = "כתובת אינה חוקית הזן רחוב,בית ועיר לפחות";

//     check if no error occured
//    if (l_error == "") {
//        _gaq.push(['_trackPageview', '/fp/?Page=Payment_Details&Pos=Submit_Order&Type=Button&Label=' + document.getElementById('ReservationIdInp').value + '_OK'])
//        return true;
//    }
//    else {
//        _gaq.push(['_trackPageview', '/fp/?Page=Payment_Details&Pos=Submit_Order&Type=Button&Label=OK_' + document.getElementById('ReservationIdInp').value])
//        alert(l_error);
//    }
//    _gaq.push(['_trackPageview', '/fp/?Page=Payment_Details&Pos=Submit_Order&Type=Button&Label=' + document.getElementById('ReservationIdInp').value + '_' + l_error])
//    return false;
//}

function CheckAddress() {
    // Here we want tocheck that the following fields entered:City,Street,Number of House %>
    if (document.frmReservation.CardOwnerCity.value == "" || document.frmReservation.CardOwnerCity.value == "בחר עיר" || document.frmReservation.CardOwnerSt.value == "" || document.frmReservation.CardOwnerSt.value == "רחוב" || document.frmReservation.CardOwnerStNum.value == "" || document.frmReservation.CardOwnerStNum.value == "בית")
        return false;

    // Check we have number of appartment and if nothing entered set it to empty value
    if (document.frmReservation.CardOwnerApt.value == "דירה")
        document.frmReservation.CardOwnerApt.value = "";
    // Check we have number of zip code and if nothing entered set it to empty value
    if (document.frmReservation.CardOwnerZC.value == "מיקוד")
        document.frmReservation.CardOwnerZC.value = "";
    return true;
}

function CheckNumber(NumberValue, TotalDigits, DecimalDigits) {
    var RegExpString = "^(\\d{0," + (TotalDigits - DecimalDigits) + "})(\\.(\\d{0," + DecimalDigits + "}))?$";
    var NumberRegExp = new RegExp(RegExpString);
    retVal = null;

    if (NumberRegExp.test(NumberValue)) {
        NumberRegExp.exec(NumberValue);
        var Integer = RegExp.$1.valueOf();
        var Decimal = RegExp.$3.valueOf();
        retVal = true;
    }
    else {
        retVal = false;
    }
    return retVal;
}

//function CheckPhones() {
//    var Phone = String(document.frmReservation.CardOwnerPhone.value);
//    var MPhone = String(document.frmReservation.CardOwnerMPhone.value);
//    var Email = String(document.frmReservation.CardOwnerEmail.value);
//    if (Email.length == 0) {
//        alert("עליך להזין כתובת דוא''ל")
//        document.frmReservation.CardOwnerEmail.focus()
//        return false
//    }

//    if (Phone != "בית" && Phone.length > 0)
//        if (!CheckNumber(Phone, 7, 0)) {
//            alert("הקש מספר ספרות מדוייק בטלפון")
//            document.frmReservation.CardOwnerPhone.focus()
//            return false
//        }
//        return true;
////    if (MPhone != "נייד" && MPhone.length > 0)
////        if (!CheckNumber(MPhone, 7, 0)) {
////            alert("הקש מספר ספרות מדוייק בטלפון הנייד")
////            document.frmReservation.CardOwnerMPhone.focus()
////            return false
////        }
////    //Make sure that the client entered one of the  phones
////    if ((Phone == "בית" || Phone.length == 0) || (MPhone == "נייד" || MPhone.length == 0)) {
////        alert("עליך להזין גם מספר טלפון וגם מספר פלאפון");
////        return false;
////    }
////    else {
////        //If the phone entered save it hidden field to be inserted to DB
////        if (Phone != "בית" && Phone.length > 0) {
////            document.all.item("hidPhone").value = Phone;
////            if (MPhone == "נייד")
////                document.frmReservation.CardOwnerMPhone.value = "";
////            return true;
////        }
////        //If the Mobile Phone entered save it hidden field to be inserted to DB
////        if (MPhone != "נייד" && MPhone.length > 0) {
////            document.all.item("hidPhone").value = MPhone;
////            if (Phone == "בית")
////                document.frmReservation.CardOwnerPhone.value = "";
////            return true;
////        }
////    }
//}

function CheckIfIdIsInDataBase() {
    var identity = document.getElementById("CardOwnerID").value;
    if (identity.charAt(0) == '0') {
        identity = identity.substring(1, identity.length);
    }
    for (var personNum = 1; personNum <= 7; personNum++) {
        if (document.getElementById("passengerItem1_idNumber_" + personNum)) {
            var currId = document.getElementById("passengerItem1_idNumber_" + personNum).value;
            if (currId.charAt(0) == '0') {
                currId = currId.substring(1, currId.length);
            }
            //Go through all the ID's from Current details form to check if the entered ID is one of them 
            if (identity != currId) {
                document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #f24e22";
            }
            else //if (document.getElementById("CardOwnerID").value == currId) 
            {
                document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                return true;
            }
        }
        if (document.getElementById("CharterPassenger_idNumber_" + personNum)) {
            var currId = document.getElementById("CharterPassenger_idNumber_" + personNum).value;
            if (currId.charAt(0) == '0') {
                currId = currId.substring(1, currId.length);
            }
            //Go through all the ID's from Current details form to check if the entered ID is one of them 
            if (identity != currId) {
                document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #f24e22";
            }
            else //if (document.getElementById("CardOwnerID").value == currId) 
            {
                document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                return true;
            }
        }
    }
    return false;
}

//function CheckName() {
//    var myName = String(document.frmReservation.CardOwnerName.value);

//    if (myName.length == 0)
//        return false;

//    return true;
//}
function CmbPaymentChng() {
    var DealTypeDDL = document.getElementById("DealTypeDDL")
    var PaymentsDDL = document.getElementById("PaymentsDDL")
    var PaymentOneDDL = document.getElementById("PaymentOneDDL")
    if (DealTypeDDL.value == "1") {
        PaymentsDDL.style.display = "none";
        PaymentOneDDL.style.display = "inline";
    }
    else {
        PaymentsDDL.style.display = "inline";
        PaymentOneDDL.style.display = "none";
    }
}
/* Javascript date check by Justin Klein Keane 2004 */
function valiDate(theDay, theMonth, theYear) 
{
    if (theDay > 31) {
        alert("תאריך לא חוקי");
        return false;
    }
    if (theMonth > 12) {
        alert("תאריך לא חוקי");
        return false;
    }
    if ((theYear % 4 == 0) && (theDay > 29) && (theMonth == 2)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else if ((theYear % 4 != 0) && (theDay > 28) && (theMonth == 2)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else if ((theDay > 30) && (theMonth == 4 || theMonth == 6 || theMonth == 0 || theMonth == 9 || theMonth == 11)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else 
    {
        return true;
    }
}
function CheckPassportValidDate(theDay, theMonth, theYear)
{
    if (theDay > 31) {
        alert("תאריך לא חוקי");
        return false;
    }
    if (theMonth > 12) {
        alert("תאריך לא חוקי");
        return false;
    }
    var maxValidDate = new Date();
    if (theYear > maxValidDate.getFullYear() + 15) {
        alert("תוקף דרכון לא חוקי");
        return false;
    }
    var departureFlightDateStr = document.getElementById("DepartureFlightDateInp").value;
    var departureFlightDate = new Date(departureFlightDateStr.split('/')[2], parseInt(departureFlightDateStr.split('/')[1])-1, departureFlightDateStr.split('/')[0]);
    var minValidDate = new Date(departureFlightDate.getFullYear(), departureFlightDate.getMonth() + 6, departureFlightDate.getDate());
    var passportValidDate = new Date(theYear, parseInt(theMonth)-1, theDay);
    if (passportValidDate < minValidDate) {
        alert("לקוח יקר, על מנת לבצע את הזמנתך דרכונך צריך להיות בתוקף חצי שנה מיום הנסיעה.");
        return false;
    }
    if ((theYear % 4 == 0) && (theDay > 29) && (theMonth == 2)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else if ((theYear % 4 != 0) && (theDay > 28) && (theMonth == 2)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else if ((theDay > 30) && (theMonth == 4 || theMonth == 6 || theMonth == 0 || theMonth == 9 || theMonth == 11)) {
        alert("תאריך לא חוקי");
        return false;
    }
    else {
        return true;
    }
}

function ChooseCar(carId, RsrvCurrencyPrice) {
    var hotelPrice = 0;
    if (document.getElementById("hotelPriceLbl").innerText == "")
        hotelPrice = 0;
    else
        hotelPrice = eval(document.getElementById("hotelPriceLbl").innerText);
    if (carId.indexOf("not_Choose") > -1) {
        document.getElementById("CarIdInp").value = "-1";
        document.getElementById("rentCarPriceLbl").innerHTML = ""
        document.getElementById("lblTotalPrice").innerHTML = eval(document.getElementById("lblPrice").innerHTML) + eval(document.getElementById("lblSumInsurance").innerHTML) + hotelPrice;
        document.getElementById("rentalTR").style.display = "none";
    }
    else {
        document.getElementById("CarIdInp").value = carId.split('_')[1];
        document.forms['frmReservation'].elements['rentCar'][carId].checked = true;
        document.getElementById("rentCarPriceLbl").innerHTML = Math.round(RsrvCurrencyPrice);
        document.getElementById("lblTotalPrice").innerHTML = Math.round(eval(document.getElementById("lblPrice").innerHTML) + eval(document.getElementById("lblSumInsurance").innerHTML) + hotelPrice + RsrvCurrencyPrice, 0);
        document.getElementById("rentalTR").style.display = "block";
    }
}
function ChooseHotel(hotelId, RsrvCurrencyPrice) {
    var rentalPrice = 0;
    if (document.getElementById("rentCarPriceLbl").innerHTML == "")
        rentalPrice = 0;
    else
        rentalPrice = eval(document.getElementById("rentCarPriceLbl").innerHTML);

    if (hotelId.indexOf("not_Choose") > -1) {
        document.getElementById("HotelIdInp").value = "-1";
        document.getElementById("hotelPriceLbl").innerHTML = ""
        document.getElementById("lblTotalPrice").innerHTML = eval(document.getElementById("lblPrice").innerHTML) + eval(document.getElementById("lblSumInsurance").innerHTML) + rentalPrice;
        document.getElementById("hotelTR").style.display = "none";
    }
    else {
        document.getElementById("HotelIdInp").value = hotelId.split('_')[1];
        document.forms['frmReservation'].elements['Hotels'][hotelId].checked = true;
        document.getElementById("hotelPriceLbl").innerHTML = Math.round(RsrvCurrencyPrice, 0);
        document.getElementById("lblTotalPrice").innerHTML = Math.round(eval(document.getElementById("lblPrice").innerHTML) + eval(document.getElementById("lblSumInsurance").innerHTML) + rentalPrice + RsrvCurrencyPrice, 0);
        document.getElementById("hotelTR").style.display = "block";
    }
}
var globLinx = "";
var globObj = "";
var globSide = "";
var hidden;
function show_tooltip_click(linx, obj, side) {
    var originalT = document.getElementById(obj).offsetHeight;
    if ((browserDetect('opera')) || (browserDetect('firefox'))) {
        leftx = (findPosX(linx)) - 320;
        topx = (findPosY(linx)) - (originalT - 5);
    }
    else if (browserDetect('msie')) {
        leftx = (findPosX(linx)) - 320;
        topx = (findPosY(linx)) - (originalT - 5);
    }

    document.getElementById(obj).style.left = leftx + 'px';
    document.getElementById(obj).style.top = topx + 'px';
    document.getElementById(obj).style.visibility = 'visible';
}
function hide_tooltip(obj) {
    document.getElementById(obj).style.visibility = 'hidden';
}
function browserDetect(text) {
    str = (navigator.userAgent.toLowerCase()).indexOf(text) + 1;
    data = text;
    return str;
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function pageTrackerInsurance(insKind) {
    var urlstring = document.frmReservation.action;
    pageTracker._trackPageview('/insurance/?InsuranceType=' + insKind + '&url=/Flights/Content/' + urlstring);
}

function ShowWriteOpinion() {
    document.getElementById('WriterNameInp').value = '';
    document.getElementById('AirLineRecommendationInp').value = '';
    document.getElementById('WriteOpinion').style.display = 'block';
    document.getElementById('WriteOpinionComplete').style.display = 'none';
}
////////////////////////End of flight reservation///////////////////

function CheckIfFieldsFullAndTransferToResults() {
    if (document.getElementById('departureToDestinationInp').value.length == 0) {
        alert('יש לבחור יעד');
        return false;
    }
    if (document.getElementById('fromDateInp').value.length == 0) {
        alert('יש לבחור תאריכים');
        return false;
    }
    if (document.getElementById('adultNumInp').value.length == 0) {
        alert('יש לבחור הרכב');
        return false;
    }
    var passengerCode = document.getElementById('adultNumInp').value + "00" + document.getElementById('childNumInp').value + "0" +
                            document.getElementById('babyNumInp').value
    document.location = "FlightsResults.aspx?from=TLV&to=" + document.getElementById('departureToDestinationInp').value +
                                "&dateFrom=" + document.getElementById('fromDateInp').value + "&dateTo=" + document.getElementById('toDateInp').value +
                                    "&Type=2&PassengersCode=" + passengerCode;
    showWaitDiv();
    return false;    
}




//combine

function setCombineResultActive(tabLinkId) {
    tabArr = document.getElementById(tabLinkId).parentNode.parentNode.getElementsByTagName('A');
    for (i = 0; i < tabArr.length; i++)
        if (tabArr[i].className.indexOf(' activBox') != -1)
            tabArr[i].className = tabArr[i].className.split(' activBox')[0];
    document.getElementById(tabLinkId).className += " activBox";
}

// search box slider
function toggleSearchBoxCombine(linxObj, toggle, heightx, oriHeightSlot) {
    if (toggle) {
        maximumHeight = heightx;
        originalHeight[oriHeightSlot] = linxObj.parentNode.parentNode.offsetHeight;
        getNextSibling(getNextSibling(linxObj.parentNode)).style.display = "";

        openingDrawer = getNextSibling(getNextSibling(linxObj.parentNode)).getElementsByTagName('div')[2];
        if (document.getElementById('searchComboHolder') && (oriHeightSlot == 1)) document.getElementById('searchComboHolder').style.visibility = "hidden";
        opening_oriHeight = originalHeight[oriHeightSlot];
        search_openUpCombine();
    }
    else {
        closingdrawer = linxObj.parentNode;
        closing_oriHeight = originalHeight[oriHeightSlot];
        search_closeDownCombine();
    }
}


var originalHeight = new Array(0, 0);
var closing_oriHeight = 0;
var opening_oriHeight = 0;
var flightsOutputHeight, flightsOutputDiv;
var flightsOutputHeight_count = 10;
var flightsOutputHeight_inProgress = false;

function search_openUpCombine() {
    inprogress = true;
    if (openingCount < maximumHeight) {
        openingCount += curSpeed;
        openingDrawer.style.height = openingCount + "px";

        if ((openingCount) >= opening_oriHeight)
            openingDrawer.parentNode.parentNode.parentNode.parentNode.style.height = (openingCount + 5) + "px";

        if ((openingCount >= easeStep01) && (openingCount < easeStep02)) curSpeed = speed03;
        else if ((openingCount >= easeStep02) && (openingCount < easeStep03)) curSpeed = speed02;
        else if ((openingCount >= easeStep03) && (openingCount < easeStep04)) curSpeed = speed01;
        setTimeout("search_openUpCombine()", 1);
    }
    else {
        openingCount = minimumHeight;
        closingCount = maximumHeight;
        curSpeed = speed02;
        inprogress = false;
    }
}

function search_closeDownCombine() {
    inprogress = true;
    if (openingCount < maximumHeight) openingCount += curSpeed;
    if (closingCount > minimumHeight) {
        closingCount -= curSpeed;
        closingdrawer.style.height = closingCount + "px";
        if (closingCount > closing_oriHeight) {
            closingdrawer.parentNode.parentNode.parentNode.parentNode.style.height = (closingCount + 5) + "px";
        }
        if ((openingCount >= easeStep01) && (openingCount < easeStep02)) curSpeed = speed03;
        else if ((openingCount >= easeStep02) && (openingCount < easeStep03)) curSpeed = speed02;
        else if ((openingCount >= easeStep03) && (openingCount < easeStep04)) curSpeed = speed01;
        setTimeout("search_closeDownCombine()", 5);
    }
    else {
        openingCount = minimumHeight;
        closingCount = maximumHeight;
        curSpeed = speed02;
        inprogress = false;
        closingdrawer.parentNode.parentNode.parentNode.style.display = "none";
        closingdrawer.parentNode.parentNode.parentNode.parentNode.style.height = closing_oriHeight + "px";
        if (document.getElementById('searchComboHolder')) document.getElementById('searchComboHolder').style.visibility = "visible";
    }
}

// results functions
function directFlights_overCombine(trObj, whichMO) {
    if (whichMO) {
        trObj.className += " flightResults_box_ro";
        getNextSibling(trObj).className += " flightResults_box_open_ro"; //trObj.nextSibling.className += " Direct_flights_box_open_ro";
    }
    else {
        trObj.parentNode.className += " flightResults_box_open_ro";
        getPrevSibling(trObj.parentNode).className += " flightResults_box_ro"; //trObj.parentNode.previousSibling.className += " Direct_flights_box_ro";
    }
}

function directFlights_outCombine(trObj, whichMO) {
    if (whichMO) {                             
        trObj.className = trObj.className.split(" flightResults_box_open_ro")[0];
        getNextSibling(trObj).className = getNextSibling(trObj).className.split(" flightResults_box_open_ro")[0]; //trObj.nextSibling.className = trObj.nextSibling.className.split(" Direct_flights_box_open_ro")[0];
    }
    else {
        trObj.parentNode.className = trObj.parentNode.className.split(" flightResults_box_open_ro")[0]
        getPrevSibling(trObj.parentNode).className = getPrevSibling(trObj.parentNode).className.split(" flightResults_box_open_ro")[0]; //trObj.parentNode.previousSibling.className = trObj.parentNode.previousSibling.className.split(" Direct_flights_box_ro")[0];
    }
}

function directFlights_closeCombine(trObj) {
    openedDiv = getPrevSibling(trObj.parentNode);
    flightsOutputDiv = openedDiv.getElementsByTagName('div')[0];
    flightsOutputHeight = openedDiv.getElementsByTagName('div')[0].offsetHeight;
    document.getElementById('liteBox').style.display = "block";
    document.getElementById('liteBox').className = "liteBox_trans";
    document.getElementById('liteBox').style.height = document.body.offsetHeight + 50 + "px";
    close_resultsTableCombine();
}

function close_resultsTableCombine() {
    flightsOutputHeight_inProgress = true;
    if ((flightsOutputHeight - flightsOutputHeight_count) > 4) {
        flightsOutputHeight_count += 4;
        flightsOutputDiv.style.height = (flightsOutputHeight - flightsOutputHeight_count) + "px";
        setTimeout('close_resultsTableCombine()', 1);
    }
    else {
        flightsOutputHeight_inProgress = false;
        flightsOutputHeight_count = 10;

        flightsOutputDiv.style.height = "auto";
        flightsOutputDiv.parentNode.style.display = "none";
        getNextSibling(flightsOutputDiv.parentNode).style.display = "none";
        flightsOutputDiv.parentNode.setAttribute('opened', 'false');

        getPrevSibling(flightsOutputDiv.parentNode).style.display = "";
        getPrevSibling(flightsOutputDiv.parentNode).className = getPrevSibling(flightsOutputDiv.parentNode).className.split(" flightResults_box_open_ro")[0];
        getPrevSibling(getPrevSibling(flightsOutputDiv.parentNode)).className = getPrevSibling(getPrevSibling(flightsOutputDiv.parentNode)).className.split(" flightResults_box_ro")[0];
        getPrevSibling(getPrevSibling(flightsOutputDiv.parentNode)).onmouseover = function () { directFlights_overCombine(this, 1); }
        getPrevSibling(getPrevSibling(flightsOutputDiv.parentNode)).onmouseout = function () { directFlights_outCombine(this, 1); }
        getPrevSibling(getPrevSibling(flightsOutputDiv.parentNode)).setAttribute('clicked', 'false');

        getPrevSibling(flightsOutputDiv.parentNode).getElementsByTagName('A')[0].onmouseover = function () { directFlights_overCombine(this, 0); }
        getPrevSibling(flightsOutputDiv.parentNode).getElementsByTagName('A')[0].onmouseout = function () { directFlights_outCombine(this, 0); }

        flightsOutputLinx = flightsOutputDiv.getElementsByTagName('A');
        for (i = 0; i < flightsOutputLinx.length; i++)
            if (flightsOutputLinx[i].className == "result_box_open_more_info_minus") {
                flightsOutputLinx[i].className = "result_box_open_more_info_plus";
                flightsOutputLinx[i].innerHTML = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
                flightsOutputLinx[i].title = "הצג טיסות נוספות, בתאריכים ושעות שונות במחירים גבוהים יותר";
            }

        document.getElementById('liteBox').style.display = "none";
        document.getElementById('liteBox').className = "liteBox";
    }
}

function onflightCharter_over(trObj) {
    trObj.className += " Direct_flights_box_oneFlight_ro";
}

function onflightCharter_out(trObj) {
    trObj.className = trObj.className.split(" Direct_flights_box_oneFlight_ro")[0];
}

function backgroundPositionOnOver(t, value) {
    t.style.backgroundPosition = value;
}

function toggleCombineFlights_tabs(tabLink) {
    contentDiv_num = 1;
    combineContent_arr = document.getElementById('combineGreyBox_flights').getElementsByTagName('div');
    for (i = 0; i < combineContent_arr.length; i++)
        if (combineContent_arr[i].className == "result_left_side_Combine")
            combineContent_arr[i].parentNode.style.minHeight = combineContent_arr[i].offsetHeight + "px";
}

function toggleCombineCharter_tabs(tabLink) {
    contentDiv_num = 1;
    combineContent_arr = document.getElementById('combineGreyBox_flights').getElementsByTagName('div');
    for (i = 0; i < combineContent_arr.length; i++)
        if (combineContent_arr[i].className == "result_left_side_Charter_Combine")
            combineContent_arr[i].parentNode.style.minHeight = combineContent_arr[i].offsetHeight + "px";
}

function CheckDepartureFromDestination(dest) {

    if (document.getElementById('departureFromDestinationInp').value == '') {
        dest.value = '';
    }
}

function CheckDepartureToDestination(dest) {

    if (document.getElementById('departureToDestinationInp').value == '') {
        dest.value = '';
    }
}

function CheckReturnFromDestination(dest) {

    if (document.getElementById('returnFromDestinationInp').value == '') {
        dest.value = '';
    }
}

function CheckReturnToDestination(dest) {

    if (document.getElementById('departureToDestinationInp').value == '') {
        dest.value = '';
    }
}

function SetDepartureFrom(source, eventArgs) {
    if (eventArgs._value.length > 0) {
        document.getElementById('departureFromDestinationInp').value = eventArgs._value.split('~')[0];
        document.getElementById('returnToDestinationInp').value = eventArgs._value.split('~')[0];
        document.getElementById('locationFrom1').value = document.getElementById('locationFrom1').value.split(',')[0].split(' - ')[0];
    }
    else {
        document.getElementById('departureFromDestinationInp').value = '';
        document.getElementById('returnToDestinationInp').value = '';
        document.getElementById('locationFrom1').value = '';
    }
    _gaq.push(['_trackPageview', '/fp/?page= Flights &Pos= search &Type=write_des &Label=' + eventArgs._text.replace(/'/g, "").replace(/\"/g, "")]);
 

    var j = Sys.UI.DomElement.getLocation(source.get_element());
    var x = j.x - 17;
    var y = j.y + 20;
    $common.setLocation($get("AutoCompletePnl"), new Sys.UI.Point(x, y));
}

function SetDepartureTo(source, eventArgs) {
    if (eventArgs._value.length > 0) {
        document.getElementById('departureToDestinationInp').value = eventArgs._value.split('~')[0];
        document.getElementById('locationTo1').value = document.getElementById('locationTo1').value.split(',')[0].split(' - ')[0];
    }
    else {
        document.getElementById('departureToDestinationInp').value = '';
        document.getElementById('locationTo1').value = '';
    }
    _gaq.push(['_trackPageview', '/fp/?page= Flights &Pos= search &Type=write_des &Label=' + eventArgs._text.replace(/'/g, "").replace(/\"/g, "")]);

    var j = Sys.UI.DomElement.getLocation(source.get_element());
    var x = j.x - 17;
    var y = j.y + 20;
    $common.setLocation($get("AutoCompletePnl"), new Sys.UI.Point(x, y));
}

function SetDepartureFrom2(source, eventArgs) {
    if (eventArgs._value.length > 0) {
        document.getElementById('returnFromDestinationInp').value = eventArgs._value.split('~')[0];
        document.getElementById('locationFrom2').value = document.getElementById('locationFrom2').value.split(',')[0].split(' - ')[0];
    }
    else {
        document.getElementById('returnFromDestinationInp').value = '';
        document.getElementById('locationFrom2').value = '';
    }
    _gaq.push(['_trackPageview', '/fp/?page= Flights &Pos= search &Type=write_des &Label=' + eventArgs._text.replace(/'/g, "").replace(/\"/g, "")]);

    var j = Sys.UI.DomElement.getLocation(source.get_element());
    var x = j.x - 17;
    var y = j.y + 20;
    $common.setLocation($get("AutoCompletePnl"), new Sys.UI.Point(x, y));
}

function SetDepartureTo2(source, eventArgs) {
    
    if (eventArgs._value.length > 0) {
        document.getElementById('returnToDestinationInp').value = eventArgs._value.split('~')[0];
        document.getElementById('locationTo2').value = document.getElementById('locationTo2').value.split(',')[0].split(' - ')[0];
    }
    else {
        document.getElementById('returnToDestinationInp').value = '';
        document.getElementById('locationTo2').value = '';
    }
    _gaq.push(['_trackPageview', '/fp/?page= Flights &Pos= search &Type=write_des &Label=' + eventArgs._text.replace(/'/g, "").replace(/\"/g, "")]);

    var j = Sys.UI.DomElement.getLocation(source.get_element());
    var x = j.x - 17;
    var y = j.y + 20;
    $common.setLocation($get("AutoCompletePnl"), new Sys.UI.Point(x, y));
}



function showTooltipflight(object, Widthx, Heightx, t) {
    if (document.getElementById) {
        leftx = Number(t.offsetWidth) + Number(Widthx);
        topx = Number(t.offsetTop) + Number(Heightx);
        document.getElementById(object).style.left = leftx + 'px';
        document.getElementById(object).style.top = topx + 'px';
        document.getElementById(object).style.visibility = 'visible';
        document.getElementById(object).style.display = 'block';
    }
}



function SetBobleClass(linx, obj, arr) {
    leftx = (findPosX(linx)) + 10;
    var viewportheight;
    if (typeof window.innerWidth != 'undefined')
        viewportheight = window.innerHeight;
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
        viewportheight = document.documentElement.clientHeight;
    else viewportheight = document.getElementsByTagName('body')[0].clientHeight;

    gStop = parseInt(getScrollTop());
    linxTopx = parseInt(findPosY(linx));
    objOffsetHeight = parseInt(document.getElementById(obj).offsetHeight);
        
    if ((linxTopx + objOffsetHeight) > (gStop + viewportheight)) {
        topx = (findPosY(linx)) - (objOffsetHeight + 10);
        document.getElementById(arr).className = "BubbleArro_dwn";
        document.getElementById(obj).style.top = (40 - objOffsetHeight) + 'px';
    }
    else {
        topx = (findPosY(linx)) + 32;
        document.getElementById(arr).className = "BubbleArro_up";
        document.getElementById(obj).style.top = 78 + 'px';
    }
    document.getElementById(obj).style.left = 20 + 'px';
}

function SetWaitingListInfoPopupClass(linx, obj, arr) {
    leftx = (findPosX(linx)) + 10;
    var viewportheight;
    if (typeof window.innerWidth != 'undefined')
        viewportheight = window.innerHeight;
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
        viewportheight = document.documentElement.clientHeight;
    else viewportheight = document.getElementsByTagName('body')[0].clientHeight;

    gStop = parseInt(getScrollTop());
    linxTopx = parseInt(findPosY(linx));
    objOffsetHeight = parseInt(document.getElementById(obj).offsetHeight);

    if ((linxTopx + objOffsetHeight) > (gStop + viewportheight)) {
        topx = (findPosY(linx)) - (objOffsetHeight + 10);
        document.getElementById(arr).className = "BubbleArro_dwn";
        document.getElementById(obj).style.top = (20 - objOffsetHeight) + 'px';
    }
    else {
        topx = (findPosY(linx)) + 32;
        document.getElementById(arr).className = "BubbleArro_up";
        document.getElementById(obj).style.top = 50 + 'px';
    }
    document.getElementById(obj).style.left = 110 + 'px';
}
function OpenBlock() {
    if (document.getElementById('LocationOpenBlockInp').value != '') {
        window.location.hash = document.getElementById('LocationOpenBlockInp').value;
    }
    if (document.getElementById('lastOpenBlockIdInp').value != '') {
        directFlightsCharter_open(document.getElementById(document.getElementById('lastOpenBlockIdInp').value), 0);
        //                if (document.getElementById('MoreOpenBlockIdInp').value != '') {
        //                    obj = document.getElementById(document.getElementById('MoreOpenBlockIdInp').value);
        //                    moreInfoOverflow_toggleOpenBlock(obj.getElementsByTagName('a')[0]);
        //                }
    }
    if (document.getElementById('LocationOpenBlockInp').value != '') {
        window.location.hash = document.getElementById('LocationOpenBlockInp').value;
    }

}
function SetInputBlock(id) {
    document.getElementById('lastOpenBlockIdInp').value = id;
    document.getElementById('LocationOpenBlockInp').value = document.getElementById(id.replace('_MultiReturnFlightA', '_BlockJumpA')).name;
}
function SetMoreFlightsInputBlock(id, id2) {
    document.getElementById('MoreOpenBlockIdInp').value = id;
    document.getElementById('lastOpenBlockIdInp').value = id2;
    document.getElementById('LocationOpenBlockInp').value = document.getElementById(id2.replace('_MultiReturnFlightA', '_BlockJumpA')).name;
    //            obj = document.getElementById(document.getElementById('MoreOpenBlockIdInp').value);
    //            document.getElementById('MoreOpenBlockHightInp').value = getNextSibling(obj).offsetHeight;
}
function SetSingleOpenBlock(id) {
    document.getElementById('LocationOpenBlockInp').value = id;
    document.getElementById('lastOpenBlockIdInp').value = '';
}

// Agent Help function
var agentOpened = false;
function AgentHelp(linx) {
    if (!agentOpened) {
        document.getElementById('discountVoucher_open').style.display = "";
        linx.innerHTML = "סגור";
        linx.title = "סגור";
        linx.className += " discountVoucher_opended";
        agentOpened = true;
    }
    else {
        document.getElementById('discountVoucher_open').style.display = "none";
        linx.innerHTML = "האם סייע לך נציג?";
        linx.title = "האם סייע לך נציג?";
        linx.className = linx.className.split(" discountVoucher_opended")[0];
        agentOpened = false;
    }
}

function SendToGoogle(dest) {    
    _gaq.push(['_trackPageview', '/fp/?Page=Charter_Results&Pos=תאריך&Type=Link&Label=' + dest]);
}
function ShowNameInstructionLB() {
    if (document.getElementById('IsNameInstructionShowed').value != 'true') {
        document.getElementById('IsNameInstructionShowed').value = 'true';
        document.getElementById('liteBox').style.display = "block";
        document.getElementById('liteBox').style.height = document.body.offsetHeight + 114 + "px";
        document.getElementById('nameInstruction').style.visibility = 'hidden';
        document.getElementById('nameInstruction').style.display = 'block';
        leftx = ((document.body.offsetWidth / 2) - (document.getElementById('nameInstruction').offsetWidth / 2));
        topx = ((vpHeight() / 2) - (document.getElementById('nameInstruction').offsetHeight / 2)) + getScrollTop();
        document.getElementById('nameInstruction').style.left = leftx + "px";
        document.getElementById('nameInstruction').style.top = topx + "px";
        document.getElementById('nameInstruction').style.visibility = 'visible';
        popOpenObj = 'nameInstruction';
    }
}
function SendToGoogle(text) {
    _gaq.push(['_trackPageview', '/fp/?Page=' + text + '&Pos=help &Type=Button&Label=help']);
}
function uptoDH_250(textObj) {
    if (textObj.value != "") {
        str = (textObj.value).length;
        if (str > 250) {
            textObj.value = textObj.value.substring(0, 250);
            str = (textObj.value).length;
        }
        getNextSibling(getNextSibling(getNextSibling(getNextSibling(getNextSibling(textObj))))).innerHTML = "נותרו " + (250 - str) + " תווים";
    }
    else {
        getNextSibling(getNextSibling(getNextSibling(getNextSibling(getNextSibling(textObj))))).innerHTML = "נותרו 250 תווים";
    }
}

function focusOnDH_upto250(textObj) {
    if (textObj.value == '(הזן מלל חופשי (עד 250 תווים') {
        textObj.value = '';
        getNextSibling(getNextSibling(getNextSibling(getNextSibling(getNextSibling(textObj))))).innerHTML = "נותרו 250 תווים";
    }
    else {
        textObj.value = textObj.value.substring(0, 250);
        str = (textObj.value).length;
        getNextSibling(getNextSibling(getNextSibling(getNextSibling(getNextSibling(textObj))))).innerHTML = "נותרו " + (250 - str) + " תווים";
    }
}

function blurOnDH_upto250(textObj) {
    if (textObj.value == '') {
        textObj.value = '(הזן מלל חופשי (עד 250 תווים';
        getNextSibling(getNextSibling(getNextSibling(getNextSibling(getNextSibling(textObj))))).innerHTML = "נותרו 250 תווים";
    }
}

function CheckPaymentDetails() {
    var flag;
    var error = ""; 

    if (!CheckDatesValidity()) {
        if (error == "")
            error = "תאריך התוקף שהוזן אינו חוקי";
        else
            error += "\nתאריך התוקף שהוזן אינו חוקי";
        document.getElementById('CardNumber').style.border = "1px solid #f24e22";
    }
    else {
        document.getElementById('CardNumber').style.border = "1px solid #7F9DB9";
    }

    var CreditCardNumber = String(document.getElementById("CardNumber").value);
    var CreditCardType = String(document.getElementById("CardTypeDDL").value);
    CreditCardType = CreditCardType.substr(0, 1)

    if ((CreditCardNumber != "2610") && (CreditCardNumber != "2708")) //In order to enable Developers tests
    {
        // If block if the card num is ok,check if user mark the chkBox to agree.
        if (!CheckCreditCardNumber(CreditCardNumber, CreditCardType)) {
            if (error == "") {
                error = "מספר כרטיס אשראי שגוי";
            }
            else {
                error += "\nמספר כרטיס אשראי שגוי";
            }
            document.getElementById('CardNumber').style.border = "1px solid #f24e22";
        }
        else {
            document.getElementById('CardNumber').style.border = "1px solid #7F9DB9";
        }
    }
    else {
        creditApproved = true; //In order to enable Developers tests
        document.getElementById('CardNumber').style.border = "1px solid #7F9DB9";
    }
    var cardLastNumbers = String(document.getElementById("CardIdLastNumbers").value);
    if (cardLastNumbers.length == 0) {
        document.getElementById("CardIdLastNumbers").style.border = "1px solid #f24e22";
        if (error == "")
            error = "יש להזין 3 ספרות אחרונות בגב הכרטיס";
        else
            error += "\nיש להזין 3 ספרות אחרונות בגב הכרטיס";
    }
    else {
        document.getElementById("CardIdLastNumbers").style.border = "1px solid #7F9DB9";
    }

   

    if (!CheckIDNumber(document.getElementById("CardOwnerID").value)) {
        if (error == "")
            error = "מס' ת.ז. של בעל הכרטיס שגוי";
        else
            error += "\nמס' ת.ז. של בעל הכרטיס שגוי";
        document.getElementById('CardOwnerID').style.border = "1px solid #f24e22";
    }
    else {
        document.getElementById('CardOwnerID').style.border = "1px solid #7F9DB9";
    }

    var myName = String(document.getElementById("CardOwnerName").value).trim();
    if (myName.length == 0) {
        if (error == "")
            error = "יש להזין שם בעל הכרטיס";
        else
            error += "\nיש להזין שם בעל הכרטיס";
        document.getElementById('CardOwnerName').style.border = "1px solid #f24e22";
    }
    else if (myName.indexOf(' ') == -1) {
        if (error == "")
            error = "בשם בעל הכרטיס יש להזין שם פרטי ומשפחה";
        else
            error += "\nבשם בעל הכרטיס יש להזין שם פרטי ומשפחה";
        document.getElementById('CardOwnerName').style.border = "1px solid #f24e22";
    }
   
        if (!IsEnglishString(myName)) {
            if (error == "")
                error = "שם בעל הכרטיס חייב להיות באנגלית";
            else
                error += "\nשם בעל הכרטיס חייב להיות באנגלית";
            document.getElementById('CardOwnerName').style.border = "1px solid #f24e22";
        }
        else {
            document.getElementById('CardOwnerName').style.border = "1px solid #7F9DB9";
        }  



   
    var phoneError = CheckPhones();
    if (phoneError.length > 0) {
        if (error.length == 0)
            error = phoneError;
        else
            error += "\n" + phoneError;
    }

    // check if no error occured
    if (error == "") {
        document.getElementById('ContinueBtn').click();   
        return true;
    }
    else {
        alert(error);     
        return false;
    }
}
function CheckLastReservationDetails() {

    var error = "";

    var passError = CheckPassengersDetails();
    if (!(passError == "Valid"))
        error = passError;

    if (!CheckIfIdIsInDataBaseForNewReservationPage())
    {
        if (error == "")
            error = "תעודת הזהות של בעל כרטיס האשראי חייבת להיות של אחד הנוסעים";
        else
            error += "\nתעודת הזהות של בעל כרטיס האשראי חייבת להיות של אחד הנוסעים";
    }

    if (!document.getElementById("chkAgree").checked) {
        if (error == "")
            error = "אנא אשר הסכמתך לתנאים הכלליים";
        else
            error += "\nאנא אשר הסכמתך לתנאים הכלליים";
        document.getElementById('chkAgree').style.border = "1px solid #f24e22";
    }
    else {
        document.getElementById('chkAgree').style.border = "";
    }


    // check if no error occured
    if (error == "") {
        if (document.getElementById("isOrderDealInp") != null)
            document.getElementById("isOrderDealInp").value = "true";
        document.getElementById("submitHref").style.visibility = "hidden";
        document.getElementById("CheckDoubleReservationBtn").click();
        return true;
    }
    else 
    {
        alert(error);
        return false;
    }

}

function CheckIfIdIsInDataBaseForNewReservationPage() {
    var identity = document.getElementById("CardOwnerId").value;
    if (identity.charAt(0) == '0') {
        identity = identity.substring(1, identity.length);
    }
    for (var personNum = 1; personNum <= 7; personNum++) {
        if (document.getElementById("passengerItem1_idNumber_" + personNum)) {
            var currId = document.getElementById("passengerItem1_idNumber_" + personNum).value;
            if (currId.charAt(0) == '0') {
                currId = currId.substring(1, currId.length);
            }
            //Go through all the ID's from Current details form to check if the entered ID is one of them 
            if (identity != currId) {
                document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #f24e22";
            }
            else //if (document.getElementById("CardOwnerID").value == currId) 
            {
                document.getElementById("passengerItem1_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                return true;
            }
        }
        if (document.getElementById("CharterPassenger_idNumber_" + personNum)) {
            var currId = document.getElementById("CharterPassenger_idNumber_" + personNum).value;
            if (currId.charAt(0) == '0') {
                currId = currId.substring(1, currId.length);
            }
            //Go through all the ID's from Current details form to check if the entered ID is one of them 
            if (identity != currId) {
                document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #f24e22";
            }
            else //if (document.getElementById("CardOwnerID").value == currId) 
            {
                document.getElementById("CharterPassenger_idNumber_" + personNum).style.border = "1px solid #7F9DB9";
                return true;
            }
        }
    }
    return false;
}

