/*
 * Discover America default java script file 
 * @author Ashok Das
 * @date 19, Oct, 2007
*/

/* Variables for Featured Agents rotation */
var startIndexFeatured = 0;
var indexFeatured = 0;
var agentDt = null;
var timerVal;

var httpRequest; 
var doa_yy_in = "";
var doa_mm_in = "";
var doa_dd_in = "";
var doa_yy_out = "";
var doa_mm_out = "";
var doa_dd_out = "";

var region_zoom = 3;
var state_zoom = 4;
var city_zoom = 8;
var attraction_zoom = 15;
var map_state = '0';

/** 
 * This method is called inside the citiAttraction template
 * to populate the Attraction Data. With Alphabetical shorting and
 * pagination. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */ 
function getAttractions(page_num, alpha_order, order_by,cityName,country_id,language_id) { 
	cityName = cityName.replaceAll("&","____");//replaced to remove issue due to & in cityName
	if(order_by == "NAME"){
			document.getElementById("byName").className="tertlink-red";
			document.getElementById("byCategory").className="tertlink-gray";
	}else if(order_by == "CATEGORY"){
			document.getElementById("byName").className="tertlink-gray";
			document.getElementById("byCategory").className="tertlink-red";
	}
	var activityType=ReadCookie("activity_type");
	if(activityType==null)activityType="";
	else if(activityType==";")activityType="";
	var url = SiteURLforJS + '/jsp/city_attractions.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				document.getElementById( "attractionsSection" ).innerHTML = str;
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order +'&orderBy='+ order_by + '&cityName='+cityName +'&country_id='+ country_id + '&language_id='+language_id + '&activityType='+activityType);
}

/** 
 * This method is called inside the stateAttraction template
 * to populate the Attraction Data. With Alphabetical shorting and
 * pagination. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */ 
function getStateAttractions(page_num, alpha_order, order_by,stateName,country_id,language_id) { 
	if(order_by == "NAME"){
			document.getElementById("byName").className="tertlink-red";
			document.getElementById("byCategory").className="tertlink-gray";
			document.getElementById("byLocation").className="tertlink-gray";
	}else if(order_by == "CATEGORY"){
			document.getElementById("byName").className="tertlink-gray";
			document.getElementById("byCategory").className="tertlink-red";
			document.getElementById("byLocation").className="tertlink-gray";
	}else if(order_by == "LOCATION"){
			document.getElementById("byName").className="tertlink-gray";
			document.getElementById("byCategory").className="tertlink-gray";
			document.getElementById("byLocation").className="tertlink-red";
	}
	var activityType=ReadCookie("activity_type");
	if(activityType==null)activityType="";
	else if(activityType==";")activityType="";
	var url = SiteURLforJS + '/jsp/state_attractions.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				document.getElementById( "attractionsSection" ).innerHTML = str;
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order +'&orderBy='+ order_by + '&stateName='+stateName +'&country_id='+ country_id + '&language_id='+language_id + '&activityType='+activityType);
}
/** 
 * This method is called inside the citiHome template
 * to populate the Weather Data based on cityID.
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param city ID value
 */ 
function getWeather(city_id) { 
   var url =  SiteURLforJS + '/jsp/weather.jsp?city_id='+ city_id;
   if (window.ActiveXObject) { 
       httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
   } 
   else if (window.XMLHttpRequest) { 
       httpRequest = new XMLHttpRequest(); 
   } 
     
   httpRequest.open("GET", url, true); 
   httpRequest.onreadystatechange = function() {processRequest("weatherSection"); } ; 
   httpRequest.send(null); 
}  

      /** 
    * This is the call back method 
    * If the call is completed when the readyState is 4 
    * and if the HTTP is successfull when the status is 200 
    * update the profileSection DIV 
    */ 
    function processRequest( div_id ) { 
        if (httpRequest.readyState == 4) { 
			if(httpRequest.status == 200) { 
			     updateHTML( div_id, httpRequest.responseText );
            }
        }
    } 

   /** 
    * This function parses the XML and updates the  
    * HTML DOM by creating a new text node is not present 
    * or replacing the existing text node. 
    */ 
function updateHTML( div_id, data ) { 
 	if(document.getElementById( div_id )) {
	    	document.getElementById( div_id ).innerHTML = data;
	}
}

function getSelectedItems(formName, cityName) {
 	 var code = get_country_code();
	 if(code == 'ca' || code == 'us')
	 	SetCookie('caSiteCookie','ca',365);
	var num_rooms = document.getElementById("room").value;
	var num_adults = document.getElementById("adult").value;
	var num_children = document.getElementById("children").value;
	
	if(formName == "Bookingfrm") {
		var t = document.getElementById(formName);
		var chk_in = t.Check_in.value;
		var chk_out = t.Check_out.value;
		dateFractorIn(chk_in);
		dateFractorOut(chk_out);
		var city = t.CityValue.value;
		city.replace(" ", "%2F");

		if(cityName != "") {
			var url = travelocityURL + "&header=" + travelocityHeaderWithSubMenu + "&footer=" + travelocityFooter + "&tab=tab0&src_aid=&avail=Y";
		} else {
			var url = travelocityURL + "&header=" + travelocityHeaderWithoutSubMenu + "&footer=" + travelocityFooter + "&tab=tab0&src_aid=&avail=Y";
		}
	} else if(formName == "Bookingfrm1") {
		var t = document.getElementById(formName);
		var chk_in = t.Check_in2.value;
		var chk_out = t.Check_out2.value;
		dateFractorIn(chk_in);
		dateFractorOut(chk_out);
		var city = t.CityValue.value;
		city.replace(" ", "");
		var url = travelocityURL + "&header=" + travelocityHeaderWithoutSubMenu + "&footer=" + travelocityFooter + "&tab=tab0&src_aid=&avail=Y";
	} else {
		var t = document.getElementById(formName);
		var chk_in = t.Check_in1.value;
		var chk_out = t.Check_out1.value;
		dateFractorIn(chk_in);
		dateFractorOut(chk_out);
		var city = t.CityValue.value;
		city.replace(" ", "%2F");
		var url = travelocityURL + "&header=" + travelocityHeaderWithSubMenu + "&footer=" + travelocityFooter + "&tab=tab0&src_aid=&avail=Y";
	}

	var citySel = document.getElementById("CityValue").value;

	if(city != "") {
		var state = document.getElementById(city).value;
		var tempState = city + "_SN";
		
		if(document.getElementById(tempState)) {
			var stateShortName = document.getElementById(tempState).value;
		} else {
			var stateShortName = "";
		}
	} else {
		var state = "";
		var stateShortName = "";
	}

	if(city == "Washington DC") {
		var state = "DC";
		var stateShortName = "DC";
	}

	var parameter = "&currency_id=" + currencyId;
	parameter += "&ADDFIELD_CITYNAME=" + city;
	city = wct_search_city(city);

	parameter += "&city=" + city;
	parameter += "&chk_in=" + doa_mm_in + "%2F" + doa_dd_in + "%2F" + doa_yy_in;
	parameter += "&doa_mm=" + doa_mm_in;
	parameter += "&doa_dd=" + doa_dd_in;
	parameter += "&doa_yy=" + doa_yy_in;
	parameter += "&chk_out=" + doa_mm_out + "%2F" + doa_dd_out + "%2F" + doa_yy_out;
	parameter += "&dod_mm=" + doa_mm_out;
	parameter += "&dod_dd=" + doa_dd_out;
	parameter += "&dod_yy=" + doa_yy_out;
	parameter += "&num_rooms=" + num_rooms;
	parameter += "&num_adults=" + num_adults;
	parameter += "&num_children=" + num_children;
	parameter += "&minorsAge1=-%3F-&minorsAge2=-%3F-&minorsAge3=-%3F-&minorsAge4=-%3F-&SearchNow=search";
	parameter += "&AddToSession=1";
	parameter += "&state=" + stateShortName;
	parameter += "&ADDFIELD_STATE=" + state;
	parameter += "&lang=" + langCode;
	if(city != "McKinney"){
		parameter += "&search_city_vicinity=1";
	}

	var finalUrl = url + parameter;
	location.href = finalUrl;
}
			
function hide() {
	for ( var i = 2; i <= 4; i++) {
		var id2='img'+i;
		document.getElementById(id2).style.display = 'none';
	}
}

/**
 *	Added by Vikas for Thanks Page
 */
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

 /**
  *	Added by Vikas for Thanks Page
  */
  function checkmail(){
	var returnval=emailfilter.test(document.myForm.myemail.value)
	if (returnval==false){
		alert(validEmail)
    	return;	
	}
	document.myForm.submit();
  }

/*
 * Used in side panel Get a deal , find an agent, book a hotel
*/
function hideShow(id){
	var theObj = document.getElementById(id);
	if(document.getElementById(id)=='')
		theObj.style.display='block';
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
	theObj.style.display = theDisp;
	if(theDisp=="none"){
		if(id=="deal-search-fields"){
			document.getElementById("deal").className="";
			document.getElementById("deal").innerHTML = "<a href=javascript:hideShow('deal-search-fields')>" + getDeal + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+getDeal+"' /></a>";
		}else if(id=="agent-search-fields"){
			document.getElementById("agent123").className="";
			document.getElementById("agent123").innerHTML ="<a href=javascript:hideShow('agent-search-fields')>" + findAgent + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+findAgent+"' /></a>";
		}else if(id=="hotel-search-fields"){
			document.getElementById("hotel").className="";
			document.getElementById("hotel").innerHTML = "<a href=javascript:hideShow('hotel-search-fields')>" + bookHotel + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+bookHotel+"' /></a>";
		}
	}else{
		if(id=="deal-search-fields"){
			document.getElementById("deal").className="grayRight";
			document.getElementById("deal").innerHTML = "<a href=javascript:hideShow('deal-search-fields')>" + getDeal + "</a>";

			document.getElementById("agent123").className="";
			document.getElementById("agent-search-fields").style.display="none";
			document.getElementById("agent123").innerHTML = "<a href=javascript:hideShow('agent-search-fields')>" + findAgent + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+findAgent+"' /></a>";
			
			document.getElementById("hotel").className="";
			document.getElementById("hotel-search-fields").style.display="none";
			document.getElementById("hotel").innerHTML = "<a href=javascript:hideShow('hotel-search-fields')>" + bookHotel + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+bookHotel+"' /></a>";
		}else if(id=="agent-search-fields"){
			document.getElementById("deal").className="";
			document.getElementById("deal-search-fields").style.display="none";
			document.getElementById("deal").innerHTML = "<a href=javascript:hideShow('deal-search-fields')>" + getDeal + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+getDeal+"' /></a>";
			
			document.getElementById("agent123").className="grayRight";
			document.getElementById("agent123").innerHTML = "<a href=javascript:hideShow('agent-search-fields')>" + findAgent + "</a>";
			
			document.getElementById("hotel").className="";
			document.getElementById("hotel-search-fields").style.display="none";
			document.getElementById("hotel").innerHTML = "<a href=javascript:hideShow('hotel-search-fields')>" + bookHotel + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+bookHotel+"' /></a>";
		}else if(id=="hotel-search-fields"){
			document.getElementById("deal").className="";
			document.getElementById("deal-search-fields").style.display="none";
			document.getElementById("deal").innerHTML = "<a href=javascript:hideShow('deal-search-fields')>" + getDeal + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+getDeal+"' /></a>";
			
			document.getElementById("agent123").className="";
			document.getElementById("agent-search-fields").style.display="none";
			document.getElementById("agent123").innerHTML = "<a href=javascript:hideShow('agent-search-fields')>" + findAgent + "<img src='"+ SiteURLforJS + "/resources/images/orangeArrow.gif' title='"+findAgent+"' /></a>";
			
			document.getElementById("hotel").className="grayRight";
			document.getElementById("hotel").innerHTML = "<a href=javascript:hideShow('hotel-search-fields')>" + bookHotel + "</a>";
		}
	}
}
	function getSidePanel(openDivId) {	
					hideShow('deal-search-fields');
			        hideShow('agent-search-fields');
					hideShow('hotel-search-fields');
					if(openDivId !="" && openDivId !="Not Required"){
						hideShow(openDivId);
					}					
					Calendar.setup({
			        inputField     :    "Check_out",     // id of the input field
				   	button         :    "checkout_trigger",  // trigger for the calendar (button ID)
			        align          :    "Bl",           // alignment (defaults to "Bl")
			        singleClick    :    true,
					showsTime		:	false
				    });
				    
				    Calendar.setup({
			        inputField     :    "Check_in",     // id of the input field
				   	button         :    "checkin_trigger",  // trigger for the calendar (button ID)
			        align          :    "Bl",           // alignment (defaults to "Bl")
			        singleClick    :    true,
					showsTime		:	false
				    });
											    
					Calendar.setup({
				    inputField     :    "deal_to",     // id of the input field
				   	//ifFormat       :    "%m/%d/%Y",      // format of the input field
					//ifFormat       :    "%Y/%m/%d",      // format of the input field
				    button         :    "deal_to_trigger",  // trigger for the calendar (button ID)
				    align          :    "Bl",           // alignment (defaults to "Bl")
				    singleClick    :    true,
					showsTime		:	false
				    });
				    
				    Calendar.setup({
				    inputField     :    "deal_from",     // id of the input field
				   	button         :    "deal_from_trigger",  // trigger for the calendar (button ID)
				    align          :    "Bl",           // alignment (defaults to "Bl")
				    singleClick    :    true,
					showsTime		:	false
				    });
   }


 /** 
 * This method is called inside the citiActivityFinder template
 * to populate the Activity Data on page Load. With Alphabetical shorting and
 * pagination. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */   
function getActivitiesOnLoad(page_num, alpha_order, activities_details,country_id,language_id) { 
	var url = SiteURLforJS + '/jsp/actDetails.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				str=xmlHttpReq.responseText;
				document.getElementById( activities_details ).innerHTML = str;
				hideShow1('select-traveltime-content');
				hideShow1('select-traveldest-content');
			}
		}
	} ; 
	xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order + '&country_id=' + country_id + '&language_id=' + language_id);
}
  /** 
    * This method is called inside the citiActivities template
    * to show and hide the Activities Data. 
    */
   function hideShow1(id){
  		var theObj = document.getElementById(id);
		var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
		theObj.style.display = theDisp;
		if(theDisp=="none"){
			if(id=="select-filter-content"){
		  		document.getElementById("head-activities").innerHTML = selectActivites+"<a href=javascript:hideShow1('select-filter-content')><img src='"+ SiteURLforJS + "/resources/images/left-arrow-white.gif' title='"+selectActivites+"' /></a>";
			}else if(id=="select-traveltime-content"){
				document.getElementById("head-traveltime").innerHTML = selectTravelTime+ "<a href=javascript:hideShow1('select-traveltime-content')><img src='"+ SiteURLforJS + "/resources/images/left-arrow-white.gif' title='"+selectTravelTime+"' /></a>";
			}else if(id=="select-traveldest-content"){
		    	document.getElementById("head-traveldest").innerHTML = selectLocation+ "<a href=javascript:hideShow1('select-traveldest-content')><img src='"+ SiteURLforJS + "/resources/images/left-arrow-white.gif' title='Select Location' /></a>";
		    }
		}else{
			if(id=="select-filter-content"){
		  		document.getElementById("head-activities").innerHTML = selectActivites+"<a href=javascript:hideShow1('select-filter-content')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow-white.gif' title='"+selectActivites+"' /></a>";
			}else if(id=="select-traveltime-content"){
		    	document.getElementById("head-traveltime").innerHTML = selectTravelTime+"<a href=javascript:hideShow1('select-traveltime-content')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow-white.gif' title='"+selectTravelTime+"' /></a>";
		    }else if(id=="select-traveldest-content"){
		    	document.getElementById("head-traveldest").innerHTML = selectLocation+"<a href=javascript:hideShow1('select-traveldest-content')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow-white.gif' title='"+selectLocation+"' /></a>";
		    }
		}
	}

/** 
 * This method is called inside the citiActivityFinder template
 * to populate the Activity Details. With Alphabetical sorting ,
 * Pagination,Activityid,Durationid,Regionid,Language and Country
 * It creates XMLHttpRequest object to communicate with the  
 * ActivityFinder and Matching Deals Jsp.
 * @param Alphabet Shorting value(Default By Name)
 */
function getActivitiesDetails(activitytype_name, city_name,duration_id, region_name, country_id, language_id, order_by ,page_num, alpha_order) {
	var matchingCountryCode = getCountryCodeForCa(country_id);
	order_by = 'Name';
	activity_array = getArrayString("chkedActivity");
	duration_array = getArray("chkedTravelTime",0);
	region_array = getArrayString("chkedTravelDest");
	
	var url = SiteURLforJS + '/jsp/activitiesFinder.jsp';
	var url1 = SiteURLforJS + '/jsp/matchingDeals.jsp';
	var xmlHttpReq = false;
	var xmlHttpReq1 = false;
	var self = this;
	
	if (window.XMLHttpRequest) {// Mozilla/Safari
        xmlHttpReq = new XMLHttpRequest();
        xmlHttpReq1 = new XMLHttpRequest();
	} else if (window.ActiveXObject) {// IE
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlHttpReq) {
        alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
        return false;
	}
 	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				document.getElementById("featured-repeat").innerHTML = xmlHttpReq.responseText;
				xmlHttpReq1.open('POST', url1, true);
				xmlHttpReq1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
				xmlHttpReq1.onreadystatechange = function() {
					if (xmlHttpReq1.readyState == 4) {
						if (xmlHttpReq1.status == 200) {
							document.getElementById("matching-text").innerHTML = xmlHttpReq1.responseText;
						}
					}
				};
				xmlHttpReq1.send('activitytype_name='+ activity_array +'&city_name='+ city_name + '&duration_id=' + duration_array + '&region_name=' + region_array  + '&country_id=' + matchingCountryCode + '&language_id=' + language_id +'&page_num='+ page_num + '&alpha_order=' + alpha_order);
			}
		}
	};
	xmlHttpReq.send('activitytype_name='+ activity_array +'&city_name='+ city_name + '&duration_id=' + duration_array + '&region_name=' + region_array  + '&country_id=' + country_id+ '&language_id=' + language_id + '&order_by=' + order_by +'&page_num='+ page_num + '&alpha_order=' + alpha_order);
}

   /** 
    * This method is called inside the citiActivityFinder template
    * to populate the Array String of Activities. 
	*
	*/
 
     function getArrayString(elementId){   
  		var txt = "";
   		var flag=0;
	  	var cbCollection = document.getElementsByName(elementId);
	  	if(cbCollection.length){
            for (i = 0; i < cbCollection.length; i++){
               if(cbCollection[i].checked == true){
                   if(cbCollection.length>0 && cbCollection[i].value!=""){
                      txt= txt + cbCollection[i].value  +  ",";
                    }else{
                    txt = txt + cbCollection[i].value ;
                    }
	    	   }    	         
           }//for close					            
           len = txt.length;
		   len = len - 1;
		   txt = txt.substring(0,len);
		}else{
	             if(cbCollection.checked == true){    
	                      txt = txt +cbCollection[i].value  ;
	             }
		}
		 return txt;
	 } 

  /** 
    * This method is called inside the citiActivityFinder template
    * to populate the Array of Matching Deals data with  duration id , from_date and to_date. 
    */
 	function getArray(chkedTravelTime,index){
 		var txt = "";
		var cbCollection = document.getElementsByName(chkedTravelTime);
	  	if(cbCollection.length){
	            for (i = 0; i < cbCollection.length; i++){
               		if(cbCollection[i].checked == true){
        	            	obj = cbCollection[i].value;
	                    	var stringArray = obj.split(",");
		            	  	txt += stringArray[index] + ",";
                    	   }
                   }
                   }else{
	          }
	   return txt;
	 }

/** 
 * This method is called inside the resturantAttraction template
 * to populate the Attraction Data. With Alphabetical shorting and
 * pagination. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */ 
function getResturants(page_num, alpha_order, order_by, city_name ,country_id,language_id) { 
	city_name = city_name.replaceAll("&","____");//replaced to remove issue due to & in cityName
	if(order_by == "NAME"){
			document.getElementById("byName").className="tertlink-red";
			document.getElementById("byCuisine").className="tertlink-gray";
			document.getElementById("byPrice").className="tertlink-gray";
	}else if(order_by == "CUISINE"){
			document.getElementById("byName").className="tertlink-gray";
			document.getElementById("byCuisine").className="tertlink-red";
			document.getElementById("byPrice").className="tertlink-gray";
	}else if(order_by == "PRICE"){
			document.getElementById("byName").className="tertlink-gray";
			document.getElementById("byCuisine").className="tertlink-gray";
			document.getElementById("byPrice").className="tertlink-red";
	}

	var url = SiteURLforJS + '/jsp/restaurant.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				if(order_by == "NAME"){
					str=str.trim();
					var displayStatus=str.substr(0, 2);
					var cuisineListSize=displayStatus.substr(0, 1);
					var priceListSize=displayStatus.substr(1, 2);
					if(cuisineListSize=="0"){
						document.getElementById("byCuisineList").style.display="none";
					}
					if(priceListSize=="0"){
						document.getElementById("byPriceList").style.display="none";
					}
					str=str.substr(2);
				}
				document.getElementById( "attractionsSection" ).innerHTML = str;
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order + '&order_by=' + order_by + '&city_name=' + city_name +'&country_id='+ country_id + '&language_id='+language_id);
}


/** 
 * This method is called inside the shoppingAttraction template
 * to populate the Attraction Data. With Alphabetical shorting and
 * pagination. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */ 
function getShopping(page_num, alpha_order,order_by,cityName,country_id,language_id) { 
	cityName=cityName.replaceAll("&","____"); //replaced to remove issue due to & in cityName
	if(order_by == "SHOP_NAME"){
		document.getElementById("byName").className="tertlink-red";
		document.getElementById("byCategory").className="tertlink-gray";
	}else if(order_by == "CATEGORIES"){
		document.getElementById("byName").className="tertlink-gray";
		document.getElementById("byCategory").className="tertlink-red";
	}

	var url = SiteURLforJS + '/jsp/shopping.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
	    self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
	    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				if(order_by == "SHOP_NAME"){
					str=str.trim();
					var displayStatus=str.substr(0, 1);
					if(displayStatus=="0"){
						document.getElementById("byCategoryList").style.display="none";
					}
					str=str.substr(1);
				}
				document.getElementById( "attractionsSection" ).innerHTML = str;
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order +'&orderBy='+ order_by  + '&cityName='+cityName +'&country_id='+ country_id + '&language_id='+language_id);
}


function getCityPanel(divId, cityName,languageCode,countryCode,optionVal) {
	if(optionVal == "All"){
		optionVal = all; 
	}else{
		optionVal = select; 
	}
	
	var url = SiteURLforJS + '/jsp/city_panel.jsp';
	var xmlHttpReq = false;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				document.getElementById( divId ).innerHTML = xmlHttpReq.responseText;
			}
		}
	} ; 
	xmlHttpReq.send('cityNameSel='+ cityName+'&languageCode='+languageCode+'&countryCode='+countryCode+'&optionVal='+optionVal);
}


   /**
    *  This method is used to get the weather results details
    */
   function getWeatherResults(city_id){
	   	var url = SiteURLforJS + '/jsp/weatherResults.jsp?city_id='+ city_id;
		if (window.ActiveXObject) { 
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if (window.XMLHttpRequest) { 
            httpRequest = new XMLHttpRequest(); 
        } 
        httpRequest.open("GET", url, true); 
        httpRequest.onreadystatechange = function() {
        	if (httpRequest.readyState == 4) { 
				if(httpRequest.status == 200) { 
	               updateHTML( "WeatherBottom", httpRequest.responseText );
	                document.getElementById("currentweather").style.display = 'none';
					document.getElementById("next24hours").style.display = 'none';
					document.getElementById("next10days").style.display = 'none';
	            } 
        	} 
		} ; 
        httpRequest.send(null);
   }

  /** 
    * This method is used for show/hide weather divs
    */
function showWeather(id){
	var theObj = document.getElementById(id);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
	theObj.style.display = theDisp;

	if(theDisp=="none"){
		if(id=="currentweather"){
			document.getElementById("currentweather-text").innerHTML = "<div style='float:left'><a href=javascript:showWeather('currentweather')>"+currentWeather+"</a></div>";
			document.getElementById("currentweather-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('currentweather')><img src='"+ SiteURLforJS + "/resources/images/left-arrow1.gif' title='"+currentWeather+"' /></a></div>";
		}else if(id=="next24hours"){
			document.getElementById("next24hours-text").innerHTML = "<div style='float:left'><a href=javascript:showWeather('next24hours')>"+next24Hours+"</a></div>";
			document.getElementById("next24hours-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('next24hours')><img src='"+ SiteURLforJS + "/resources/images/left-arrow1.gif' title='"+next24Hours+"' /></a></div>";
		}else if(id=="next10days"){
				document.getElementById("next10days-text").innerHTML = "<div style='float:left'><a href=javascript:showWeather('next10days')>"+next10Days+"</a></div>";
			document.getElementById("next10days-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('next10days')><img src='"+ SiteURLforJS + "/resources/images/left-arrow1.gif' title='"+next10Days+"' /></a></div>";
		}
	}else{
		if(id=="currentweather"){
			document.getElementById("currentweather-text").innerHTML = "<div style='float:left' class='weather-display-text'><a href=javascript:showWeather('currentweather')>"+currentWeather+"</a></div>";
			document.getElementById("currentweather-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('currentweather')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow.gif' title='"+currentWeather+"' /></a></div>";
		}else if(id=="next24hours"){
			document.getElementById("next24hours-text").innerHTML = "<div style='float:left' class='weather-display-text'><a href=javascript:showWeather('next24hours')>"+next24Hours+"</a></div>";
			document.getElementById("next24hours-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('next24hours')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow.gif' title='"+next24Hours+"' /></a></div>";
		}else if(id=="next10days"){
			document.getElementById("next10days-text").innerHTML = "<div style='float:left' class='weather-display-text'><a href=javascript:showWeather('next10days')>"+next10Days+"</a></div>";
			document.getElementById("next10days-icon-arrow").innerHTML = "<div style='float:left;'><a href=javascript:showWeather('next10days')><img src='"+ SiteURLforJS + "/resources/images/bottom-arrow.gif' title='"+next10Days+"' /></a></div>";
		}
	}
}

/**
 * Google mini Site Search Integration
 * For search on Textbox search
 */

function siteSearch(){
   		var searchHttpRequest;
		var q = ReadCookie("GoogleSearch");
		q=q.trim();
		document.form1.textfield.value=q;
		var url = SiteURLforJS + '/jsp/searchResults.jsp?q='+escape(encodeURIComponent(q));
		if (window.ActiveXObject) { 
	            searchHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	        } 
	        else if (window.XMLHttpRequest) { 
	            searchHttpRequest = new XMLHttpRequest(); 
	        }
	        searchHttpRequest.open("GET", url, true); 
	        searchHttpRequest.onreadystatechange = function() {
	        	if (searchHttpRequest.readyState == 4) {
	        		if(searchHttpRequest.status == 200) {
					document.getElementById( "container-left" ).innerHTML = searchHttpRequest.responseText;
				}
			}
	        } ; 
	        searchHttpRequest.send(null);
	   }

/*
 * prototype function.. 
 */
String.prototype.replaceAll = function(s1, s2) {return this.split(s1).join(s2)}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };


/**
 * Google mini Site new Search Integration
 * For search on pagination numbers
 */
   function newSearch(str){
   		str = str.replaceAll("&","||");
		var q = ReadCookie("GoogleSearch");
		var ind_1=str.indexOf("||q=");
	       var ind_2=str.indexOf("||",ind_1+1);
       	var newStr=str.substring(0,ind_1)+"||q="+escape(encodeURIComponent(q))+str.substring(ind_2);
       	str=newStr;
   		var searchHttpRequest;
   		var url = SiteURLforJS + '/jsp/searchResults.jsp?str='+str;
   		if (window.ActiveXObject) { 
            searchHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if (window.XMLHttpRequest) { 
            searchHttpRequest = new XMLHttpRequest(); 
        }
        searchHttpRequest.open("GET", url, true); 
        searchHttpRequest.onreadystatechange = function() {
        	if (searchHttpRequest.readyState == 4) {
        		if(searchHttpRequest.status == 200) {
        			document.getElementById( "container-left" ).innerHTML = searchHttpRequest.responseText;
			}
		}
        } ; 
        searchHttpRequest.send(null);
   }

 
/**
 * Method to retrieve agent panel.
 * @param divid
 */
function getAgentPanel(divId,languageCode,countryCode) {
        countryCode = getCountryCodeForCa(countryCode);
		var dropDownId = '';

		if(divId != null && divId != '') {
			switch(divId) {
				case 'agentDropdownMain1':
					dropDownId = "AgentfrmMain.countryOfResidence_agent";
					break;
				case 'agentDropdown':
					dropDownId = "Agentfrm.countryOfResidence_agent";
					break;
				case 'noAgentFoundId':
					dropDownId = "f5.countryOfResidence_agent";
					break;
			}
			
			if(eval("document." + dropDownId)) {
				var selVal = eval("document." + dropDownId + ".options[document." + dropDownId + ".selectedIndex].value");
				
				if(selVal != '') {
					countryCode	= selVal;
				}
			}
		}
		
        var url = SiteURLforJS + '/jsp/agent_panel.jsp';
        var xmlHttpReq = false;
        //var self = this;
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
                xmlHttpReq = new XMLHttpRequest();
        }
        // IE
        else if (window.ActiveXObject) {
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (!xmlHttpReq) {
                alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
                return false;
        }
        xmlHttpReq.open('POST', url, true);
        xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
        xmlHttpReq.onreadystatechange = function() {
                if (xmlHttpReq.readyState == 4) {
                        if (xmlHttpReq.status == 200) {
                                str=xmlHttpReq.responseText;
                                document.getElementById( divId  ).innerHTML = str;
                        }
                }
        } ;
        xmlHttpReq.send('languageCode='+languageCode+'&countryCode='+countryCode);
}


/**
 * Deals retrieval fn.
 * @param frmName
 */
function getDeals(frmName,languageCode,countryCode){
	var countryOfResidence = '';
	var countryOfResidenceDropdown = eval("document."+frmName+".countryOfResidence_deal");
	
	if(countryOfResidenceDropdown != null) {
		countryOfResidence = eval("document."+frmName+".countryOfResidence_deal.options[document."+frmName+".countryOfResidence_deal.selectedIndex].value");
	}
	
	if(countryOfResidence != '') {
		countryCode = countryOfResidence;
	} else {
		countryCode = getCountryCodeForCa(countryCode);
	}

   	var dealHttpRequest; 
   	var city=eval("document."+frmName+".city.options[document."+frmName+".city.selectedIndex].value");
	var activity=eval("document."+frmName+".activity.options[document."+frmName+".activity.selectedIndex].value");
	var otherCity=eval("document."+frmName+".otherCity.value");
   		if(frmName == "DealfrmMain"){
   			var dealFrom=eval("document."+frmName+".deal_from1.value");
   			var dealTo=eval("document."+frmName+".deal_to1.value");
   		}else if(frmName == "f4"){
   			var dealFrom=eval("document."+frmName+".deal_from3.value");
   			var dealTo=eval("document."+frmName+".deal_to3.value");
   		}else{
   			var dealFrom=eval("document."+frmName+".deal_from.value");
   			var dealTo=eval("document."+frmName+".deal_to.value");
   		}
		if(dealFrom == dateFormat_display){
   			dealFrom = "";
   		}
		if(dealTo == dateFormat_display){
   			dealTo = "";
   		}
	var url = SiteURLforJS + '/jsp/get_deal.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
					document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:location.reload(true)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+getDeal+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
					if(document.getElementById( "secondary-navigation" )){
					document.getElementById( "secondary-navigation" ).style.display = "none";
					}
					if(document.getElementById( "photo-album-heading" )){
					document.getElementById( "photo-album-heading" ).style.display = "none";
					}
					if(document.getElementById( "matching-text" )){
					document.getElementById( "matching-text" ).innerHTML = "";
					}
					changeHeaderClass();

					if(document.getElementById( "advertisement-div" )){
					document.getElementById( "advertisement-div" ).innerHTML = "";
					}

					Calendar.setup({
				    inputField     :    "deal_to3",     // id of the input field
				   	button         :    "deal_to_trigger3",  // trigger for the calendar (button ID)
				    align          :    "Bl",           // alignment (defaults to "Bl")
				    singleClick    :    true,
					showsTime		:	false
				    });
				    
				    Calendar.setup({
				    inputField     :    "deal_from3",     // id of the input field
				   	button         :    "deal_from_trigger3",  // trigger for the calendar (button ID)
				    align          :    "Bl",           // alignment (defaults to "Bl")
				    singleClick    :    true,
					showsTime		:	false
					});
					
					if(frmName == "DealfrmMain"){
						document.getElementById("side-panel-widget").style.display='block';
						hideShow('deal-search-fields');
						document.Dealfrm.otherCity.value=otherCity;
						document.Dealfrm.deal_from.value=dealFrom;
			   			document.Dealfrm.deal_to.value=dealTo;
						for(i=0;i<document.Dealfrm.city.length;i++){
							if(document.Dealfrm.city.options[i].value==city){
								document.Dealfrm.city.selectedIndex=i
							}
						}
						for(i=0;i<document.Dealfrm.activity.length;i++)	{
							if(document.Dealfrm.activity.options[i].value==activity){
								document.Dealfrm.activity.selectedIndex=i
							}
						}
						
						if(countryOfResidenceDropdown != null) {
							for(i = 0; i < document.Dealfrm.countryOfResidence_deal.length; i++) {
								if(document.Dealfrm.countryOfResidence_deal.options[i].value == countryOfResidence){
									document.Dealfrm.countryOfResidence_deal.selectedIndex = i
								}
							}
						}
						changeHotelBookingWidget("");
					}

					if(frmName == "f4"){
						document.Dealfrm.otherCity.value=otherCity;
						document.Dealfrm.deal_from.value=dealFrom;
			   			document.Dealfrm.deal_to.value=dealTo;
						for(i=0;i<document.Dealfrm.city.length;i++){
							if(document.Dealfrm.city.options[i].value==city){
								document.Dealfrm.city.selectedIndex=i
							}
						}
						for(i=0;i<document.Dealfrm.activity.length;i++)	{
							if(document.Dealfrm.activity.options[i].value==activity){
								document.Dealfrm.activity.selectedIndex=i
							}
						}
						
						if(countryOfResidenceDropdown != null) {
							for(i = 0; i < document.Dealfrm.countryOfResidence_deal.length; i++) {
								if(document.Dealfrm.countryOfResidence_deal.options[i].value == countryOfResidence){
									document.Dealfrm.countryOfResidence_deal.selectedIndex = i
								}
							}
						}
					}
					
				}
			}
	} ; 
	self.xmlHttpReq.send('city='+city+'&activity='+activity+'&otherCity='+otherCity+'&dealFrom='+dealFrom+'&dealTo='+dealTo+'&languageCode='+languageCode+'&countryCode='+countryCode+'&countryOfResidence='+countryOfResidence);
}


function getDealNo(page,city,activity,dealFrom,dealTo,languageCode,countryCode,orderBy,otherCity){
	var url = SiteURLforJS + '/jsp/get_deal.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				if(document.getElementById( "container-left" )){
						document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
					}else{
						document.getElementById( "mainDiv" ).innerHTML = dealHttpRequest.responseText;
					}

			}
		}
	} ; 
	self.xmlHttpReq.send('city='+city+'&activity='+activity+'&dealFrom='+dealFrom+'&dealTo='+dealTo+'&page='+page+'&languageCode='+languageCode+'&countryCode='+countryCode+'&orderBy='+orderBy+'&otherCity='+otherCity);
}

function sortDeals(city,activity,dealFrom,dealTo,languageCode,countryCode,otherCity){
	var changeCountryCode = 0;
	
	if(document.DealfrmMain != null && document.DealfrmMain.countryOfResidence_deal != null && document.DealfrmMain.countryOfResidence_deal.value != '') {
		countryCode = document.DealfrmMain.countryOfResidence_deal.value;
		changeCountryCode = changeCountryCode + 1;
	}

	if(document.Dealfrm != null && document.Dealfrm.countryOfResidence_deal != null && document.Dealfrm.countryOfResidence_deal.value != '') {
		countryCode = document.Dealfrm.countryOfResidence_deal.value;
		changeCountryCode = changeCountryCode + 1;
	} 
	
	if(document.f4 != null && document.f4.countryOfResidence_deal != null && document.f4.countryOfResidence_deal.value != '') {
		countryCode = document.f4.countryOfResidence_deal.value;
		changeCountryCode = changeCountryCode + 1;
	}
	if(changeCountryCode == 0) {
		countryCode = getCountryCodeForCa(countryCode);
	}

	var orderBy=document.sortForm.sortBy.options[document.sortForm.sortBy.selectedIndex].value;
	getDealNo("1",city,activity,dealFrom,dealTo,languageCode,countryCode,orderBy,otherCity);
}

/**
 * Find an getAgent fn
 * @param agent
 * @languageCode
 * @countryCode
 */
function sortAgent(city,activity,agent,languageCode,countryCode,otherCity){
	var changeCountryCode = 0;

	if(document.AgentfrmMain != null && document.AgentfrmMain.countryOfResidence_agent != null && document.AgentfrmMain.countryOfResidence_agent.value != '') {
		countryCode = document.AgentfrmMain.countryOfResidence_agent.value;
		changeCountryCode = changeCountryCode + 1;
	} 
	
	if(document.Agentfrm != null && document.Agentfrm.countryOfResidence_agent != null && document.Agentfrm.countryOfResidence_agent.value != '') {
		countryCode = document.Agentfrm.countryOfResidence_agent.value;
		changeCountryCode = changeCountryCode + 1;
	} 
	
	if(document.f5 != null && document.f5.countryOfResidence_agent != null && document.f5.countryOfResidence_agent.value != '') {
		countryCode = document.f5.countryOfResidence_agent.value;
		changeCountryCode = changeCountryCode + 1;
	} 

	if(changeCountryCode == 0) {
		countryCode = getCountryCodeForCa(countryCode);
	} 

	var orderBy=document.sortForm.sortBy.options[document.sortForm.sortBy.selectedIndex].value;
	getAgentNo("1",city,activity,agent,findAgent,languageCode,countryCode,orderBy,otherCity)
}

/**
 * Find an agent fn
 * @param form Name
 */
function getAgents(frmName,languageCode,countryCode){
	var countryOfResidence = '';
	var countryOfResidenceDropdown = eval("document."+frmName+".countryOfResidence_agent");
	
	if(countryOfResidenceDropdown != null) {
		countryOfResidence = eval("document."+frmName+".countryOfResidence_agent.options[document."+frmName+".countryOfResidence_agent.selectedIndex].value");
	}
	
	if(countryOfResidence != '') {
		countryCode = countryOfResidence;
	} else {
		countryCode = getCountryCodeForCa(countryCode);
	}
	
	var agentHttpRequest; 
	var city=eval("document."+frmName+".city.options[document."+frmName+".city.selectedIndex].value");
	var activity=eval("document."+frmName+".activity.options[document."+frmName+".activity.selectedIndex].value");
	var agent=eval("document."+frmName+".agent.options[document."+frmName+".agent.selectedIndex].value");
	var otherCity=eval("document."+frmName+".otherCity.value");
	var url = SiteURLforJS + '/jsp/get_agent_result.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
				document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:location.reload(true)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+findAgent+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
				if(document.getElementById( "secondary-navigation" )){
				document.getElementById( "secondary-navigation" ).style.display = "none";
				}
				if(document.getElementById( "photo-album-heading" )){
				document.getElementById( "photo-album-heading" ).style.display = "none";
				}
				if(document.getElementById( "matching-text" )){
				document.getElementById( "matching-text" ).innerHTML = "";
				}

				changeHeaderClass();
				
				if(document.getElementById( "advertisement-div" )){
				document.getElementById( "advertisement-div" ).innerHTML = "";
				}
				if(frmName == "AgentfrmMain"){
					document.getElementById("side-panel-widget").style.display='block';
					hideShow('agent-search-fields');
					document.Agentfrm.otherCity.value=otherCity;
					for(i=0;i<document.Agentfrm.city.length;i++){
						if(document.Agentfrm.city.options[i].value==city){
							document.Agentfrm.city.selectedIndex=i
						}
					}
					for(i=0;i<document.Agentfrm.activity.length;i++)	{
						if(document.Agentfrm.activity.options[i].value==activity){
							document.Agentfrm.activity.selectedIndex=i
						}
					}
					for(i=0;i<document.Agentfrm.agent.length;i++)	{
						if(document.Agentfrm.agent.options[i].value==agent){
							document.Agentfrm.agent.selectedIndex=i
						}
					}
					
					if(countryOfResidenceDropdown != null) {
						for(i = 0; i < document.Agentfrm.countryOfResidence_agent.length; i++) {
							if(document.Agentfrm.countryOfResidence_agent.options[i].value == countryOfResidence){
								document.Agentfrm.countryOfResidence_agent.selectedIndex = i
							}
						}
					}
					changeHotelBookingWidget("");
				}

				/* Function to create array for Featured Agents rotation */
				if(document.getElementById("featured-agent-detail") != null) {
					createAgentDetails(document.getElementById("featured-agent-detail").value);
				}

				if(frmName == "f5"){
					document.Agentfrm.otherCity.value=otherCity;
					for(i=0;i<document.Agentfrm.city.length;i++){
						if(document.Agentfrm.city.options[i].value==city){
							document.Agentfrm.city.selectedIndex=i
						}
					}
					for(i=0;i<document.Agentfrm.activity.length;i++)	{
						if(document.Agentfrm.activity.options[i].value==activity){
							document.Agentfrm.activity.selectedIndex=i
						}
					}
					for(i=0;i<document.Agentfrm.agent.length;i++)	{
						if(document.Agentfrm.agent.options[i].value==agent){
							document.Agentfrm.agent.selectedIndex=i
						}
					}
					
					if(countryOfResidenceDropdown != null) {
						for(i = 0; i < document.Agentfrm.countryOfResidence_agent.length; i++) {
							if(document.Agentfrm.countryOfResidence_agent.options[i].value == countryOfResidence){
								document.Agentfrm.countryOfResidence_agent.selectedIndex = i
							}
						}
					}
				}
		}
	} 
   }; 
	self.xmlHttpReq.send('city='+city+'&activity='+activity+'&otherCity='+otherCity+'&agent='+agent+'&languageCode='+languageCode+'&countryCode='+countryCode+'&countryOfResidence='+countryOfResidence);
}


function getAgentNo(page,city,activity,agent,heading,languageCode,countryCode,orderBy,otherCity){
	var url = SiteURLforJS + '/jsp/get_agent_result.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
					document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:location.reload(true)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+heading+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
			}
		}
	} ; 
	self.xmlHttpReq.send('city='+ city +'&activity='+activity+'&agent='+agent+'&page='+page+'&languageCode='+languageCode+'&countryCode='+countryCode+'&orderBy='+orderBy+'&otherCity='+otherCity);
}

/**
 * Check email validation fn.
 * @param email as string
 */
function emailchk(str) {
	var at="@";
	var dot=".";
	var comm=",";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){
	   return email_error_message;
	}

	if (str.indexOf(comm) > -1){
	   return email_Address;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return email_error_message;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return email_error_message;
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return email_error_multi_message;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return email_error_message;
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return email_error_message;
	}

	if (str.indexOf(" ")!=-1){
		return email_error_message;
	}
	return msg = "";
}

/**
 * check each fields
 */
function checkfields(sitePath){
	document.getElementById("srcHTMLNew").style.display = "none";
	var sendMe = "";
	var strValidationUrl = "";
	var msg = "";	  	
	var usrName = document.sendForm.p_name.value;
	userName = usrName.trim();
	var usrId = document.sendForm.p_email.value;
	userId = usrId.trim();
	var errorFlag = false;
	if (userName == "") {
		document.getElementById("error").innerHTML=requestError;
		document.getElementById("name").innerHTML=enterName;
		document.getElementById("error").className="email-form-red";
		document.getElementById("name").className="email-form-red";
		document.sendForm.p_name.focus();
		errorFlag=true;
	}else{
		document.getElementById("error").style.display = 'none';
		document.getElementById("name").innerHTML=yourName;
		document.getElementById("name").className="email-form-label";
	}
	if (userId == "") {
		document.getElementById("error").style.display = 'block';
		document.getElementById("error").innerHTML=requestError;
		document.getElementById("yourEmail").innerHTML=enterEmailAddress;
		document.getElementById("error").className="email-form-red";
		document.getElementById("yourEmail").className="email-form-red";
		errorFlag=true;
	}else{
		document.getElementById("error").style.display = 'none';
		document.getElementById("yourEmail").innerHTML=yrEmailAddress;
		document.getElementById("yourEmail").className="email-form-label";
	msg = emailchk(userId);
	if(msg != ""){
		document.getElementById("error").style.display = 'block';
		document.getElementById("error").innerHTML=requestError;
		document.getElementById("yourEmail").innerHTML= msg ;
		document.getElementById("yourEmail").className="email-form-red";
		document.getElementById("error").className="email-form-red";
		errorFlag=true;
	}else{
		document.getElementById("error").style.display = 'none';
		document.getElementById("yourEmail").innerHTML=yrEmailAddress ;
		document.getElementById("yourEmail").className="email-form-label";
	}
	}
	var id = document.sendForm.f_email.value;
	var ids = id.trim();
	var lenth = ids.length;
	if(lenth == 0){
		document.getElementById("error").style.display = 'block';
		document.getElementById("error").innerHTML=requestError;
		document.getElementById("frndEmail").innerHTML=moreEmailAddress ;
		document.getElementById("frndEmail").className="email-form-red";
		document.getElementById("error").className="email-form-red";
		errorFlag=true;
	}
	while(lenth > 0){
		var index = ids.indexOf(",");
		if(index >= 0){
			var tmpEmail = ids.substring(0, index);
			var tempEmail = tmpEmail.trim();
			msg = emailchk(tempEmail);
			if(msg != ""){
				document.getElementById("error").style.display = 'block';
				document.getElementById("error").innerHTML=requestError;
				document.getElementById("frndEmail").innerHTML= msg ;
				document.getElementById("frndEmail").className="email-form-red";
				document.getElementById("error").className="email-form-red";
				document.sendForm.f_email.focus();
				errorFlag=true;
				lenth = 0;
			}else{
				document.getElementById("error").style.display = 'none';
				document.getElementById("frndEmail").innerHTML=moreEmailAddress ;
				document.getElementById("frndEmail").className="email-form-label";
			}
			if(lenth > 0){
			ids = ids.substring(index + 1, lenth);
			ids = ids.trim();
			lenth = ids.length; 
			}
		}else{
			msg = emailchk(ids);
			if(msg != ""){
				document.getElementById("error").style.display = 'block';
				document.getElementById("error").innerHTML=requestError;
				document.getElementById("frndEmail").innerHTML= msg ;
				document.getElementById("frndEmail").className="email-form-red";
				document.getElementById("error").className="email-form-red";
				document.sendForm.f_email.focus();
				errorFlag=true;
				lenth = 0;
			}else{
				document.getElementById("error").style.display = 'none';
				document.getElementById("frndEmail").innerHTML=moreEmailAddress ;
				document.getElementById("frndEmail").className="email-form-label";
				lenth = 0;
			}
		}
	}	  
	// Here to check either to call send mail or break and return from here.
	if ( errorFlag == true )
	 return;
	var friendId = document.sendForm.f_email.value;
	if(document.sendForm.sendMe.checked == true) { sendMe = "clicked" }
	else { sendMe = "not_clicked" }
	if(document.sendForm.OptionalMessage.value){
		var optionalMessage = document.sendForm.OptionalMessage.value;
		strValidationUrl =  'userName=' + userName + '&userId=' + userId + '&friendId=' + friendId + '&sendMe=' + sendMe + '&optionalMessage=' + optionalMessage;
	}else{  
		strValidationUrl =  'userName=' + userName + '&userId=' + userId + '&friendId=' + friendId + '&sendMe=' + sendMe;
	}
	var url = SiteURLforJS + '/shareEmail';
	var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				document.getElementById("srcHTML").innerHTML = THANK_YOU_MSG;
			}
		}
    } ; 
    self.xmlHttpReq.send(strValidationUrl);
}




/** 
 * This method gets the Advance Hotel Search page
 */
function getAdvanceSearch(languageCode,countryCode){
	countryCode = getCountryCodeForCa(countryCode);
	var url = SiteURLforJS + '/jsp/advanceHotelSearch.jsp?languageCode='+languageCode+'&countryCode='+countryCode;
	if (window.ActiveXObject) { 
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else if (window.XMLHttpRequest) { 
		httpRequest = new XMLHttpRequest(); 
	} 
	httpRequest.open("GET", url, true); 
	httpRequest.onreadystatechange = function() {
		if (httpRequest.readyState == 4) { 
			if(httpRequest.status == 200) { 
			 document.getElementById( "bradcrum-heading" ).innerHTML = "<h1>"+advBookingText+"</h1>";
			 if(document.getElementById( "secondary-navigation" )){
				document.getElementById( "secondary-navigation" ).style.display = "none";
			 }
				updateHTML( "container-left", httpRequest.responseText );

				changeHeaderClass();

				document.title = AdvBookingTitle;
				
				Calendar.setup({
				inputField     :    "chk_in",     // id of the input field
				//ifFormat       :    "%m/%d/%Y",      // format of the input field
				button         :    "check_in",  // trigger for the calendar (button ID)
				align          :    "Bl",           // alignment (defaults to "Bl")
				singleClick    :    true,
				showsTime		:	false
				});

				Calendar.setup({
				inputField     :    "chk_out",     // id of the input field
				//ifFormat       :    "%m/%d/%Y",      // format of the input field
				button         :    "check_out",  // trigger for the calendar (button ID)
				align          :    "Bl",           // alignment (defaults to "Bl")
				singleClick    :    true,
				showsTime		:	false
				});
			} 
		} 
	} ; 
	httpRequest.send(null);
}


/**
 * Hotel advance search aminity validation.
 * @param form
 */
function amenityCheckboxLimit(form) {
	var checkgroup = eval("document."+form+".amenityCheckbox");

	// limit specifies how many checkboxes should be selected
	var limit = eval("document."+form+".amenitycheckedlimit.value;");

	for(var i=0; i<checkgroup.length; i++) {
		checkgroup[i].onclick =  function (){
			var checkedcount=0;
			for (var i=0; i<checkgroup.length; i++)
				checkedcount += (checkgroup[i].checked)? 1 : 0 ;
				
			if (checkedcount > limit) {
				document.getElementById("amenities-error-msg").innerHTML = amenityCheckboxLimit_Text1 + " " + limit + " " + amenityCheckboxLimit_Text2;
			} else {
				document.getElementById("amenities-error-msg").innerHTML = "";
			}
		}
	}
}

    /**
     * convertTextField();
     * 
     */
     function convertTextField(formName,objName,destinationDiv) {
     	var selectedOption = eval("document."+formName+"."+objName+".options[document."+formName+"."+objName+".selectedIndex].value");
		if(selectedOption == ""){
			if(destinationDiv == "destination-error-msg"){
				document.getElementById(destinationDiv).innerHTML = selectDestination;				
			}else if(destinationDiv == "hotelcompany-error-msg") {
				document.getElementById(destinationDiv).innerHTML = selectHotel;
			}
		}
     	else {
     		document.getElementById(destinationDiv).innerHTML = "";	
     	}
     }

/** 
 * This method retrieves city name to search for travelocity
 */ 
function wct_search_city(city) {
	if(city == "Hawaii Island") {
		var city = "Big Island";
		city.replace(" ", "%2F");
	} else if(city == "Annapolis and Anne Arundel County") {
		city = "Annapolis";
	} else if(city == "Greater Grand Forks") {
		city = "Grand Forks";
	} else if(city == "Prescott Area") {
		city = "Prescott";
	} else if(city == "Washington County") {
		city = "Hillsboro";
	} else if(city == "Custer Country") {
		city = "Billings";
	} else if(city == "Flagler County") {
		city = "Palm Coast";
	} else if(city == "Naples / Marco Island") {
		city = "Naples";
	} else if(city == "Greater New Braunfels") {
		city = "New Braunfels";
    } else if(city == "Glacier Country") {
		city = "Kalispell";
	} else if(city == "Park County") {
		city = "Cody";
	} else if(city == "San Juan County") {
		city = "Monticello";
	} else if(city == "Dinosaurland") {
		city = "Vernal";
	} else if(city == "Carbon County") {
		city = "Price";
	} else if(city == "Currituck") {
		city = "Shawboro";
	} else if(city == "Eugene, Cascades & Coast") {
		city = "Eugene";
	} else if(city == "Finger Lakes") {
		city = "Canandaigua";
	} else if(city == "Calvert County") {
		city = "Prince Frederick";
	} else if(city == "Brunswick and the Golden Isles") {
        city = "Brunswick";
    } else if(city == "Morris County") {
		city = "Morristown";
    } else if(city == "Shasta Cascade Wonderland") {
		city = "Anderson";
    } else if(city == "Pocono Mountains") {
		city = "Poconos";
    } else if(city == "Mystic Country") {
		city = "Mystic";
    } else if(city == "Westchester County") {
		city = "White Plains";
    } else if(city == "Southeast South Dakota") {
		city = "Sioux Falls";
    } else if(city == "Florence-Muscle Shoals") {
		city = "Florence";
    } else if(city == "Auburn-Opelika") {
		city = "Auburn";
    } 

	return city;
}
	
/** 
 * This method retrieves 
 * parameters required for Advance Hotel Search and append them in 
 * url for travelocity
 */ 
function hotelSearchQuery(theForm) {
	var code = get_country_code();
	if(code == 'ca' || code == 'us')
		SetCookie('caSiteCookie','ca',365);
	var url = travelocityURL + "&header=" + travelocityHeaderWithoutSubMenu + "&footer=" + travelocityFooter + "&tab=tab0&src_aid=&avail=Y";
	var dataString = "";
	var destination = document.getElementById("city");
	var selectedDestination = destination.options[destination.selectedIndex].value;
	var destErrorDiv = document.getElementById("destination-error-msg");
	
	if(selectedDestination != "") {
		destErrorDiv.innerHTML = "";
	} else {
		destErrorDiv.innerHTML = selectDestination;
	}
	
	var checkInElemt = document.getElementById("chk_in");
	var checkOutElemt = document.getElementById("chk_out");
	var checkIn = eval("document."+theForm+".chk_in.value");
	var checkOut = eval("document."+theForm+".chk_out.value");

	if(checkIn == "" || checkIn == dateFormat_display) {
		document.getElementById("general-error-msg").style.display = 'block';
		document.getElementById("date-error-msg").innerHTML = checkInDateError;
		return;
	}
	
	if(checkOut == "" || checkOut == dateFormat_display) {
		document.getElementById("general-error-msg").style.display = 'block';
		document.getElementById("date-error-msg").innerHTML = checkOutDateError;
		return;
	}

	dateFractorIn(checkIn );
	dateFractorOut(checkOut);
	var outYear = parseInt(doa_yy_out);
	var inYear = parseInt(doa_yy_in);
	var outMonth = parseInt(doa_mm_out);
	var inMonth = parseInt(doa_mm_in);
	var outDate = parseInt(doa_dd_out);
	var inDate = parseInt(doa_dd_in);

	if (outYear < inYear) {
		document.getElementById("general-error-msg").style.display = 'block';
		document.getElementById("date-error-msg").innerHTML = toDateError;
		return;
	}
	if (outMonth < inMonth) {
		document.getElementById("general-error-msg").style.display = 'block';
		document.getElementById("date-error-msg").innerHTML = toDateError;
		return;
	}
	if (outMonth == inMonth) {
		if (outDate < inDate) {
			document.getElementById("general-error-msg").style.display = 'block';
			document.getElementById("date-error-msg").innerHTML = toDateError;
			return;
		}
	}
	document.getElementById("date-error-msg").innerHTML = "";
	document.getElementById("general-error-msg").style.display = 'none';

	// From date & To date comparison
	
	var roomSelect = eval("document."+theForm+".num_rooms.options[document."+theForm+".num_rooms.selectedIndex].value"); 		
	var adultSelect = eval("document."+theForm+".num_adults.options[document."+theForm+".num_adults.selectedIndex].value"); 		
	var childSelect = eval("document."+theForm+".num_children.options[document."+theForm+".num_children.selectedIndex].value"); 		
	var nameOfHotel = eval("document."+theForm+".name.value");

	var hotelCompany = document.getElementById("brand");
	var	selectedHotels = "";
	var selectFlag = false;
	var hotelCompErrorDiv = document.getElementById("hotelcompany-error-msg");
	for(var index = 0; index < hotelCompany.length; index++) {
		if(hotelCompany[index].selected) {
			var selectFlag = true;
			
			if(hotelCompany[index].value !=""){
				hotelCompErrorDiv.innerHTML = "";
				selectedHotels += hotelCompany[index].value+ ",";
			}
		}
	}
	
	if(selectFlag) {
		hotelCompErrorDiv.innerHTML = "";
	}

	var resultSelectedHotels = selectedHotels.substring(0, selectedHotels.lastIndexOf(","));
	var starRating = eval("document."+theForm+".star_rating.options[document."+theForm+".star_rating.selectedIndex].value"); 		
	var checkgroup = eval("document."+theForm+".amenityCheckbox");
	var limit = eval("document."+theForm+".amenitycheckedlimit.value;");
	var checkedcount=0;
	var selectedAmenity = "&";
	var resultAmenity = "";
	var amenityName = "";

	for(var i = 0; i < checkgroup.length; i++) {
		if(checkgroup[i].checked){
			checkedcount += 1;
			amenityName = checkgroup[i].name.replaceAll(" ","+");
			selectedAmenity += amenityName+"="+checkgroup[i].value+"&";
		}
	}

	resultAmenity = selectedAmenity.substring(0, selectedAmenity.lastIndexOf("&"));
	
	if(selectedDestination != "") {
		var tempState = selectedDestination + "_SN";
		if(document.getElementById(tempState)) {
			var stateShortName = document.getElementById(tempState).value;
		} else {
			var stateShortName = "";
		}
	} else {
		var stateShortName = "";
	}

	selectedDestination = wct_search_city(selectedDestination);
	var parameter = "";
	selectedDestination.replace(" ", "%2F");

	var parameter = "&currency_id=" + currencyId;
	parameter += "&city=" + selectedDestination;
	parameter += "&chk_in=" + doa_mm_in + "%2F" + doa_dd_in + "%2F" + doa_yy_in;
	parameter += "&doa_mm=" + doa_mm_in;
	parameter += "&doa_dd=" + doa_dd_in;
	parameter += "&doa_yy=" + doa_yy_in;
	parameter += "&chk_out=" + doa_mm_out + "%2F" + doa_dd_out + "%2F" + doa_yy_out;
	parameter += "&dod_mm=" + doa_mm_out;
	parameter += "&dod_dd=" + doa_dd_out;
	parameter += "&dod_yy=" + doa_yy_out;
	parameter += "&num_rooms=" + roomSelect;
	parameter += "&num_adults=" + adultSelect;
	parameter += "&num_children=" + childSelect;
	parameter += "&minorsAge1=-%3F-&minorsAge2=-%3F-&minorsAge3=-%3F-&minorsAge4=-%3F-";
	parameter += "&star_rating="+starRating;
	parameter += "&name=" + nameOfHotel;
	parameter += "&brand="+resultSelectedHotels;
	parameter += resultAmenity;
	parameter += "&lang=" + langCode; 
	parameter += "&state=" + stateShortName;
	parameter += "&SearchNow=search"; 	
	if(selectedDestination != "McKinney"){
		parameter += "&search_city_vicinity=1";
	}

	var finalSearchUrl = url + parameter;
	
	if(selectedDestination != "" && checkedcount <= limit){
		document.getElementById("general-error-msg").style.display = 'none';
		location.href = finalSearchUrl;
	} else {
		document.getElementById("general-error-msg").style.display = 'block';
	}
}


/** 
 * This method is called inside the Login template
 * to populate the userLogin Data. With email and
 * password. 
 * It creates XMLHttpRequest object to communicate with the  
 * servlet
 * @param Alphabet Shorting value
 */ 
function getUserLogin(userName, password) { 
	var url1 = "";
	if (window.ActiveXObject) { 
    	httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
    else if (window.XMLHttpRequest) { 
    	httpRequest = new XMLHttpRequest(); 
	} 
        
    httpRequest.open("GET", url1, true); 
    httpRequest.onreadystatechange = function() {processRequest("userlogin"); } ; 
    httpRequest.send(null); 
}

/* Used for Attractions, Entry & about USA written by Swati */ 
function show_hide_attraction(id, title, link) {
	id = id.replaceAll("&apos;","'");
  	title = title.replaceAll("&apos;","'");

	var theObj = document.getElementById(id);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';

	theObj.style.display = theDisp;
	
	var div_id = id + '_arrow';
	var div_id1 = id + '_arrow1';
	var div_id2 = id + '_name';
	
	if(theDisp == "none") {
		document.getElementById(div_id).style.display='block';
		document.getElementById(div_id1).style.display='none';
		document.getElementById(div_id2).innerHTML='<a href="'+link+'">'+title+'</a>';
	} else {
		document.getElementById(div_id).style.display = 'none';
		document.getElementById(div_id1).style.display = 'block';
		document.getElementById(div_id2).innerHTML = title;
	}
}

function Show_hide_detail(id) {
	var id = id.replaceAll("&apos;", "'");
	var img_id = id + '_img';
	var desc_id = id + '_desc';
	var theObj = document.getElementById(img_id);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
	document.getElementById(img_id).style.display = theDisp;
	document.getElementById(desc_id).style.display = theDisp;          
}
	
	
    // Show Hide Map
	function show_hide_map()
	{		
		document.getElementById('loc').style.display = 'block';
		document.getElementById('cmap').style.display = 'block';
	}
	
	function show_hide_cmap()
	{
		document.getElementById('loc').style.display = 'block';
		document.getElementById('columns-content2-locationtxt').style.display = 'none';
		document.getElementById('cmap').style.display = 'block';	
	}
	
	function close_map()
	{
		document.getElementById('cmap').style.display = 'none';
		document.getElementById('loc').style.display = 'none';
	}
	
/* Google map script */
function showAddress(searchAdd, divid, zoom) {
	var zoomLevel = zoom;
    var location = document.getElementById(divid);
    var map = new GMap2(location);
    var geocoder = new GClientGeocoder();
	if (geocoder) {
	geocoder.getLatLng(searchAdd,
		function(point)
		{
			if (!point)
			{
				location.innerHTML=generic_error_msg;
			}
			else
			{
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
				map.setCenter(point, zoomLevel);
				var marker = new GMarker(point);
				map.addOverlay(marker);
			}
		}
		);
	}
}

//to open random widget in booking panel - start
var currentdate = 0
var core = 0

function StringArray (n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' '

  }
}

option = new StringArray(3)
option[0] = 'hotel-search-fields'
option[1] = 'agent-search-fields'
option[2] = 'deal-search-fields'

var ran = 60/option.length

function ranOption() {
  currentdate = new Date()
  core = currentdate.getSeconds()
  core = Math.floor(core/ran)
  return(option[core])
}
//to open random widget in booking panel - end

function printMe() {
   	print();
}


   function hideShowWeather(id){
		var theObj = document.getElementById(id);
		if(document.getElementById(id)=='')
			theObj.style.display='block';
		var theDisp = theObj.style.display;
		if(theDisp=="none"){
			if(id=="weatherinF"){
		  		document.getElementById("weatherinF").style.display='block';
		  		document.getElementById("Fahrenheit").className="weatherlink-gray";
		  		document.getElementById("weatherinC").style.display='none';
		  		document.getElementById("Celsius").className="weatherlink-blue";
			}else if(id=="weatherinC"){
				document.getElementById("weatherinC").style.display='block';
				document.getElementById("Fahrenheit").className="weatherlink-blue";
		  		document.getElementById("weatherinF").style.display='none';
		  		document.getElementById("Celsius").className="weatherlink-gray";
		    }
		}else{
			if(id=="weatherinF"){
		  		document.getElementById("weatherinF").style.display='block';
		  		document.getElementById("Fahrenheit").className="weatherlink-gray";
		  		document.getElementById("weatherinC").style.display='none';
		  		document.getElementById("Celsius").className="weatherlink-blue";
			}else if(id=="weatherinC"){
				document.getElementById("weatherinC").style.display='block';
				document.getElementById("Fahrenheit").className="weatherlink-gray";
		  		document.getElementById("weatherinF").style.display='none';
		  		document.getElementById("Fahrenheit").className="weatherlink-blue";
		    }
		}	
	}

	/**
	 * pagination display fn
	 *  @param id 
	 *  @param maxId
	 *  @param show
	 */
function displayPagination(id , maxId, show) {
   if(maxId > show)
   {
   		var lowerLimit = (id * show) - (show-1);
		var upperLimit = (id * show);
		if(upperLimit > maxId)
				upperLimit = maxId;
		for(var i =1; i<= maxId; i++){
			if(i >= lowerLimit && i <= upperLimit){
				document.getElementById(i).style.display = 'block';
			}
			else{
				document.getElementById(i).style.display = 'none';
			}
		}
		var maxPage=Math.ceil(maxId/show);
		var pagingText="";
		if (id!=1)
			pagingText="<img src='"+ SiteURLforJS + "/resources/images/left-arrow2.gif' hspace='5' onclick=\"javascript:displayPagination("+(parseInt(id)-1)+","+maxId+","+show+")\"/>";
		for(var i =1; i<= maxPage; i++){
			if(i!=id){
				pagingText+="<a href=\"javascript:displayPagination(" + i + "," + maxId + ","+show+")\"  >" + i + "</a>" + " ";
			}else{
				pagingText+=i + " ";
			}
		}
		if (maxPage!=id)
			pagingText+="<img src='"+ SiteURLforJS + "/resources/images/right-arrow2.gif' hspace='5' onclick=\"javascript:displayPagination("+(parseInt(id)+1)+","+maxId+","+show+")\">"
		document.getElementById("acitivitesPagination").innerHTML = pagingText;
		if(document.getElementById("editRight")){
		var limit = ""
		limit += lowerLimit;
		limit += " - ";
		limit += upperLimit;
		limit += " of ";
		limit += maxId ;
		document.getElementById("editRight").innerHTML=limit;
		}
	}
}   
   /**
    * pop window fn.
	*/
	function displayPopup(){
		showPopup('share');
	} 


function displayNewPopup(){
	document.getElementById("srcHTMLNew").style.display = "none";
	var url = SiteURLforJS + '/jsp/send-mail.jsp';
	var shareHttpRequest; 
	if (window.ActiveXObject) { 
            shareHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if (window.XMLHttpRequest) { 
            shareHttpRequest = new XMLHttpRequest(); 
        } 
        shareHttpRequest.open("GET", url, true); 
        shareHttpRequest.onreadystatechange = function() {
        	if (shareHttpRequest.readyState == 4) { 
				if(shareHttpRequest.status == 200) {
					document.getElementById("srcHTML").innerHTML = shareHttpRequest.responseText;
						setText();
						checkCookie();
				}
			}
        } ; 
        shareHttpRequest.send(null);
	} 

	
//*********************************** New >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>72 END<<<<<<<< 
 
/** 
 * This method is called inside the activitiesFinder page
 * to show and hide the state name of particular region. 
 */
function showToolTip(id) {
	document.getElementById(id).style.display = 'block';
} 

	
function hideToolTip(id) {
	document.getElementById(id).style.display = 'none';
} 

//************************************** CONTACT ME BY EMAIL Method *************************
/**
 * This method is used to send contact me email
 */
function contactAgent(agentId,dealId,languageCode,countryCode) {
	document.getElementById("srcHTMLNew").style.display = "none"; 
	var contactHttpRequest; 
	var url = SiteURLforJS + '/jsp/contactme-by-email.jsp?agentId=' + agentId + '&dealId=' + dealId + '&languageCode=' + languageCode + '&countryCode=' + countryCode;
	if (window.ActiveXObject) { 
		contactHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else if (window.XMLHttpRequest) { 
		contactHttpRequest = new XMLHttpRequest(); 
	} 
	
	contactHttpRequest.open("GET", url, true); 
   
	contactHttpRequest.onreadystatechange = function() {
		if (contactHttpRequest.readyState == 4) { 
			if(contactHttpRequest.status == 200) {
				document.getElementById( "srcHTML" ).innerHTML = contactHttpRequest.responseText;
				setCookieValue();
			}
		}
	} ; 
	contactHttpRequest.send(null); 
}

function disableAllErrorDivs(checkBoxName){
	var checkBoxElement = document.getElementById(checkBoxName);

	if(checkBoxName == 'contactEmailCheckbox' && !checkBoxElement.checked ){
		document.getElementById("error").style.display = 'none';
		document.getElementById("yourPostalMail").style.display = 'none';
	}else if(checkBoxName == 'contactPhoneCheckbox' && !checkBoxElement.checked ){
		document.getElementById("error").style.display = 'none';
		document.getElementById("yourPostalMail").style.display = 'none';
	}
}

/**
 * This method is used to validate the ContactMeForm
 */
function validateContactMeForm(theForm,sitePath,agentId,dealId,languageCode,countryCode) {
	    var strValidationUrl = "";
	    var validEmailId = "";
	    var usrMailIdValue = "";
	    var userPhoneValue = "";
	    var userFirstName = "";
	    var userLastName  = "";
	    var eventSource  = document.getElementById('contactType');
	    var contactByEmail = document.getElementById('contactEmailCheckbox');
	    var contactByPhone = document.getElementById('contactPhoneCheckbox');
	    var recieveNewsletter = document.getElementById('recieveNewsletterCheckbox');
	    var mailMessage = document.getElementById('OptionalMessage').value.trim();
		
		var userFName = eval("document."+theForm+".contactMailFname");
		userFirstName = userFName.value.trim();
				
		if (userFirstName == "") {
		  	document.getElementById("error").style.display = 'block';
		  	document.getElementById("error").innerHTML=requestError;
		  	document.getElementById("yourPostalMail").style.display = 'block';
		  	document.getElementById("yourPostalMail").innerHTML=enterFirstName;
		  	document.getElementById("error").className="contact-email-error-message";
		    	userFName.focus();
			return;
		}else{
		    document.getElementById("error").style.display = 'none';
		    document.getElementById("yourPostalMail").style.display = 'none';
		}

		var userLName = eval("document."+theForm+".contactMailLname");
		userLastName = userLName.value.trim();
		if (userLastName == "") {
		  	document.getElementById("error").style.display = 'block';
		  	document.getElementById("error").innerHTML=requestError;
		  	document.getElementById("yourPostalMail").style.display = 'block';
		  	document.getElementById("yourPostalMail").innerHTML=enterLastName;
		  	document.getElementById("error").className="contact-email-error-message";
		    	userLName.focus();
			return;
		}else{
		    document.getElementById("error").style.display = 'none';
		    document.getElementById("yourPostalMail").style.display = 'none';
		}
		
		if(contactByPhone.type == 'checkbox' && contactByPhone.checked){
		var userPhone = eval("document."+theForm+".contactPhoneInputBox");
		userPhoneValue = userPhone.value.trim();
		
		if (userPhoneValue == "") {
			  	document.getElementById("error").style.display = 'block';
			  	document.getElementById("error").innerHTML=requestError;
			  	document.getElementById("yourPostalMail").style.display = 'block';
			  	document.getElementById("yourPostalMail").innerHTML=enterPhoneNumber;
			  	document.getElementById("error").className="contact-email-error-message";
			    	userPhone.focus();
				return;
		}else{
			var numArray=userPhoneValue.split("");
			var charError="";
			for(var numCheck=0;numCheck<numArray.length;numCheck++){
				if(numArray[numCheck]==0 || numArray[numCheck]==1 || numArray[numCheck]==2 || numArray[numCheck]==3 || numArray[numCheck]==4 || numArray[numCheck]==5 || numArray[numCheck]==6 || numArray[numCheck]==7 || numArray[numCheck]==8 || numArray[numCheck]==9){
				}else{
				   charError="1";
				}
			}
			if(charError==""){
		  		document.getElementById("error").style.display = 'none';
		  		document.getElementById("yourPostalMail").style.display = 'none';
			}else{
				document.getElementById("error").style.display = 'block';
		  		document.getElementById("error").innerHTML=requestError;
			  	document.getElementById("yourPostalMail").style.display = 'block';
			  	document.getElementById("yourPostalMail").innerHTML=invalidPhone;
			  	document.getElementById("error").className="contact-email-error-message";
			    	userPhone.focus();
				return;
			}
		}
		eventSource.value = 'contactByPhone';	
	}
	if(contactByEmail.type == 'checkbox' && contactByEmail.checked){
		var userMail = eval("document."+theForm+".contactEmailInputBox");
		usrMailIdValue = userMail.value.trim();

		if (usrMailIdValue == "") {
			document.getElementById("error").style.display = 'block';
			document.getElementById("error").innerHTML=requestError;
			document.getElementById("yourPostalMail").style.display = 'block';
			document.getElementById("yourPostalMail").innerHTML=enterEmailAddress;
			document.getElementById("error").className="contact-email-error-message";
				userMail.focus();
			return;
		}else{
			document.getElementById("error").style.display = 'none';
			document.getElementById("yourPostalMail").style.display = 'none';
		}
		validEmailId = emailchk(usrMailIdValue);
		if(validEmailId != ""){ 
			document.getElementById("error").style.display = 'block';
			document.getElementById("error").innerHTML=requestError;
				document.getElementById("yourPostalMail").style.display = 'block';
			document.getElementById("yourPostalMail").innerHTML= validEmailId;
			document.getElementById("error").className="contact-email-error-message";
			userMail.focus();
			return;
		}else{
			document.getElementById("error").style.display = 'none';
			document.getElementById("yourPostalMail").style.display = 'none';
			
			var confirmMail = eval("document."+theForm+".confirmEmailInputBox");
			confirmMailIdValue = confirmMail.value.trim();
	
			if (confirmMailIdValue == "") {
				document.getElementById("error").style.display = 'block';
				document.getElementById("error").innerHTML=requestError;
				document.getElementById("yourPostalMail").style.display = 'block';
				document.getElementById("yourPostalMail").innerHTML=confirmEmailmsg;
				document.getElementById("error").className="contact-email-error-message";
					confirmMail.focus();
				return;
			}else{
				document.getElementById("error").style.display = 'none';
				document.getElementById("yourPostalMail").style.display = 'none';
			}
			if (confirmMailIdValue != usrMailIdValue) {
				document.getElementById("error").style.display = 'block';
				document.getElementById("error").innerHTML=requestError;
				document.getElementById("yourPostalMail").style.display = 'block';
				document.getElementById("yourPostalMail").innerHTML=confirmEmailErrormsg;
				document.getElementById("error").className="contact-email-error-message";
					confirmMail.focus();
				return;
			}else{
				document.getElementById("error").style.display = 'none';
				document.getElementById("yourPostalMail").style.display = 'none';
			}
			if(recieveNewsletter.checked) {
				var strValidationUrl = SiteURLforJS + "/RegisterEmail?emailID=" + usrMailIdValue + '&languageCode=' + languageCode + '&countryCode=' + countryCode;
				if (window.ActiveXObject) {
					httpRequestNews = new ActiveXObject("Microsoft.XMLHTTP");
				}
				else if (window.XMLHttpRequest) {
						httpRequestNews = new XMLHttpRequest();
				}
				httpRequestNews.open("GET", strValidationUrl, true);
				httpRequestNews.onreadystatechange = function() {
						if (httpRequestNews.readyState == 4) {
								if(httpRequestNews.status == 200) {
										var result = httpRequestNews.responseText;
								} 
						} 
				} ;
				httpRequestNews.send(null);
			 }
		}
		eventSource.value = 'contactByEmail';
	}
	
	if(contactByPhone.checked || contactByEmail.checked){																																				
		  	strValidationUrl =  SiteURLforJS + '/ContactMeEmail?validEmailId=' + usrMailIdValue + '&userPhoneValue=' + userPhoneValue + '&userFirstName=' + userFirstName + '&userLastName=' + userLastName +  '&agentId=' + agentId + '&dealId=' + dealId + '&mailMessage=' + mailMessage;
			processContactMeMail(strValidationUrl);
	}else {
		document.getElementById("error").style.display = 'block';
		document.getElementById("error").innerHTML=requestError+"<BR><BR>"+oneContactMethod ;
		document.getElementById("error").className="contact-email-error-message";
		return;
	}
}

function validateRecEmail(){
	var val = document.getElementById("contactEmailCheckbox").checked;
	document.getElementById("recieveNewsletterCheckbox").checked=val;
}

function validateContByEmail(){
	var val = document.getElementById("recieveNewsletterCheckbox").checked;
	if(val){
		disableAllErrorDivs('contactEmailCheckbox');
		document.getElementById("contactEmailCheckbox").checked=val;
	}
}

function validateChkBox(chkBoxId,txtBoxId){
	var val=document.getElementById(txtBoxId).value;
	if(val.trim().length>0){
		document.getElementById(chkBoxId).checked=true;
	}
}

function processContactMeMail(strValidationUrl){
	document.getElementById("srcHTMLNew").style.display = "none";
 	var contactMeUrl = strValidationUrl;
 	if (window.ActiveXObject) { 
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else if (window.XMLHttpRequest) { 
		httpRequest = new XMLHttpRequest(); 
	} 
	httpRequest.open("GET", contactMeUrl, true); 
	httpRequest.onreadystatechange = function() {
		if (httpRequest.readyState == 4) { 
			if(httpRequest.status == 200) {
			 		httpRequest.responseText;
					document.getElementById("srcHTML").innerHTML = THANK_YOU_MSG;
			} 
		} 
	} ; 
	httpRequest.send(null);	
}

function setText(){
	username = ReadCookie('HD');
	var loction = ""+window.location;
	if (username != null && username != ""){
		var index1 = username.indexOf("|");
		var index2 = username.indexOf("||");
		var user_name = username.substring(index1+1,index2);
		var user_email = username.substring(index2+2);
		document.getElementById("OptionalMessage").value = setText_UserMessage1 + " " + user_name + setText_UserMessage2 + " " + loction + " ";
		document.getElementById("p_name").value=user_name;
		document.getElementById("p_email").value=user_email;
	}
	else{
		document.getElementById("OptionalMessage").value = setText_Message + " " + loction + " ";
		document.getElementById("p_name").value="";
		document.getElementById("p_email").value="";
	}
}

function privacyLink() {
	var privacyUrl = SiteURLforJS + "/privacy-policy.html"
	newWin = window.open(privacyUrl, "_blank", "width=auto, height=auto, resizable=1, toolbar=1, menubar=1, scrollbars=1, location=1, status=1");
}

function termsLink() {
	var termsUrl = SiteURLforJS + "/terms.html"
	newWin = window.open(termsUrl, "_blank", "width=auto, height=auto, resizable=1, toolbar=1, menubar=1, scrollbars=1, location=1, status=1");
}

function dateFractorIn(dateFrmat) {
	var index_yy = dateFormat.indexOf("y");
	doa_yy_in = dateFrmat.substr(index_yy, 4);
	var index_mm = dateFormat.indexOf("m");
	doa_mm_in = dateFrmat.substr(index_mm, 2);
	var index_dd = dateFormat.indexOf("d");
	doa_dd_in = dateFrmat.substr(index_dd, 2);
} 

function dateFractorOut(dateFrmat) {
	var index_yy = dateFormat.indexOf("y");
	doa_yy_out = dateFrmat.substr(index_yy, 4);
	var index_mm = dateFormat.indexOf("m");
	doa_mm_out = dateFrmat.substr(index_mm, 2);
	var index_dd = dateFormat.indexOf("d");
	doa_dd_out = dateFrmat.substr(index_dd, 2);
} 

function displayDivIdPagination(id , maxId, show, MainDivId, DivId, RightDivId) {
   	if(maxId > show)
   	{
   		var lowerLimit = (id * show) - (show-1);
		var upperLimit = (id * show);
		if(upperLimit > maxId)
				upperLimit = maxId;
		for(var i =1; i<= maxId; i++){
		var cityDivId = DivId+i;
			if(i >= lowerLimit && i <= upperLimit){
				document.getElementById(cityDivId).style.display = 'block';
			}
			else{
				document.getElementById(cityDivId).style.display = 'none';
			}
		}
		var maxPage=Math.ceil(maxId/show);
		var pagingText="";
		if (id!=1)
			pagingText="<img src='"+ SiteURLforJS + "/resources/images/left-arrow2.gif' hspace='5' onclick=\"javascript:displayDivIdPagination("+(parseInt(id)-1)+","+maxId+","+show+", '"+MainDivId+"', '"+DivId+"')\"/>";
		for(var i =1; i<= maxPage; i++){
			if(i!=id){
				pagingText+="<a href=\"javascript:displayDivIdPagination(" + i + "," + maxId + ","+show+", '"+MainDivId+"', '"+DivId+"')\"  >" + i + "</a>" + " ";
			}else{
				pagingText+=i + " ";
			}
		}
		if (maxPage!=id)
			pagingText+="<img src='"+ SiteURLforJS + "/resources/images/right-arrow2.gif' hspace='5' onclick=\"javascript:displayDivIdPagination("+(parseInt(id)+1)+","+maxId+","+show+", '"+MainDivId+"', '"+DivId+"')\">"
		document.getElementById(MainDivId).innerHTML = pagingText;
		if(RightDivId != ""){
		var limit = ""
		limit += lowerLimit;
		limit += " - ";
		limit += upperLimit;
		limit += " of ";
		limit += maxId ;
		document.getElementById(RightDivId).innerHTML=limit;
		}
	}
}

function show_hide_attraction_cookie(id, title, link, activity_type, cookie_name) {    	
	var id1=id.replaceAll("&apos;", "'");
	title=title.replaceAll("&apos;", "'");	
	var theObj = document.getElementById(id1);
	
    var theDisp = theObj.style.display == 'none' ? 'block' : 'none';

    theObj.style.display = theDisp;
	
	var div_id=id1+'_arrow';
	var div_id1=id1+'_arrow1';
	var div_id2=id1+'_name';
	
	if(theDisp=="none")
	{
		document.getElementById(div_id).style.display='block';
		document.getElementById(div_id1).style.display='none';
		document.getElementById(div_id2).innerHTML='<a href="'+link+'" onClick="callcookie('+"'"+activity_type+"'"+', '+"'"+cookie_name+"'"+')">'+title+'</a>';
    } 
	else
	{				
		document.getElementById(div_id).style.display='none';
		document.getElementById(div_id1).style.display='block';
		document.getElementById(div_id2).innerHTML=title;
	}
}

function checkUserCookieShare() {	
   	username = ReadCookie('HD');
	var divClassfound = "";
	var requiredDiv = "";
	if(document.getElementById('plcksubmit')){
		var td = document.getElementsByTagName('div');
		for(i=0;i<td.length;i++) {
			if(td[i].className == 'SiteLife_Login') {
				divClassfound = 'yes';
				requiredDiv = td[i];		
			}
		}
		if(divClassfound){
			if (username == null || username == ""){	
				requiredDiv.innerHTML = loginTextShare+' <a href="#" class="blue-normal" onclick="javascript:showPopup(\'login\'); return false;" style="color:#0099cb; font-size:12px; text-decoration:none;" rel="lightbox">'+login+' </a>'+or+'<a href="#" class="blue-normal" onclick="javascript:showPopup(\'Reg\'); return false;" style="color:#0099cb; font-size:12px; text-decoration:none;" rel="lightbox">'+register+'</a>.';
			}
		}
	}
}

function show_hide_site_map(id, redcss, bluecss, imagePath) {    	
	var desc_id = id + '_desc';	
   	var theObj = document.getElementById(desc_id);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
	theObj.style.display = theDisp;		
		
	var div_id2=id+'_name';
	var div_id3=id+'_img';
	
	if(theDisp=="none")
	{			
		document.getElementById(div_id3).src = imagePath+"/left-arrow-off-link.gif";
		document.getElementById(div_id2).className=bluecss;
	} 
	else
	{				
		document.getElementById(div_id3).src = imagePath+"/bottom-arrow-off-link.gif";
		document.getElementById(div_id2).className=redcss;
	}
}

function showInput(){
	var si = document.getElementById('storyinput');
	if(si)
	si.style.display = 'block';
}

function renderCommentPage(responseBatch) {
	if (responseBatch.Responses.length == 0) {   
      } else {
		var commentPage = responseBatch.Responses[0].CommentPage; 
		if(commentPage.Comments.length==0){
			showInput();
	             	if(document.getElementById("travelerstories")){
       	      		document.getElementById("travelerstories").style.display='none';
                    	}	
		}
        } 
	var username = ReadCookie('HD');
	if (username == null || username == "") {
		if(document.getElementById('loginMsg')){
			document.getElementById('loginMsg').innerHTML=loginTextStory+' <a href="javascript:window.parent.showPopup(\'login\')" style="color:#0099cb; font-size:12px;" rel="lightbox">'+login+'</a>&nbsp;'+or+'&nbsp;<a href="javascript:window.parent.showPopup(\'Reg\')" style="color:#0099cb; font-size:12px;" rel="lightbox">'+register+'</a>';
		}
	}  
}

/* *********** Interactive Map Flash Cards functions ****************** */
function Popup_AttractionFlashCard(attractionPath,attractionName,cityName,stateName,regionName)
{   		
	if(cityName == "")
	{
		callcookie(attractionName, 'category');
		var url= stateName+ '/' + 'attractions.html';

		//attractionPath = get_html(attractionPath);
		//var url="activities/"+attractionPath+".html";
	}
	else
	{
		callcookie(attractionName, 'category');		
		if(cityName == 'dc')
		{
			var url= cityName + '-' + 'attractions.html';  
		}
		else
		{
			var url= stateName + '/' + cityName + '-' + 'attractions.html';  
		}

	}
   	location.href = url;
}

function Popup_RegionFlashCard(regionName)
{	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
    {
      alert (ajax_browser_error);
      return;
    } 
	
    var url=regionName + '/' + 'flash-card.html'; 
	var url=url.toLowerCase();
	xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function Popup_StateFlashCard(stateName)
{	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    } 

    var url=stateName + '/' + 'flash-card.html'; 
	var url=url.toLowerCase();
	xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function Popup_CityFlashCard(cityName,stateName)
{	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    } 

	if(cityName == 'dc')
	{
		var url=cityName +'-flash-card.html';
	}
	else
	{
    	var url=stateName + '/' + cityName +'-flash-card.html';
	}
	
	var url=url.toLowerCase();
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    { 
    	if(xmlHttp.status == 200) { 
			val = false;
    		document.getElementById("city_detail").innerHTML=xmlHttp.responseText;
    	}else{
    		alert(generic_error_msg);
    	}
    }
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}

function closewin()
{
  val = true;
  document.getElementById('opcl').style.display='none';
}

function ActivateMap()
{
	return val;
}
/* *********** Interactive Map Flash Cards functions - end ****************** */

function setCookieValue(){
	username = ReadCookie('HD');
	if (username != null && username != ""){
		var index1 = username.indexOf("|");
		var index2 = username.indexOf("||");
		var user_name = username.substring(index1+1,index2);
		var user_email = username.substring(index2+2);
		document.getElementById("contactMailFname").value=user_name;
		document.getElementById("contactEmailInputBox").value=user_email;
	}
	else{
		document.getElementById("contactMailFname").value="";
		document.getElementById("contactEmailInputBox").value="";
	}
}

function getCityPanelWct(divId, cityName,languageCode,countryCode,optionVal) {
	var newHttpRequest; 
	if(optionVal == "All"){
	optionVal = all; 
	}else{
	optionVal = select; 
	}

	var url = SiteURLforJS + '/jsp/city_panel_wct.jsp';
	var xmlHttpReq = false;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				document.getElementById( divId ).innerHTML = xmlHttpReq.responseText;
			}
		}
	} ; 
	xmlHttpReq.send('cityNameSel='+ cityName+'&languageCode='+languageCode+'&countryCode='+countryCode+'&optionVal='+optionVal);
}

function get_html(string)
{
	string = string.toLowerCase();
	string = string.replaceAll("the ","");
	string = string.replaceAll("and ", "");
	string = string.replaceAll("if ", "");
	string = string.replaceAll("not ", "");
	string = string.replaceAll("you ", "");
	string = string.replaceAll("they ", "");
	string = string.replaceAll("he ", "");
	string = string.replaceAll("she ", "");
	string = string.replaceAll(", ", "-");
	string = string.replaceAll(",", "-");
	string = string.replaceAll(" ", "-");
	string = string.replaceAll("_", "-");   		
	return string;	
}

function show_hide_attraction_new(id, title, link, imagepath) {
	var id1=id.replaceAll("&apos;", "'");  		
	var theObj = document.getElementById(id1);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';
	theObj.style.display = theDisp;
	var div_id=id1+'_arrow';
	var div_id1=id1+'_arrow1';
	var div_id2=id1+'_name';
	var disp_title=title.replaceAll("&apos;", "'");
	id=id.replaceAll("'", "&apos;");
	title=title.replaceAll("'", "&apos;")
	
	if(theDisp=="none")
	{		
		var image="<a href='javascript: show_hide_attraction_new("+'"'+id+'"'+", "+'"'+title+'"'+", "+'"'+link+'"'+", "+'"'+imagepath+'"'+")'><img src='"+imagepath+"/images/left-arrow-off-link.gif' title='' border='0' /></a>";
		document.getElementById(div_id2).innerHTML="<a href='"+link+"'>"+disp_title+"</a>"+image;
	} 
	else
	{	
		var image=disp_title+"<a href='javascript: show_hide_attraction_new("+'"'+id+'"'+", "+'"'+title+'"'+", "+'"'+link+'"'+", "+'"'+imagepath+'"'+")'><img src='"+imagepath+"/images/bottom-arrow-off-link.gif' title='' border='0' /></a>";
		document.getElementById(div_id2).innerHTML=image;
	}
}

function Show_hide_detail_title(id){		
	var id = id.replaceAll("&apos;","'");
	var desc_id=id+'_desc';
	var theObj=document.getElementById(desc_id);
	var theDisp = theObj.style.display == 'none' ? 'block' : 'none';

	document.getElementById(desc_id).style.display = theDisp;          
}

function displayAdditionalFeaturePopup(){
	document.getElementById("srcHTMLNew").style.display = "none";
	var divhtml='<div id="comingsoon"><div id="comingsoon-btn-logo"><img src="'+SiteURLforJS+'/resources/images/small-discover-logo.gif"></div><div id="comingsoonlogotext">'+bookAdditionalFeatureLogo+'</div><div class="clear"></div><div class="comingsoon-text">'+bookAdditionalFeature+'</div></div>';
	document.getElementById("srcHTML").innerHTML = divhtml;
} 

/* New Function - Coupons Integration */

function show_hide_city_coupon(id)
    {    		
    	var theObj = document.getElementById(id);
		
        var theDisp = theObj.style.display == 'none' ? 'block' : 'none';

        theObj.style.display = theDisp;
		
		var div_id=id+'_arrow';
		var div_id1=id+'_arrow1';
		var div_id2=id+'_name';
		
		if(theDisp=="none")
		{
			document.getElementById(div_id).style.display='block';
			document.getElementById(div_id1).style.display='none';
			document.getElementById(div_id2).className="icon-link-heading";
        } 
		else
		{				
			document.getElementById(div_id).style.display='none';
			document.getElementById(div_id1).style.display='block';
			document.getElementById(div_id2).className="icon-link-heading-red";
		}
    }

/* New Function - Agent & Deal Integration on home page */
function home_booking(){
	var q = ReadCookie("daBooking");
	var val=q.split("|");


	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}

	
	if(val[0] == 'AgentDetail')
	{
		var url = SiteURLforJS + '/jsp/get_agent.jsp';
		self.xmlHttpReq.open('POST', url, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				if (self.xmlHttpReq.status == 200) {
					if(document.getElementById( "container-left" )){
						if(document.getElementById( "advertisement-div" )){
							document.getElementById( "advertisement-div" ).innerHTML = "";
						}
						document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
						document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript: history.go(-1)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br><br><h1>"+aboutThisAgent+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
						hideShow('agent-search-fields');
						for(i=0;i<document.Agentfrm.city.length;i++){
							if(document.Agentfrm.city.options[i].value==val[2]){
								document.Agentfrm.city.selectedIndex=i
							}
						}
					}
				}
			}
		}; 
		self.xmlHttpReq.send('agent='+val[1]+'&languageCode='+language_Code+'&countryCode='+country_Code);	
		
	}
	if(val[0] == 'Agent')
	{
		var url = SiteURLforJS + '/jsp/get_agent_result.jsp';

		self.xmlHttpReq.open('POST', url, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
		self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				if(document.getElementById( "container-left" )){
					if(document.getElementById( "advertisement-div" )){
					document.getElementById( "advertisement-div" ).innerHTML = "";
					}
					document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
					document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:history.go(-1)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+aboutThisAgent+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";					
					hideShow('agent-search-fields');
					for(i=0;i<document.Agentfrm.city.length;i++){
						if(document.Agentfrm.city.options[i].value==val[1]){
							document.Agentfrm.city.selectedIndex=i
						}
					}
				}
				
			}
		}
		} ; 
	self.xmlHttpReq.send('city='+ val[1]+'&activity=&agent=&page=1&languageCode='+language_Code+'&countryCode='+country_Code+'&orderBy=&otherCity=');
		
	}
	if(val[0] == 'DealDetail')
	{
		var url = SiteURLforJS + '/jsp/get_deal_id.jsp?dealID='+val[1]+ '&languageCode='+language_Code+'&countryCode='+country_Code;

		self.xmlHttpReq.open("GET", url, true); 
        self.xmlHttpReq.onreadystatechange = function() {
        	if (self.xmlHttpReq.readyState == 4) { 
				if(self.xmlHttpReq.status == 200) {
					if(document.getElementById( "container-left" )){
						if(document.getElementById( "advertisement-div" )){
							document.getElementById( "advertisement-div" ).innerHTML = "";
						}
						document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
						document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:history.go(-1)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+val[2]+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
						hideShow('deal-search-fields');
						for(i=0;i<document.Dealfrm.city.length;i++){
							if(document.Dealfrm.city.options[i].value==val[3]){
								document.Dealfrm.city.selectedIndex=i
							}
						}

					}
				}
			}
        } ; 
        self.xmlHttpReq.send(null);
	}
	if(val[0] == 'Deal')
	{
		var url = SiteURLforJS + '/jsp/get_deal.jsp';

		self.xmlHttpReq.open('POST', url, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				if (self.xmlHttpReq.status == 200) {
					if(document.getElementById( "container-left" )){
							if(document.getElementById( "advertisement-div" )){
								document.getElementById( "advertisement-div" ).innerHTML = "";
							}
							document.getElementById( "container-left" ).innerHTML = self.xmlHttpReq.responseText;
							document.getElementById( "bradcrum-heading" ).innerHTML = "<a href='javascript:history.go(-1)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+getDeal+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div>";
							hideShow('deal-search-fields');
							for(i=0;i<document.Dealfrm.city.length;i++){
								if(document.Dealfrm.city.options[i].value==val[1]){
									document.Dealfrm.city.selectedIndex=i
								}
							}
						}
				}
			}
		} ; 
		self.xmlHttpReq.send('city='+val[1]+'&activity=&dealFrom=&dealTo=&page=1&languageCode='+language_Code+'&countryCode='+country_Code+'&orderBy=&otherCity=');
	}
}

function getShoppingIntro(page_num, alpha_order,order_by,cityName,country_id,language_id) { 
	var url = SiteURLforJS + '/jsp/shopping.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
	    self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
	    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				if(order_by == "SHOP_NAME"){
					str=str.trim();
					var displayStatus=str.substr(0, 1);
					if(displayStatus=="0"){
						document.getElementById("byCategoryList").style.display="none";
					}
					str=str.substr(1);
				}
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order +'&orderBy='+ order_by  + '&cityName='+cityName +'&country_id='+ country_id + '&language_id='+language_id);
}

function getResturantsIntro(page_num, alpha_order, order_by, city_name ,country_id,language_id) { 
	
	var url = SiteURLforJS + '/jsp/restaurant.jsp';
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!self.xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				str=self.xmlHttpReq.responseText;
				if(order_by == "NAME"){
					str=str.trim();
					var displayStatus=str.substr(0, 2);
					var cuisineListSize=displayStatus.substr(0, 1);
					var priceListSize=displayStatus.substr(1, 2);
					if(cuisineListSize=="0"){
						document.getElementById("byCuisineList").style.display="none";
					}
					if(priceListSize=="0"){
						document.getElementById("byPriceList").style.display="none";
					}
					str=str.substr(2);
				}				
			}
		}
	} ; 
	self.xmlHttpReq.send('page_num='+ page_num + '&alpha_order=' + alpha_order + '&order_by=' + order_by + '&city_name=' + city_name +'&country_id='+ country_id + '&language_id='+language_id);
}

function getHomeFeaturedDealsPanel(divId,languageCode,countryCode) {
	countryCode = getCountryCodeForCa(countryCode);
	var url = SiteURLforJS + '/jsp/home_featured_deals.jsp';
	var xmlHttpReq = false;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlHttpReq) {
		alert('Giving up :( Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				document.getElementById( divId ).innerHTML = xmlHttpReq.responseText;
			}
		}
	} ; 
	xmlHttpReq.send('languageCode='+languageCode+'&countryCode='+countryCode);
}

function getDealDetail(dealID,language_id,country_id,dealName){
	country_id = getCountryCodeForCa(country_id);	
	dealName=dealName.replaceAll("-----", "\"");
	dealName=dealName.replaceAll("----", "'");
	var dealHttpRequest; 
	var url = SiteURLforJS + '/jsp/get_deal_id.jsp?dealID='+ dealID+ '&languageCode='+language_id +'&countryCode='+ country_id ;
	if (window.ActiveXObject) { 
		dealHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} else if (window.XMLHttpRequest) { 
		dealHttpRequest = new XMLHttpRequest(); 
	} 
    dealHttpRequest.open("GET", url, true); 
    dealHttpRequest.onreadystatechange = function() {
    	if (dealHttpRequest.readyState == 4) { 
			if(dealHttpRequest.status == 200) {
				if(document.getElementById( "mainDiv" )){
					document.getElementById( "mainDiv" ).innerHTML = "<div id=\"bradcrum-heading\"><a href='javascript:location.reload(true)'><img src='"+ SiteURLforJS + "/resources/images/icon-previous.gif'/>"+previousPage+"</a><br/><br/><h1>"+dealName+"</h1><div id='utility-nav'><a href='javascript:printMe()' class='utility-nav-link'>"+printText+"</a></div><div class='clear'></div><div id='breadcrum'></div><div class=\"clear\"></div></div><div class=\"clear\"></div><div id=\"container-box\">" + dealHttpRequest.responseText + "</div>";
				}
			}
		}
	}; 
	dealHttpRequest.send(null);
}

/* Function to create array from string obtained from 'get_agent_result.jsp' for rotatation of Featured Agents */
function createAgentDetails(featuredDet) {
	agentDt = featuredDet.split("@@@@");
	
	for(var i = 0; i < agentDt.length; i++) {
		agentDt[i] = agentDt[i].split("||");
	}

	//Pick the starting index as random and then rotate the agents sequentially
	startIndexFeatured = Math.floor(Math.random() * (agentDt.length));
	indexFeatured = startIndexFeatured;
	clearTimeout(timerVal);
	timer();
}

/* Rotate the agents with some time delay */
function timer() {
	rotateAgents(indexFeatured);
	indexFeatured++;
	
	if(indexFeatured >= agentDt.length) {
		indexFeatured = 0;
	}
	timerVal = setTimeout("timer()", 7000);
}

/* Create details to be displayed on the site */
function rotateAgents() {
	/*	Index details
		0  - agentId			1  - languageCode				2  - countryCode 		3  - address1
		4  - address2			5  - city						6  - state				7  - zip
		8  - phone				9  - url						10 - logo				11 - description
		12 - companyName		13 - Request Context Path		14 - View Details
	*/
	var agentDetail = "";
	agentDetail += "<div class=\"agent-detail-rotate\">";
	
	if(agentDt[indexFeatured][10] != ""){
		agentDetail += "<div id=\"agent-detail-logo\" class=\"agent-detail-logo\" style=\"background-image: url('" + agentDt[indexFeatured][10] + "'); background-repeat:no-repeat;\"  title=\"" + agentDt[indexFeatured][12] + "\"></div>";
	} else {
		agentDetail += "<div id=\"agent-detail-logo\" class=\"agent-detail-logo\" style=\"background-image: url('" + agentDt[indexFeatured][13] + "/resources/images/logo-img.gif'); background-repeat:no-repeat;\" title=\"\"></div>";
	}
	
	agentDetail += "<div class=\"agent-detail-text\">" + "<a href=\"" + SiteURLforJS + "/jsp/get_agent.jsp?agentId=" + agentDt[indexFeatured][0] + "&languageCode=" + agentDt[indexFeatured][1] + "&countryCode=" + agentDt[indexFeatured][2] + "\" target=\"_blank\" class=\"blue-link1\">" + agentDt[indexFeatured][12] + "</a><br />" + agentDt[indexFeatured][3] + "<br />";
	
	if(agentDt[indexFeatured][4] != "") {
		agentDetail += agentDt[indexFeatured][4] + "<br />";
	}
	
	if(agentDt[indexFeatured][5] != "") {
		agentDetail += agentDt[indexFeatured][5] + "," + agentDt[indexFeatured][6] + " " + agentDt[indexFeatured][7] + "<br />";
	} else {
		agentDetail += agentDt[indexFeatured][6] + " " + agentDt[indexFeatured][7] + "<br />";
	}
	
	if(agentDt[indexFeatured][8] != "") {
		agentDetail += agentDt[indexFeatured][8] + "<br />";
	}
	
	if(agentDt[indexFeatured][9] != "") {
		agentDetail += "<a href=\"http://" + agentDt[indexFeatured][9] + "\" target=\"_blank\" class=\"blue-link1\">" + agentDt[indexFeatured][9] + "</a><br /><br />";
	}
	
	if(agentDt[indexFeatured][11] != null && agentDt[indexFeatured][11] !="") {
		var desc = agentDt[indexFeatured][11];
		var finalDesc = "";
		var leng = desc.length;
	
		if(leng > 0) {
			if (leng > 100){
				finalDesc = desc.substring(0, 100);
			} else {
				finalDesc = desc;
			}
			agentDetail += finalDesc + "... <a href=\"" + SiteURLforJS + "/jsp/get_agent.jsp?agentId=" + agentDt[indexFeatured][0] + "&languageCode=" + agentDt[indexFeatured][1] + "&countryCode=" + agentDt[indexFeatured][2] + "\" target=\"_blank\" class=\"blue-link1\">" + agentDt[indexFeatured][14] + "</a><br />";
		}
	}
	agentDetail += "</div><div class=\"clear\"></div>";
	
	//Set the data to div 'agent-detail-rotate'
	if(document.getElementById("agent-detail-rotate") != null) {
		document.getElementById("agent-detail-rotate").innerHTML = agentDetail;
	}
}

/* Function for USA Today photo gallery on About USA page - start*/
function show_hide_comment(imagePath) {
 this.aboutTag = function () {
    var gotInput="";
    if(document.getElementById("plckphoto")){
	var nodes = document.getElementById("plckphoto").getElementsByTagName("div");
	var courtesyDivHtml = "<div class='courtesy' align='right'>"+courtesy_of+"&nbsp;&nbsp;<img src='"+imagePath+"/images/logo_Usa2day.gif'></div>";

	for(i=0;i<nodes.length;i++) {
		if(nodes.item(i).className == "GalleryPhoto_Heading"){
			gotInput = "1";
			nodes.item(i).innerHTML=nodes.item(i).innerHTML + courtesyDivHtml;
		}
	}
	
	var flag=false;
	var cookie_val=ReadCookie('HD');
	
	if(cookie_val != "") {
		var user = cookie_val.split("|");
		var user_email = user[3];
	
		var judges=judges_email.split(",");
		for(var i=0; i < judges.length; i++) {
			if(judges[i] == user_email) {
				flag=true;
			}
		}
	}
	
	if(flag == false) {
		if(document.getElementById("commentsiframe"))
			document.getElementById("commentsiframe").style.display = 'none';
	}
	
	if(document.getElementById("Comments_OuterContainer")){
		var nodes = document.getElementById("Comments_OuterContainer").getElementsByTagName("tr");
		var judgesDivHtml = "<div class='judges_comment-left'><h3>"+WhatJudgesSaid+"</h3></div><div class='clear'></div>";
	
		if(nodes.length > 0) {
			var divHtml = judgesDivHtml + document.getElementById("Comments_OuterContainer").innerHTML;
			document.getElementById("Comments_OuterContainer").innerHTML = divHtml;
		}
	}
    }
	if(gotInput==""){
		callmelateron();
		return;
	}
  }
}

function hide_shareyourphoto_Div(imagePath) {
 this.aboutTag = function () {
	var gotInput="";

	if(document.getElementById("plckgallery"))
	{
		var nodes = document.getElementById("plckgallery").getElementsByTagName("div");
		var courtesyDivHtml = "<div class='courtesy' align='right'>"+courtesy_of+"&nbsp;&nbsp;<img src='"+imagePath+"/images/logo_Usa2day.gif' border='0' /></div>";

		var flag=false;
		var admin_email="laura.uhart@gmail.com";
		var cookie_val=ReadCookie('HD');
	
		if(cookie_val != "") {
			var user = cookie_val.split("|");
			var user_email = user[3];
	
			var admin=admin_email.split(",");
			for(var i=0; i < admin.length; i++) {
				if(admin[i] == user_email) {
					flag=true;
				}
			}
		}
	
		for(i=0;i<nodes.length;i++) 
		{
    			if(nodes.item(i).className == "PublicGallery_Details")
			{
				gotInput = "1";
				if(flag == true)
	  				nodes.item(i).innerHTML=nodes.item(i).innerHTML+courtesyDivHtml;
				else
					nodes.item(i).innerHTML = courtesyDivHtml;
			}
    		}
		
	}
	if(gotInput==""){
		callmelateron();
		return;
	}
  }
}
/* Function for USA Today photo gallery on About USA page - end */

/* Functions for New US site - start */
function get_country_code() {
	var cookieCode = ReadCookie('caSiteCookie');
	return cookieCode;
}

function show_hide_through_IP(divId, country_code) {
	var code = get_country_code();
	if(code == country_code) {
		document.getElementById(divId).style.display = 'block';
	} else {
		document.getElementById(divId).style.display = 'none';
	}
}

function change_dropdown_value() {
	var code = get_country_code();
	
	if(document.getElementById("countryOfResidence_deal") != null) {
		for(var i=0; i < document.getElementById("countryOfResidence_deal").length; i++) {
			if(document.getElementById("countryOfResidence_deal").options[i].value == code)
				document.getElementById("countryOfResidence_deal").options[i].selected=true;
		}
	}

	if(document.getElementById("countryOfResidence_agent") != null) {
		for(var i=0; i < document.getElementById("countryOfResidence_agent").length; i++) {
			if(document.getElementById("countryOfResidence_agent").options[i].value == code)
				document.getElementById("countryOfResidence_agent").options[i].selected=true;
		}
	}

	if(document.getElementById("countryOfResidence_hotel") != null) {
		for(var i=0; i < document.getElementById("countryOfResidence_hotel").length; i++) {
			if(document.getElementById("countryOfResidence_hotel").options[i].value == code)
				document.getElementById("countryOfResidence_hotel").options[i].selected=true;
		}
	}
}

function NavTopChanges(imagePath, text) {
	var code = get_country_code();

	if(code == 'us') {
		var mainDivHtml = '<img src="'+imagePath+'/images/flagUsa.gif" border="0" />';
		document.getElementById("currentLangFlag").innerHTML = mainDivHtml;

		caFlagDiv = '<span class="langPos"><a href="/ca" onclick="SetCookie('+"'"+'caSiteCookie'+"'"+','+"'"+'ca'+"'"+',365)">'+text+'</a></span><a href="/ca" onclick="SetCookie('+"'"+'caSiteCookie'+"'"+','+"'"+'ca'+"'"+',365)"><img src="'+imagePath+'/images/flagCanada.gif" border="0" /></a>';
		usFlagDiv = '<span class="langPos">'+text+'</span><img src="'+imagePath+'/images/flagUsa.gif" border="0" />';
		document.getElementById("caLink").innerHTML = caFlagDiv;
		document.getElementById("usLink").innerHTML = usFlagDiv;	

		document.getElementById("AboutUSA").style.display = "none";
		document.getElementById("Entry").style.display = "none";
		
		if(document.getElementById("OfficialLinks"))
			document.getElementById("OfficialLinks").style.display = "block";
	} else {
		if(document.getElementById("OfficialLinks"))
			document.getElementById("OfficialLinks").style.display = "none";
	}
}

function changeHeaderClass() {
	if(document.getElementById("Places")) 	{
		document.getElementById("Places").className="Places";
		document.getElementById("txtPlaces").className="txtPlaces";
	}
	
	if(document.getElementById("Activities")) {
		document.getElementById("Activities").className="Activities";
		document.getElementById("txtActivities").className="txtActivities";
	}

	if(document.getElementById("Stories")) {
		document.getElementById("Stories").className="Stories";
		document.getElementById("txtStories").className="txtStories";
	}
	
	if(document.getElementById("AboutUSA")) {
		document.getElementById("AboutUSA").className="AboutUSA";
		document.getElementById("txtAboutUSA").className="txtAboutUSA";
	}

	if(document.getElementById("Entry")) {
		document.getElementById("Entry").className="Entry";
		document.getElementById("txtEntry").className="txtEntry";
	}

	if(document.getElementById("OfficialLinks")) {
		document.getElementById("OfficialLinks").className = "OfficialLinks";
		document.getElementById("txtOfficialLinks").className = "txtOfficialLinks";
	}

	if(document.getElementById("Booking")) {
		document.getElementById("Booking").className="Booking_sel";
		document.getElementById("txtBooking").className="txtBooking_sel";
	}
}

/* Set CountryCode to 'ca' if the site is Canada */
function getCountryCodeForCa(countryCode) {
	if(countryCode == 'ca' || countryCode == 'CA' || countryCode == 'us' || countryCode == 'US') {
		var cookieVal = get_country_code();
		
		if(cookieVal != 'US' && cookieVal != 'us') {
			countryCode = 'ca';
		}
	}
	
	return countryCode;
}
/* Functions for New US site - end */

/*Booking widget changes */
function changeHotelBookingWidget(countryOfResident) {
	var code = "";

	if(countryOfResident != "")
		code = document.getElementById(countryOfResident).value;
	if(code == "")
		code = get_country_code();

	if(document.getElementById("countryOfResidence_hotel") != null) {
		for(var i = 0; i < document.getElementById("countryOfResidence_hotel").length; i++) {
			if(document.getElementById("countryOfResidence_hotel").options[i].value == code)
				document.getElementById("countryOfResidence_hotel").options[i].selected = true;
		}
	}

	if(document.getElementById("us_countryOfResidence_hotel") != null) {
		for(var i = 0; i < document.getElementById("us_countryOfResidence_hotel").length; i++) {
			if(document.getElementById("us_countryOfResidence_hotel").options[i].value == code)
				document.getElementById("us_countryOfResidence_hotel").options[i].selected = true;
		}
	}

	if(code == 'us') {
		if(document.getElementById("cadata") != null)
			document.getElementById("cadata").style.display = "none";
		
		if(document.getElementById("usdata") != null)
			document.getElementById("usdata").style.display = "block";
		
		if(document.getElementById("bookText"))
			document.getElementById("bookText").style.display = "none";
		
		if(document.getElementById("usBookText"))
			document.getElementById("usBookText").style.display = "block";
	} else {
		if(document.getElementById("cadata") != null)
			document.getElementById("cadata").style.display = "block";

		if(document.getElementById("usdata") != null)
			document.getElementById("usdata").style.display = "none";
		
		if(document.getElementById("usBookText"))
			document.getElementById("usBookText").style.display = "none";		
		
		if(document.getElementById("bookText"))
			document.getElementById("bookText").style.display = "block";
	}
}

/* Function to get XMLHttpRequest object for Ajax calls */
function getRequestObject(self, xmlHttpReq) {
	if (window.XMLHttpRequest) {// Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {// IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (!self.xmlHttpReq) {
		alert('Giving up :(Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	
	return self.xmlHttpReq;
}

/* Function to get data for Official Links filters */
function getOfficialLinksFilterData(languageCode, countryCode) {
	var url = SiteURLforJS + '/jsp/officialLinksFilters.jsp';
	var xmlHttpReq = false;
	var self = this;
	
	self.xmlHttpReq = getRequestObject(self, xmlHttpReq);
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById("officialLinksFilters").innerHTML = self.xmlHttpReq.responseText;
				
				/* Set Destination radio button as default */
				setOfflinksDefault('officialLinks');
				document.officialLinks.locationDestination.style.display = 'block';
				document.getElementById("locDestRadio").checked = 'checked';
			}
		}
	};
	self.xmlHttpReq.send('languageCode='+languageCode+'&countryCode='+countryCode);
}

/* Function to get data for Official Links search */
function getOfficialLinkData(frmName, languageCode, countryCode, selected) {
	var selLocation = '';
	var selAttraction = '';
	var selCategory = '';
	var selViewAll = ''
	
	switch(selected) {
		case 'LOCATION_STATE':
			selLocation = eval("document." + frmName + ".locationState.options[document." + frmName + ".locationState.selectedIndex].value");
			setOfflinksDefault(frmName);
			eval("document." + frmName + ".locationState.style.display = 'block'");
			break;
		case 'LOCATION_REGION':
			selLocation = eval("document." + frmName + ".locationRegion.options[document." + frmName + ".locationRegion.selectedIndex].value");
			setOfflinksDefault(frmName);
			eval("document." + frmName + ".locationRegion.style.display = 'block'");
			break;
		case 'LOCATION_DESTINATION':
			selLocation = eval("document." + frmName + ".locationDestination.options[document." + frmName + ".locationDestination.selectedIndex].value");
			setOfflinksDefault(frmName);
			eval("document." + frmName + ".locationDestination.style.display = 'block'");
			break;
		case 'attraction':
			selAttraction = eval("document." + frmName + ".attraction.options[document." + frmName + ".attraction.selectedIndex].value");
			setOfflinksDefault(frmName);
			document.officialLinks.locationDestination.style.display = 'block';
			document.getElementById("locDestRadio").checked = 'checked';
			break;
		case 'category':
			selCategory = eval("document." + frmName + ".category.options[document." + frmName + ".category.selectedIndex].value");
			setOfflinksDefault(frmName);
			document.officialLinks.locationDestination.style.display = 'block';
			document.getElementById("locDestRadio").checked = 'checked';
			break;
		case 'viewAllLoc':
			setOfflinksDefault(frmName);
			selViewAll = 'viewAllLoc';
			document.officialLinks.locationDestination.style.display = 'block';
			document.getElementById("locDestRadio").checked = 'checked';
			break;
		case 'viewAllAtt':
			setOfflinksDefault(frmName);
			selViewAll = 'viewAllAtt';
			document.officialLinks.locationDestination.style.display = 'block';
			document.getElementById("locDestRadio").checked = 'checked';
			break;
		case 'viewAllCateg':
			setOfflinksDefault(frmName);
			selViewAll = 'viewAllCateg';
			document.officialLinks.locationDestination.style.display = 'block';
			document.getElementById("locDestRadio").checked = 'checked';
			break;
	}

	var url = SiteURLforJS + '/jsp/officialLinks.jsp';
	var xmlHttpReq = false;
	var self = this;
	
	self.xmlHttpReq = getRequestObject(self, xmlHttpReq, url);
	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById("officialLinksData").innerHTML = self.xmlHttpReq.responseText;
			}
		}
	};
	self.xmlHttpReq.send('locType='+ selected + '&location='+selLocation+'&attraction='+selAttraction+'&category='+selCategory+'&languageCode='+languageCode+'&countryCode='+countryCode+'&viewAll='+selViewAll);
}

/* Function to set data for Official Links elements to default search */
function setOfflinksDefault(frmName) {
	eval("document." + frmName + ".locationState.value = ''");
	eval("document." + frmName + ".locationRegion.value = ''");
	eval("document." + frmName + ".locationDestination.value = ''");
	eval("document." + frmName + ".attraction.value = ''");
	eval("document." + frmName + ".category.value = ''");
	eval("document." + frmName + ".locationState.style.display = 'none'");
	eval("document." + frmName + ".locationRegion.style.display = 'none'");
	eval("document." + frmName + ".locationDestination.style.display = 'none'");
}

function FooterChanges(imagePath, text){
	var code = get_country_code();

	if(code == 'us'){
		document.getElementById("Official Links").style.display = "none";
		document.getElementById("travelocity_partner").style.display = "none";
	}else{
		document.getElementById("Official Links").style.display = "block";
	}
}

function closeIntroSwf() {	
	document.getElementById('flashcontent').style.display='none';
}

function changeUSATHomeLink(){
	var code = get_country_code();
	if(code == 'us'){
		if(document.getElementById("usat")){
			gal = eval("about_usa_gallery_id");
				document.getElementById("usat").href = "/ca/about-usa-gallery.html?plckGalleryID="+gal;

		}
	}
}
function hideAboutUSATitle(divId){
	var code = get_country_code();
	if(code == 'us'){
		if(document.getElementById(divId))
			document.getElementById(divId).style.display = "none";
	}
}

/* Get XMLHttpRequest Object */
function getXmlHttpReqObj(self, xmlHttpReq, methodType, url) {
	if (window.XMLHttpRequest) {// Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {// IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (!self.xmlHttpReq) {
		alert('Giving up :(Cannot create an XMLHTTP instance) Please check the Browser Settings');
		return false;
	}
	self.xmlHttpReq.open(methodType, url, true);

	if(methodType == "POST" || methodType == "post") {
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	}
	
	return self.xmlHttpReq;
}

/* Display Activity Type details using AJAX call */
function getActivityTypeDetails(countryCode, languageCode, activityType, activityTypeKeyName, page) {
	var url = SiteURLforJS + '/jsp/activityTypeDetails.jsp';
	var xmlHttpReq = false;
	var self = this;
	
	self.xmlHttpReq = getXmlHttpReqObj(self, xmlHttpReq, "POST", url);
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			if (self.xmlHttpReq.status == 200) {
				document.getElementById("activityTypeDetails").innerHTML = self.xmlHttpReq.responseText;
			}
		}
	};

	if(page == null)
		page = 1;
	self.xmlHttpReq.send('countryCode=' + countryCode + '&languageCode=' + languageCode + '&activityType=' + activityType + '&page=' + page + '&activityTypeKeyName=' + activityTypeKeyName);
}