﻿// 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();
}

// *******************Initial calendar.js file ******************** //
var today = new Date();
var curr_month = today.getMonth();
var curr_day = today.getDate();
var curr_year = today.getFullYear();
var curr_date = getDateObject(curr_month + "/01/" + curr_year, "/");
var month2 = "";
var year2 = "";
var prev_month = "";
var prev_year = "";
var next_month = "";
var next_year = "";
var prev_date = "";
var next_date = "";
var position_id = "";
var max_year = curr_year * 1 + 1;
var max_month = curr_month * 1;
var max_day = curr_day * 1;
var max_date = getDateObject(max_month + "/01/" + max_year, "/");
var form_id = "";
var cal_header = "";
var month_string = "";
var month_string2 = "";
var year_string2 = "";

function generate_calendar(year, month, id, form_id, cal_header) {
	month = month * 1;
	year = year * 1;

	var first_of_month = new Date();
	first_of_month.setFullYear(year, month, 1);

	SetDisplayedMonth(year, month);


	var calendar = '<div>';

	calendar += '<div class="cal_top clearfix">';
	calendar += '<div class="cal_title">' + cal_header + '</div>';
	calendar += '<div class="cal_close"><a href="javascript:popup_exit();" class="no_hover" title="' + close_string + '">X</a></div>';
	calendar += '</div>';



	calendar += '<div class="clearfix contents" style="border-bottom: 1px solid #78B9FC; background-color:#FFFFFF;">';

	calendar += '<div style="float:left; width:188px; border-right:1px solid #78B9FC; border-right: 1px solid #78B9FC;">';
	if (prev_date <= curr_date) {
		calendar += '<div class="calendar_prev">' + prev + '</div>';
	} else {
		calendar += '<div class="calendar_prev"><a href="javascript: open_cal(' + prev_year + ', ' + prev_month + ', \'' + id + '\', \'' + form_id + '\',\'' + cal_header + '\');" class="no_hover">' + prev + '</a></div>';
	}

	calendar += '<div style="float:right; padding: 2px 50px 2px 0;">' + month_string + ' - ' + year + '</div>';
	calendar += '</div>';

	calendar += '<div style="float:right; width:188px;">';
	calendar += '<div style="float:left; padding:2px 0 2px 50px;">' + month_string2 + ' - ' + year_string2 + '</div>';
	if (next_date < max_date) {
		calendar += '<div class="calendar_next"><a href="javascript: open_cal(' + next_year + ', ' + next_month + ', \'' + id + '\', \'' + form_id + '\', \'' + cal_header + '\');" class="no_hover">' + next + '</a></div>';
	} else {
		calendar += '<div class="calendar_next">' + next + '</div>';
	}
	calendar += '</div></div>';
	calendar += '<div style="padding: 1px 0;" class="clearfix">';
	calendar += generate_calendar_contents(month, year, "border");
	calendar += generate_calendar_contents(month2, year2, "none");
	calendar += '<br class="clearboth" /></div>';
	calendar += '</div>';

	return calendar;
}

function generate_calendar_contents(month, year, border) {
	var day_field = position_id + 'Day';
	var month_field = position_id + 'Month';

	var max_days = 1000;
	var prev_month_days = new Date(year, month - 1, 1);
	var start_day = prev_month_days.getDay() - firstDay;
	var num_days = days_in_month(month, year);
	var prev_num_days = days_in_month(prev_month, prev_year);
	var prev_start_day = prev_num_days - start_day + 1;
	var calendar = '<div style="float:left; width:189px; border-top: 1px #78B9FC solid;';
	if (border == "border") {
		calendar += ' border-right: 1px #78B9FC solid" id="left-calendar">';
	} else {
		calendar += '" id="right-calendar">';
	}

	/* display headings */
	calendar += '<div class="clearfix">';
	for (s = 0; s < 7; s++) {
		if (((s == 0 || s == 6) && (firstDay == 0)) || ((s == 5 || s == 6) && (firstDay == 1))) {
			calendar += '<div class="weekend line_under">';
		} else {
			calendar += '<div class="weekdays line_under">';
		}
		calendar += day_headings[s] + '</div>';
	}
	calendar += '</div>';

	/* display days */
	calendar += '<div class="clearfix" style="text-align:center">';
	j = 1;
	k = prev_start_day;
	for (i = 0; i < 42; i++) {
		/* days in the month */
		if ((i - start_day >= 0) && (i - start_day < num_days)) {
			x = i - start_day + 1;
			input_month = month;
			input_year = year;
		} else if (i - start_day + 1 < num_days) { // next month
			x = k;
			k++;
			if (month == 1) {
				input_month = 12;
				input_year = year - 1;
			} else {
				input_month = month - 1;
				input_year = year;
			}
		} else { // prev month
			x = j;
			j++;
			if (month == 12) {
				input_month = 1;
				input_year = year + 1;
			} else {
				input_month = month + 1;
				input_year = year;
			}
		}


		var day = new Date();
		day.setFullYear(input_year);
		day.setMonth(input_month - 1);
		day.setDate(x);

		if ((((i) % 7 == 0 || (i) % 7 == 6) && (firstDay == 0)) || (((i) % 7 == 5 || (i) % 7 == 6) && (firstDay == 1))) {
			calendar += '<div class="weekend" ';
			hover_off_class = "hover_off_weekend";
		} else {
			calendar += '<div class="weekdays" ';
			hover_off_class = "hover_off_weekdays";
		}

		if (day >= today) {
			/*
			if (input_month > month) {
			calendar += 'style="color:#000;">' + x + '</div>';
			} else if (input_month < month) {
			calendar += 'style="color:#999;">' + x + '</div>';
			*/
			if (input_month != month) {
				calendar += 'style="color:#999;">' + x + '</div>';
			} else {
				calendar += 'onmouseover="this.className=\'hover_on\'" onmouseout="this.className=\'' + hover_off_class + '\'" class="hover_off"><a href="javascript:selectDate(' + x + ', ' + input_month + ', ' + input_year + ', \'' + form_id + '\', \'' + day_field + '\', \'' + month_field + '\')" >' + x + '</a></div>';
			}
		} else {
			calendar += 'style="color:#999;">' + x + '</div>';
		}

		if (((i) % 7 == 6) && (i < 36)) {
			if (i - start_day + 1 > num_days) {
				break;
			}
			calendar += '</div><div class="clearfix">';
		}
	}
	calendar += '</div>';
	calendar += '</div>';


	return calendar;
}

/* count how many days in month */
function days_in_month(m, y) {
	if (m == 0) {
		m = 1; y += 1;
	}
	var md = new Date();
	md.setDate(1);
	md.setFullYear(y);
	md.setMonth(m);

	md.setDate(md.getDate() - 1);

	return md.getDate();
}


function selectDate(selected_day, selected_month, selected_year, form_id, day_field, month_field) {

	// show the dropdowns
	document.getElementById('retDay').style.visibility = 'visible';
	document.getElementById('retMonth').style.visibility = 'visible';

	if (selected_month > 12) {
		selected_month = 1;
		selected_year += 1;
	}

	if ((day_field == "depDay") || (month_field == "depMonth")) {
		var mon_element = document.getElementById("depMonth");
		document.getElementById("depDay").options[selected_day - 1].selected = true;

		for (i = 0; i < mon_element.options.length; i++)
			if (mon_element.options[i].value == selected_month - 1) {
			mon_element.options[i].selected = true;
		}

		if (typeof (mon_element.onchange) == "function") {
			mon_element.onchange();
		}

	} else if ((day_field == "retDay") || (month_field == "retMonth")) {
		var mon_element = document.getElementById("retMonth");
		document.getElementById("retDay").options[selected_day - 1].selected = true;

		for (i = 0; i < mon_element.options.length; i++)
			if (mon_element.options[i].value == selected_month - 1)
			mon_element.options[i].selected = true;
	}

	if (document.getElementById('popup')) {
		document.getElementById('popup').style.display = "none";
	}
}

function open_cal(year, month, id, formId, cal_header) {
	if (month.length == 0)
		month = curr_month;
	if (year.length == 0)
		year = curr_year;
	position_id = id;
	form_id = formId;

	document.getElementById('calendar_field').innerHTML = generate_calendar(year, month, id, form_id, cal_header);
	setBorder();
}


function setBorder() {
	h1 = document.getElementById("left-calendar");
	h2 = document.getElementById("right-calendar");
	boxh1 = h1.clientHeight;
	boxh2 = h2.clientHeight;
	if (boxh1 >= boxh2) {
		document.getElementById("right-calendar").style.height = boxh1 + "px";
	} else {
		document.getElementById("left-calendar").style.height = boxh2 + "px";
	}
}

// Sets the currently-displayed month object
function SetDisplayedMonth(year, month) {
	month_string = month_array[month - 1];
	if (month == 1) {
		prev_month = 12;
		prev_year = year - 1;
		next_month = month + 1;
		next_year = year;
		month_string2 = month_array[month];
		year_string2 = year;
	} else if (month == 12) {
		prev_month = month - 1;
		prev_year = year;
		next_month = 1;
		next_year = year + 1;
		month_string2 = month_array[0];
		year_string2 = year + 1;
	} else {
		prev_month = month - 1;
		prev_year = year;
		next_month = month + 1;
		next_year = year;
		month_string2 = month_array[month];
		year_string2 = year;
	}

	month2 = next_month;
	year2 = next_year;

	// Creates the previous and next month objects
	prev_date = getDateObject(prev_month + "/01/" + prev_year, "/");
	next_date = getDateObject(next_month + "/01/" + next_year, "/");
}

function getDateObject(dateString, dateSeperator) {
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue = dateString;
	var sepChar = dateSeperator;
	var curPos = 0;
	var cDate, cMonth, cYear;

	//extract day portion
	curPos = dateString.indexOf(sepChar);
	cDate = dateString.substring(0, curPos);

	//extract month portion				
	endPos = dateString.indexOf(sepChar, curPos + 1);
	cMonth = dateString.substring(curPos + 1, endPos);

	//extract year portion				
	curPos = endPos;
	endPos = curPos + 5;
	cYear = curValue.substring(curPos + 1, endPos);

	//Create Date Object
	dtObject = new Date(cYear, cMonth, cDate);
	return dtObject;
}

function ShowHideDropDownLists(show) {
	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7) {
		var lValue = true;
		if (show) {
			lValue = false;
		}
		var lRetDayContainer = document.getElementById('retDay');
		if (lRetDayContainer != null) {
			lRetDayContainer.disabled = lValue;
		}

		var lRetMonthContainer = document.getElementById('retMonth');
		if (lRetMonthContainer != null) {
			lRetMonthContainer.disabled = lValue;
		}

		var lDepDayContainer = document.getElementById('depDay');
		if (lDepDayContainer != null) {
			lDepDayContainer.disabled = lValue;
		}

		var lDepMonthContainer = document.getElementById('depMonth');
		if (lDepMonthContainer != null) {
			lDepMonthContainer.disabled = lValue;
		}
	}
}


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"
	}
    ]
};

BrowserDetect.init()

// ************** Merged from popup.js file ******************************** //


// ******************** CALENDAR ******************************************* //

// ----- popup_exit ----------------------------------------------------------
function popup_exit(e) {
	var element = document.getElementById('popup');

	element.style.visibility = 'hidden';
	element.style.display = 'none';

	// show the dropdowns
	document.getElementById('retDay').style.visibility = 'visible';
	document.getElementById('retMonth').style.visibility = 'visible';
}

// ----- popup_show ----------------------------------------------------------
function popup_show(id, x, y, position_id, form_id, cal_header) {
	if (position_id == 'dep' || position_id == 'ret') {
		var lDepMonth = document.getElementById('depMonth');
		if (lDepMonth && lDepMonth.disabled) {
			return;
		}
	}

	if (position_id == 'dep') {
		// hide the dropdowns
		document.getElementById('retDay').style.visibility = 'hidden';
		document.getElementById('retMonth').style.visibility = 'hidden';
	}

	var element = document.getElementById(id);

	element.style.position = "absolute";
	element.style.visibility = "visible";
	element.style.display = "block";

	var position_element = document.getElementById(position_id);

	element.style.left = x + 'px';
	if (position_id == "dep" && BrowserDetect.browser == 'Explorer' && BrowserDetect.version <= 7) {
		y = y + 4;
	}
	element.style.marginTop = y + 'px';

	if (Calendar) {
		var lCalendar = new Calendar();
		var lDate;
		if (position_id == 'dep') {
			lDate = lCalendar.GetStartDate();
		}
		else {
			lDate = lCalendar.GetEndDate();
		}
		year = lDate.getFullYear();
		month = lDate.getMonth();
	}
	else {

		year = today.getFullYear();
		current_month = today.getMonth();

		month_id = position_id + 'Month';
		month = document.getElementById(month_id).selectedIndex;
		if (current_month > month) {
			year = year + 1;
		}
	}
	open_cal(year, month + 1, position_id, form_id, cal_header);
}

//*******************Merged from scripts.js file ********************//


var page_type = 'r';

function foc() {
	if (document.getElementById('classic_box').className == 'show') {
		document.air.depCity.focus();
	} else if (document.getElementById('onebox_box').className == 'show') {
		document.onebox_air.onebox.focus();
	}
	page_type = 's';
}

function foc_onebox() {
	document.air.onebox.focus();
	page_type = 's';
}

function foc_hotel() {
	document.hotel.dest.focus();
	page_type = 's';
}

function foc_car() {
	document.car.pulocation.focus();
	page_type = 's';
}

function foc_activity() {
	document.air.depCity.focus();
	page_type = 's';
}

// launch new windows
// user for choosing destination and date

function fill_in(page, w, h, scrollBars) {
	if (arguments.length < 4) {
		scrollBars = 0;
	}
	mywin = window.open(page, 'Note', 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=' + scrollBars + ', resizable=1, copyhistory=0, width=' + w + ',height=' + h);
}


function emlWrite(a, b, c, d) {
	var mail;
	var link;
	mail = a + "@" + b + "." + c;
	link = '<a href="mailto:' + mail + '">' + d + '</a>';
	document.write(link);
}

function openChat(uri, name) {
	day = new Date();
	id = day.getTime();
	settings = "resizable=no,scrollbars=no,width=700,height=400,top=" + ((screen.height - (screen.height / 1.618)) - (400 / 2)) + ",left=" + ((screen.width - 700) / 2);
	eval("cw" + id + " = window.open(\"" + uri + "\",\"" + name + "\",\"" + settings + "\");");
}

function show_multires(obj, num_dests) {
	// change the highlighted row
	var highlight = document.getElementById('multi-highlight');
	highlight.style.backgroundPosition = '0 ' + (obj * 27) + 'px';
	// turn off the currently active info box
	for (i = 1; i <= num_dests; i++) {
		if (i != obj) {
			var temp_el = document.getElementById('multi-flight-' + i);
			temp_el.style.visibility = 'hidden';
		}
	}
	// turn on the new info box
	var el = document.getElementById('multi-flight-' + obj);
	el.style.visibility = 'visible';
}

// 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.Binaries');
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService=function() {
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.prototype={
_get_path:function() {
 var p = this.get_path();
 if (p) return p;
 else return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_path();},
MarkEntityPhotoAsVisited:function(url,succeededCallback, failedCallback, userContext) {
return this._invoke(this._get_path(), 'MarkEntityPhotoAsVisited',false,{url:url},succeededCallback,failedCallback,userContext); },
GetVisitedEntityPhotoCounter:function(url,succeededCallback, failedCallback, userContext) {
return this._invoke(this._get_path(), 'GetVisitedEntityPhotoCounter',false,{url:url},succeededCallback,failedCallback,userContext); }}
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.registerClass('NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService',Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance = new NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService();
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_path = function(value) { NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.get_path = function() { return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_path(); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_timeout = function(value) { NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.get_timeout = function() { return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.set_path("/Services/Binaries/PhotoStatisticsService.asmx");
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.MarkEntityPhotoAsVisited= function(url,onSuccess,onFailed,userContext) {NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.MarkEntityPhotoAsVisited(url,onSuccess,onFailed,userContext); }
NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService.GetVisitedEntityPhotoCounter= function(url,onSuccess,onFailed,userContext) {NetMatch.Zoover.Web.Services.Binaries.PhotoStatisticsService._staticInstance.GetVisitedEntityPhotoCounter(url,onSuccess,onFailed,userContext); }

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';
	}
}
Type.registerNamespace('NetMatch.Zoover.Web.AccoOwner.Services');
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService = function() {
	NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.initializeBase(this);
	this._timeout = 0;
	this._userContext = null;
	this._succeeded = null;
	this._failed = null;
}
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.prototype = {
	_get_path: function() {
		var p = this.get_path();
		if (p) return p;
		else return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_path();
	},
	GetAddReactionForm: function(testimonialId, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'GetAddReactionForm', true, { testimonialId: testimonialId }, succeededCallback, failedCallback, userContext);
	},
	IsAccoOwner: function(accommodationId, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'IsAccoOwner', false, { accommodationId: accommodationId }, succeededCallback, failedCallback, userContext);
	},
	SaveReaction: function(testimonialId, userName, reaction, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'SaveReaction', false, { testimonialId: testimonialId, userName: userName, reaction: reaction }, succeededCallback, failedCallback, userContext);
	} 
}
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.registerClass('NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService', Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance = new NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService();
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_path = function(value) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.get_path = function() { return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_path(); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_timeout = function(value) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.get_timeout = function() { return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.set_path("/AccoOwner/Services/AccoOwnerService.asmx");
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.GetAddReactionForm = function(testimonialId, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.GetAddReactionForm(testimonialId, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.IsAccoOwner = function(accommodationId, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.IsAccoOwner(accommodationId, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService.SaveReaction = function(testimonialId, userName, reaction, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService._staticInstance.SaveReaction(testimonialId, userName, reaction, onSuccess, onFailed, userContext); }
var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;
if (typeof (NetMatch.Zoover.Web.AccoOwner.Services.client_result) === 'undefined') {
	NetMatch.Zoover.Web.AccoOwner.Services.client_result = gtc("NetMatch.Zoover.Web.AccoOwner.Services.client_result");
	NetMatch.Zoover.Web.AccoOwner.Services.client_result.registerClass('NetMatch.Zoover.Web.AccoOwner.Services.client_result');
}

var _PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();

// call ApplicationLoadHandler on each page load (on the client)
Sys.Application.add_load(ApplicationLoadHandler)

// on each non async request tell the PRM to execute InitializeRequest for each request
function ApplicationLoadHandler(sender, args) {
	if (!_PageRequestManager.get_isInAsyncPostBack()) {
		_PageRequestManager.add_initializeRequest(InitializeRequest);
	}
}

// cancel any async request that is made during the execution of the previous async request
function InitializeRequest(sender, args) {
	if (_PageRequestManager.get_isInAsyncPostBack()) {
		args.set_cancel(true);
	}
}

// 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");
}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();