﻿// sid - shader id
// tid - shader text id
function ShowShader(sid, tid, msg)
{
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shaderOn";
		tex.innerHTML = '<span>' + msg + '</span>';
	}
}

// sid - shader id
// tid - shader text id
function HideShader(sid, tid)
{
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shaderOff";
		tex.innerHTML = "&nbsp;";
	}
}

// sid - shader id
// tid - shader text id
function Show3Shader(sid, tid, msg) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader3On";
		tex.innerHTML = '<span>' + msg + '</span>';
	}
}

// sid - shader id
// tid - shader text id
function Hide3Shader(sid, tid) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader3Off";
		tex.innerHTML = "&nbsp;";
	}
}

// aid - adlinks container id
// sid - shader id
// cid - collapse container id
function ExpandAdLinks(aid, sid, cid)
{	
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var ads = document.getElementById(aid);
	var sha = document.getElementById(sid);
	var col = document.getElementById(cid);
	if (ads) {
		sha.style.display = "none";
		ads.style.height = ads.scrollHeight + "px";
		col.style.display = "block";
		// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
		ads.parentNode.style.display = "none";
		ads.parentNode.style.display = "block"; 
	}
}

// aid - adlinks container id
// sid - shader id
// cid - collapse container id
// height - the height at which to collapse the container
function CollapseAdLinks(aid, sid, cid, height)
{
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var ads = document.getElementById(aid);
	var sha = document.getElementById(sid);
	var col = document.getElementById(cid);
	if (ads) {
		ads.style.height = height + "px";
		sha.style.display = "block";
		col.style.display = "none";
		// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
		ads.parentNode.style.display = "none"; 
		ads.parentNode.style.display = "block";
	}
}

// show - bool value to show or hide drop down lists (true = visible)
function SetDropDownsVisibilityIE6(show)
{
	if (typeof document.body.style.maxHeight == "undefined") // This returns "undefined" only for IE6
	{
		var ddls = document.getElementsByTagName("select");
		for (i = 0; i < ddls.length; i++) {
			ddls[i].style.visibility = show ? "visible" : "hidden";
		}
	}
}

function EnableVerticalSupplierLinks(element)
{
	var lContainer = document.getElementById("verticalSupplierLinks");

	SetDropDownsVisibilityIE6(false);
	
	if (lContainer != null)
	{
		lContainer.style.top = findPosY(element) - 200 + 'px';
	
		SetSupplierDisplayStyle(lContainer,true);
	}
}

// by default - we hide the dropdown lists in IE6
function EnableVerticalSupplierLinksWithPublication(element, code, hideFlashMap, wideContainer, offsetX, offsetY, showDropDownLists)
{
	var lHtmlChildrenElements;
	var lContainer = document.getElementById("verticalSupplierLinksGeneralContainer");

//	if (!showDropDownLists)
//		SetDropDownsVisibilityIE6(false);
		
	if (hideFlashMap == true) {
		ShowCountryFlashMap(false);
	}
	
	if (lContainer != null) {
		if (offsetX != null)
			lContainer.style.left = (element.offsetLeft + 20) + offsetX + 'px';
		else
			lContainer.style.left = (element.offsetLeft + 20) + 'px';

		if (offsetY != null)
			lContainer.style.top = (element.offsetTop + 25) + offsetY + 'px';
		else
			lContainer.style.top = (element.offsetTop + 25) + 'px';

		if (wideContainer == true) {
			lContainer.style.width = '410px';
			if (offsetX == null) {
				lContainer.style.left = (element.offsetLeft) + 'px';
			}
		}
		else {
			lContainer.style.width = '201px';
		}
	
		SetSupplierDisplayStyle(lContainer,true);
		
		lHtmlChildrenElements = lContainer.childNodes;
	
		for (i = 0; i < lHtmlChildrenElements.length; i++)
		{
			if (lHtmlChildrenElements[i].id != null &&
			    lHtmlChildrenElements[i].id.indexOf ("verticalSupplierLinksSpecificContainer-") == 0)
			{
				if (lHtmlChildrenElements[i].id == ("verticalSupplierLinksSpecificContainer-" + code))
				{
					SetSupplierDisplayStyle(lHtmlChildrenElements[i], true);
				}
				else
				{
					SetSupplierDisplayStyle(lHtmlChildrenElements[i], false);
				}
			}
		}
		
		// Set the iframe
		var lIFrame = document.getElementById("SuppliersIFrame");
		var IE = document.all; // for IE6 we will add some extra width and height
		lIFrame.style.width = lContainer.scrollWidth + (IE ? 4 : 0) + "px";
		lIFrame.style.height = lContainer.scrollHeight + (IE ? 4 : 0) + "px";
		lIFrame.style.top = lContainer.offsetTop + "px";
		lIFrame.style.left = lContainer.offsetLeft + "px";
		lIFrame.style.display = "block";
	}
}


function DisableVerticalSupplierLinks()
{
	var lContainer = document.getElementById("verticalSupplierLinks");
	if (lContainer != null)
	{
		SetSupplierDisplayStyle(lContainer,false);
	}
	
	SetDropDownsVisibilityIE6(true);
}

function DisableVerticalSupplierLinksWithPublication ()
{
	var lContainer = document.getElementById("verticalSupplierLinksGeneralContainer");
	if (lContainer != null)
	{
		SetSupplierDisplayStyle(lContainer,false);
		
		// Set the iframe
		var lIFrame = document.getElementById("SuppliersIFrame");
		lIFrame.style.display = "none";
	}

	SetDropDownsVisibilityIE6(true);
	ShowCountryFlashMap(true);
}

function SetSupplierDisplayStyle(container,display)
{
		if(display == true)
		{	
			container.style.display = "block";
		}
		else
		{
			container.style.display = "none";
		}	
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) 
	{
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curtop += obj.offsetTop
		}
	}
	return curtop;
}


var BrowserDetector = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "IE",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function setBodyClassName ()
{
	var lBodyObject;
	var lBodyTags = document.getElementsByTagName ('body');

	if (lBodyTags != null && lBodyTags.length > 0)
	{
		BrowserDetector.init();
		lBodyObject = lBodyTags[0];
		if (lBodyObject.className != '')
		{
			lBodyObject.className = lBodyObject.className + ' ' + BrowserDetector.browser;
		}
		else
		{
			lBodyObject.className = BrowserDetector.browser;
		}
	}
}
// global variables
var popUpDivClassName = "popUpDivClass";
var pageLoaded = false;
var SelectedDropDown = '';

// This function creates an opaque overlay div 
// and adds the content of the contentPopup parameter to the center of the overlay
function CreateOverlayPopUpWindow(contentPopupId, closeButtonText, entityId) {
	if (CreateOuterOverlay(contentPopupId, closeButtonText, entityId))
		CreateOverlayContent(contentPopupId, closeButtonText, entityId);
}

// This function creates an opaque overlay div 
// and adds the content of the contentPopup parameter to the center of the overlay
function CreateFlightTicketsOverlayPopUpWindow(contentPopupId, closeButtonText, url, selectId) {
	if (CreateOuterOverlay(contentPopupId, closeButtonText, null)) {
		if (selectId != 'undefined' && selectId != null) {
			RememberSelection(selectId);
			SelectedDropDown = selectId;
		}
		CreateFlightOverlayContent(contentPopupId, closeButtonText, url);
	}
}

// This function creates an opaque overlay div for the google pop-up only
// and adds the content of the contentPopup parameter to the center of the overlay
function CreateGoogleOverlayPopUpWindow(contentPopupId, closeButtonText, entityId, score, url) {
	if (pageLoaded) {
		if (CreateOuterOverlay(contentPopupId, closeButtonText, entityId))
			CreateGoogleOverlayPopupContent(contentPopupId, closeButtonText, entityId, score, url);
	}
}

// This checks if the user accepts cookies. If it doesn't than the popup is not displayed
// NOTE: The test cookie is added in the control for the site selection overlay
function CheckCookie() {
    if (document.cookie == "") {
        return false;
    } else {
        return true;
    }
}

function CreateOuterOverlay(contentPopupId, closeButtonText, entityId) {
	var wucPopUpOverlayExtender = document.getElementById(contentPopupId);
	var lTempDivId = "tempDiv_" + contentPopupId;
	if (wucPopUpOverlayExtender == null) {
		//only show the pop-up when the overlay external control
		//in rendered into the page
		var tempDiv = document.getElementById(lTempDivId);
		if (tempDiv != null)
		//removes the div from page
			tempDiv.parentNode.removeChild(tempDiv);
		return false;
	}

	//set banners visibility
	//solution for the overlay banner pop-up problem
	ShowFlashObjects(false);
	ShowCountryFlashMap(false);
	ShowFrames(false);

	//create the overlay div
	var modalDiv = document.getElementById(lTempDivId);
	if (modalDiv == null) {
		modalDiv = document.createElement("div");
		modalDiv.name = lTempDivId;
		modalDiv.id = lTempDivId;

		if (typeof (tempDivClassName) != 'undefined') {
			//for syndication pages, it is set in the syndication pages
			modalDiv.className = tempDivClassName;
		}
		else {
			modalDiv.className = "modalBackground";
			modalDiv.style.width = screen.width + 'px';
			modalDiv.style.height = screen.height + 'px';

			if (typeof (BrowserDetector.browser) == 'undefined') {
				BrowserDetector.init();
			}
			if ((BrowserDetector.browser == 'IE' || BrowserDetector.browser == 'Explorer') && BrowserDetector.version < 7) {
				modalDiv.className += " modalBackgroundIE";
				modalDiv.style.height = document.body.offsetHeight;
			}
		}

		document.body.appendChild(modalDiv);
	}

	if (BrowserIsIE6())
	{
	    SetDropDownsVisibility(false);
    }
		
	return true;
}

function BrowserIsIE6() {
    return getInternetExplorerVersion() == 6;
}

// Returns the version of Internet Explorer or a -1 (indicating the use of another browser).
function getInternetExplorerVersion()
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null) {
            rv = parseFloat(RegExp.$1);
        }
    }
    return rv;
}

// show - bool value to show or hide drop down lists (true = visible)
function SetDropDownsVisibility(show) {
    if (typeof document.body.style.maxHeight == "undefined") // This returns "undefined" only for IE6
    {
        var ddls = document.getElementsByTagName("select");
        for (i = 0; i < ddls.length; i++) {
            ddls[i].style.visibility = show ? "visible" : "hidden";
        }
    }
}

function SetCustomVisibleDelay (timeout)
{
	setTimeout("setVisibility()", timeout);	
}

function setVisibility() {
    var div = document.getElementById("popupTopCloseButton");
    if (div != null) {
        div.style.display = "block";
    }
}

function CloseOverlay(lTempDivId, hideFlashMapCountry)
{
    var modalDiv = document.getElementById(lTempDivId);

    if (modalDiv != null) {
        if (BrowserIsIE6()) {
            SetDropDownsVisibility(true);
        }
    	modalDiv.style.display = "none";
    }    

    var popUpDiv = document.getElementById("temp_popupOverlayExternal");
    if(popUpDiv != null){
	    popUpDiv.style.display = "none";
	}
	
    //set banners visibility
    //solution for the overlay pop-up problem
	ShowFlashObjects(true);
	if (hideFlashMapCountry != true) {
		ShowCountryFlashMap(true);
	}
	ShowFrames(true);
	
	if (typeof (BrowserDetector.browser) == 'undefined') {
		BrowserDetector.init();
	}
	
	if (BrowserDetector.browser == 'Firefox' || BrowserDetector.browser == 'Mozilla') {
		//This piece of code makes sure that the videos from the page are not over the vertical supplier links if they are visible
		var lVerticalSuppliers = document.getElementById("SuppliersIFrame");
		if (lVerticalSuppliers != "undefined" && lVerticalSuppliers != null && lVerticalSuppliers.style.display == "block") {
			lVerticalSuppliers.contentWindow.document.body.innerHTML = lVerticalSuppliers.contentWindow.document.body.innerHTML;
			lVerticalSuppliers.style.display = "block";
		}
	}
}

function CloseOverlayFlight(lTempDivId) {
	var lHideFlash = false;
	if (SelectedDropDown.indexOf("flight_supp") > 0) {
		lHideFlash = true;
	}
	CloseOverlay(lTempDivId, lHideFlash);
	
	SetRememberSelections();
}

function CreateOverlayContent(contentPopupId, closeButtonText, entityId) 
{
    if (contentPopupId == 'InvisiblepopupOverlayExternal') {
        CreateExternalOverlayContent(contentPopupId, closeButtonText);
    }
    if (contentPopupId == 'SiteSelectionOverlayPopup') {
        CreateUserSiteSelectionOverlayContent(contentPopupId);
    }
   }

function CreateFlightOverlayContent(contentPopupId, closeButtonText, url) {
	var popUpDiv = document.getElementById("temp_popupOverlayExternal");

	if (popUpDiv == null) {
		popUpDiv = document.createElement("div");
		popUpDiv.name = "temp_popupOverlayExternal";
		popUpDiv.id = "temp_popupOverlayExternal";
		popUpDiv.className = popUpDivClassName;
		popUpDiv.style.left = Math.abs((screen.width - 990) / 2) + 145 + 'px';
		popUpDiv.style.top = 315 + 'px';
		document.body.appendChild(popUpDiv);
	}
	else {
		popUpDiv.style.display = "";
		document.getElementById("tempDiv_" + contentPopupId).style.display = "";
	}

	popUpDiv.innerHTML = "<div id='popupOverlayExternal' class='overlayExternal google-pop-up'>"
            + "<div id='popupTopCloseButton' onclick='CloseOverlayFlight(\"tempDiv_" + contentPopupId + "\")' class='close' style='cursor:pointer'>"
            + "<span>" + closeButtonText + "</span></div>"
            + "<iframe src='" + url + "' width='660' height='480' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>"
			+ "</div>";

	SetPopupScrollPosition(popUpDiv);   
}

function CreateExternalOverlayContent(contentPopupId, closeButtonText) 
{
    var popUpDiv = document.getElementById("temp_popupOverlayExternal");

    if (popUpDiv == null) {
        popUpDiv = document.createElement("div");
        popUpDiv.name = "temp_popupOverlayExternal";
        popUpDiv.id = "temp_popupOverlayExternal";
        popUpDiv.className = popUpDivClassName;
        popUpDiv.style.left = Math.abs((screen.width - 990) / 2) + 255 + 'px';
        popUpDiv.style.top = 10 + 'px';
        popUpDiv.innerHTML = "<div id='popupOverlayExternal' class='overlayExternal' style='width:550px'>"
            + "<div id='popupTopCloseButton' onclick='CloseOverlay(\"tempDiv_" + contentPopupId + "\")' class='topOverlayExternalCloseButton' style='display:none'>"
            + "<span>" + closeButtonText + "</span></div>"
			+ document.getElementById(contentPopupId).innerHTML
			+ "</div>";

        document.body.appendChild(popUpDiv);
    }
    SetCustomVisibleDelay(5000);
}

function CreateUserSiteSelectionOverlayContent(contentPopupId) {
    var popUpDiv = document.getElementById("temp_popupOverlayExternal");

    if (popUpDiv == null) {
    		popUpDiv = document.createElement("div");
        popUpDiv.name = "temp_popupOverlayExternal";
        popUpDiv.id = "temp_popupOverlayExternal";
        popUpDiv.className = popUpDivClassName;
        popUpDiv.style.top = 315 + 'px';
        popUpDiv.style.width = 'auto';
        popUpDiv.innerHTML = "<div id='popupOverlayExternal' class='overlayExternal'>"
			+ document.getElementById(contentPopupId).innerHTML
			+ "</div>";
        
        document.body.appendChild(popUpDiv);

        var lWidth = 0;
        if (popUpDiv.clientWidth)
        	lWidth = popUpDiv.clientWidth;
        if (lWidth != 0)
        	popUpDiv.style.marginLeft = Math.abs((screen.width - lWidth) / 2) + 'px';
    }
}

function CreateGoogleOverlayPopupContent(contentPopupId, closeButtonText, entityId, score, url) {
	var popUpDiv = document.getElementById("temp_popupOverlayExternal");

	if (popUpDiv == null) {
		popUpDiv = document.createElement("div");
		popUpDiv.name = "temp_popupOverlayExternal";
		popUpDiv.id = "temp_popupOverlayExternal";
		popUpDiv.className = popUpDivClassName;
		popUpDiv.style.left = Math.abs((screen.width - 990) / 2) + 145 + 'px';
		popUpDiv.style.top = 315 + 'px';
		document.body.appendChild(popUpDiv);
	}
	else
	{
		popUpDiv.style.display = "";
		document.getElementById("tempDiv_" + contentPopupId).style.display = ""; 
	}

	popUpDiv.innerHTML = "<div id='popupOverlayExternal' class='overlayExternal google-pop-up'>"
            + "<div id='popupTopCloseButton' onclick='CloseOverlay(\"tempDiv_" + contentPopupId + "\")' class='close' style='cursor:pointer'>"
            + "<span>" + closeButtonText + "</span></div>"
            + "<iframe src='" + url + "?entid=" + entityId + "&score=" + score
            + "' width='660' height='464' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>"
			+ "</div>";
			
	SetPopupScrollPosition(popUpDiv);
}

function SetPopupScrollPosition(popUpDiv)
{
	var lScrollY, lDefaultY = 100;

	if (window.scrollY)
		lScrollY = window.scrollY;
	else
		if (document.documentElement.scrollTop)
		lScrollY = document.documentElement.scrollTop;
	else
		lScrollY = document.body.scrollTop;

	popUpDiv.style.top = lScrollY + lDefaultY + 'px';
}

var BrowserDetect = {
	init: function() {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function(data) {
		for (var i = 0; i < data.length; i++) {
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function(dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
	},
	dataBrowser: [
		{ string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS: [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function SetPageLoaded() {
	pageLoaded = true;
}

BrowserDetect.init();

if (BrowserDetect.browser == 'Explorer') {
	window.onload = SetPageLoaded;
}
else {
	SetPageLoaded();
}

Type.registerNamespace('NetMatch.Zoover.Web.MyZoover.Services');
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService = function() {
	NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.initializeBase(this);
	this._timeout = 0;
	this._userContext = null;
	this._succeeded = null;
	this._failed = null;
}
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.prototype = {
	_get_path: function() {
		var p = this.get_path();
		if (p) return p;
		else return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_path();
	},
	GetLoginBox: function(mlmmCode, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetLoginBox', false, { mlmmCode: mlmmCode }, succeededCallback, failedCallback, userContext);
	},
	GetForgotPasswordBox: function(mlmmCode, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetForgotPasswordBox', false, { mlmmCode: mlmmCode }, succeededCallback, failedCallback, userContext);
	},
	PerformLogin: function(userEmail, userPassword, rememberMe, mlmmCode, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'PerformLogin', false, { userEmail: userEmail, userPassword: userPassword, rememberMe: rememberMe, mlmmCode: mlmmCode }, succeededCallback, failedCallback, userContext);
	},
	PerformLogout: function(mlmmCode, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'PerformLogout', false, { mlmmCode: mlmmCode }, succeededCallback, failedCallback, userContext);
	},
	ForgotPassword: function(email, mlmmCode, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'ForgotPassword', false, { email: email, mlmmCode: mlmmCode }, succeededCallback, failedCallback, userContext);
	},
	GetMyZooverProfiles: function(emailAddresses, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetMyZooverProfiles', false, { emailAddresses: emailAddresses }, succeededCallback, failedCallback, userContext);
	} 
}
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.registerClass('NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService', Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_path = function(value) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.get_path = function() { return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_path(); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_timeout = function(value) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.get_timeout = function() { return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.set_path("/MyZoover/Services/MyZooverUIService.asmx");
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.GetLoginBox = function(mlmmCode, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.GetLoginBox(mlmmCode, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.GetForgotPasswordBox = function(mlmmCode, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.GetForgotPasswordBox(mlmmCode, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.PerformLogin = function(userEmail, userPassword, rememberMe, mlmmCode, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.PerformLogin(userEmail, userPassword, rememberMe, mlmmCode, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.PerformLogout = function(mlmmCode, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.PerformLogout(mlmmCode, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.ForgotPassword = function(email, mlmmCode, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.ForgotPassword(email, mlmmCode, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService.GetMyZooverProfiles = function(emailAddresses, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService._staticInstance.GetMyZooverProfiles(emailAddresses, onSuccess, onFailed, userContext); }
var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;
Type.registerNamespace('NetMatch.Zoover.MyZoover');
if (typeof (NetMatch.Zoover.MyZoover.MyZooverProfileInformation) === 'undefined') {
	NetMatch.Zoover.MyZoover.MyZooverProfileInformation = gtc("NetMatch.Zoover.MyZoover.MyZooverProfileInformation");
	NetMatch.Zoover.MyZoover.MyZooverProfileInformation.registerClass('NetMatch.Zoover.MyZoover.MyZooverProfileInformation');
}

/*
This script is used for myZoover functionality
*/
var _LoginBoxContainerId = "myZooverLoginBoxContainer";
var _ForgotPasswordBoxContainerId = "MyZooverModalContent";
var _Email = "";

// Gets the HTML for the login box
function GetLoginBox() {
    var proxy = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
    proxy.GetLoginBox(getMlmmCode(), getLoginBoxHTML, onError);
}

// Gets the HTMl for the Forgot Password popup
function GetForgotPasswordBox() {
	var proxy = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
	proxy.GetForgotPasswordBox(getMlmmCode(), getForgotPasswordBoxHTML, onError);
}

// Performs the login
function PerformLogin(user, pass, rememberMe) {
    var proxy = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
    proxy.PerformLogin(user, pass, rememberMe, getMlmmCode(), doLoginResult, onError);
}

// Performs the logout
function DoLogout() {
    var proxy = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
    proxy.PerformLogout(getMlmmCode(), doLogoutResult);
}

// Performs the forgot password action on a myZoover account email
function ForgotPassword(email) {
	_Email = email;
	var proxy = new NetMatch.Zoover.Web.MyZoover.Services.MyZooverUIService();
	proxy.ForgotPassword(email, getMlmmCode(), ForgotPasswordResult);
}

// Shows the error message in case the forgot password did not work as expected
function ForgotPasswordResult(result) {
	if (result != '') { alert(result); }
	else {
		alert(Password_Remembered.replace("{0}", _Email));
		RemoveForgotPasswordModal();
	}
}

// Refresh the login box if the login was successful
function doLoginResult(result) {
    if (result != '') { alert(result); }
    else {
        GetLoginBox();
    }
}

// Renders the HTML in the login box container
function getLoginBoxHTML(result) {
    if (result != '') { $get(_LoginBoxContainerId).innerHTML = result; }
}

// Renders the HTML in the login box container
function getForgotPasswordBoxHTML(result) {
	if (result != '') { $get(_ForgotPasswordBoxContainerId).innerHTML = result; }
}

// Refresh the login box after the logout
function doLogoutResult(result, userContext, methodName) {
    GetLoginBox();
}

function onError(result) {
	// Don't do anything in case of error - the client shouldn't know about the error.
	//if (result.get_statusCode() != '0')
		//alert(result.get_message());
}

function getMlmmCode() {
    if (typeof (MLMMCode) == 'undefined') {
        alert('There is no SiteContext defined!');
    }
    return MLMMCode;
}

// DoLogin function used here is registered from code
function MyZooverKeyPress(event) {
    if (navigator.appName == 'Netscape') {
        if (event.which == 13) {
            event.cancelBubble = true;
            event.returnValue = false;
            DoLogin();
            return false;
        }
    }
    else {
        if (window.event.keyCode == 13) {
            window.event.cancelBubble = true;
            window.event.returnValue = false;
            DoLogin();
            return false;
        }
    }
    return true;
}

function DoForgotPassword() {
	var lEmail = document.getElementById('txtMyZooverFPEmail');
	if (lEmail.value != '') {
		ForgotPassword(lEmail.value);
	} else {
		alert(Error_EmailRequired);
	}
}

function ForgotPasswordModal() {
	ShowDropDownsIE6(false);

	ShowCountryFlashMap(false);

	ShowVideoPlayer(false);

	var modalDiv = document.getElementById("MyZooverModalBg");
	if (modalDiv == null) {
		modalDiv = document.createElement("div");
		modalDiv.name = "MyZooverModalBg";
		modalDiv.id = "MyZooverModalBg";
		modalDiv.className = "modalBackground";
		modalDiv.style.width = document.body.offsetWidth + 'px';
		modalDiv.style.height = screen.height + 'px';

		if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
			modalDiv.className += " modalBackgroundIE";
			modalDiv.style.height = document.body.offsetHeight;
		}
		document.body.appendChild(modalDiv);
	}
	else {
		modalDiv.style.display = "block";
	}

	var popUpDiv = document.getElementById("MyZooverModalMainContainer");
	if (popUpDiv == null) {
		popUpDiv = document.createElement("div");
		popUpDiv.name = "MyZooverModalMainContainer";
		popUpDiv.id = "MyZooverModalMainContainer";
		popUpDiv.className = "popUpDivClassMyZoover";

		popUpWindow = document.createElement('div');
		popUpWindow.id = 'MyZooverModalContent';
		popUpWindow.className = "popUpDivClassMyZoover";

		popUpDiv.appendChild(popUpWindow);

		document.body.appendChild(popUpDiv);
	}
	else {
		popUpDiv.style.display = "block";
	}
	
	var left = (document.body.offsetWidth - 500) / 2;
	if (left < 0) left = 0;
	popUpDiv.style.left = left + "px";

	SetDefaultMyZooverModalTopPosition();

	GetForgotPasswordBox();
}

function RemoveForgotPasswordModal() {
	var modalDiv = document.getElementById("MyZooverModalBg");
	if (modalDiv != null) {
		modalDiv.style.display = "none";
	}

	var popUpDiv = document.getElementById("MyZooverModalMainContainer");
	if (popUpDiv != null) {
		popUpDiv.style.display = "none";
	}

	ShowCountryFlashMap(true);

	ShowVideoPlayer(true);

	ShowDropDownsIE6(true);
}

// show - bool value to show or hide drop down lists (true = visible)
function ShowDropDownsIE6(show) {
	if (typeof document.body.style.maxHeight == "undefined") // This returns "undefined" only for IE6
	{
		var ddls = document.getElementsByTagName("select");
		for (i = 0; i < ddls.length; i++) {
			ddls[i].style.visibility = show ? "visible" : "hidden";
		}
	}
}

function ShowVideoPlayer(show) {
	var videoPlayer = document.getElementById('frameVideoPlayer');
	if (videoPlayer != null) {
		if (show) {
			videoPlayer.style.visibility = 'visible';
		}
		else {
			videoPlayer.style.visibility = 'hidden';
		}
	}
}

function SetDefaultMyZooverModalTopPosition() {
	var lScrollY, lDefaultY = 250;
	var lMyZooverMainModalContainer;

	if (window.scrollY)
		lScrollY = window.scrollY;
	else
		if (document.documentElement.scrollTop)
		lScrollY = document.documentElement.scrollTop;
	else
		lScrollY = document.body.scrollTop;

	lMyZooverMainModalContainer = document.getElementById('MyZooverModalMainContainer');
	if (lMyZooverMainModalContainer != null) {
		lMyZooverMainModalContainer.style.top = lScrollY + lDefaultY + 'px';
	}
}
// JavaScript functionality for the carousel control
var Carousel_ActiveTabIndex = 0;
var Carousel_LoopStopped = false;

$(function() {
	// In IE6 and IE7 we have an issue with the banner that overlaps the carousel. Refresh the carousel to fix the overlap.
	if ($.browser.msie && $.browser.version.substr(0, 1) <= 7) {
		setTimeout('CarouselRefresh(0)', 300); 
	}
});

function InitCarousel() {
	if (typeof arr_Carousel  == 'undefined' || arr_Carousel.length == 0) return;
	// We always set the first carousel tab to be the active one
	Carousel_SetActiveTab(0, false);
	// Set the onclick events for the carousel tabs
	for (i = 0; i < arr_Carousel.length; i++) {
		var lnkObj = document.getElementById(arr_Carousel[i][0]);
		if (lnkObj) {
			if (lnkObj.attachEvent) {
				lnkObj.attachEvent("onclick", new Function("Carousel_SetActiveTab(" + i + ", false)"));
			}
			else {
				lnkObj.setAttribute("onclick", "Carousel_SetActiveTab(" + i + ", false)");
			}
		}
	}
	// Start looping - only if looping time is greater than 0
	if (CarouselLoopTime > 0) {
		Carousel_LoopStopped = false;
		setTimeout(function() { CarouselLoop(Carousel_ActiveTabIndex + 1) }, CarouselLoopTime);
	}
}

// Method that handles the looping of the carousel tabs
function CarouselLoop(tabIndex) {
	if (tabIndex > 0 && !Carousel_LoopStopped && tabIndex < arr_Carousel.length) {
		Carousel_SetActiveTab(tabIndex, true);
		if (Carousel_ActiveTabIndex < arr_Carousel.length - 1) {
			// We continue the loop if we are not at the last tab
			setTimeout(function() { CarouselLoop(Carousel_ActiveTabIndex + 1) }, CarouselLoopTime);
		}
		else {
			// If we are at the last tab than after the display of the tab is done we get back to the first (thus stopping the loop)
			setTimeout(function() { Carousel_SetActiveTab(0, true) }, CarouselLoopTime);
		}
	}
}

// Method that activates a tab of the carousel control
function Carousel_SetActiveTab(tabIndex, fromLoop) {
	// We prevent setting an active tab from the loop if the loop was stopped by the user by clicking on a tab
	if (fromLoop && Carousel_LoopStopped) {
		return;
	}

	// Get the ids of the objects that need to be activated
	var linkId = arr_Carousel[tabIndex][0];
	var layerId = arr_Carousel[tabIndex][1];

	// Set all objects to off state
	Carousel_SetTabsOff();

	// Get the objects to be activated and activate them
	var lnkObj = document.getElementById(linkId);
	var layerObj = document.getElementById(layerId);
	if (lnkObj && layerObj) {
		Carousel_SetOnClass(lnkObj);
		Carousel_SetOnClass(layerObj);
		lnkObj.blur();
	}

	if (!fromLoop) {
		// If it is not from loop then we either have finshed the loop or the user has clicked on a tab and we must stop the loop
		Carousel_LoopStopped = true;
	}

	Carousel_ActiveTabIndex = tabIndex;
	// Check if the container has logos.
	var lLogosContainer = GetLogosContainer(layerId);
	if (lLogosContainer.length > 0) {
		// Logos container found, setup logos animation.
		clearInterval(_LogosInterval);
		SetLogosScrollRight(layerId);
	}
	else {
		clearInterval(_LogosInterval);
	}
}

function StopCarouselLoop() {
	Carousel_LoopStopped = true;
}

// Method that sets all the tabs of the carousel to off state
function Carousel_SetTabsOff() {
	for (i = 0; i < arr_Carousel.length; i++) {
		var obj = document.getElementById(arr_Carousel[i][0]);
		Carousel_SetOffClass(obj);
		obj = document.getElementById(arr_Carousel[i][1]);
		Carousel_SetOffClass(obj);
	}
}

// Method that sets the off state for the given object
// The logic is based on the fact that there are two CSS classes (xxx_off and xxx_on) 
// The method just replaces the _off part with the _on part
function Carousel_SetOffClass(obj) {
	if (obj == null) return;
	obj.className = obj.className.replace("_on", "_off");
}

// Method that sets the on state for the given object
// The logic is based on the fact that there are two CSS classes (xxx_off and xxx_on) 
// The method just replaces the _on part with the _off part
function Carousel_SetOnClass(obj) {
	if (obj == null) return;
	obj.className = obj.className.replace("_off", "_on");
}

// *******************************************************************************
// JS functionality for the logos in the flight tickets and car rental controls
// *******************************************************************************
var _LogosContainerId = "";
var _LogosInterval = null;
var _DefaultLogoWidth = 75;

function SetLogosScrollRight(logosContainerId) {
	_LogosContainerId = logosContainerId;
	_LogosInterval = setInterval(Logos_RightClick, 2000);
}

function Logos_RightClick() {
	var lLogosContainer = GetLogosContainer(_LogosContainerId);
	if (lLogosContainer.length == 0)
		return;
		
	// get all the logo divs
	var lLogosList = $(lLogosContainer[0]).find("div");
	
	// We have to move all the logos (div elements) to the left and bring the first one in the last position
	lLogosList.each(function(index, logo) {
		$(logo).animate({ "left": "-=" + _DefaultLogoWidth + "px" }, 500,
					function() {
						if (index != 0)
							return;

						var lLogo = lLogosList[0];
						lLogo.style.left = (lLogosList.length - 1) * _DefaultLogoWidth + "px";
						// Move the first element to the last position
						lLogosContainer[0].removeChild(lLogo);
						lLogosContainer[0].appendChild(lLogo);
					});
	});
}

function CarouselRefresh(counter) {
	if (!window.arr_Carousel || !window.IsAdlinkCarouselEnabled || arr_Carousel.length == 0) {
		return;
	}

	if (Carousel_ActiveTabIndex == 0) {
		var lCarousel = $('#' + arr_Carousel[Carousel_ActiveTabIndex][1]);
		// Add and remove a dummy CSS class to force the browser to refresh the layout.
		lCarousel.addClass("dummy-class");
		lCarousel.removeClass("dummy-class");

		if (counter < 10) {
			setTimeout('CarouselRefresh(' + ++counter + ')', 200);
		}
	}
}

function GetLogosContainer(containerId) {
	return $("#" + containerId).find("div.logoscontainer");
}

// This file is cached. If you change the content of the file than it should be renamed to force the clients to get the new version.

Type.registerNamespace('NetMatch.Zoover.Web.Services.Suppliers');
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService=function() {
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.prototype={
_get_path:function() {
 var p = this.get_path();
 if (p) return p;
 else return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_path();},
TrackLinks:function(linksProperties,succeededCallback, failedCallback, userContext) {
return this._invoke(this._get_path(), 'TrackLinks',false,{linksProperties:linksProperties},succeededCallback,failedCallback,userContext); }}
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.registerClass('NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService',Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance = new NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService();
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_path = function(value) { NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.get_path = function() { return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_path(); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_timeout = function(value) { NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.get_timeout = function() { return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.set_path("/Services/Suppliers/SuppliersLinksService.asmx");
NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService.TrackLinks= function(linksProperties,onSuccess,onFailed,userContext) {NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService._staticInstance.TrackLinks(linksProperties,onSuccess,onFailed,userContext); }

function TrackSuppliersLinks(supplierLinksNames) {

    var service = new NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService();

    service.TrackLinks(supplierLinksNames, OnTrackLinksComplete, OnTrackLinksError);
}

function OnTrackLinksComplete(result) {
}

function OnTrackLinksError(result) {
	// Removed the alert since on FireFox you get an annoying message if the user leaves the page before the 
	// request to the server has executed
	//alert(result.get_message());
}

/* EXPAND-COLLAPSE behaviour for suppliers with pricing info*/
// sid - shader id
// tid - shader text id
function ShowSuppliersShader(sid, tid, msg) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader-on";
		tex.style.lineHeight = tex.clientHeight + 'px';
		tex.innerHTML = "<span>" + msg + "</span>";
	}
}

// sid - shader id
// tid - shader text id
function HideSuppliersShader(sid, tid) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader-off";
		tex.innerHTML = "&nbsp;";
	}
}

// sid - shader id
// stid - shader text id
// cid - collapse container id
function ExpandSuppliers(sid, cid, stid, hidden_suppliers_id) {
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var sha = document.getElementById(sid);
	var shta = document.getElementById(stid);
	var col = document.getElementById(cid);
	var hidden_suppliers = document.getElementById(hidden_suppliers_id);

	if (sha)
		sha.style.display = "none";
	if (shta)
		shta.style.display = "none";
	if (col)
		col.style.display = "block";
	if (hidden_suppliers)
		hidden_suppliers.style.display = "block"

	// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
	sha.parentNode.parentNode.style.display = "none";
	sha.parentNode.parentNode.style.display = "block";
}

// sid - shader id
// stid - shader text id
// cid - collapse container id
function CollapseSuppliers(sid, cid, stid, hidden_suppliers_id) {
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var sha = document.getElementById(sid);
	var shta = document.getElementById(stid);
	var col = document.getElementById(cid);
	var hidden_suppliers = document.getElementById(hidden_suppliers_id);

	if (sha)
		sha.style.display = "block";
	if (shta)
		shta.style.display = "block";
	if (col)
		col.style.display = "none";

	if (hidden_suppliers)
		hidden_suppliers.style.display = "none"

	// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
	sha.parentNode.parentNode.style.display = "none";
	sha.parentNode.parentNode.style.display = "block";
}

// for IE6 only - as height: 100% does not work on IE6 - we force the shader and the shader text to have it's parent container
function setIE6ShaderHeight(shc, sha, sht) {
	var shcElement = document.getElementById(shc);
	if (shcElement != null) {
		var height = shcElement.offsetHeight;
		var shaElement = document.getElementById(sha);
		var shtElement = document.getElementById(sht);
		if ((shaElement != null) && (shtElement != null)) {
			shaElement.style.height = height;
			shtElement.style.height = height;
		}
	}
}

/*
function PriceInfo(name, price){
	var _Name = name;
	var _Price = price;
	
	this.getName = function() { return _Name; }
	this.getPrice = function() { return _Price; }
}

function PriceInfoToolTip(){
	this.PriceInfoArray = new Array();
}

PriceInfoToolTip.prototype.Length = function(){
	return this.PriceInfoArray.length;
}

PriceInfoToolTip.prototype.InfoAtIndex = function(index){
if (index < this.PriceInfoArray.length) {
	return this.PriceInfoArray[index];
	}
	return null;
}

PriceInfoToolTip.prototype.AddPriceInfo = function(priceInfo) {
	this.PriceInfoArray[this.PriceInfoArray.length] = priceInfo;
}

function HoverTooltips(){
	this.HoverInfo = new Array();
	this.Codes = new Array();
	this.DurationTitle = "";
	this.PriceTitle = "";
	this.HoverTitle = "";
	this.ParentsTitle = "";
}

HoverTooltips.prototype.AddPriceInfo = function(code, name, price) {
	var lExistingInfo = this.GetObjectForCode(code);
	if (lExistingInfo == null) {
		var lPriceInfo = new PriceInfoToolTip();
		lPriceInfo.AddPriceInfo(new PriceInfo(name, price));
		this.HoverInfo[this.HoverInfo.length] = lPriceInfo;
		this.Codes[this.Codes.length] = code;
	}
	else {
		lExistingInfo.AddPriceInfo(new PriceInfo(name, price));
	}
}

// The method that returns the current object for the current code if it exists and null if it doesn't exist

HoverTooltips.prototype.GetObjectForCode = function(code) {
	for (var i = 0; i < this.Codes.length; i++) {
		if (this.Codes[i] == code) {
			return this.HoverInfo[i];
		}
	}
	return null;
}

HoverTooltips.prototype.SetDurationTitle = function(value) {
	this.DurationTitle = value;
}

HoverTooltips.prototype.GetDurationTitle = function() {
	return this.DurationTitle;
}

HoverTooltips.prototype.SetPriceTitle = function(value) {
	this.PriceTitle = value;
}

HoverTooltips.prototype.GetPriceTitle = function() {
	return this.PriceTitle;
}

HoverTooltips.prototype.SetAccommodationTitle = function(value) {
	this.HoverTitle = value;
}

HoverTooltips.prototype.GetAccommodationTitle = function() {
	return this.HoverTitle;
}

HoverTooltips.prototype.SetParentsTitle = function(value) {
	this.ParentsTitle = value;
}

HoverTooltips.prototype.GetParentsTitle = function() {
	return this.ParentsTitle;
}

HoverTooltips.prototype.GetHtmlForCode = function(code, div, containerName, widthOffset) {
	var lInfo = this.GetObjectForCode(code);
	div.style.color = "#4C9EDB";
	var lContainer = document.getElementById(containerName);
	if (lInfo != null && lContainer != null) {
		var lParent = this.GetAccommodationTitle().length + this.GetParentsTitle().length;
		var lRatio = lInfo.Length() > 6 ? 22 : 24;
		if (lInfo.Length() < 3 && lParent < 80) {
			lRatio += 5;
		}
		var lExtra = lParent > 80 ? 40 : 31;
		if (lParent > 80) {
			lRatio += 2;
			if (lInfo.Length() > 6) {
				lRatio -= 2;
			}
		}
		var lHeight = lInfo.Length() * lRatio + (lParent / 50) * lExtra + 22;
		var lTop = div.offsetTop + 19;
		var lLeft = div.offsetLeft + parseInt(widthOffset) + 10;
		if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1 || navigator.userAgent.toLowerCase().indexOf('msie 7') != -1) {
			lTop = div.parentNode.offsetTop + 18;
			lLeft += 6;
			if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
				lLeft += 12;
			}
		}

		if (lInfo.Length() < 3 && lParent > 70) {
			lHeight += 30;
		}

		var lStyle = "height:" + lHeight + "px;top:" + lTop + "px;left:" + lLeft + "px";
		var lHtml = "<div class=\"hoverContainer\" style=\"" + lStyle + "\"><div class=\"hoverAccoTitle\">" + this.GetAccommodationTitle()
			+ "<span class=\"parentsTitle\">" + this.ParentsTitle + "</span></div>";
		var lFirstDiv = "<div class=\"durationContainer\"><span class=\"priceTitle\">" + this.GetDurationTitle() + "</span><br/>";
		var lSecondDiv = "<div class=\"priceContainer\"><span class=\"priceTitle\">" + this.GetPriceTitle() + "</span><br/>";
		for (var i = 0; i < lInfo.Length(); i++) {
			var lObj = lInfo.InfoAtIndex(i);
			if (lObj != null) {
				lFirstDiv += "<span>" + lObj.getName() + "</span><br/>";
				lSecondDiv += "<span>" + lObj.getPrice() + "</span><br/>";
			}
		}
		lFirstDiv += "</div>";
		lSecondDiv += "</div>";
		lHtml += lFirstDiv + lSecondDiv + "</div>";
		lContainer.innerHTML = lHtml;
		lContainer.style.display = "block";
	}
}

HoverTooltips.prototype.HideHtmlCode = function(div, containerName) {
	div.style.color = "#FF5D10";
	var lContainer = document.getElementById(containerName);
	if (lContainer != null) {
		lContainer.style.display = "none";
	}
}

var HoverTooltipsAccos = new HoverTooltips();

*/

/* --END-- SUPPLIERS FOR PRICING INFO */


/* initialize some variables */
var calendarstate = 'CLOSED';
var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var dropdownYearMonth;
var dropdownDay;
var updateJS = 0;

// we validate against dates like 30 feb, 31 iun etc
function ValidateDay(monthCtrlId, dayCtrlId, changeDay, uniqueKeyword) {
	//alert(date_validator + " " + typeof (date_validator));
	if (typeof (date_validator) == 'undefined' || date_validator == null)
		return true;

	var lCalendar = new CalendarFlight(uniqueKeyword);

	var lYearIndex;
	if (dayCtrlId == 'depDayFlight_' + uniqueKeyword)
		lYearIndex = lCalendar.GetStartDate().getFullYear();
	else
		lYearIndex = lCalendar.GetEndDate().getFullYear();

	lYearIndex = lYearIndex - (new Date()).getFullYear();

	var dayCtrl = document.getElementById(dayCtrlId);
	var monthCtrl = document.getElementById(monthCtrlId);

	var lSelDay = dayCtrl.options[dayCtrl.selectedIndex].value;

	if (Number(lSelDay) > date_validator[lYearIndex][monthCtrl.options[monthCtrl.selectedIndex].value]) {
		if (changeDay == 1) {
			dayCtrl.selectedIndex = date_validator[lYearIndex][monthCtrl.options[monthCtrl.selectedIndex].value] - 1;
		}
		else {
			return false;
		}
	}
	return true;
}

// make sure that the start date is less than the end date
function ValidateDateChronology(uniqueKeyword) {
	var lCalendar = new CalendarFlight(uniqueKeyword);

	if (lCalendar.GetStartDate() >= lCalendar.GetEndDate())
		return false;

	return true;
}

// make sure the selection is not in the past
function ValidateDateSelection(uniqueKeyword) {
	var lCalendar = new CalendarFlight(uniqueKeyword);
	var lToday = new Date();
	if (lCalendar.GetStartDate() < lToday)
		return false;

	return true;
}

// we set the return date to be always 8 days after the departure date
function ChangeRetDate(uniqueKeyword) {
	var lCalendar = new CalendarFlight(uniqueKeyword);

	var lRetDate = lCalendar.GetStartDate();
	var lEndDate = lCalendar.GetEndDate();
	if (lRetDate <= lEndDate) {
		return;
	}

	lRetDate.setDate(lRetDate.getDate() + 8);

	var lDayCombo = document.getElementById('retDayFlight_'+uniqueKeyword);
	var lMonthCombo = document.getElementById('retMonthFlight_'+uniqueKeyword);

	lDayCombo.options[lRetDate.getDate() - 1].selected = true;

	// Get the return month. Add 1 since the month is zero based in JavaScript.
	var lReturnMonth = (lRetDate.getMonth() + 1).toString();
	if (lReturnMonth.length == 1) {
		lReturnMonth = "0" + lReturnMonth;
	}
	var lReturnMonthYear = lRetDate.getFullYear().toString() + lReturnMonth;
	for (i = 0; i < lMonthCombo.options.length; i++) {
		if (lMonthCombo.options[i].value == lReturnMonthYear) {
			lMonthCombo.options[i].selected = true;
		}
	}
}

function ShowNavigationCalendar(monthSelectId, daySelectId, leftOffsetReturn, topOffsetReturn, uniqueKeyword, monthsCount, changeReturnDate) {
	// Get the year and the month from the current selected value.
	var lSelectedValue = document.getElementById(monthSelectId).value;
	var lYear = lSelectedValue.substr(0, 4);
	// Parse the month and substract one because JavaScript months are zero based.
	// Also, doing so makes the current select month to be on the right side of the calendar, so advancing further when there
	// are no more months in the month select will not be possible.
	var lMonth = lSelectedValue.substr(4);
	lMonth = lMonth - 1;

	showCalendar('', lYear, lMonth, monthSelectId, daySelectId, 1, leftOffsetReturn, topOffsetReturn, 
		uniqueKeyword, monthsCount, changeReturnDate);
}

var CalendarFlight = function(uniqueKeyword) 
{ 
	this.UniqueKeyword = uniqueKeyword 
};

CalendarFlight.prototype.GetStartDate = function() {
	return this.GetDateFromControls('depMonthFlight_', 'depDayFlight_');
}

CalendarFlight.prototype.GetEndDate = function() {
	return this.GetDateFromControls('retMonthFlight_', 'retDayFlight_');
}

CalendarFlight.prototype.GetDateFromControls = function(monthId, dayId) {
	var lDayCombo = document.getElementById((dayId + this.UniqueKeyword));
	var lDay = lDayCombo.options[lDayCombo.selectedIndex].value;

	var lMonthCombo = document.getElementById((monthId + this.UniqueKeyword));
	var lYear = lMonthCombo.options[lMonthCombo.selectedIndex].value.substring(0, 4);
	var lMonth = lMonthCombo.options[lMonthCombo.selectedIndex].value.substring(4);

	// The month is zero based in JavaScript Date.
	lMonth = lMonth - 1;

	var lSelDate = new Date(lYear, lMonth, lDay);
	return lSelDate;
}

// gets the end date in the form 'ddMMyyyy'
CalendarFlight.prototype.GetEndDateString = function() {
	return this.GetDateString(this.GetEndDate());
}

// gets the start date in the form 'ddMMyyyy'
CalendarFlight.prototype.GetStartDateString = function() {
	return this.GetDateString(this.GetStartDate());
}

CalendarFlight.prototype.GetDateString = function(date) {
	var lDay = date.getDate();
	if (lDay < 10)
		lDay = '0' + lDay;

	var lMonth = (date.getMonth() + 1);
	if (lMonth < 10)
		lMonth = '0' + lMonth;

	var lYear = date.getFullYear();

	return '' + lDay + lMonth + lYear;
}

function InitDatesFlights(uniqueKeyword) {
	var lToday = new Date();
	lToday.setDate(lToday.getDate() + 14);
	selectDateFlight(lToday.getDate(), lToday.getMonth() + 1, lToday.getFullYear(), 'depDayFlight_' + uniqueKeyword,
		'depMonthFlight_' + uniqueKeyword, uniqueKeyword);

	lToday.setDate(lToday.getDate() + 14);
	selectDateFlight(lToday.getDate(), lToday.getMonth() + 1, lToday.getFullYear(), 'retDayFlight_' + uniqueKeyword,
		'retMonthFlight_' + uniqueKeyword, uniqueKeyword);
}

function selectDateFlight(selected_day, selected_month, selected_year, day_field, month_field, uniqueKeyword) {

	// show the dropdowns
	document.getElementById(('retDayFlight_' + uniqueKeyword)).style.visibility = 'visible';
	document.getElementById(('retMonthFlight_' + uniqueKeyword)).style.visibility = 'visible';

	if (selected_month > 12) {
		selected_month = 1;
		selected_year += 1;
	}

	if ((day_field == ("depDayFlight_" + uniqueKeyword)) || (month_field == ("depMonthFlight_" + uniqueKeyword))) {
		var mon_element = document.getElementById(("depMonthFlight_" + uniqueKeyword));
		document.getElementById(("depDayFlight_" + uniqueKeyword)).options[selected_day - 1].selected = true;

		for (i = 0; i < mon_element.options.length; i++)
			if (mon_element.options[i].value == createMonthValue(selected_month, selected_year)) {
			mon_element.options[i].selected = true;
		}

		if (typeof (mon_element.onchange) == "function") {
			mon_element.onchange();
		}

	} else if ((day_field == ("retDayFlight_" + uniqueKeyword)) || (month_field == ("retMonthFlight_" + uniqueKeyword))) {
		var mon_element = document.getElementById(("retMonthFlight_" + uniqueKeyword));
		document.getElementById(("retDayFlight_" + uniqueKeyword)).options[selected_day - 1].selected = true;
	
		for (i = 0; i < mon_element.options.length; i++)
			if (mon_element.options[i].value == createMonthValue(selected_month, selected_year))
			mon_element.options[i].selected = true;
	}
}

function createMonthValue(month, year) {
	if (month <= 9) {
		return year + '0' + month;
	}
	return year + '' + month; 
}

/* draw calendar */
function showCalendar(type, y, m, yd, dd, ujs, leftOffset, topOffset, uniqueKeyword, maxMonthCount, changeReturnDate) {
	var lMaxMonthCount = 15;
	if (maxMonthCount != undefined && maxMonthCount != null) {
		lMaxMonthCount = maxMonthCount;
	}
	var lChangeReturnDate = false;
	if (changeReturnDate != undefined && changeReturnDate != null) {
		if (changeReturnDate === true) {
			lChangeReturnDate = true;
		}		 
	}
	var h = '';
	/* set dropdowns if they are set */
	if (yd && dd) {
		dropdownYearMonth = yd;
		dropdownDay = dd;
		updateJS = ujs;
	}

	y = parseInt(y);

	if (type != 'UPDATE') {
		if (type == calendarstate) {
			return closeCalendar();
		} else {
			calendarstate = type;
		}
	}
	if (window.attachEvent) h += '<iframe style="position:absolute; width:447px;height:216px;background-color:#FFFFFF;z-index:10;"></iframe>';
	h += '<table border="0" cellpadding="0" cellspacing="0" class="calheader">';
	/* Print close button, that closes the calendar window */

	h += '<tr>';
	h += '<td width="50%" valign="top">' + drawMonth(1, y, m, uniqueKeyword, yd, dd, leftOffset, topOffset, lMaxMonthCount, lChangeReturnDate) + '</td>';
	h += '<td width="50%" valign="top">' + drawMonth(2, y, m + 1, uniqueKeyword, yd, dd, leftOffset, topOffset, lMaxMonthCount, lChangeReturnDate) + '</td>';
	h += '</tr>';

	/* Print close button, that closes the calendar window */

	h += '</table>';

	var divob = document.getElementById(('calendardiv_' + uniqueKeyword));
	divob.innerHTML = h;
	divob.style.top = topOffset+'px';
	divob.style.left = leftOffset+'px';

	setVisibilityCalendarFC('calendardiv_' + uniqueKeyword, 1);
}

/* close calendar */
function closeCalendar(uniqueKeyword) {
	calendarstate = 'CLOSED';
	setVisibilityCalendarFC('calendardiv_' + uniqueKeyword, 0);
}

/*
* function drawMonth(position, y, m)
*
* - position = This is either 1 (left) or 2 (right). Don't alter.
* - y = Year
* - m = Month
*
*/
function drawMonth(position, y, m, uniqueKeyword, yd, dd, leftOffset, topOffset, maxMonthCount, changeReturnDate) {
	var lMaxMonthCount = 15;
	if (maxMonthCount != undefined && maxMonthCount != null) {
		lMaxMonthCount = maxMonthCount;
	}
	var lChangeReturnDate = false;
	if (changeReturnDate != undefined && changeReturnDate != null) {
		if (changeReturnDate === true) {
			lChangeReturnDate = true;
		}
	}
	var h = '';
	var cells = 0;
	var today_dob = new Date();

	/* Let's do a sanity check. This works nicely if someone enters for example month 13, which would become 1, and year increased by 1 also */
	var dob = new Date(y, m - 1, 1);
	m = dob.getMonth() + 1;
	y = dob.getFullYear();

	/* Start table */
	h = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

	/* Print the header row with month name */
	h += '<tr class="scalheader1">';

	/* Print the 'previous' button (for left calendar only) */
	if (position == 1) {
		var plink_y = y;
		var plink_m = m;

		if (plink_m == 1) {
			plink_y--;
			plink_m = 12;
		}
		h += '<td>&nbsp;</td>';
		if (dob <= today_dob) {
			h += '<td align="center" class="scalheader1">&nbsp;</td>';
		} else {
		h += '<td align="center" class="scalheader1"><a style="color: black;" href="javascript://" onClick="showCalendar(\'UPDATE\', ' + plink_y + ', ' +
				(plink_m - 1) + ',\'' + yd + '\',\'' + dd + '\',1,' + leftOffset + ',' + topOffset + ',\'' + uniqueKeyword + '\',' + lMaxMonthCount + ',' + lChangeReturnDate + ');"><img src="../shared/images2/datepicker_prev-inactive.png"></a></td>';
		}
	}

	/* Print month name */
	h += '<td colspan="5" align="center" class="scalheader1">' + monthNames[m - 1] + ' ' + y + '</td>';

	/* Print the 'next' button (for right calendar only) */
	if (position == 2) {
		var mdiff = (y * 12 + m) - (today_dob.getFullYear() * 12 + today_dob.getMonth() + 1) + 2;
		/* if the 'next month' is further than 15 months from today.. let's not show it :) */
		if (mdiff > lMaxMonthCount) {
			h += '<td>&nbsp;</td>';
		} else {
			h += '<td align="center" class="scalheader1 scalheader1-next"><a style="color: black;" href="javascript://" onClick="showCalendar(\'UPDATE\', ' + y + ', ' + (m) + ',\'' + yd + '\',\'' + dd + '\',1,' + leftOffset + ',' + topOffset + ',\'' + uniqueKeyword + '\',' + lMaxMonthCount + ',' + lChangeReturnDate + ');"><img src="../shared/images2/datepicker_next-inactive.png"></a></td>';
		}
		/* Always display the close calendar box. */
		h += '<td align="center"><a href="javascript://" onclick="closeCalendar(\'' + uniqueKeyword + '\');" class="closebutton"><img src="../shared/images2/datepicker_close-inactive.png"></a></td>';
	}

	h += '</tr>';

	/* Print day names */
	h += '<tr class="scalheader2">';

	for (var i = 0; i < dayNames.length; i++) {
		h += '<td align="center" width="14%" class="scalheader2">' + dayNames[i] + '</td>';
	}

	h += '</tr>';

	/* Print the calendar */
	h += '<tr class="scalcell">';

	/* Fill empty cells in the beginning of the 'first week of month' if necessary. For example 1st day of a month can be wednesday */
	for (var i = 0; i < getStartDay(dob); i++) {
		h += '<td>&nbsp;</td>';
		cells++;
	}

	/* Check how many days there are in this month. Also checks for leap year */
	var daysInThisMonth = getDaysInThisMonth(y, m);

	/* Print the day numbers of the week */
	for (var i = 1; i <= daysInThisMonth; i++) {
		dob.setDate(i);
		cells++;

		var mStr = m + '';
		if (mStr.length == 1) {
			mStr = '0' + mStr;
		}

		var onClickStr = 'updateCalendar(\'' + y + '\',\'' + mStr + '\',\'' + i + '\',\'' + uniqueKeyword + '\',' + lChangeReturnDate + ');';

		if (dob.getFullYear() == today_dob.getFullYear() && dob.getDate() == today_dob.getDate() && dob.getMonth() == today_dob.getMonth()) {
			/* today */
			h += '<td align="center" style="color: black;"><b>' + i + '</b></td>';
		} else if (dob.getTime() < today_dob.getTime()) {
			/* days before today are not selectable */
			h += '<td align="center" style="color: gray;">' + i + '</td>';
		} else {
			h += '<td align="center"><a href="javascript://" style="color: black;" onClick="' + onClickStr + '">' + i + '</a></td>';
		}

		/* next week row */
		if (!(cells % 7)) {
			h += '</tr><tr class="scalcell">';
		}
	}

	/* Add some empty cells to tidy the table */
	if (cells < 42) {
		var cells2 = 42 - cells;
		for (var i = 0; i < cells2; i++) {
			cells++;
			h += '<td align="center">&nbsp;</td>';

			if (!(cells % 7)) {
				h += '</tr><tr class="scalcell">';
			}
		}
	}

	/* close table */
	h += '</tr></table>';

	return h;
}

function updateCalendar(y, mStr, i, uniqueKeyword, changeReturnDate) {
	document.getElementById(dropdownYearMonth).value = (y + mStr);
	document.getElementById(dropdownDay).value = i;
	closeCalendar(uniqueKeyword);
	if (changeReturnDate === true) {
		ChangeRetDate(uniqueKeyword);
	}
}

/* Get position of the day in a week */
function getStartDay(d) {
	var startDay = d.getDay();

	if (startDay == 0) {
		startDay = 7;
	}

	return startDay - 1;
}

/* Amount of days in a month */
function getDaysInThisMonth(y, m) {
	/* leap year check for february */
	if (m == 2) {
		if (!(y % 400) || (!(y % 4) && y % 100)) {
			return 29;
		} else {
			return 28;
		}
	} else {
		return daysInMonth[m - 1];
	}
}

/* set visibility of an element. */
function setVisibilityCalendarFC(obname, state) {
	var ob = document.getElementById(obname);
	if (ob != null) {
		if (state == 1) {
			ob.style.display = '';
			ob.style.visibility = 'visible';
		} else {
			ob.style.display = 'none';
			ob.style.visibility = 'hidden';
		}
	}
}


Type.registerNamespace('NetMatch.Zoover.Web.Services.Suppliers');
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService = function() {
	NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.initializeBase(this);
	this._timeout = 0;
	this._userContext = null;
	this._succeeded = null;
	this._failed = null;
}
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.prototype = {
	_get_path: function() {
		var p = this.get_path();
		if (p) return p;
		else return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_path();
	},
	GetFlightTicketsUrl: function(children, departureIata, destinationIata, departureDay, departureMonthYear, returnDay, returnMonthYear, adults, from, to, date1, date2, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetFlightTicketsUrl', false, { children: children, departureIata: departureIata, destinationIata: destinationIata, departureDay: departureDay, departureMonthYear: departureMonthYear, returnDay: returnDay, returnMonthYear: returnMonthYear, adults: adults, from: from, to: to, date1: date1, date2: date2 }, succeededCallback, failedCallback, userContext);
	},
	GetCarRentalUrl: function(pickupIata, pickUpDayDay, pickUpMonthYear, pickUpTime, dropOffIata, dropOffDay, dropOffMonthYear, dropOffTime, fromAirport, toAirport, date1, date2, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetCarRentalUrl', false, { pickupIata: pickupIata, pickUpDayDay: pickUpDayDay, pickUpMonthYear: pickUpMonthYear, pickUpTime: pickUpTime, dropOffIata: dropOffIata, dropOffDay: dropOffDay, dropOffMonthYear: dropOffMonthYear, dropOffTime: dropOffTime, fromAirport: fromAirport, toAirport: toAirport, date1: date1, date2: date2 }, succeededCallback, failedCallback, userContext);
	},
	GetDirectFlights: function(fromIataCode, countryId, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetDirectFlights', false, { fromIataCode: fromIataCode, countryId: countryId }, succeededCallback, failedCallback, userContext);
	} 
}
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.registerClass('NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService', Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance = new NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService();
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_path = function(value) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.get_path = function() { return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_path(); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_timeout = function(value) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.get_timeout = function() { return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.set_path("/Services/Suppliers/FlightTicketsService.asmx");
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetFlightTicketsUrl = function(children, departureIata, destinationIata, departureDay, departureMonthYear, returnDay, returnMonthYear, adults, from, to, date1, date2, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.GetFlightTicketsUrl(children, departureIata, destinationIata, departureDay, departureMonthYear, returnDay, returnMonthYear, adults, from, to, date1, date2, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetCarRentalUrl = function(pickupIata, pickUpDayDay, pickUpMonthYear, pickUpTime, dropOffIata, dropOffDay, dropOffMonthYear, dropOffTime, fromAirport, toAirport, date1, date2, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.GetCarRentalUrl(pickupIata, pickUpDayDay, pickUpMonthYear, pickUpTime, dropOffIata, dropOffDay, dropOffMonthYear, dropOffTime, fromAirport, toAirport, date1, date2, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetDirectFlights = function(fromIataCode, countryId, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService._staticInstance.GetDirectFlights(fromIataCode, countryId, onSuccess, onFailed, userContext); }

var SelectFlightTicketsArray = new Array();
var InputFlightTicketsArray = new Array();
var CalendarRowSeparators = new Array();
var SelectedDropDownId = null;
var SelectedDropDownValue = null;
var DirectFlightsCache = new Object();

function InitializeDropDownValues() {
	SelectedDropDownValue = new Array();
	for (var i = 0; i < SelectFlightTicketsArray.length; i++) {
		SelectedDropDownValue[i] = null;
	}
}

function RememberSelection(selectId) {
	if (SelectedDropDownValue == null) {
		InitializeDropDownValues();
	}
	var lContainer = document.getElementById(selectId);
	if (lContainer != null) {
		SelectedDropDownId = selectId;
		var index = GetIndexOfSelect(selectId);
		if (SelectedDropDownValue[index] == null || SelectedDropDownValue[index] == '') {
			SelectedDropDownValue[index] = lContainer.options[1].value;
		}
	}
}

function SetRememberSelections() {
	var index = GetIndexOfSelect(SelectedDropDownId);
	if (SelectedDropDownId != null && SelectedDropDownValue[index] != null) {
		var lSelectElement = document.getElementById(SelectedDropDownId);
		if (lSelectElement.selectedIndex == 0) {
			lSelectElement.value = SelectedDropDownValue[index];
		}
	}
}

function GetIndexOfSelect(selectId) {
	for (var i = 0; i < SelectFlightTicketsArray.length; i++) {
		if (SelectFlightTicketsArray[i] == selectId) {
			return i;
		}
	}
}

var PreviousRowSepHeight = new Array();
function VerifyDestAirport(selectElem, txtBoxId, errId, popUpContainer, closeText, popUpUrl, selectId, calendarRowSep) {
	var lTxtAirOther = document.getElementById(txtBoxId);
	if (selectElem.selectedIndex == 0) {
		CreateFlightTicketsOverlayPopUpWindow(popUpContainer, closeText, popUpUrl, selectId);
	}
	else {
		if (SelectedDropDownValue == null) {
			InitializeDropDownValues();
		}
		if (selectElem.value != '') {
			SelectedDropDownValue[GetIndexOfSelect(selectId)] = selectElem.value;
		}
	}
	if (selectElem.options[selectElem.selectedIndex].value == '') {
		lTxtAirOther.style.display = 'block';
		if (calendarRowSep && calendarRowSep.length > 0) {
			var lSepObj = document.getElementById(CalendarRowSeparators[calendarRowSep][0]);
			if (lSepObj) {
				PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][0]] = lSepObj.clientHeight;
				lSepObj.style.height = (lSepObj.clientHeight + lTxtAirOther.clientHeight + 5) + 'px';
				if (CalendarRowSeparators[calendarRowSep][1] != '') {
					var lSubmitButtonSep = document.getElementById(CalendarRowSeparators[calendarRowSep][1]);
					if (lSubmitButtonSep && lSubmitButtonSep.clientHeight > 0) {
						PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][1]] = lSubmitButtonSep.clientHeight;
						lSubmitButtonSep.style.height = (lSubmitButtonSep.clientHeight + lTxtAirOther.clientHeight + 5) + 'px';
					}
				}
			}
		}
	}
	else {
		if (calendarRowSep && calendarRowSep.length > 0) {
			var lSepObj = document.getElementById(CalendarRowSeparators[calendarRowSep][0]);
			if (lSepObj && PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][0]]) {
				lSepObj.style.height = PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][0]] + 'px';
			}
			if (CalendarRowSeparators[calendarRowSep][1] != '') {
				var lSubmitButtonSep = document.getElementById(CalendarRowSeparators[calendarRowSep][1]);
				if (lSubmitButtonSep && lSubmitButtonSep.clientHeight > 0 && PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][1]]) {
					lSubmitButtonSep.style.height = PreviousRowSepHeight[CalendarRowSeparators[calendarRowSep][1]] + 'px';
				}
			}
		}
		lTxtAirOther.style.display = 'none';
		document.getElementById(errId).style.display = 'none';
	}
}

var CountryId;
var PopulateSelectId;
var PopulateSelectIdSupp;
var UniqueKey;
var UniqueKeySupp;
var AllGroup = new Array();
var OptionsObject = new Array();
var DirectFlights = new Array();
var SelectedValue = null;
var Options = null;
var CurrentKey;

function AddDirectFlights(selectElem, countryId, populateSelectId, uniqueKey, directFlightsEnabled) {
	CountryId = countryId;

	SelectedValue = document.getElementById(populateSelectId).value;
	if (uniqueKey.indexOf("_supp") > 0) {
		UniqueKeySupp = uniqueKey;
		PopulateSelectIdSupp = populateSelectId;
	}
	else {
		UniqueKey = uniqueKey;
		PopulateSelectId = populateSelectId;
	}
	if (typeof (AllGroup[uniqueKey]) == "undefined" || AllGroup[uniqueKey] == null) {
		AllGroup[uniqueKey] = $("#allOptionGroup_" + uniqueKey).clone();
		$("#allOptionGroup_" + uniqueKey).remove();
	}

	if (Options == null) {
		Options = $("#" + populateSelectId + " option").clone();
	}

	if (typeof (OptionsObject[uniqueKey]) == "undefined" || OptionsObject[uniqueKey] == null) {
		OptionsObject[uniqueKey] = $("#" + populateSelectId + " option:not(optgroup > *):not([value='map']):not([value=''])").clone();
		$("#" + populateSelectId + " option:not(optgroup > *):not([value='map']):not([value=''])").remove();
	}

	if (typeof (DirectFlights[uniqueKey]) == "undefined" || DirectFlights[uniqueKey] == null) {
		DirectFlights[uniqueKey] = $("#directOpt_" + uniqueKey).clone();
		$("#directOpt_" + uniqueKey).remove();
	}

	if (directFlightsEnabled != "True") {
		if (uniqueKey.indexOf("_supp") > 0) {
			OnDirectFlightsAvailableSupp(null);
			return;
		}
		OnDirectFlightsAvailable(null);
		return;
	}
	CurrentKey = selectElem.value;
	var lAirports = CheckLocalVariableDirectFlights(selectElem.value);
	if (uniqueKey.indexOf("_supp") > 0) {
		if (lAirports != null) {
			OnDirectFlightsAvailableSupp(lAirports);
			return;
		}
		NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetDirectFlights(selectElem.value, countryId, OnDirectFlightsAvailableSupp, null, null);
		return;
	}
	
	if (lAirports != null) {
		OnDirectFlightsAvailable(lAirports);
		return;
	}
	
	NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetDirectFlights(selectElem.value, countryId, OnDirectFlightsAvailable, null, null);
}

function CheckLocalVariableDirectFlights(selectedValue){
	var lAirports = DirectFlightsCache[selectedValue];
	if (typeof(lAirports) != 'undefined' && lAirports != null){
		return lAirports;
	}
	return null;
}

function OnDirectFlightsAvailableSupp(result) {
	DirectFlightsCache[CurrentKey] = result;
	HandleResults(result, UniqueKeySupp, PopulateSelectIdSupp);
}

function OnDirectFlightsAvailable(result) {
	DirectFlightsCache[CurrentKey] = result;
	HandleResults(result, UniqueKey, PopulateSelectId);
}

function HandleResults(result, uniqueKey, populateSelectId) {
	if (result != null && result.length > 0) {
		var lOptGroup = "";
		for (var i = 0; i < result.length; i++) {
			var lAirportName = GetValueForId(Options, result[i]);
			if (typeof (lAirportName) != "undefined") {
				lOptGroup += "<option value=\"" + result[i] + "\" airportname=\"" + lAirportName.attributes["airportname"].value + "\">"
					+ lAirportName.text + "</option>";
			}
		}

		if (lOptGroup != "") {
			$("#" + populateSelectId + " option[value='map']").after($(DirectFlights[uniqueKey]));
			$("#directOpt_" + uniqueKey).html($(lOptGroup));
			HandleGrouping(true, uniqueKey, populateSelectId);
		}
		else {
			$("#directOpt_" + uniqueKey).remove();
			HandleGrouping(false, uniqueKey, populateSelectId);
		}
	}
	else {
		$("#directOpt_" + uniqueKey).remove();
		HandleGrouping(false, uniqueKey, populateSelectId);
	}
	$("#" + populateSelectId).val(SelectedValue);
}

function HandleGrouping(status, uniqueKey, populateSelectId) {
	if (status) {
		$("#directOpt_" + uniqueKey).after($(AllGroup[uniqueKey]));
	}
	else {
		var lToRemove = $("#allOptionGroup_" + uniqueKey);
		if (lToRemove.length != 0) {
			lToRemove.remove();
		}
	}

	if (status) {
		//We make sure the operation won't be too heavy (for IE especially) - this should be made for destination and accommodation level where 
		//no more than 5 airports aree grouped in no more than 3 groups + the other and the map option - no more than 20 options
		if ($("#" + populateSelectId + " option").length < 20) {
			var lToRemove = $("#" + populateSelectId + " option:not(optgroup > *):not([value='map']):not([value=''])");
			if (lToRemove.length != 0) {
				lToRemove.remove();
			}
		}
	}
	else {
		$("#" + populateSelectId + " option[value='map']").after($(OptionsObject[uniqueKey]));

	}
}

function GetValueForId(options, value) {
	for (var i = 0; i < options.length; i++) {
		if (options[i].value == value) {
			return options[i];
		}
	}
}

function SelectAirportFromIframe(selectId, value, valueName) {
	var lSelectElement = document.getElementById(selectId);
	var lExistsOption = false;
	for (var i = 0; i < lSelectElement.options.length; i++) {
		if (lSelectElement.options[i].value == value) {
			lExistsOption = true;
			break;
		}
	}
	var lCount = -1;
	for (var j = 0; j < SelectFlightTicketsArray.length; j++) {
		if (SelectFlightTicketsArray[j] == selectId) {
			lCount = j;
			break;
		}
	}

	if (lExistsOption) {
		lSelectElement.value = value;
		SelectedDropDownValue[GetIndexOfSelect(selectId)] = value;
		if (lCount >= 0) {
			var lInputText = document.getElementById(InputFlightTicketsArray[lCount]);
			if (lInputText != null) {
				lInputText.style.display = "none";
			}
		}
	}
	else {

		if (lCount >= 0) {
			var lInputText = document.getElementById(InputFlightTicketsArray[lCount]);
			if (lInputText != null) {
				lSelectElement.value = "";
				lInputText.style.display = "block";
				lInputText.value = valueName;
			}
		}
	}
}

function ChangeDestinationSelect(uniqueKeyword) {
	var lDepAirport = document.getElementById(("selCarsFrom_" + uniqueKeyword)).value;
	if (lDepAirport != '' && lDepAirport != 'map') {
		var lDestinationAirport = document.getElementById(("selCarsTo_" + uniqueKeyword));
		lDestinationAirport.value = lDepAirport;
	}
}

function ValidateFlightTicketAndCarData(startIdFrom, startIdTo, uniqueKeyword, select1, select2) {
	var lErrorMessageFrom = document.getElementById(("errorFrom_" + uniqueKeyword));
	var lErrorMessageTo = document.getElementById(("errorTo_" + uniqueKeyword));
	lErrorMessageFrom.style.display = "none";
	lErrorMessageTo.style.display = "none";
	var lReturn = true;

	//Verify that the value of the airport departure is not the map option
	if (select1 != null && select1.value == 'map') {
		lErrorMessageFrom.style.display = "block";
		lReturn = false;
	}

	var lInputText = document.getElementById((startIdFrom + uniqueKeyword));
	if (lInputText.style.display == "block") {
		if (lInputText.value == '') {
			lErrorMessageFrom.style.display = "block";
			lReturn = false;
		}
	}

	//Verify that the value of the airport destination is not the map option
	if (select2 != null && select2.value == 'map') {
		lErrorMessageTo.style.display = "block";
		lReturn = false;
	}

	var lInputTextTo = document.getElementById((startIdTo + uniqueKeyword));
	if (lInputTextTo.style.display == "block") {
		if (lInputTextTo.value == '') {
			lErrorMessageTo.style.display = "block";
			lReturn = false;
		}
	}
	var lDate = ValidateDateFlight(uniqueKeyword);
	lReturn = lReturn && lDate;

	return lReturn;
}

function ValidateDateFlight(uniqueKeyword) {
	var currentDate = new Date();
	currentDate.setDate(currentDate.getDate() + 1);
	var lDepDay = document.getElementById(("depDayFlight_" + uniqueKeyword));
	var lDepMonth = document.getElementById(("depMonthFlight_" + uniqueKeyword));
	var lRetDay = document.getElementById(("retDayFlight_" + uniqueKeyword));
	var lRetMonth = document.getElementById(("retMonthFlight_" + uniqueKeyword));
	var lDepYear = lDepMonth.value.substr(0, 4);
	var lDepMonthValue = lDepMonth.value.substr(4, 2);
	var lRetYear = lRetMonth.value.substr(0, 4);
	var lRetMonthValue = lRetMonth.value.substr(4, 2);

	var lDepDate = new Date();
	lDepDate.setFullYear(lDepYear, trimDateFlight(lDepMonthValue) - 1, lDepDay.value);

	var lRetDate = new Date();
	lRetDate.setFullYear(lRetYear, trimDateFlight(lRetMonthValue) - 1, lRetDay.value);

	var lErrorMessage = document.getElementById(("dateError_" + uniqueKeyword));
	lErrorMessage.style.display = "none";
	var lErrorMessage2 = document.getElementById(("errorInvalidDates_" + uniqueKeyword));
	lErrorMessage2.style.display = "none";
	var lErrorMessage3 = document.getElementById(("errorInvalidPastDates_" + uniqueKeyword));
	lErrorMessage3.style.display = "none";

	if ((lDepDate.getMonth() != trimDateFlight(lDepMonthValue) - 1) || (lRetDate.getMonth() != trimDateFlight(lRetMonthValue) - 1)) {
		lErrorMessage2.style.display = "block";
		return false;
	}

	if (lRetDate < lDepDate) {
		lErrorMessage.style.display = "block";
		return false;
	}

	///If current selected dates are in the past, display error message
	///Current date won't be a valid date
	if (lRetDate < currentDate || lDepDate < currentDate) {
		lErrorMessage3.style.display = "block";
		return false;
	}

	return true;
}

function trimDateFlight(month) {
	if (month[0] == '0') {
		return month[1];
	}
	return month;
}

function InitCarouselFlights(uniqueKeyword) {
	var lDestinationAirportSelect = document.getElementById("selFlightsTo_" + uniqueKeyword);
	if (lDestinationAirportSelect) {
		var lDestinationAirportTxt = document.getElementById("txtFlightTo_" + uniqueKeyword);
		if (lDestinationAirportTxt) {
			if ((lDestinationAirportSelect.options.length <= 0) || (lDestinationAirportSelect.options.length == 1 && lDestinationAirportSelect.options[0].value.length == 0)) {
				lDestinationAirportSelect.style.display = "none";
				lDestinationAirportTxt.style.display = "block";
			}
		}
	}
}

var lFlightWin;
var lCarWin;
function flightRedirect(uniqueKeyword) {
	if (!ValidateFlightTicketAndCarData("txtFlightFrom_", "txtFlightTo_", uniqueKeyword,
		document.getElementById(("selFlightsFrom_" + uniqueKeyword)), document.getElementById(("selFlightsTo_" + uniqueKeyword)))) {
		return;
	}
	var lChildren = document.getElementById(("selbOfChildren_" + uniqueKeyword)) ? document.getElementById(("selbOfChildren_" + uniqueKeyword)).value : 0;
	var lAdults = document.getElementById(("selNbOfAdults_" + uniqueKeyword)) ? document.getElementById(("selNbOfAdults_" + uniqueKeyword)).value : 1;
	var lAirport;
	var lDepatureAirport;
	var lInputText = document.getElementById(("txtFlightTo_" + uniqueKeyword));
	var lDepatureAirportInput = document.getElementById(("txtFlightFrom_" + uniqueKeyword));
	var lDepartureAirportName;
	var lDestinationAirportName;
	if (lDepatureAirportInput.style.display == 'block') {
		lDepatureAirport = lDepatureAirportInput.value;
		lDepartureAirportName = lDepatureAirportInput.value;
	}
	else {
		var lCurrentSelect = document.getElementById(("selFlightsFrom_" + uniqueKeyword));
		lDepatureAirport = lCurrentSelect.value;
		lDepartureAirportName = lCurrentSelect.options[lCurrentSelect.selectedIndex].attributes["airportname"].value;
	}
	if (lInputText.style.display == 'block') {
		lAirport = lInputText.value;
		lDestinationAirportName = lInputText.value;
	}
	else {
		var lCurrentSelectTo = document.getElementById(("selFlightsTo_" + uniqueKeyword));
		lAirport = lCurrentSelectTo.value;
		lDestinationAirportName = lCurrentSelectTo.options[lCurrentSelectTo.selectedIndex].attributes["airportname"].value;
	}
	var lDepartureDay = document.getElementById(("depDayFlight_" + uniqueKeyword)).value;
	var lDepartureYearMonth = document.getElementById(("depMonthFlight_" + uniqueKeyword)).value;
	var lReturnDay = document.getElementById(("retDayFlight_" + uniqueKeyword)).value;
	var lReturnYearMonth = document.getElementById(("retMonthFlight_" + uniqueKeyword)).value;
	var lLink;

	NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetFlightTicketsUrl(lChildren, lDepatureAirport, lAirport, lDepartureDay,
		lDepartureYearMonth, lReturnDay, lReturnYearMonth, lAdults, EscapeSequence(lDepartureAirportName), EscapeSequence(lDestinationAirportName),
		GetDateForQueryString(lDepartureDay, lDepartureYearMonth), GetDateForQueryString(lReturnDay, lReturnYearMonth), OnFlightLinkAvailable,
		OnTimeOut, null);
	lFlightWin = window.open("");
	lFlightWin.opener = this;
	lFlightWin.focus();
}

function OnFlightLinkAvailable(result) {
	lFlightWin.location.href = result;
}

function OnCarLinkAvailable(result) {
	lCarWin.location.href = result;
}

function OnTimeOut() {

}

function EscapeSequence(value) {
	return encodeURIComponent(value); //.replace(' ', '%2B');
}

function GetDateForQueryString(day, yearMonth) {
	return day + EscapeSequence(' ') + monthNames[trimDateFlight(yearMonth.substr(4, 2)) - 1] + EscapeSequence(' ') + yearMonth.substr(0, 4);
}

function InitCarouselCars(uniqueKeyword) {
	var lDepartureAirportSelect = document.getElementById("selCarsFrom_" + uniqueKeyword);
	var lDestinationAirportSelect = document.getElementById("selCarsTo_" + uniqueKeyword);
	if (lDestinationAirportSelect && lDepartureAirportSelect) {
		var lDepartureAirportTxt = document.getElementById("txtCarFrom_" + uniqueKeyword);
		var lDestinationAirportTxt = document.getElementById("txtCarTo_" + uniqueKeyword);
		if (lDestinationAirportTxt && lDepartureAirportSelect) {
			if ((lDestinationAirportSelect.options.length <= 0) || (lDestinationAirportSelect.options.length == 1 && lDestinationAirportSelect.options[0].value.length == 0)) {
				lDestinationAirportSelect.style.display = "none";
				lDestinationAirportTxt.style.display = "block";
				lDepartureAirportSelect.style.display = "none";
				lDepartureAirportTxt.style.display = "block";
			}
		}
	}
}

function carRedirect(uniqueKeyword) {
	if (!ValidateFlightTicketAndCarData("txtCarFrom_", "txtCarTo_", uniqueKeyword, document.getElementById(("selCarsFrom_" + uniqueKeyword)),
		document.getElementById(("selCarsTo_" + uniqueKeyword)))) {
		return;
	}
	var lAirport;
	var lDepatureAirport;
	var lDepartureAirportName;
	var lDestinationAirportName;
	var lInputText = document.getElementById(("txtCarTo_" + uniqueKeyword));
	var lInputFrom = document.getElementById(("txtCarFrom_" + uniqueKeyword));
	if (lInputFrom.style.display == "block") {
		lDepatureAirport = lInputFrom.value;
		lDepartureAirportName = lInputFrom.value;
	}
	else {
		var lCurrentSelect = document.getElementById(("selCarsFrom_" + uniqueKeyword));
		lDepatureAirport = lCurrentSelect.value;
		lDepartureAirportName = lCurrentSelect.options[lCurrentSelect.selectedIndex].attributes["airportname"].value;
	}

	if (lInputText.style.display == 'block') {
		lAirport = lInputText.value;
		lDestinationAirportName = lInputText.value;
	}
	else {
		var lCurrentSelectTo = document.getElementById(("selCarsTo_" + uniqueKeyword));
		lAirport = lCurrentSelectTo.value;
		lDestinationAirportName = lCurrentSelectTo.options[lCurrentSelectTo.selectedIndex].attributes["airportname"].value;
	}
	var lDepartureDay = document.getElementById(("depDayFlight_" + uniqueKeyword)).value;
	var lDepartureYearMonth = document.getElementById(("depMonthFlight_" + uniqueKeyword)).value;
	var lReturnDay = document.getElementById(("retDayFlight_" + uniqueKeyword)).value;
	var lReturnYearMonth = document.getElementById(("retMonthFlight_" + uniqueKeyword)).value;
	var lLink;
	var lPickUpTime = document.getElementById(("depTimeFlight_" + uniqueKeyword)) ? document.getElementById(("depTimeFlight_" + uniqueKeyword)).value : "12:00";
	var lDropOffTime = document.getElementById(("retTimeFlight_" + uniqueKeyword)) ? document.getElementById(("retTimeFlight_" + uniqueKeyword)).value : "12:00";
	NetMatch.Zoover.Web.Services.Suppliers.FlightTicketsService.GetCarRentalUrl(lDepatureAirport, lDepartureDay, lDepartureYearMonth, EscapeSequence(lPickUpTime),
		lAirport, lReturnDay, lReturnYearMonth, EscapeSequence(lDropOffTime), EscapeSequence(lDepartureAirportName), EscapeSequence(lDestinationAirportName),
		EscapeSequence(GetDateForQueryString(lDepartureDay, lDepartureYearMonth)), EscapeSequence(GetDateForQueryString(lReturnDay, lReturnYearMonth)), OnCarLinkAvailable, OnTimeOut, null);
	lCarWin = window.open("");
	lCarWin.opener = this;
	lCarWin.focus();
}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();