var cur_var;

var variant_map=new Array();
variant_map['cn'] = '/CN';
variant_map['cncn'] = '/CN';
variant_map['caen'] = '';
variant_map['ie'] = '/IE';
variant_map['uk'] = '/UK';
variant_map['es'] = '';
variant_map['au'] = '';
variant_map['be'] = '/UK';
variant_map['ca'] = '';
variant_map['cnen'] = '';
variant_map['enc'] = '/UK';
variant_map['int'] = '/UK';
variant_map['de'] = '/DE';
variant_map['cafr'] = '';
variant_map['it'] = '/UK';
variant_map['mx'] = '';

function $(elementID) {
	if (document.getElementById) {
		return document.getElementById(elementID);
	} else if (document.all) {
		return document.all[elementID];
	} else if (document.layers) {
		document.layers[elementID];
	} else {
		window[elementID];
	}
}

// basic AJAX connector
function getHttpObject()
{
	var xmlHttpRequest;
  /*@cc_on
  @if (@_jscript_version >= 5)
  try {
    xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (exception1) {
    try {
      xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (exception2) {
      xmlHttpRequest = false;
    }
  }
  @else
    xmlhttpRequest = false;
  @end @*/

  if (!xmlHttpRequest && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlHttpRequest = new XMLHttpRequest();
    } catch (exception) {
      xmlHttpRequest = false;
    }
  }
  else
  {
  	try{  	    
		xmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");			  
		}
		catch (e){		
		xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		  
		}
  }
  return xmlHttpRequest;
}


var HttpObjState = getHttpObject();
var HttpObjCity = getHttpObject();

function clearSelect(selectObj, newText) {
 for (var i=selectObj.options.length;i>=0;i--)
 selectObj.options[i] = null;
 selectObj.options[0] = new Option(newText,"", false, false );
}


// Runs getStates with a parameter enabling to invoke a callback.
// If client wills to use a callback, it must implement it in itself.
// Please see countryChanged() and stateChanged() descriptions in
// the city_dd.jsp component.
function getStates(country, selectedState, selectedCity, runStateCallback) {
    clearSelect(document.getElementById('state'), "Loading...");
    clearSelect(document.getElementById('destination'), "-----------------------");
    HttpObjState.open("GET", "../CityDropdownServlet?task=getStateOptions&countryNameForCity=" + country + "&selectedState=" + selectedState + "&selectedCity=" + selectedCity, true);
    //  HttpObjState.onreadystatechange= stateResponse;
    HttpObjState.onreadystatechange = function () {
        if (HttpObjState.readyState == 4) {

            try {
                var stateSelect = $('state');
                var ops = HttpObjState.responseXML.getElementsByTagName('option');
                var StateSelected = '';
                for (var i = 0; i < ops.length; i++) {
                    if (ops[i].getAttribute("selected") == "true") {
                        stateSelect.options[i] = new Option(ops[i].firstChild.data, ops[i].attributes[0].value, true, true);
                        StateSelected = ops[i].attributes[0].value;
                        stateSelect.options[i].selected = true;
                    } else {
                        stateSelect.options[i] = new Option(ops[i].firstChild.data, ops[i].attributes[0].value, false, false);
                    }
                }
                if (ops.length <= 1) {
                    getCities($('country').value, 'NA', selectedCity)
                }
                else {
                    getCities($('country').value, selectedState, selectedCity)
                }

                // Run the callback to handle custom logic upon country change.
                // Any client using the country-state-city dropdown component and
                // willing to implement a custom callback should define it in itself.
                if (runStateCallback != undefined) {
                    statesLoadedCallback();
                }

            } catch (ex) {
                // alert("exception");
            }
        }
    }
    HttpObjState.send(null);
}


// Runs getCities with a parameter enabling to invoke a callback.
// If client wills to use a callback, it must implement it in itself. 
// Please see countryChanged() and stateChanged() descriptions in
// the city_dd.jsp component.
function getCities(country, state, city, runCityCallback) {
    clearSelect(document.getElementById('destination'), "Loading...");
    HttpObjCity.open("GET", "../CityDropdownServlet?task=getCityOptions&stateNameForCity=" + state + "&countryNameForCity=" + country + "&selectedCity=" + city, true);
    HttpObjCity.onreadystatechange = function() {
        if (HttpObjCity.readyState == 4) {
            try {
                var citySelect = $('destination');
                var CitySelected = '';

                var ops = HttpObjCity.responseXML.getElementsByTagName("option");
                for (var i = 0; i < ops.length; i++) {
                    if (ops[i].getAttribute("selected") == "true") {
                        citySelect.options[i] = new Option(ops[i].firstChild.data, ops[i].attributes[0].value, true, true);
                        CitySelected = ops[i].attributes[0].value;
                        citySelect.options[i].selected = true;
                    } else
                        citySelect.options[i] = new Option(ops[i].firstChild.data, ops[i].attributes[0].value, false, false);
                }

                // Run the callback to handle custom logic upon country change.
                // Any client using the country-state-city dropdown component and
                // willing to implement a custom callback should define it in itself.
                if (runCityCallback != undefined) {
                    citiesLoadedCallback();
                }
                
            } catch (ex) {
                // alert("exception");
            }
        }
    }
    HttpObjCity.send(null);
}




function new_win(url,name,options)
{
   var new_window = window.open(url, name, options)

   //4889 - Sujay - 20041125
   new_window.focus();
}


function preselect(selectObject, value) {
	for (i = 0; i < selectObject.options.length; i++) {
		if (selectObject.options[i].value.toUpperCase() == value.toUpperCase()) {
			selectObject.selectedIndex = i;
			return value;
		}
	}
	return "";
}
function preselectCombo(selectObject, value) {
	for (i = 0; i < selectObject.options.length; i++) {
		if (selectObject.options[i].value == value) {
		selectObject.options[i].selected = true; 
		}
	}
	
}

function preselectTextbox(textboxObject, value) {
	textboxObject.value = value;
}

function resetSelect(selectObject) {
	selectObject.selectedIndex = 0;
}

function swapCountry(countrySelectObject, selectedState) {
	var usaStates = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN",
					"IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV",
					"NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","PR","RI","SC","SD","TN",
					"TX","UT","VT","VA","WA","WV","WI","WY");
	var canadaStates = new Array("AB","BC","MB","NB","NT","NS","ON","PE","QC","SK","NF","NU","YT");

	var usa = false;
	var canada = false;

	for (i = 0; i < usaStates.length; i++) {
		if (selectedState.toUpperCase() == usaStates[i].toUpperCase()) {
			usa = true;
			break;
		}
	}
	for (i = 0; i < canadaStates.length; i++) {
		if (selectedState.toUpperCase() == canadaStates[i].toUpperCase()) {
			canada = true;
			break;
		}
	}

	if (usa) {
		preselect(countrySelectObject, "US");
	}
	if (canada) {
		preselect(countrySelectObject, "CA");
	}
}


function swapState(stateSelectObject, selectedCountry) {
	if (selectedCountry.toUpperCase() != "US" && selectedCountry.toUpperCase() != "CA" && selectedCountry.toUpperCase() != "") {
		preselect(stateSelectObject, "NA");
	} else {
		if (stateSelectObject.value == "NA" || selectedCountry=="") {
			preselect(stateSelectObject, ""); // "Select A State/Province"
		}
        }
}


function incDate(dateElement, currentDate, isReverse) {

	// consider currentDate is in 'mm/dd' format
	var splits = currentDate.split("/");
	var valid = false;
	if (splits.length == 2) {
		if (!isNaN(trim(splits[0])) && !isNaN(trim(splits[1]))) {
			valid = true;
		}
	}
	if (!valid)	{
		return;
	}
	if(isReverse=='false') {
		var m = parseInt(trim(splits[0]) , 10);
		var d = parseInt(trim(splits[1]) , 10);
	}
	else {
		var m = parseInt(trim(splits[1]) , 10);
		var d = parseInt(trim(splits[0]) , 10);
	}

	var daysInMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	// Set 29 days in Feb if this is a leap year
	if ("undefined" != typeof(isLeapYear) && isLeapYear == false) {
		daysInMonth[1] = 28;
	}

	d++;
	if (d < 1 || d > daysInMonth[m - 1]) {
		d = 1;
		m++;
	}
	if (m < 1 || m > 12) {
		m = 1;
	}

	// convert m/d to mm/dd
	if (m < 10) {
		m = "0" + m;
	}
	if (d < 10) {
		d = "0" + d;
	}

	if(isReverse=='false') var result = m + "/" + d;
	else if(isReverse=='true') var result = d + "/" + m;
	dateElement.value = result;
}

function incDatePromo(dateElement, currentDate, isReverse, incParam) {

	// consider currentDate is in 'mm/dd' format
	var splits = currentDate.split("/");
	var valid = false;
	if (splits.length == 2) {
		if (!isNaN(trim(splits[0])) && !isNaN(trim(splits[1]))) {
			valid = true;
		}
	}
	if (!valid)	{
		return;
	}
	if(isReverse=='false') {
		var m = parseInt(trim(splits[0]) , 10);
		var d = parseInt(trim(splits[1]) , 10);
	}
	else {
		var m = parseInt(trim(splits[1]) , 10);
		var d = parseInt(trim(splits[0]) , 10);
	}

	var daysInMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	// Set 29 days in Feb if this is a leap year
	if ("undefined" != typeof(isLeapYear) && isLeapYear == false) {
		daysInMonth[1] = 28;
	}
	var daysRemainingInMonth = eval(daysInMonth[m - 1]) - eval(d);
	if(daysRemainingInMonth < 0){
		daysRemainingInMonth = 0; 
	}
	var mlosToBeAdded = eval(incParam) - eval(daysRemainingInMonth);
	d = eval(d) + eval(incParam);
	if (d < 1 || d > daysInMonth[m - 1]) {
		d = eval(mlosToBeAdded);
		m++;
	}
	if(d == 0){
		d = 1;
	}
	if (m < 1 || m > 12) {
		m = 1;
	}

	// convert m/d to mm/dd
	if (m < 10) {
		m = "0" + m;
	}
	if (d < 10) {
		d = "0" + d;
	}

	if(isReverse=='false') var result = m + "/" + d;
	else if(isReverse=='true') var result = d + "/" + m;
	dateElement.value = result;
}




//being used in Use Case 6 Exception 2
function decrDate(dateElement, currentDate) {
	// consider currentDate and dateElement.value is in 'mm/dd' format
	var splits1 = dateElement.value.split("/");
	var splits2 = currentDate.split("/");
	var valid = false;
	if (splits2.length == 2) {
		if (!isNaN(trim(splits2[0])) && !isNaN(trim(splits2[1])) && !isNaN(trim(splits1[0])) && !isNaN(trim(splits1[1]))) {
			valid = true;
		}
	}
	if (!valid)	{
		return;
	}

	var m1 = parseInt(trim(splits1[0]) , 10);
	var d1 = parseInt(trim(splits1[1]) , 10);
	var m2 = parseInt(trim(splits2[0]) , 10);
	var d2 = parseInt(trim(splits2[1]) , 10);

	var daysInMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	// Set 29 days in Feb if this is a leap year
	if ("undefined" != typeof(isLeapYear) && isLeapYear == false) {
		daysInMonth[1] = 28;
	}

	if ((m1 == m2) && (d1 > d2)) {
		d2--;
		if (d2 < 1 || d2 > daysInMonth[m2 - 1]) {
			m2--;
			d2 = daysInMonth[m2 - 1];
		}
		if (m2 < 1 || m2 > 12) {
			m2 = 12;
			d2 = daysInMonth[m2 - 1];
		}
		// convert m/d to mm/dd
		if (m2 < 10) {
			m2 = "0" + m2;
		}
		if (d2 < 10) {
			d2 = "0" + d2;
		}
		var result = m2 + "/" + d2;
		dateElement.value = result;
	} else {
		// convert m/d to mm/dd
		if (m1 < 10) {
			m1 = "0" + m1;
		}
		if (d1 < 10) {
			d1 = "0" + d1;
		}
		var result = m1 + "/" + d1;
		dateElement.value = result;
	}

}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}



// takes the original URL and removes any entry_src out of there
function getEntrySourceUrl(original) {
	var startIndex = original.indexOf("entry_source");
	if (startIndex == -1) {
		return original;
	}
	var endIndex = original.indexOf("&", startIndex);
	var ret;
	if (endIndex != -1)	{
		ret = original.substring(0, startIndex) + original.substring(endIndex + 1);
	}
	else {
		ret = original.substring(0, startIndex);
	}
	return ret;
}


// Set of handlers to populate the country-state-city dropdown with
// a value user has selected from the popular destinations list.
var _dd_city;
var _dd_state;
var _dd_country;

function populateCityStateDropdown(value) {
    // Remember the selected value
    var splitted = value.split(',');
    _dd_city = splitted[0];
    _dd_state = splitted[1];
    _dd_country = splitted[2];

    if ($("country").value == _dd_country && $("state").value == _dd_state ) {
        $("destination").value = _dd_city;
        return;
    }

    if ($("country").value == _dd_country ) {
        preselect($("state"), _dd_state);
        if (document.createEventObject){
            // dispatch for IE
            var stateEvt = document.createEventObject();
            stateEvt.runCallback = true;
            $("state").fireEvent('onchange', stateEvt);
        }
        else{
            // dispatch for firefox + others
            var stateEvt = document.createEvent("HTMLEvents");
            stateEvt.initEvent("change", true, true); // event type,bubbling,cancelable
            stateEvt.runCallback = true;
            $("state").dispatchEvent(stateEvt);
        }
        return;
    }
    // Pre-select the country
    preselect($("country"), _dd_country);

    // Create an event obj and fire it
    if (document.createEventObject){
        // dispatch for IE
        var countryEvt = document.createEventObject();
        countryEvt.runCallback = true;
        $("country").fireEvent('onchange', countryEvt);
    }
    else{
        // dispatch for firefox + others
        var countryEvt = document.createEvent("HTMLEvents");
        countryEvt.initEvent("change", true, true); // event type,bubbling,cancelable
        countryEvt.runCallback = true;
        $("country").dispatchEvent(countryEvt);
    }

    // Further handling will happen in statesLoadedCallback...
}

function statesLoadedCallback() {
    // Pre-select the state
    preselect($("state"), _dd_state);

    // Create an event obj and fire it
    if (document.createEventObject){
        // dispatch for IE
        var stateEvt = document.createEventObject();
        stateEvt.runCallback = true;
        $("state").fireEvent('onchange', stateEvt);
    }
    else{
        // dispatch for firefox + others
        var stateEvt = document.createEvent("HTMLEvents");
        stateEvt.initEvent("change", true, true); // event type,bubbling,cancelable
        stateEvt.runCallback = true;
        $("state").dispatchEvent(stateEvt);
    }
    
    // Further handling will happen in citiesLoadedCallback...
}

function citiesLoadedCallback() {
    preselect($("destination"), _dd_city);
}



//TED 7753
var txtCityState = new Array();
var checkedValues;
var txtCity;
var txtState;
var txtCountry;
function populateCityState(r,f){
	for(var i=0;i<f.elements[r].length;i++){
			if (f.elements[r][i].checked){
				checkedValues = f.elements[r][i].value;
				txtCityState = checkedValues.split(',');
				f.destination.value=txtCityState[0];
				f.state.value=txtCityState[1];
				f.country.value=txtCityState[2];
			}
	}
}
//----------------------------------------------start SEO javascript optimization----------------------
//---------------------------from BookingReq-----------------------------------------------------
function doAcceptTerms(){
								var termsAccepted = document.booking.acceptTerms.checked;
								if (termsAccepted){
									document.booking.fsubmit_active.style.display = "inline";
									document.booking.fsubmit_inactive.style.display = "none";
								}else{
									document.booking.fsubmit_active.style.display = "none";
									document.booking.fsubmit_inactive.style.display = "inline";
								}
							}

function combo_select(opts,selected)
{
  if (!opts) {
    return;
  }
  for (var i = 0; i < opts.length; i++) {
    var option = opts[i];
    if (option.value == selected) {
	option.selected = true;
	break;
    }
  }
}
//---------------------------from BookingReq-----------------------------------------------------
//---------------------------TLSLoging Wideget1--------------------------------------------------
/* change done for Adjust Auto-Enroll,@author: cognizant,parameter added*/
			function change_st(chkbox) {
				if(chkbox.checked){
						document.forms.booking.trEnroll.value = "on";
					}
					else{
						document.forms.booking.trEnroll.value = "off";
					}

			}
//---------------------------TLSLoging Wideget1--------------------------------------------------
//---------------------------check_avail--------------------------------------------------
// swaps pictures in the left upper corner
function showPic(src, descr, def) {
	if (document.getElementById){
		var placeholderImage = document.getElementById("placeholder");
		placeholderImage.src = src;
		var obj = document.getElementById("desc");
		if (descr != null && descr != "") {
			//desc.innerText = descr;
			obj.innerHTML = descr;
			placeholderImage.alt = descr
		}
		else {
			//desc.innerText = def;
			obj.innerHTML = "";//def;
			placeholderImage.alt = "";//def;
		}
	}
}
//-------------------------------------For Home page of WyndhamRewards (header_tr.jsp)----------------------------------------

function goToVariant(path,object,qaurl,produrl)
{
    oldVariant = "<%=variant%>";
    variant=object.options[object.selectedIndex].value;
	//for Wyndham Rewards cn variant
	var host = window.location.host;
	var pathname1 = document.location.pathname;
	pathArray = path.split('?');
	var pathname2 = pathArray[1];
	//End of Code
	//For navigating from cn to other variant
	var storepath = path;
	var testpath = path;
	var tempPathName = '';
	if(variant != "cn"){
		if(testpath.indexOf('sdqa') != -1){
			tempPathName = testpath.replace("/enzh/sdqa/dwyndhamrewards","");
			tempPathName = tempPathName.replace("cn.","qa.");
			tempPathName = tempPathName.replace("cn",variant);
			
		}else if(testpath.indexOf('sdwr') != -1){
			tempPathName = testpath.replace("/enzh/sdwr/dwyndhamrewards","");
			tempPathName = tempPathName.replace("cn.","wr.");
			tempPathName = tempPathName.replace("cn",variant);
			
		}
	}
	if((tempPathName != null) && (tempPathName != "")){
	path = tempPathName;
	}
	//End of Code
 if (variant == "cn"){
	//for Wyndham Rewards cn variant
	var newcnpath = '';
	if(host.indexOf('qa.wyndhamrewards.com') != -1){
		newcnpath =  qaurl + pathname1 + '?' + pathname2;
		
	}else if(host.indexOf('wr.wyndhamrewards.com') != -1){
		newcnpath =  produrl + pathname1 + '?' + pathname2;
	}
	else {
		newcnpath = storepath;
	}
	if (newcnpath.indexOf('?')== -1) {
		newcnpath=newcnpath+'?variant='+variant;
	} else {
        if (newcnpath.indexOf('variant')== -1){
            newcnpath=newcnpath+'&variant='+object.options[object.selectedIndex].value;
        } else {
            newcnpath=newcnpath.replace(/variant=(\w\w)?(&?)/,"variant="+variant+"$2");
        }
	}
	//End of Code
	location.href = newcnpath;
 } else {
	if (path.indexOf('?')== -1) {
		path=path+'?variant='+variant;
	} else {
        if (path.indexOf('variant')== -1){
            path=path+'&variant='+object.options[object.selectedIndex].value;
        }else{
            path=path.replace(/variant=(\w\w)?(&?)/,"variant="+variant+"$2");
        }
	}
    if((variant != "" && oldVariant == "") || (variant == "" && oldVariant != "")){
        path=path.replace(/checkInDate=(\d+)\/(\d+)/,"checkInDate=$2/$1");
        path=path.replace(/checkOutDate=(\d+)\/(\d+)/,"checkOutDate=$2/$1");
    }

    location.href = path;
 }

}
//-------------------------------------For Home page(home.jsp)----------------------------------------
function gotoUrl() {
		var text = document.TRIPform.TRIPlist.options[document.TRIPform.TRIPlist.selectedIndex].text;
		var value = document.TRIPform.TRIPlist.options[document.TRIPform.TRIPlist.selectedIndex].value;
		if (value == "") {
			;
		}else{
			window.location.href=value;
		}
	}
//-------------------------------------For whg_dd.jsp ----------------------------------------
function setRadioB(){
	if($('areaType3').checked) ChangeType('attraction');
	else  if($('areaType2').checked) ChangeType('airport');
  else ChangeType('city');

}
function ChangeType(changedTo) {
	switch (changedTo) {
		case "city":
			$('cityArea').style.display="block";
			$('airportArea').style.display="none";
			$('dest').name="dest";
			$('destination').name="destination";
		break;
		case "airport":
		case "attraction":
			$('cityArea').style.display="none";
			$('airportArea').style.display="block";
			$('dest').name="destination";
			$('destination').name="dest";
		break;
	}
}

//JavaScripts from receipt.jsp , search_res_content.jsp , search_res_directions.jsp, maneuvers_route.jsp

	// MapQuest functions

	function getMqForm() {
	    var form;
	    if (browserSupportDocumentAll()) {
	        form = document.all["mqForm"];
	    }
	    else {
	        form = document.getElementById("mqForm");
        }
        return form;
    }

	function onZoomIn() {
		getMqForm().mq_zoom_in.value = "true";
		getMqForm().submit();
	}

	function onZoomOut() {
		getMqForm().mq_zoom_out.value = "true";
		getMqForm().submit();
	}

	function onSetZoom(zoom) {
		getMqForm().mq_setzoom.value = zoom;
		getMqForm().submit();
	}

	function onPan(deltaX, deltaY) {
		getMqForm().mq_delta_x.value = deltaX;
		getMqForm().mq_delta_y.value = deltaY;
		getMqForm().submit();
	}

	function onRecenter() {
		getMqForm().mq_recenter.value = "true";
		getMqForm().submit();
	}
	//End MapQuest functions

	function browserSupportDocumentAll() {
        var docAll = document.all;
		var byEl = document.getElementById;
		if (docAll != null && docAll != "undefined") {
		    return true;
		}
		else {
		    return false;
		}
    }

//End JavaScripts from receipt.jsp , search_res_content.jsp , search_res_directions.jsp, maneuvers_route.jsp

	function printerFriendly(path) {

        if (typeof(event) != "undefined" && event != null) {
            event.cancelBubble = true;
        }

        // For Hotel Details page, call the specific implementation.
        // Determine that it's the Hotel Details page by checking a javascript
        // variable being set only on HDP.
        if (typeof(__ms_current_tab) != "undefined" && __ms_current_tab != null) {
            printerFriendlyMS(path);
        }
        // Run the regular Printer Friendly logic
        else {
            var popup;
            if (path.indexOf('?')== -1) {
                popup=window.open(path+'?print=true','printerFriendlyView','width=624,height=600,resizable=yes,status=yes,scrollbars=yes,menubar=yes');
                popup.focus();
            }
            else {
                popup=window.open(path+'&print=true','printerFriendlyView','width=624,height=600,resizable=yes,status=yes,scrollbars=yes,menubar=yes');
                popup.focus();
            }
        }
    }


//JavaScripts from search_res_content.jsp

	// To make possible comparing properties checked on different pages
	function onPageChange(linkEl) {
		var res = linkEl.href;
		if (res.indexOf("?") == -1) {
			res += "?";
		}
		else {
			if (res.substring(res.length - 1) != "&")
				res += "&";
		}
		// Add property checkboxes from the current page
		var elements = document.getElementsByTagName("input");
		for (var i = 0; i < elements.length; i++) {
			if (typeof elements[i].name != undefined && elements[i].name != null) {
				if (elements[i].name.indexOf("__comp_cb") != -1) {
					if (elements[i].checked == true) {
						// checked.
						if (res.indexOf(elements[i].name) == -1) {
							res += elements[i].name + "=on&";
						}
					}
				}
			}
		}
		// Add previously checked properties from URL
		var tmp = location.href;
		while (tmp.indexOf("__comp_cb") != -1) {
			var start = tmp.indexOf("__comp_cb");
			var end = tmp.indexOf("&", start + 1);
			var param;
			if (end != -1)
				param = tmp.substring(start, end);
			else
				param = tmp.substring(start);
			if (res.indexOf(param) == -1)
				res += param + "&";
			tmp = tmp.substring(0, start) + (end == -1 ? "" : tmp.substring(end));
		}
		// Remove unchecked properties
		elements = document.getElementsByTagName("input");
		for (var i = 0; i < elements.length; i++) {
			if (typeof elements[i].name != undefined && elements[i].name != null) {
				if (elements[i].name.indexOf("__comp_cb") != -1 && elements[i].type == "checkbox") { // elements with names "__comp_cb" may come both as checkboxes and as hidden fields.
					if (elements[i].checked == false) {
						// unchecked
						if (res.indexOf(elements[i].name) != -1) {
							var start = res.indexOf(elements[i].name);
							var end = res.indexOf("&", start + 1);
							res = res.substring(0, start) + (end == -1 ? "" : res.substring(end));
						}
					}
				}
			}
		}

		location.href = res;
	}

	function onChangeSorting(direction, parameter) {
	    var changeSortForm;
	    if (browserSupportDocumentAll()) {
	        changeSortForm = document.all["changeSort"];
        }
        else {
            changeSortForm = document.getElementById("changeSort");
        }
        changeSortForm.sortDirection.value = direction;
		changeSortForm.sortParameter.value = parameter;
        changeSortForm.submit();
	}
	
	function onChangeDistance(distance) {
	    var changeDistanceForm;
	    if (browserSupportDocumentAll()) {
	        changeDistanceForm = document.all["changeDistance"];
        }
        else {
            changeDistanceForm = document.getElementById("changeDistance");
        }
       changeDistanceForm.searchWithinMiles.value = distance;
       changeDistanceForm.brandFlag.value = "false";
       changeDistanceForm.brandPropPair.value = "";
       changeDistanceForm.suppPropList.value = "";
       changeDistanceForm.pageNumber.value = "1";
       changeDistanceForm.submit();
	}
//End JavaScripts from search_res_content.jsp

//JavaScripts from search_narrow.jsp

	function onSelect(areaCode) {
		narrowForm.areaCode.value = areaCode;
		narrowForm.submit();
	}

//End JavaScripts from search_narrow.jsp

//JavaScripts from search_widget_maneuvers.jsp

	function reverseRoute_search_widget_maneuvers() {
		var curr_url = location.href;
		if (curr_url.indexOf('reverse=true') == -1) {
			if (curr_url.indexOf('?') == -1)
				curr_url += "?reverse=true";
			else
				curr_url += "&reverse=true";
		}
		else {
			// remove the reverse attribute
			if ((index = curr_url.indexOf('?reverse=true&')) != -1) {
				curr_url = curr_url.substring(0, index) + "?" + curr_url.substring(index + 14);
			}
			else if ((index = curr_url.indexOf('?reverse=true')) != -1) {
				curr_url = curr_url.substring(0, index);
			}
			else if ((index = curr_url.indexOf('&reverse=true')) != -1) {
				curr_url = curr_url.substring(0, index) + curr_url.substring(index + 13);
			}

		}
		location.href = curr_url;
	}

//End JavaScripts from search_widget_maneuvers.jsp

//JavaScripts from search_widget3.jsp

		function reverseRoute_search_widget3() {
			var curr_url = location.href;
			if (curr_url.indexOf('reverse=true') == -1) {
				if (curr_url.indexOf('?') == -1)
					curr_url += "?reverse=true";
				else
					curr_url += "&reverse=true";
			}
			else {
				// remove the reverse attribute
				if ((index = curr_url.indexOf('?reverse=true&')) != -1) {
					curr_url = curr_url.substring(0, index) + "?" + curr_url.substring(index + 14);
				}
				else if ((index = curr_url.indexOf('?reverse=true')) != -1) {
					curr_url = curr_url.substring(0, index);
				}
				else if ((index = curr_url.indexOf('&reverse=true')) != -1) {
					curr_url = curr_url.substring(0, index) + curr_url.substring(index + 13);
				}
			}
			// Remove the page number parameter, if any
			if (curr_url.indexOf('pageNumber=') != -1) {
				// replace it with some foo parameter name
				var i1 = curr_url.indexOf('pageNumber');
				var i2 = curr_url.indexOf('&', i1 + 1);
				if (i2 != -1) {
					curr_url = curr_url.substring(0, i1) + 'pageNumber=1' + curr_url.substring(i2);
				}
				else {
					curr_url = curr_url.substring(0, i1) + 'pageNumber=1'
				}
			}
			location.href = curr_url;
		}

//End JavaScripts from search_widget3.jsp

//End JavaScripts from maneuvers_route.js

	// Opens a maneuver map
	function openManeuverMap(maneuverId, tdId) {
		if ("" == tdId.innerHTML)
			tdId.innerHTML = '<img src="../ManeuverImageServlet?maneuverId=' + maneuverId + '" alt="Driving directions maneuver map">';
		else
			tdId.innerHTML = "";
	}

//JavaScripts from footer.js

	function returnFalse() {
		return false;
	}

//end of SEO changes

	function getElementPosition(theElement) {
		var posX = 0;
		var posY = 0;
		while(theElement != null) {
			posX += theElement.offsetLeft;
			posY += theElement.offsetTop;
			theElement = theElement.offsetParent;
		}
		return {x:posX,y: posY};
	}


    //enable WR Bubble
    function enableWRBubble() {
        if (document.getElementById("gbr_popup") != null)
            document.getElementById("gbr_popup").style.display='none';
        popUp = document.getElementById("wr_popup");
        if ('block' == popUp.style.display) {
            popUp.style.display = 'none';
            return;
        }
        anchor = document.getElementById("wr_bubble_anchor");
        anchorPos = getElementPosition(anchor);
        popUp.style.top = anchorPos.y-250;
        popUp.style.left = anchorPos.x+160;
        popUp.style.display = 'block';
    }

    //enable GBR Bubble
    function enableGBRubble() {
        if (document.getElementById("wr_popup") != null)
            document.getElementById("wr_popup").style.display='none';
        popUp = document.getElementById("gbr_popup");
        if ('block' == popUp.style.display) {
            popUp.style.display = 'none';
            return;
        }
        anchor = document.getElementById("gbr_bubble_anchor");
        anchorPos = getElementPosition(anchor);
        popUp.style.top = anchorPos.y-200;
        popUp.style.left = anchorPos.x+100;
        popUp.style.display = 'block';
    }

    //enable WR Controls
    function enableWRControls(form, displayHiddenTiers) {
        document.getElementById("rate").disabled = true;
        form.rateDummy.name = 'rate';

        if (displayHiddenTiers) {
            form.tier1.name = 'tier1';
            form.tier2.name = 'tier2';
            form.tier3.name = 'tier3';
            form.tier4.name = 'tier4';
        }
    }

    //disable WR Controls
    function disableWRControls(form, displayHiddenTiers) {
        document.getElementById("rate").disabled = false;
        form.rateDummy.name = '__rate';

        if (displayHiddenTiers) {
            form.tier1.name = '__tier1';
            form.tier2.name = '__tier2';
            form.tier3.name = '__tier3';
            form.tier4.name = '__tier4';
        }
    }

// Cuts out a parameter from a URL string
function removeUrlParameter(url, parameterName) {
    var inTheBeginning = false;
    parameterName += "=";

    // Determine if the URL has the tab parameter...
    var startIndex = url.indexOf("?" + parameterName);
    // Try looking for the parameter in the middle of the query string
    if (startIndex == -1) {
        startIndex = url.indexOf("&" + parameterName);
    }
    if (startIndex == -1 && parameterName == url.substring(0, parameterName.length)) {
        startIndex = 0;
        inTheBeginning = true;
    }

    // No parameter found? Return immediately
    if (startIndex == -1) {
        return url;
    }

    var endIndex = url.indexOf("&", startIndex + 1);
    // Cut the ampersand that follows the parameter
    if (endIndex != -1) {
        endIndex += 1;
    }
    // Detect if for any reason we moved endIndex beyond the max length
    if (endIndex >= url.length) {
        endIndex = -1;
    }

    // If the url does not begin with the parameter,
    // leave the preceeding ampersand or questionmark
    var ret = url.substring(0, startIndex + (inTheBeginning ? 0 : 1));
    if (endIndex != -1)
        ret += url.substring(endIndex);

    return ret;
}


//Currency Converter functions
function getCurrencyConverter(elm, xOffset, amount, sourceCurrencyCode) {
      var elemPos = getElementPosition(elm);
      var HttpObjCC = getHttpObject();
      HttpObjCC.open(
              "GET",
              '../Booking/currency_converter_popup.jsp?amount=' +
                amount +
                '&sourceCurrencyCode=' +
                sourceCurrencyCode,
              true);;
      HttpObjCC.onreadystatechange= function () {
          if (HttpObjCC.readyState == 4) {
            if (HttpObjCC.status == 200) {
              try {
                var ret =  HttpObjCC.responseText;
                if (ret !=null && ret.replace(/^\s+|\s+$/g,"").length > 0){
                    newDiv = document.createElement('div');
                    newDiv.id = "divCurrencyConverter";
                    newDiv.innerHTML = ret;

                    newDiv.style.position = "absolute";
                    newDiv.style.top = elemPos.y - 220 + "px";
                    newDiv.style.left = elemPos.x + xOffset + "px";

                    closeCurrencyConverter();
                    elm.parentNode.appendChild(newDiv);
                    $('closeCCcontrol').style.display = "";
                 } else {
                    //location.href = 'error';
                 }
              } catch (ex) {
              }
            } else if (HttpObjCC.status != 0) {
                //location.href = 'error';
            }
          }
      }
      HttpObjCC.send(null);
}
function goCurrencyConverter(){
      // The hashCurrConv array is defined on Check Avail as it would be impossible
      // to define it in the AJAX content area.
      var res = hashCurrConv[$('currency').value] * $('amount').value;

      if (!isNaN(res)) {
        res = Math.round(res * 100)/100;

        // Format the number:
        // 1) Separate all 3-digit groups with commas
        // 2) Leave two decimal digits 

        // Decimal digits
        res = "" + res;
        var pointPosition = res.indexOf(".");
        if (pointPosition == -1) {
            res += ".00";
        }
        else {
            // It cannot be 3+ as we have rounded the number above
            while (res.length - pointPosition < 3) {
                res += "0";
            }
        }

        // 3-digit groups

        // Point position: res.length - 3
        var currPosition = res.length - 3 - 3;
        while(currPosition > 0) {
            res = res.substring(0, currPosition) + "," + res.substring(currPosition);
            currPosition -= 3;
        }

        $('resultCurrConv').value = $('currency').value + " " + res;
        $('warnCCMsg').style.display = "none";
      } else {
        $('warnCCMsg').style.display = "";
        $('resultCurrConv').value = ""; 
      }
}
function closeCurrencyConverter(){
        var divCurrencyConverter = $("divCurrencyConverter");
        if (divCurrencyConverter != null){
            var nonie = document.getElementById && ! document.all;
            if (nonie) {
                divCurrencyConverter.parentNode.removeChild(divCurrencyConverter);
            } else {
                divCurrencyConverter.id="";
                divCurrencyConverter.innerHTML = "";
                divCurrencyConverter.style.display='none';
            }
        }
}

    // Function to support dragging
    function selectmouse(e) {
        var fobj = nn6 ? e.target : event.srcElement;
        var topelement = nn6 ? "HTML" : "BODY";

        while (fobj.tagName != topelement && fobj.className != "dragme") {
            fobj = nn6 ? fobj.parentNode : fobj.parentElement;
        }

        if (fobj.className == "dragme") {
            isdrag = true;
            dobj = fobj;
            while ((dobj.id != "recentHotels__Div")  && (dobj.id != "divCurrencyConverter")) {
                dobj = nn6 ? dobj.parentNode : dobj.parentElement;   
            }
            //dobj = document.getElementById(divName);
            tx = parseInt(dobj.offsetLeft + 0);
            ty = parseInt(dobj.offsetTop + 0);
            x = nn6 ? e.clientX : event.clientX;
            y = nn6 ? e.clientY : event.clientY;
            document.onmousemove = movemouse;
            return false;
        }

    }

    // Function to support dragging
    function movemouse(e) {
        if (isdrag) {
            // Move the div
            dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
            dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;

            // Move the frame
            fobj = document.getElementById(iframeName);
            if (fobj != null) {
                fobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
                fobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
            }

            return false;
        }
    }
	

//Change for TED 13711
function hidediv() { 
	document.getElementById('detailsView').style.display = 'none'; 
	document.getElementById('listView').style.display = 'block'; 
	document.getElementById('div1').innerHTML="Detail View";
	document.getElementById('div2').innerHTML="<b>List View</b>";
	document.getElementById('div1').style.textDecoration='underline';
	document.getElementById('div2').style.textDecoration='none';
	for(i=0; i<document.rm_exp_dtl_img.length/2; i++){
	document.rm_exp_dtl_img[i].style.display = 'inline';
	document.getElementById('rm_link_td_'+i).style.display = 'inline';
	document.getElementById('rm_td_'+i).style.display = 'none';
   }
} 
			
function showdiv() { 
	document.getElementById('detailsView').style.display = 'block'; 
	document.getElementById('listView').style.display = 'none'; 
	document.getElementById('div1').innerHTML="<b>Detail View</b>";
	document.getElementById('div2').innerHTML="List View";
	document.getElementById('div1').style.textDecoration='none';
	document.getElementById('div2').style.textDecoration='underline';
	for(i=0; i<document.rm_exp_dtl_img.length/2; i++){
	document.rm_exp_dtl_img[i].style.display = 'none';
	document.getElementById('rm_link_td_'+i).style.display = 'none';
	document.getElementById('rm_td_'+i).style.display = 'inline';
   }
}

function popupRoomDetailShow(div,id,dDiv,evt,roomdes,daysCount,img1,img2){
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		//alert(version);
		if (version < 7){
			return;
		}

		if (daysCount > 7){
			daysCount = 1;
		}
	
	var height;
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			height=document.body.clientHeight;
		}
		else
		{
		 height=window.innerHeight;
		}
	
	    popUp = document.getElementById(div);
		var dDiv = document.getElementById(dDiv);
		if ('block' == dDiv.style.display) {
            return;
        }
		
        if ('block' == popUp.style.display) {
            popUp.style.display = 'none';

            return;
        }
		
		

/* -------------------------*/
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
/* -------------------------*/
        anchor = document.getElementById(id);
        anchorPos = getElementPosition(anchor);
		
	 if(evt.clientY>=0 && evt.clientY<=129)
		{
		  /*----control top portion ----*/

		   popUp.style.top = (evt.clientY+scrOfY)-14;
           popUp.style.left = evt.clientX+19;
		  document.getElementById(img2).src="../content/images/common/top_Pointer.png";
		  document.getElementById(img1).style.top = 9; 
		  document.getElementById(img1).style.left = 11; 		  
		}
	 else if(evt.clientY>=1 && (evt.clientY+138+daysCount*18)>=height)
		{
		 
		 /*----control bottom portion ----*/
	    
		  document.getElementById(img2).src="../content/images/common/bottom_Pointer.png";
		  if(roomdes.length<21)
			{
			
			 popUp.style.top = (evt.clientY+scrOfY)-(243+daysCount*21);
			 document.getElementById(img1).style.top = 209+daysCount*21;
			}
			else
			{
			  popUp.style.top = (evt.clientY+scrOfY)-(227+daysCount*16);
			  document.getElementById(img1).style.top = 199+daysCount*16;
			}
			  popUp.style.left = evt.clientX+9;
			  document.getElementById(img1).style.left = 10; 		  
		}
	  else
	    {
		  /*----control mid portion ----*/	 
			popUp.style.top = (evt.clientY+scrOfY)-149;
			popUp.style.left = evt.clientX+11;

			document.getElementById(img2).src="../content/images/common/middle_Pointer.png";
			document.getElementById(img1).style.top = 124; 
			document.getElementById(img1).style.left = 5; 
		}
		
        popUp.style.display = 'block';
		
}
function popupRoomDetailShowIE6(div,id,dDiv,evt,roomdes,daysCount,img1,img2){
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
				
		if (daysCount > 7){
			daysCount = 1;
		}
	
	var height;
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			height=document.body.clientHeight;
		}
		else
		{
		 height=window.innerHeight;
		}
	
	    popUp = document.getElementById(div);
		var dDiv = document.getElementById(dDiv);
		if ('block' == dDiv.style.display) {
            return;
        }
		
        if ('block' == popUp.style.display) {
            popUp.style.display = 'none';

            return;
        }
		
		

/* -------------------------*/
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
/* -------------------------*/
        anchor = document.getElementById(id);
        anchorPos = getElementPosition(anchor);
		
	 if(evt.clientY>=0 && evt.clientY<=129)
		{
		  /*----control top portion ----*/

		   popUp.style.top = (evt.clientY+scrOfY)-11;
           popUp.style.left = evt.clientX+30;
		  document.getElementById(img2).src="../content/images/common/topPointer.gif";
		  document.getElementById(img1).style.top = 12; 
		  document.getElementById(img1).style.left = 3; 		  
		}
	 else if(evt.clientY>=1 && (evt.clientY+138+daysCount*18)>=height)
		{
		 
		 /*----control bottom portion ----*/
	    
		  document.getElementById(img2).src="../content/images/common/bottomPointer.gif";
		  if(roomdes.length<21)
			{
			
			 popUp.style.top = (evt.clientY+scrOfY)-(225+daysCount*18);
			 document.getElementById(img1).style.top = 180+daysCount*18;
			}
			else
			{
			  popUp.style.top = (evt.clientY+scrOfY)-(219+daysCount*16);
			  document.getElementById(img1).style.top = 179+daysCount*16;
			}
			  popUp.style.left = evt.clientX+19;
			  document.getElementById(img1).style.left = 4; 		  
		}
	  else
	    {
		  /*----control mid portion ----*/	 
			popUp.style.top = (evt.clientY+scrOfY)-142;
			popUp.style.left = evt.clientX+9;

			document.getElementById(img2).src="../content/images/common/pointer.gif";
			document.getElementById(img1).style.top = 124; 
			document.getElementById(img1).style.left = 2; 
		}
		
        popUp.style.display = 'block';
		
}
function popupRoomDetailClose(div){

        popUp = document.getElementById(div).style.display = 'none';
}

function roomDetailExpnd(detailDiv,popupDiv,supRowId){

		var dDiv = document.getElementById(detailDiv);
		var rmDiv = document.getElementById(popupDiv);
		var supRow = document.getElementById(supRowId);
		//var expRow = document.getElementById(expRowId);
		
		if ('block' == rmDiv.style.display) {
            rmDiv.style.display = 'none';
        }
        if ('block' == dDiv.style.display) {
            dDiv.style.display = 'none';
			supRow.style.display = 'block';
			//img.src="../images/navigation/plus.gif";
            return;
        }
		supRow.style.display = 'none';
        dDiv.style.display = 'block';
		
		//img.src="../images/navigation/minus.gif";
}

function subFrom(){
//alert("fromFrm");
document.getElementById("subButton").value="buttonFrom";
document.buttonToFrm.submit(); 
}

function subTo(){
//alert("toFrm");
document.getElementById("subButton").value="buttonTo";
document.buttonToFrm.submit(); 
}
/*Lami Redesign Changes */
function roll_over(img_name, img_src)
{
	document[img_name].src = img_src;
}
/*Added to set corporate id according to the rate plan*/
/*Added for WBER */
function setCorpId() {
	
	var rateCode=document.getElementById('rate').value;
	if (rateCode=='S3A')
	{
		document.getElementById('corporateCode').value="235163";
	}
	if (rateCode=='SGV')
	{
		document.getElementById('corporateCode').value='6657484';
	}
	if (rateCode=='SSR')
	{
		document.getElementById('corporateCode').value='235164';
	}
	if (rateCode=='000')
	{
		document.getElementById('corporateCode').value='';
	}
}

/*Added for WBER */
// takes the original URL and removes any entry_src out of there
function getEntrySourceUrl(original) {
	var startIndex = original.indexOf("entry_source");
	if (startIndex == -1) {
		return original;
	}
	var endIndex = original.indexOf("&", startIndex);
	var ret;
	if (endIndex != -1)	{
		ret = original.substring(0, startIndex) + original.substring(endIndex + 1);
	}
	else {
		ret = original.substring(0, startIndex);
	}
	return ret;
}

function redirectSecondaryUrl(redirectUrl){
	parent.window.location.href = redirectUrl;
}

function overlay(){
	var el = document.getElementById("overlayPromo");
	document.getElementById("cCode").value=document.formState.corporateCode.value;
	
	if((el.style.visibility == "hidden") || (el.style.visibility == "")){
		showOverlayForPromo();
	} else{
		hideOverlayForPromo();
	}
}

function showOverlayForPromo(){
	// show layer
    var el = document.getElementById('overlayPromo');
    el.style.visibility = 'visible';

	// show IFRAME
    var iframe = document.getElementById('iframe');
    iframe.style.visibility = 'visible';
    iframe.style.width = el.offsetWidth;
    iframe.style.height = el.offsetHeight;
    iframe.style.left = el.offsetLeft;
    iframe.style.top = el.offsetTop;	
}

function hideOverlayForPromo(){
	// hide IFRAME
    var iframe = document.getElementById('iframe');
    iframe.style.visibility = 'hidden';

    // hide layer
    var layer = document.getElementById('overlayPromo');
    layer.style.visibility = 'hidden';
}

function iconOverlay(){
	var e2 = document.getElementById("overlayIcon");
	e2.style.visibility = (e2.style.visibility == "hidden" || e2.style.visibility == "") ? "visible" : "hidden";
}

function submitOverlay(){
	document.formState.promotionCode.value=document.getElementById("pCode").value;
	document.formState.groupID.value=document.getElementById("gID").value;
	document.formState.iataNumber.value=document.getElementById("iNumber").value;
	document.formState.corporateCode.value=document.getElementById("cCode").value;
	overlay();
}

//this method will hide thickbox window
function closeMe(){
	window.top.tb_remove();
}
//End of WBER changes 

/*WBER Amenity*/
function showHideAmenity(divID,acLinkID) {
	var el = document.getElementById(divID);
	var al = document.getElementById(acLinkID);
	if(el.style.display == 'none' || el.style.display == ''){
		el.style.display = 'block';
		al.className = "minusLink";
		al.innerHTML = "<strong>Hide hotel amenities</strong>";
	} else{
		el.style.display = 'none';
		al.className = "addLink";
		al.innerHTML = "<strong>View hotel amenities</strong>";
    }
}

/*Function to fetch rate details by Ajax*/
function showRateDetails(divID,url, visibleDivId, hiddenDivId, waitImage){
	document.getElementById(waitImage).style.visibility = 'visible';
	var xmlhttp;
	xmlhttp = getHttpRequest(xmlhttp);
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{// 4 = "loaded"
			if (xmlhttp.status==200)
			{// 200 = "OK"	
				
				document.getElementById(divID).innerHTML=xmlhttp.responseText;
				document.getElementById(divID).style.display = "block";
				document.getElementById(hiddenDivId).style.display = "block";
				document.getElementById(visibleDivId).style.display = "none";
				document.getElementById(waitImage).style.visibility = 'hidden';
			}
			else if (xmlhttp.status==500 ||xmlhttp.status==404)
			{// 500||404
				document.getElementById(waitImage).style.visibility = 'hidden';
			}			
		}
	}	
	xmlhttp.send(null);	
}
/*Function to fetch rate details by Ajax*/
function showTaxDetails(divID,url, visibleDivId, hiddenDivId, waitImage)
{
	var flag=document.getElementById(divID).style.display;

	if(flag=="none")
    {
	
		showRateDetails(divID,url, visibleDivId, hiddenDivId, waitImage);
	}
	else
	{
	
		hideRateDetails(visibleDivId, hiddenDivId,divID);
	}
}
function hideRateDetails(visibleDivId,hiddenDivId, divID){
	var showLinkDiv = document.getElementById(visibleDivId);
	var hideLinkDiv = document.getElementById(hiddenDivId);
	var rateDetailDiv = document.getElementById(divID);
	showLinkDiv.style.display = "block";
	hideLinkDiv.style.display = "none";
	rateDetailDiv.style.display = "none";
	
}

function getHttpRequest (xmlhttp) {
	xmlhttp=null;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

//method to show currency converter overlay
function currencyOverlay(overlay_param){
	var el = overlay_param;
	el.style.visibility = (el.style.visibility == "hidden" || el.style.visibility == "") ? "visible" : "hidden";
}
/*method to do currency converter  
 *@param base_param
  @param currency_param 
  @param resultCurrConv_param 
  @param warnCCMsg_param
 */
function goCurrencyConverter(base_param,currency_param,resultCurrConv_param,warnCCMsg_param){
      // The hashCurrConv array is defined on Check Avail as it would be impossible
      // to define it in the AJAX content area.
	  var amount=base_param.value;
	  var currency=currency_param.value;
      var res = hashCurrConv[currency] * amount;

      if (!isNaN(res)) {
        res = Math.round(res * 100)/100;

        // Format the number:
        // 1) Separate all 3-digit groups with commas
        // 2) Leave two decimal digits

        // Decimal digits
        res = "" + res;
        var pointPosition = res.indexOf(".");
        if (pointPosition == -1) {
            res += ".00";
        }
        else {
            // It cannot be 3+ as we have rounded the number above
            while (res.length - pointPosition < 3) {
                res += "0";
            }
        }

        // 3-digit groups
        // Point position: res.length - 3
        var currPosition = res.length - 3 - 3;
        while(currPosition > 0) {
            res = res.substring(0, currPosition) + "," + res.substring(currPosition);
            currPosition -= 3;
        }

		
		resultCurrConv_param.value= currency +" "+res;
      	warnCCMsg_param.style.display = "none";
      } else {
       warnCCMsg_param.style.display = "";
		if(isNaN(amount)){
			  warnCCMsg_param.innerHTML="* Please give numeric value in amount field.";
			  base_param.value=""
		} else {
			  warnCCMsg_param.innerHTML="* Please choose a target currency to convert.";
			
		}
        resultCurrConv_param.value= "";
      }
}


function formSubmit(formState_param){
	 formState_param.submit();
}

function checkComment(form_name,comments_param){
	
	if(comments_param.value.length > 1000) {
		alert('You cannot have comments more than 1000 characters.');
		return false;
	}
	document.getElementById("joinWBRCheck").value="";
	if(document.getElementById("joinWBR")!=null) {
		if(document.getElementById("joinWBR").checked) {
			document.getElementById("joinWBRCheck").value = document.getElementById("joinWBR").value;
		}
	}
	form_name.submit();
} 
function showDetailMap(myMap_param,mapDetailLink_param) {
	//var mapDiv = document.getElementById("myMap");
	//var mapDetailLink = document.getElementById("mapDetailLink");
	  var mapDiv = myMap_param;
	  var mapDetailLink = mapDetailLink_param;
	if (mapDiv.style.display == 'none') {
		mapDiv.style.display = 'block';
		//document.getElementById("mapExpandLink").innerHTML = "<img src=\"../images/minus-ico.gif\" />"
		//mapDetailLink.innerHTML = "Hide results on map";
		mapDetailLink.innerHTML ="<table  class=\"detailMapLink\" >  <tr><td>  <img src=\"../images/homecontent/minus-ico.gif\"/></td><td><div class=\"detailMapLink\">Hide results on map</div></td></tr></table>";
		
		GetMap();
	} else if(mapDiv.style.display == 'block'){
		mapDiv.style.display = 'none';
		//document.getElementById("mapExpandLink").innerHTML = "<img src=\"../images/plus-ico.gif\" />"
		//mapDetailLink.innerHTML = "View results on map";
		mapDetailLink.innerHTML ="<table  class=\"detailMapLink\" >  <tr><td>  <img src=\"../images/homecontent/plus-ico.gif\"/></td><td><div class=\"detailMapLink\">View results on map</div></td></tr></table>";
	}
}
function formSubmit(formStateParam){
	//document.getElementById('formState').submit();
	 formStateParam.submit();
}

function showCalendar(a_Control,home_resv_arrival_param,home_resv_departure_param){
	var vValue=null;

	if(a_Control=='home_resv_arrival'){
		var X = 500 + window.screenLeft;
		var Y = 100 + window.screenTop;
		/*vValue = window.showModalDialog("cal0002.htm",document.getElementById('home_resv_arrival').value,
										"dialogHeight: 205px; dialogWidth: 205px; dialogTop: " + Y + "px; dialogLeft: " +
										X + "px; edge: Raised; center: No; help: No; resizable: No; status: No;");*/
		vValue = window.showModalDialog("cal0002.htm",home_resv_arrival_param.value,
										"dialogHeight: 205px; dialogWidth: 205px; dialogTop: " + Y + "px; dialogLeft: " +
										X + "px; edge: Raised; center: No; help: No; resizable: No; status: No;");								
	}
	if(a_Control=='home_resv_departure'){
		var X = 500 + window.screenLeft;
		var Y = 100 + window.screenTop;
		/*vValue = window.showModalDialog("cal0002.htm",document.getElementById('home_resv_departure').value,
										"dialogHeight: 205px; dialogWidth: 205px; dialogTop: " + Y + "px; dialogLeft: " +
										X + "px; edge: Raised; center: No; help: No; resizable: No; status: No;");*/
		vValue = window.showModalDialog("cal0002.htm",home_resv_departure_param.value,
										"dialogHeight: 205px; dialogWidth: 205px; dialogTop: " + Y + "px; dialogLeft: " +
										X + "px; edge: Raised; center: No; help: No; resizable: No; status: No;");								
	}
	if (vValue){
		if(a_Control=='home_resv_arrival'){
			home_resv_arrival_param.value = vValue;
		}
		if(a_Control=='home_resv_departure'){
			home_resv_departure_param.value = vValue;
		}
	}
}

function iconOverlay(overlayIconadvsrchParam){    
	//var e2 = document.getElementById("overlayIconadvsrch");
	var e2 = overlayIconadvsrchParam;	
	e2.style.visibility = (e2.style.visibility == "hidden" || e2.style.visibility == "") ? "visible" : "hidden";
}

function formSubmitPayment(form_name){
	var formName=form_name;
	formName.acceptTerms.value="on";
	formName.submit();
}
function userAccept(chkBox,btn_name){

    var button_name=btn_name;
	if(chkBox.checked){
		button_name.disabled=false;
	} else{
		button_name.disabled=true;
	}
}

function setCorpIdAdvWidget() {
	
	var advRadioValue="";

	for (var i=0;i<document.formState.empRate.length;i++) 
	{ 
		 if (document.formState.empRate[i].checked) 
      { 
			advRadioValue=document.formState.empRate[i].value;
	  }
	}

	if (advRadioValue=='DISWEMP')
	{
		document.getElementById('corporateCode').value="10970243";
	}
	if (advRadioValue=='DISFAF')
	{
		document.getElementById('corporateCode').value='10970228';
	}
	
}
function openPopUp()
{
		var anchor = document.getElementById("learnmore");
		var divElement = document.getElementById('popupOuter');
        anchorPos = getElementPosition(anchor);
		if(navigator.appName == "Microsoft Internet Explorer")
		{
	    divElement.style.top = anchorPos.y;
        divElement.style.left = anchorPos.x+80;
		}
		else{
		divElement.style.top = anchorPos.y-300;
        divElement.style.left = anchorPos.x+30;
		}
 
 var iframe = document.getElementById("outerIframe");
    iframe.style.width = divElement.offsetWidth;
    iframe.style.height = divElement.offsetHeight;
    iframe.style.left = divElement.offsetLeft;
    iframe.style.top = divElement.offsetTop;
	divElement.style.visibility='visible';
	iframe.style.visibility='visible';
	
}
function openAutoEnrollPopUp(a,b,c,d)
{
		var anchor = document.getElementById("learnmore");
		var divElement = document.getElementById('popupOuter');
        anchorPos = getElementPosition(anchor);
		if(navigator.appName == "Microsoft Internet Explorer")
		{
		//alert(a+","+b);
	    divElement.style.top = anchorPos.y+a;
        divElement.style.left = anchorPos.x+b;
		}
		else{
		divElement.style.top = anchorPos.y+c;
        divElement.style.left = anchorPos.x+d;
		}
 
 var iframe = document.getElementById("outerIframe");
    iframe.style.width = divElement.offsetWidth;
    iframe.style.height = divElement.offsetHeight;
    iframe.style.left = divElement.offsetLeft;
    iframe.style.top = divElement.offsetTop;
	divElement.style.visibility='visible';
	iframe.style.visibility='visible';
	
}


function openAutoEnrollPopUpOveriew(a,b,c,d)
{
		var anchor = document.getElementById("learnmore1");
		var divElement = document.getElementById('popupOuter1');
        	anchorPos = getElementPosition(anchor);
		//alert(anchorPos.y +" , "+anchorPos.x );

		if(navigator.appName == "Microsoft Internet Explorer")
		{
		//alert(a+" , "+b);
	    		divElement.style.top = anchorPos.y-500;
        		divElement.style.left = anchorPos.x-300;
		}
		else{
			divElement.style.top = anchorPos.y-600;
        		divElement.style.left = anchorPos.x-300;
		}
 
 var iframe = document.getElementById("outerIframe");
    iframe.style.width = divElement.offsetWidth;
    iframe.style.height = divElement.offsetHeight;
    iframe.style.left = divElement.offsetLeft;
    iframe.style.top = divElement.offsetTop;
	divElement.style.visibility='visible';
	iframe.style.visibility='visible';
	
}




function makeAutoenrollLink(url,subdir)
{
 var path= '';
 if(cur_var=='US' || cur_var==null)
	path = url+subdir;
 else 
	path=url+variant_map[cur_var]+subdir;
 
 location.href=path;
}
 /* Start of change for TED 20432 */

function submitForm(city,state,country){
		
		document.advsearchlink.destination.value = city;
		document.advsearchlink.state.value = state;
		document.advsearchlink.country.value = country;
		document.advsearchlink.submit();
	 }
	 
 /* End of change for TED 20432 */