var eDt;
var eDur;
var eAdlt ;
var eSlp;
var eDtFlt;
var ePsnAgFlt;
var mElmFlt;
var infCutFlt;
var prtySzCutFlt;
var chngChlCntFlt;
var eRadMap;
var eTwnNmMap;
var eMp;
var noChldSelAge;
var trvlOptNtSel;
var invChar;
var mAdlt;
var mAr;
var mBed;
var mChld1;
var mChld2;
var mChld;
var mFlyFrm;
var mFlyTo;
var mGrd;
var mInf;
var mPrtnCd;
var mPrcRng;
var mPropRef;
var mRad;
var mReg;
var mRes;
var mStDt;
var mTwn;
var mRar;
var mUntType;
var commonImageUrl;
var enterPassAgeHieght;
var enterPassAgeWidth;
var iFrameLeft;
var iFrameTop;
var noOfChild=0;
var ie4 = false; 
var selectedFeature="";
var xmlDocCityUrl;
var status=false;
var multimapErrorStatus=false;
var sourceCd="";
var clickCd="";
var promoUrl="";
var isPushMerch=""
var campaign="";
var referalUrl="";
var rarName='';
var hdnRARInfo='' ;
var town='';
var openCityList = "";
var controlInnerHtml;

//Function to do an auto postback for the saerch page
function SelfPostback()
{
   document.getElementById("frmSearch").submit();
	
}
function post()
{
    document.getElementById("frmSearch").submit();
}
//Function to get the lattitude and longitude for a town search through Multimap call
function GetLocationLonLat()
{
	var callLatLon = 0;
	var cityName;
	town = document.getElementById("txtTown");
	var radius = document.getElementById("cmbRadius")	
	var txtPeriphery = document.getElementById("txtPeriphery")			
	if(town!=null && radius!=null && txtPeriphery.value.length ==0)
	{
		if(radius.length>1)
		{
			if(Trim(town.value).length>0 && radius.value!="0")
			{
				cityName = town.value;
				callLatLon = 1;
			}	
			else if(Trim(town.value) .length>0 && radius.value=="0")
			{
				alert(eRadMap);
				return false;
			}
			else if(Trim(town.value).length==0 && radius.value!="0")
			{
				alert(eTwnNmMap);
				return false;
			}
		}
		else
		{
			alert(eRadMap);
			return false;
		}
	}
	else if(town!=null && radius == null)
	{
		alert(eRadMap);
		return false;
	}
	else if(document.getElementById("tabMapHolder")!=null && radius != null)
	{
		if(radius.length>1)
		{	
			if(radius.value != "0" && txtPeriphery.value.length ==0)
			{
				alert(eMp);
				return false;
			}
			if(radius.value == "0" && txtPeriphery.value.length !=0)
			{
				alert(eRadMap);
				return false;
			}
		}
		else if(txtPeriphery.value.length !=0)
		{
			alert(eRadMap);
			return false;
		}	
	}
	return true;
}
//Function to set the no of children for 'EnterPassengerAges' page
function SetNoOfChild() 
{
	noOfChild = 0;
	var children = 0;
	var child = document.getElementById("cmbChildren");
	if (child!=null && child.length>0)
	{
		noOfChild = child.value;		
	}	
}
//Function to handle the show-hide logic for flight section when user choose different travel option
function ShowHideFlight() 
{
	var rdbTravelOpt = document.getElementById("rdbTravelOptions");
	var tabFlight = document.getElementById("tabFlight");
	var tabError = document.getElementById("tabError");
	var lblErrorMessage = document.getElementById("lblErrorMessage");	
	var defTravelOpt = document.getElementById( "hdnDefTravelOpt" ).value; 	
		
	if (rdbTravelOpt!=null)
	{			
		var radioList = rdbTravelOpt.getElementsByTagName( "INPUT" );
		if(radioList.length>0)
		{
			if(tabFlight != null)
				tabFlight.style.display = "none";
		}
		for( count= 0 ; count< radioList.length ; count++ )
		{
			if( radioList[ count ].type == "radio" && radioList[ count ].checked )
			{				
				if( radioList[ count ].value == "FLIGHTINCLUSIVE" )
				{
					if(tabFlight != null)
						tabFlight.style.display = "block";	
					if(lblErrorMessage!=null && lblErrorMessage.firstChild!=null && lblErrorMessage.firstChild.nodeValue.length != 0 && tabError!=null)
					{
						lblErrorMessage.style.display = "block";
						tabError.style.display = "block";
					}
					ShowChildInfantControls();										
				}
				else
				{
					if(tabFlight != null)
						tabFlight.style.display = "none";
					
					if(lblErrorMessage!=null && tabError!=null)
					{
						lblErrorMessage.style.display = "none";
						tabError.style.display = "none";
					}
					HideChildInfantControls();
				}
			}
		}	
	}
	else if( defTravelOpt == "FLIGHTINCLUSIVE" )
	{
		ShowChildInfantControls();
	}
	else
	{
		HideChildInfantControls();
	}
}
//Function to show the Child and Infant related controls
function ShowChildInfantControls() 
{
	var cmbChildren = document.getElementById("cmbChildren");
	var cmbInfants = document.getElementById("cmbInfants");
	var lblAdults = document.getElementById("lblAdults");
	var cmbAdults = document.getElementById("cmbAdults");
	var lblChildren = document.getElementById("lblChildren");
	var lblInfants = document.getElementById("lblInfants");
	var cmbSleeps = document.getElementById("cmbSleeps");
	var lblSleeps = document.getElementById("lblSleeps");
	if(cmbChildren!=null)
		cmbChildren.style.display = "inline";
	if(cmbInfants!=null)
		cmbInfants.style.display = "inline";
	if(cmbAdults!=null)
		cmbAdults.style.display = "inline";
	if(lblAdults!=null)
		lblAdults.style.display = "inline";
	if(lblChildren!=null)
		lblChildren.style.display = "inline";
	if(lblInfants!=null)
		lblInfants.style.display = "inline";
	if(cmbSleeps!=null)
		cmbSleeps.style.display = "none";
	if(lblSleeps!=null)
		lblSleeps.style.display = "none";
}
//Function to hide the Child and Infant related controls
function HideChildInfantControls() 
{
	var cmbChildren = document.getElementById("cmbChildren");
	var cmbChild1 = document.getElementById("cmbChild1");
	var cmbChild2 = document.getElementById("cmbChild2");
	var cmbInfants = document.getElementById("cmbInfants");
	var cmbAdults = document.getElementById("cmbAdults");
	var lblAdults = document.getElementById("lblAdults");
	var lblChildren = document.getElementById("lblChildren");
	var lblInfants = document.getElementById("lblInfants");
	var cmbSleeps = document.getElementById("cmbSleeps");
	var lblSleeps = document.getElementById("lblSleeps");
	if(cmbChildren!=null)
		cmbChildren.style.display = "none";
	if(cmbChild1!=null)
		cmbChild1.style.display = "none";
	if(cmbChild2!=null)
		cmbChild2.style.display = "none";	
	if(cmbInfants!=null)
		cmbInfants.style.display = "none";
	if(cmbAdults!=null)
		cmbAdults.style.display = "none";
	if(lblAdults!=null)
		lblAdults.style.display = "none";
	if(lblChildren!=null)
		lblChildren.style.display = "none";
	if(lblInfants!=null)
		lblInfants.style.display = "none";
	if(cmbSleeps!=null)
		cmbSleeps.style.display = "inline";
	if(lblSleeps!=null)
		lblSleeps.style.display = "inline";
}
//Function to handle body on-load functionality
function PageOnLoad() 
{
	var tabMapHolder = document.getElementById("tabMapHolder");
	var ovrvwMapClicked = document.getElementById("hdnOverViewMapClickIndicator");
	if(tabMapHolder!=null && ovrvwMapClicked.value == "0")
	{
		LoadInteractiveMap();
	}
	else if(tabMapHolder!=null && ovrvwMapClicked.value == "1")
	{
		//fetchPixel();
		CallMultimapOnPostBack();
	}
	//Code for hiding travel options in page in case of only one travel option offered for a country in a site
	var tabTrvlOpt = document.getElementById("tabTravelOpt");
	
	//Code for focusing arrival airport while change of departure airport
	var depAptChnged = document.getElementById("hdnDepAptChnged")
	var arrApt = document.getElementById("cmbFlyingTo")
	if(depAptChnged != null && depAptChnged.value == "1")
	{
		if(arrApt != null && arrApt.length > 0)
			arrApt.focus();
		depAptChnged.value = "0";
	}	
	if(openCityList)
	{
	    windowProperties = 'height=' + 500 + ',width=' + 500 + ',left=270,top=180,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes';
	    window.open("CityList.aspx?siteGuid="+document.getElementById('hdnSiteGuid').value,"rar",windowProperties);
	}
	ShowHideFlight();
	var startdate = document.getElementById("txtStartDate");
	if(startdate != null)
	{
	    startdate.value = startdate.value.replace(/&lt;/g,"<");
	}
	var partnerCd = document.getElementById("txtPartnerCode");
	if(partnerCd != null)
	{
	    partnerCd.value = partnerCd.value.replace(/&lt;/g,"<");
	}
	var propRef = document.getElementById("txtPropertyRef");
	if(propRef!=null)
	{
	    propRef.value = propRef.value.replace(/&lt;/g,"<");
	}
	var town = document.getElementById("txtTown");
	if(town != null)
	{
	    town.value = town.value.replace(/&lt;/g,"<");
	}
	ShowHideSBT();
	populateSelectedFeature();

}
if(document.all) { ie4 = true; }
function getObject(id) 
{
	if (ie4) 
		{return document.all[id]; }
		else 
		{ return document.getElementById(id); 
	}
}
// This function expand/ collapse the Divs
function toggle(image,divId) 
{
	var imageUrl = image.src;
	var d = getObject(divId);
	if (imageUrl.indexOf('zoomInIcon.gif') > 0 ) 
	{
		image.src = commonImageUrl + 'zoomOutIcon.gif'; 
		d.style.display = "block"; 
	}
	else
	{ 
		image.src = commonImageUrl + 'zoomInIcon.gif'; 
		d.style.display = "none"; 
	}
} 
// This function select/unselect the Checkboxs of feature
function SelectFeature(Feature,chkBoxIds)
{
	var arrCheckBoxId = chkBoxIds.split("|");
	var checkBox;
	if(Feature.checked==true)
	{
		for (var i=0;i<arrCheckBoxId.length-1;i++)
		{
			checkBox = document.getElementById(arrCheckBoxId[i]); 
			if(checkBox != null)
				checkBox.checked = true;
		}
	}
	else
	{
		if(chkBoxIds.search(/.\|./)>0)
		{
			for(var i=0;i<arrCheckBoxId.length-1;i++)
				document.getElementById(arrCheckBoxId[i]).checked = false;
		}
		else
		{
			checkBox = document.getElementById(chkBoxIds); 
			if(checkBox != null)
				checkBox.checked = false;
		}
	}
}
//Function to show the frame with RAR mapping info
function ShowSearchCriteria(searchWindow,countryCd)
{
	fetchUserInputOnPostback();
	var control = document.getElementById("spncmbRegion");
	if(control == null)
	    control= document.getElementById("spncmbArea");
	
	controlInnerHtml = control.innerHTML;
	control.style.display="none";
	var ddl = new Array("cmbGrading","cmbPriceRange","cmbNoBedroom","cmbRegion","cmbArea","cmbResort","cmbRadius","cmbSleeps","cmbAdults","cmbChildren","cmbInfants","cmbLengthofStay","cmbFlyingTo","cmbFlyingFrom","cmbCountry");
	for (var i = 0; i < ddl.length; i++)
	{
	    var span = document.getElementById("spn"+ddl[i]);
	    if(span!= null && ddl[i] != null)
	    {
	        ddlList = document.getElementById(ddl[i]);
                if( ddlList != null && ddlList.selectedIndex >= 0)
	        span.innerHTML = ddlList.options[ddlList.selectedIndex].text;
	    }
	}
	
	control.innerHTML = "";
	launch_file_upload_internal_dialog();	
	control.innerHTML = controlInnerHtml;
}
//Function to hide the RAR hierchical display frame
function HideSearch(searchWindow)
{
	var hdnTownLatLong = parent.document.getElementById("hdnTownLatLong");
	var hdnRARInfo = parent.document.getElementById("hdnRARInfo");
	if(hdnTownLatLong != null)
	{
		hdnTownLatLong.value = "";
	}
	if(hdnRARInfo != null)
	{
		hdnRARInfo.value = "";
	}
    opener.fetchUserInputOnPostback();
	opener.SelfPostback();
	hide_modal_dialog();
	self.close();
	return false;
}
//Function to capture the selected value for RAR 
function SelectValue(text,value)
{
    
	var control = document.getElementById("cmbRegion");
	if(control == null)
	    control =document.getElementById("cmbArea");
	text = text.replace(/~/g,"'");
	control.options[0].text = text;
	control.options[0].value = value;
	document.getElementById("hdnRARInfo").value = value.replace(/_/g,",") + "," + text;
    //fetchUserInputOnPostback();
	SelfPostback();	
}
//Function to Save the latitude and longitude of the selected place
function SelectCity(lat,lon,city)
{
    var txtTown = parent.document.getElementById("txtTown");
	parent.document.getElementById("hdnTownLatLong").value = lat + '^' + lon + '^' + city;
    if(txtTown != null)
		txtTown.value = city;
    parent.fetchUserInputOnPostback();
    parent.SelfPostback();
}
//Function to open calendar window
function ShowCal(controlName)
{
	var url;
	var windowProperties;	
	var controlStartDate = document.getElementById(controlName);
	
	if(!ValidateDate(controlStartDate))
		return false;
	ValidateMessage("txtPartnerCode"); 
	ValidateMessage("txtPropertyRef");   
	ValidateMessage("txtTown");   
	OpenCalendar(controlName,earliestStartDate,null) ;
	var partnerCd = document.getElementById("txtPartnerCode");
	if(partnerCd != null)
	{
	    partnerCd.value = partnerCd.value.replace(/&lt;/g,"<");
	}
	var propRef = document.getElementById("txtPropertyRef");
	if(propRef!=null)
	{
	    propRef.value = propRef.value.replace(/&lt;/g,"<");
	}
	var town = document.getElementById("txtTown");
	if(town != null)
	{
	    town.value = town.value.replace(/&lt;/g,"<");
	}
	return false;
}
function Selection(element)
{
	var type=element.charAt(0);
	var valueField=element.substring(2,element.length);
	var cmbRegion = document.getElementById('cmbRegion');
	var cmbArea = document.getElementById('cmbArea');
	var cmbResort = document.getElementById('cmbResort');
	if(type=='R' && cmbRegion!=null) 
	{
		if(cmbRegion.length > 1)
		{
			cmbRegion.value=valueField;
			document.getElementById('hdnRegionInfo').value = valueField;
			fetchUserInputOnPostback();
			__doPostBack('cmbRegion','');
		}
	}
	else if(type=='A' && cmbArea!=null) 
	{
		if(cmbArea.length > 1)
		{
			cmbArea.value=valueField;
			document.getElementById('hdnAreaInfo').value = valueField;
			fetchUserInputOnPostback();
			__doPostBack('cmbArea','');
		}
	}
	else if(type=='S' && cmbResort!=null) 
	{
		if(cmbResort.length > 1)
		{
			cmbResort.value=valueField;
			document.getElementById('hdnResortInfo').value = valueField;
			fetchUserInputOnPostback();
			__doPostBack('cmbResort','');
		}
	}
}
function Rar(elementName,elementVal) 
{
	var cmbRar=document.getElementById('cmbRegion');
	if(cmbRar != null)
	{
		cmbRar.options[0].value=elementVal;
		cmbRar.options[0].text=elementName;
		document.getElementById('hdnRARInfo').value = elementVal+','+elementName;
		fetchUserInputOnPostback();
		__doPostBack('cmbRegion','');
	}
}
function regionOnClick() 
{
	var regionClickInd= document.getElementById( "hdnRegionClickedInd" ) ; 
	var cmbCountry = document.getElementById( "cmbCountry" ) ; 
	if(regionClickInd != null)
	{	l
		regionClickInd.value = "1";
	}
	if(cmbCountry != null)
		cmbCountry.disabled = true ;
	fetchUserInputOnPostback();
	
}
function resortOnClick() 
{
	var resortClickInd= document.getElementById( "hdnResortChnged" ) ;
	
	if(resortClickInd != null)
	{
		resortClickInd.value = "1";
	}      
   fetchUserInputOnPostback();
}
function areaOnClick() 
{
	var areaClickInd= document.getElementById( "hdnAreaClickedInd" ) ;
	
	if(areaClickInd != null)
	{
		areaClickInd.value = "1";
	}      
   fetchUserInputOnPostback();
}
function countryOnChage() 
{
	var countryClickInd= document.getElementById( "hdnCountryClickedInd" ) ;
	
	if(countryClickInd != null)
	{
		countryClickInd.value = "1";
	}      
   fetchUserInputOnPostback();
}
function depAptChanged() 
{
	var hdnDepAptChnged= document.getElementById( "hdnDepAptChnged" ) ;
	
	if(hdnDepAptChnged != null)
	{
		hdnDepAptChnged.value = "1";
	}      
   fetchUserInputOnPostback();
}
//Function to open child ages window
function OpenChildAgesWindow()
{
	if(noOfChild == 0)
	{
		alert(noChldSelAge);
		return;
	}
	var url;
	var windowProperties;
	document.getElementById("hdnNoChildForEnterPsngrAge").value = noOfChild;
	url= "EnterPassengerAges.aspx?NoOfChildren="+noOfChild+"&SiteGuid="+document.getElementById( "hdnSiteGuid" ).value+"&chldAge="+document.getElementById( "hdnChildAge" ).value; 
	windowProperties = 'height=' + enterPassAgeHieght + ',width=' + enterPassAgeWidth + ',left=270,top=180,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes';

	window.open(url,'childage_window',windowProperties);
}
//Function to handle radio button checked event for search result display in list/map
function ValidateSelect(controlId)
{
	var rdbOnAMap = parent.document.getElementById("rdbOnAMap");
	var rdbAsAList = parent.document.getElementById("rdbAsAList");
		
	if(controlId == "rdbAsAList")
	{		
		rdbAsAList.checked = true;
	
		// unchecking while checking the other one
		if(rdbOnAMap != null && rdbOnAMap.checked)
		{
			rdbOnAMap.checked = false;
		}
	}
	else
	{
		if(rdbOnAMap != null)
		{
			rdbOnAMap.checked = true;
		}
		
		// unchecking while checking the other one
		if(rdbAsAList != null && rdbAsAList.checked)
		{
			rdbAsAList.checked = false;
		}
	}
}
function ValidatePartnerCode()
{
	var txtPartnerCode = document.getElementById("txtPartnerCode");
	if(txtPartnerCode != null && txtPartnerCode.value.length !=0)
	{
		if(!FilterWildCharacters("txtPartnerCode",'!,",$,\',%,&,(,),-,_,+,=,[,],{,},:,;,@,#,|,<,>,.,/,?,',''))
		{
			return false;
		}
	}
	return true;
}
//Function to check whether all the search parameters are filled or not
function ValidatePropRefSearch()
{
	var propertyRef = document.getElementById( "txtPropertyRef" ) ;	
	if(propertyRef!=null && Trim(propertyRef.value).length ==0)
	{
		alert(mPropRef);
		propertyRef.focus();
		return false;
	}
	else
	{
	    var url = populatePropResSearchUrl(propertyRef.value);
	    location.href = url;
	    return false;
	}
	
}
//Function to check whether all the search parameters are filled or not
function ValidateSearch()
{
	var status =true;
	var startDate = document.getElementById("txtStartDate");
	var lengthofStay = document.getElementById("cmbLengthofStay");
	var travelOptions = document.getElementById("rdbTravelOptions");
	var cmbAdults = document.getElementById("cmbAdults");
	var cmbSleeps = document.getElementById("cmbSleeps");
	var txtTown = document.getElementById("txtTown");
	if(!ValidateMandatoryFiled())
	{
		return false;
	}
	if(travelOptions != null)
	{
		var radioList = travelOptions.getElementsByTagName( "INPUT" );
		var selected = false;
		for( count= 0 ; count< radioList.length ; count++ )
		{
			if( radioList[ count ].type == "radio" && radioList[ count ].checked )
			{	
				selected = true;
				break;
			}
		}
		if(!selected)
		{
			alert(trvlOptNtSel);
			return false; 
		}
	}
	if(startDate != null && lengthofStay != null)
	{
		if ((startDate.value.length == 0 && lengthofStay.value == "0")
		||(startDate.value.length == 0 && lengthofStay.length == 0))
		{
			//if user has selected for flight search, but has selected neither holiday start date nor length of stay
			if(travelOptions != null)
			{
				var radioList = travelOptions.getElementsByTagName( "INPUT" );
				for( count= 0 ; count< radioList.length ; count++ )
				{
					if( radioList[ count ].type == "radio" && radioList[ count ].checked )
					{						
						if( radioList[ count ].value == "FLIGHTINCLUSIVE" )
						{
							alert(eDtFlt);								
							startDate.focus();
							return false; 
						}
					}
				}				
			}	
		}
		//if user has selected holiday start date, has not selected any length of stay					
		if ((startDate.value.length != 0 && lengthofStay.value == "0")
		||(startDate.value.length != 0 && lengthofStay.length == 0))
		{	
			alert(eDur);								
			lengthofStay.focus();
			return false; 
		}
		//if user has selected length of stay, has not selected any holiday start date			
		if (startDate.value.length ==0 && lengthofStay.value != "0" && lengthofStay.value.length != 0)
		{	
			alert(eDt);								
			startDate.focus();
			return false; 
		}
		//if user has opted for dated search, but has not selected any no of adults/sleeps 
		if (startDate.value.length != 0  && lengthofStay.value != "0" && lengthofStay.value.length != 0)
		{	
			if(cmbAdults != null && cmbAdults.style["display"]!="none" && cmbAdults.value == "0")
			{	
				alert(eAdlt);					
				cmbAdults.focus();
				return false;
			}
			if(cmbSleeps != null && cmbSleeps.style["display"]!="none"&& cmbSleeps.value == "0")
			{	
				alert(eSlp);					
				cmbSleeps.focus();
				return false; 
			}	
		}				
	}
	if(!ValidateDate(startDate))
		return false;
		
	if(!ValidatePartnerCode())
		return false;		
	if(travelOptions != null)
	{
		var travelOptList = travelOptions.getElementsByTagName( "INPUT" );
		for( count= 0 ; count< travelOptList.length ; count++ )
		{
			if( travelOptList[ count ].type == "radio" && travelOptList[ count ].checked )
			{						
				if( travelOptList[ count ].value == "FLIGHTINCLUSIVE" )
				{
					if(!ValidateFlightOnSubmit())
					{
						return false;
					}					
				}
			}			
		}
	}
	else
	{
		var defTravelOpt = document.getElementById( "hdnDefTravelOpt" ).value; 	
		if( defTravelOpt == "FLIGHTINCLUSIVE" )
		{
			if(!ValidateFlightOnSubmit())
			{
				return false;
			}					
		}
	}
	if(!GetLocationLonLat())
	{
		return false;
	}
	if(txtTown != null && txtTown.value.length > 0)
	{
		fetchUserInputOnPostback();	
		var hdnQueryString = document.getElementById("hdnQueryString");
		if(hdnQueryString!=null)
		{
		    hdnQueryString.value = fetchUserInputOnSubmit();
		}
	}
	else
	{   fetchUserInputOnPostback();
		var strRedirectUrl = fetchUserInputOnSubmit();
		location.href = strRedirectUrl;
		return false;
	}	
	return true;		
}
//Function to perform the flight related validation
function ValidateFlightOnSubmit() 
{ 	
	var adultCount = 0;
	var infantCount = 0;
	var childCount = 0;
	var partyCount = 0;
	var cmbAdults = document.getElementById("cmbAdults");
	var cmbSleeps = document.getElementById("cmbSleeps");
	var flyingFrom = document.getElementById("cmbFlyingFrom");
	var flyingTo = document.getElementById("cmbFlyingTo");
	var cmbChildren = document.getElementById("cmbChildren");
	var cmbChild1 = document.getElementById("cmbChild1");
	var cmbChild2 = document.getElementById("cmbChild2");
	var cmbInfants = document.getElementById("cmbInfants");
	//if user has selected for flight inclusive travel option, but user has not selected any departure airport
	if(flyingFrom != null)
	{	
		if (flyingFrom.value == "0" || flyingFrom.value.length == 0)
		{			
			alert(mElmFlt);						
			flyingFrom.focus();
			return false;
		}
	}
	else
	//if user has selected for flight inclusive travel option, but there is no drop down for departure airport 					
	{
		alert(mElmFlt);
		return false;
	}
	//if user has selected for flight inclusive travel option, but user has not selected any arrival airport
	if(flyingTo != null)
	{	
		if (flyingTo.value == "0" || flyingTo.value.length == 0)
		{			
			alert(mElmFlt);						
			flyingTo.focus();
			return false;
		}
	}
	else
	//if user has selected for flight inclusive travel option, but there is no drop down for arrival airport 					
	{
		alert(mElmFlt);
		return false;
	}
	if(cmbAdults != null && cmbAdults.value.length != 0)
	{	
		adultCount = parseInt(cmbAdults.value,10); 
	}
	else if(cmbSleeps != null && cmbSleeps.value.length !=0)
	{
	    adultCount = parseInt(cmbSleeps.value,10);
	}
	if(cmbChildren != null && cmbChildren.value.length != 0)
	{	
		childCount = parseInt(cmbChildren.value,10); 
	}	
	if(cmbInfants != null && cmbInfants.value.length != 0)
	{	
		infantCount = parseInt(cmbInfants.value,10); 
	}
	//if user has selected for flight inclusive travel option, but user has not selected given any of the passenger age details or he has not clicked on 'Enter passenger Details' link at all
	if(document.getElementById( "hdnPsngrAgeIndicator" ).value == "0" && childCount != 0)
	{	
		alert(ePsnAgFlt);
		return false;			
		
	}
	partyCount = adultCount + childCount + infantCount;
	//if user has changed the party compostion after entering the passenger ages
	if(childCount != parseInt(document.getElementById("hdnNoChildForEnterPsngrAge").value,10) && childCount != 0)
	{
		alert(chngChlCntFlt);
		return false;
	}
	//if no of infants is greater than no of adults for multicom booking request
	if(infantCount > adultCount	)
	{						
		alert(infCutFlt);
		return false; 		
	}
	//if party count is greater than 8 for multicom booking request
	if(partyCount > 8 )
	{									
		alert(prtySzCutFlt);		
		return false; 		
	}
	return true;
}
//Function to set passenger age verification indicator in a hidden field
function SetPsngrAgeIndicator( psngrAgeIndicatorValue ) 
{ 
	document.getElementById( "hdnPsngrAgeIndicator" ).value = psngrAgeIndicatorValue ; 
}
//Function to check whether user has given any input for a mandatory field set by Site-Admin
function ValidateMandatoryFiled() 
{ 	
	var partnerCode = document.getElementById( "txtPartnerCode" ) ;	
	if(partnerCode!=null)
	{
		if(partnerCode.getAttribute("mandatory") == "Y" && (Trim(partnerCode.value)).length == 0)
		{
			alert(mPrtnCd);
			partnerCode.focus();
			return false;
		}
	}
	var propertyRef = document.getElementById( "txtPropertyRef" ) ;	
	if(propertyRef!=null)
	{
		if(propertyRef.getAttribute("mandatory") == "Y" && (Trim(propertyRef.value)).length == 0)
		{
			alert(mPropRef);
			propertyRef.focus();
			return false;
		}
	}
		
	var grading = document.getElementById( "cmbGrading" ) ;	
	if(grading!=null)
	{
		if(grading.getAttribute("mandatory") == "Y" && (grading.value.length == 0 || grading.value=="0"))
		{
			alert(mGrd);
			grading.focus();
			return false;
		}
	}
	var priceRange = document.getElementById( "cmbPriceRange" ) ; 
    if(priceRange !=null)
    {
        if(priceRange.getAttribute("mandatory") == "Y" && (priceRange.value.length == 0 || priceRange.value=="0"))
        {
            alert(mPrcRng);
            priceRange.focus();
            return false;
        }
    }
	var bedroom = document.getElementById( "cmbNoBedroom" ) ;  
    if(bedroom  !=null) 
    {
        if(bedroom.getAttribute("mandatory") == "Y" && (bedroom.value.length == 0 || bedroom.value=="0"))
        {
            alert(mBed);
            bedroom.focus();
            return false;
        }
    }    
    
    var region= document.getElementById( "cmbRegion" ) ;
    if(region!=null)   
    {      
        if(region.getAttribute("mandatory") == "Y" && (region.value.length == 0 ||region.value=="0"))
        {
            alert(mReg);
            region.focus();
            return false;
        }
    }   
    var area= document.getElementById( "cmbArea" ) ; 
    if( area!=null) 
    {    
        if( area.getAttribute("mandatory") == "Y" && ( area.value.length == 0 ||area.value=="0"))
        {
            alert(mAr);
            area.focus();
            return false;
        }
    }    
    var resort= document.getElementById( "cmbResort" ) ; 
    if( resort!=null)  
    {          
        if( resort.getAttribute("mandatory") == "Y" && ( resort.value.length == 0 || resort.value=="0"))
        {
            alert(mRes);
            resort.focus();
            return false;
        }
    }   
    var town = document.getElementById( "txtTown" ) ; 
    if(town!=null)
    { 
        if(town.getAttribute("mandatory") == "Y" && Trim(town.value).length==0)
        {
            alert(mTwn);
            town.focus();
            return false;
        }
    }    
	var radius= document.getElementById( "cmbRadius" ) ;   
    if( radius!=null)  
    {          
        if( radius.getAttribute("mandatory") == "Y" && ( radius.value.length == 0 || radius.value=="0"))
        {
            alert(mRad);
            radius.focus();
            return false;
        }
    }  
    var sleeps= document.getElementById( "cmbSleeps" ) ;   
    if( sleeps!=null)  
    {          
        if( sleeps.getAttribute("mandatory") == "Y" && ( sleeps.value.length == 0 || sleeps.value=="0"))
        {
            alert(eSlp);
            sleeps.focus();
            return false;
        }
    }    
    var adults= document.getElementById( "cmbAdults" ) ; 
    if( adults!=null)  
    {          
        if( adults.getAttribute("mandatory") == "Y" && ( adults.value.length == 0 || adults.value=="0"))
        {
            alert(eAdlt);
            adults.focus();
            return false;
        }
    }   
    var children= document.getElementById( "cmbChildren" ) ; 
    if( children!=null)  
    {          
		if( children.getAttribute("mandatory") == "Y" && ( children.value.length == 0 ||children.value=="0"))
		{
			alert(mChld);
			children.focus();
			return false;
		}
    }    
    
    var infants= document.getElementById( "cmbInfants" ) ;   
    if( infants!=null) 
    {          
        if( infants.getAttribute("mandatory") == "Y" && ( infants.value.length == 0 ||infants.value=="0"))
        {
            alert(mInf);
            infants.focus();
            return false;
        }
    }   
    var lengthOfStay= document.getElementById( "cmbLengthofStay" ) ;        
    if( lengthOfStay!=null)   
    {        
        if( lengthOfStay.getAttribute("mandatory") == "Y" && ( lengthOfStay.value.length == 0 ||lengthOfStay.value=="0"))
        {
            alert(eDur);
            lengthOfStay.focus();
            return false;
        }
    }   
    var startDate = document.getElementById( "txtStartDate" ) ;        
    if(startDate!=null)
    { 
        if(startDate.getAttribute("mandatory") == "Y" && startDate.value.length == 0)
        {
            alert(mStDt);
            startDate.focus();
            return false;
        }
    } 
	return true;
}
function Trim(Value)
{	
	var len=Value.length;
	var i;
	for ( i=0;i<len;i++)
	{	
		if (Value.charAt(0)==" ")
		{
			Value=Value.substr(1);
		}
		else
		{
			break;
		}
	}
	if (Value!=null)
	{
		len=Value.length;
		for (i=len;i!=-1;i--)
		{
			len1=Value.length;
			if (Value.charAt(len1-1)==" ")
			{
				Value=Value.substr(0,len1-1);
			}
			else
				break;
		}
	}	
	return Value;
}
function fetchUserInputOnPostback()
{
	var partyComp;
	var strBuilder;
	var cmbCountry = document.getElementById('cmbCountry');
	var cmbRegion = document.getElementById('cmbRegion');
	var cmbArea = document.getElementById('cmbArea');
	var cmbResort = document.getElementById('cmbResort');
	var cmbGrading = document.getElementById('cmbGrading');
	var cmbPriceRange = document.getElementById('cmbPriceRange');
	var cmbNoBedroom = document.getElementById('cmbNoBedroom');
	var cmbUnitType = document.getElementById('cmbUnitType');
	var cmbRadius = document.getElementById('cmbRadius');
	var cmbSleeps = document.getElementById('cmbSleeps');
	var cmbAdults = document.getElementById('cmbAdults');
	var cmbChildren = document.getElementById('cmbChildren');
	var cmbChild1 = document.getElementById('cmbChild1');
	var cmbChild2 = document.getElementById('cmbChild2'); 
	var cmbInfants = document.getElementById('cmbInfants');
	var cmbLengthofStay = document.getElementById('cmbLengthofStay');
	var cmbFlyingFrom = document.getElementById('cmbFlyingFrom');
	var rdbTrvlOpt = document.getElementById('rdbTravelOptions');
	var rdbUnitType = document.getElementById('rdbUnitTypes');
	var hdnCountryCd = document.getElementById('hdnCountryCd');
	var hdnRegionInfo = document.getElementById('hdnRegionInfo');
	var hdnAreaInfo = document.getElementById('hdnAreaInfo');
	var hdnResortInfo = document.getElementById('hdnResortInfo');
	var hdnGrading = document.getElementById('hdnGrading');
	var hdnPriceRange = document.getElementById('hdnPriceRange');
	var hdnNoBedroom = document.getElementById('hdnNoBdroom');
	var hdnUnitType = document.getElementById('hdnUnitType');
	var hdnRadius = document.getElementById('hdnRadius');
	var hdnPartyComp = document.getElementById('hdnPartyComp');
	var hdnDur = document.getElementById('hdnDur');	
	var hdnDepApt = document.getElementById('hdnDepApt');
	var hdnTrvlOpt = document.getElementById('hdnTrvlOpt');	
	if(hdnCountryCd != null && cmbCountry != null && cmbCountry.length > 0)
	{	
		hdnCountryCd.value = cmbCountry.value;
	}
	if(hdnRegionInfo != null && cmbRegion != null && cmbRegion.length > 0)
	{	
		hdnRegionInfo.value = cmbRegion.value;
	}
	if(hdnAreaInfo != null && cmbArea != null && cmbArea.length > 0)
	{	
		hdnAreaInfo.value = cmbArea.value;
	}
	if(hdnResortInfo != null && cmbResort != null && cmbResort.length > 0)
	{	
		hdnResortInfo.value = cmbResort.value;
	}
	if(hdnGrading != null && cmbGrading != null && cmbGrading.length > 0)
	{	
		hdnGrading.value = cmbGrading.value;
	}
	if(hdnPriceRange != null && cmbPriceRange != null && cmbPriceRange.length > 0)
	{	
		hdnPriceRange.value = cmbPriceRange.options[cmbPriceRange.selectedIndex].text;
				
	}
	if(hdnNoBedroom != null && cmbNoBedroom != null && cmbNoBedroom.length > 0)
	{	
		hdnNoBedroom.value = cmbNoBedroom.value;
	} 
	if(hdnUnitType != null && cmbUnitType != null && cmbUnitType.length > 0)
	{	
		hdnUnitType.value = cmbUnitType.value;
	}
	if(hdnRadius != null && cmbRadius != null && cmbRadius.length > 0)
	{	
		hdnRadius.value = cmbRadius.value;
	}
	if(hdnPartyComp != null && cmbSleeps != null && cmbSleeps.style["display"]!="none" &&cmbSleeps.length > 0)
	{	
		hdnPartyComp.value = cmbSleeps.value;
	}
	if(hdnPartyComp != null && cmbAdults != null && cmbAdults.style["display"]!="none" && cmbAdults.length > 0)
	{	
		hdnPartyComp.value = cmbAdults.value;
	}
	if(hdnPartyComp != null && cmbChildren != null)
	{	
		strBuilder = new Array();
		strBuilder.push(hdnPartyComp.value);
		strBuilder.push(",");
		strBuilder.push(cmbChildren.value);
		hdnPartyComp.value = strBuilder.join("");
		strBuilder = null;
	}
	if(hdnPartyComp != null && cmbChild1 != null)
	{	
		strBuilder = new Array();
		strBuilder.push(hdnPartyComp.value);
		strBuilder.push(",");
		strBuilder.push(cmbChild1.value);
		hdnPartyComp.value = strBuilder.join("");
		strBuilder = null;
	}
	if(hdnPartyComp != null && cmbChild2 != null)
	{	
		strBuilder = new Array();
		strBuilder.push(hdnPartyComp.value);
		strBuilder.push(",");
		strBuilder.push(cmbChild2.value);
		hdnPartyComp.value = strBuilder.join("");
		strBuilder = null;
	}
	if(hdnPartyComp != null && cmbInfants != null)
	{	
		strBuilder = new Array();
		strBuilder.push(hdnPartyComp.value);
		strBuilder.push(",");
		strBuilder.push(cmbInfants.value);
		hdnPartyComp.value = strBuilder.join("");
		strBuilder = null;
	}
	if(hdnDur != null && cmbLengthofStay != null && cmbLengthofStay.length > 0)
	{	
		hdnDur.value = cmbLengthofStay.value;
	} 
	if(hdnDepApt != null && cmbFlyingFrom != null && cmbFlyingFrom.length > 0)
	{	
		hdnDepApt.value = cmbFlyingFrom.value;
	} 
	if(hdnUnitType != null && rdbUnitType != null)
	{	
		var radioList = rdbUnitType.getElementsByTagName( "INPUT" );
		if(radioList.length > 0)
		{
			for( count= 0 ; count< radioList.length ; count++ )
			{
				if( radioList[ count ].type == "radio" && radioList[ count ].checked )
				{				
					hdnUnitType.value = radioList[ count ].value;
					break;
				}
			}
		}
	} 
	if(hdnTrvlOpt != null && rdbTrvlOpt != null)
	{	
		var radioList = rdbTrvlOpt.getElementsByTagName( "INPUT" );
		if(radioList.length > 0)
		{
			for( count= 0 ; count< radioList.length ; count++ )
			{
				if( radioList[ count ].type == "radio" && radioList[ count ].checked )
				{				
					hdnTrvlOpt.value = radioList[ count ].value;
					break;
				}
			}
		}
	}
	ValidateMessage("txtStartDate");
	ValidateMessage("txtPartnerCode"); 
	ValidateMessage("txtPropertyRef");   
	ValidateMessage("txtTown");   
}
function fetchUserInputOnSubmit()
{
	
	var partyComp;
	var hdnPropType = document.getElementById('hdnPropType');
	var countryCd = document.getElementById('cmbCountry');
	if(countryCd == null)
	    countryCd = document.getElementById('hdnCountryCd');
	var currencyCd = document.getElementById('hdnCurrencyCd');
	var hdnSiteGuid = document.getElementById('hdnSiteGuid');
	var cmbRegion = document.getElementById('cmbRegion');
	var cmbArea = document.getElementById('cmbArea');
	var cmbResort = document.getElementById('cmbResort');
	var cmbGrading = document.getElementById('cmbGrading');
	var cmbPriceRange = document.getElementById('cmbPriceRange');
	var cmbNoBedroom = document.getElementById('cmbNoBedroom');
	var cmbUnitType = document.getElementById('cmbUnitType');
	var txtPeriphery = document.getElementById('txtPeriphery');
	var cmbRadius = document.getElementById('cmbRadius');
	var cmbSleeps = document.getElementById('cmbSleeps');
	var cmbAdults = document.getElementById('cmbAdults');
	var cmbChildren = document.getElementById('cmbChildren');
	var cmbChild1 = document.getElementById('cmbChild1');
	var cmbChild2 = document.getElementById('cmbChild2'); 
	var cmbInfants = document.getElementById('cmbInfants');
	var hdnAvailDateRange = document.getElementById('hdnAvailDateRange');
	var chkExactDateSearch = document.getElementById('chkExactDateSearch');
	var txtStartDate = document.getElementById('txtStartDate');
	var cmbLengthofStay = document.getElementById('cmbLengthofStay');
	var cmbFlyingFrom = document.getElementById('cmbFlyingFrom');
	var cmbFlyingTo = document.getElementById('cmbFlyingTo');
	var rdbTrvlOpt = document.getElementById('rdbTravelOptions');
	var hdnTrvlOpt = document.getElementById('hdnDefTravelOpt');
	var rdbUnitType = document.getElementById('rdbUnitTypes');
	var txtPartnerCode = document.getElementById('txtPartnerCode');
	var chkShowPropWithDiscnt = document.getElementById('chkShowPropertyWithDiscount');
	var chkShowPropOnCmplx = document.getElementById('chkShowPropertiesOnComplex');
	var rdbOnAMap = document.getElementById('rdbOnAMap');
	var tabMapHolder = document.getElementById('tabMapHolder');
	var hdnOverViewMapClickIndicator = document.getElementById('hdnOverViewMapClickIndicator');
	var hdnDynamicMapInfo = document.getElementById('hdnDynamicMapInfo');
	var hdnDynamicMapScaleInfo = document.getElementById('hdnDynamicMapScaleInfo');
	var regionCd="", regionNm="",areaCd="",areaNm="",resortCd="",resortNm="";
	var rarInfo='',regionInfo='',areaInfo='',resortInfo='',dynamicMapInfo="",dynamicScaleInfo='',peripheryInfo='',selectedPreference='',passengerind='', noChild='';
	var selectedSearchInfo="";
	var selectedTravelOpt = "";
	var userInput = new Array();
	userInput.push("QS=");
	if(hdnSiteGuid != null && hdnSiteGuid.value.length > 0)
	{	
		userInput.push(hdnSiteGuid.value);
		userInput.push('~');  
		
	}
	else
			userInput.push('~');  
	if(hdnPropType != null && hdnPropType.value.length > 0)
	{	
		userInput.push(hdnPropType.value);  
		userInput.push('~');  
		
	}
	else
			userInput.push('~');  
	
    if(countryCd != null && countryCd.value.length > 0)
	{	
		userInput.push(countryCd.value);  
		userInput.push('~');  
	}
	else
			userInput.push('~');  
	if(currencyCd != null && currencyCd.value.length > 0)
	{	
		userInput.push(currencyCd.value); 
		userInput.push('~'); 
		
	}
	else
			userInput.push('~');  
	
	if(rdbTrvlOpt != null)
	{	
		var radioList = rdbTrvlOpt.getElementsByTagName( "INPUT" );
		if(radioList.length > 0)
		{
			for( count= 0 ; count< radioList.length ; count++ )
			{
				if( radioList[ count ].type == "radio" && radioList[ count ].checked )
				{	
					if(userInput.length > 0)
					{
						userInput.push(getTravelOptForQueryStr(radioList[ count ].value)); 
						userInput.push('~'); 
						
					}
					else
						userInput.push('~'); 	
					if(hdnTrvlOpt != null)
						selectedTravelOpt = radioList[ count ].value;
					break;
				}
			}
		}
	} 
	else if(hdnTrvlOpt != null)
	{
		selectedTravelOpt = hdnTrvlOpt.value;
		if(userInput.length > 0)
		{
			userInput.push(getTravelOptForQueryStr(hdnTrvlOpt.value));
			userInput.push('~');
		}
		else
			userInput.push('~');  
	}
	else
			userInput.push('~');  
	if(txtStartDate != null && txtStartDate.value.length > 0)
	{	
		var startDate = txtStartDate.value;
		var dateComp = startDate.split("/");
		if(userInput.length > 0)
		{
			userInput.push(dateComp[1]);  
			userInput.push('-');  
			userInput.push(dateComp[0]);  
			userInput.push('-');  
			userInput.push(dateComp[2]);  
			userInput.push('~');  
		}
		dateComp = null;
	} 
	else
			userInput.push('~');  
	if(cmbLengthofStay != null && cmbLengthofStay.length > 0 && cmbLengthofStay.value != "0")
	{	
		userInput.push(cmbLengthofStay.value);
		userInput.push('~'); 
		
	} 
	else
			userInput.push('~');  
			
	if(chkExactDateSearch != null)
	{	
		if(!chkExactDateSearch.checked)
		{
			userInput.push('Y');  
			userInput.push('~');  
		}
		else
		{
			userInput.push('N');  
			userInput.push('~');  	
				
		}
	}
	else
			userInput.push('~');  
	
	//step preference
	var strPref = getSelectedFeatures();
	
	if(strPref.length > 0)
	{
		userInput.push(strPref);  
	}
	else
		userInput.push('~~~~~~~~');
	//Hiearachial Feature Display Flag
	userInput.push(document.getElementById('hdnIsHierarchicalFeature').value);  
	userInput.push('~');
	
	if (chkShowPropWithDiscnt != null)
	{
	    if(chkShowPropWithDiscnt.checked)
		{
			userInput.push('Y');
			userInput.push('~');
		}
		else
		{
			userInput.push('N');
			userInput.push('~');
			
		}
	}
	else
			userInput.push('~');  
	if(chkShowPropOnCmplx != null)
	{	
		if(chkShowPropOnCmplx.checked)
		{
			userInput.push('Y');
			userInput.push('~');
		}
		else
		{
			userInput.push('N');
			userInput.push('~');
			
		}
	}
	else
		userInput.push('~');   
	var resortSelected=false;
	if(cmbResort != null && cmbResort.length > 0 && cmbResort.value != "0")
	{	
		resortInfo=cmbResort.value;
		resortCd= resortInfo.split(",")[2] ;
		resortNm=escape((cmbResort.options[cmbResort.selectedIndex].text).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		resortInfo = escape(resortInfo.replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		
	}
	else if(cmbArea != null && cmbArea.length > 0 && cmbArea.value != "0")
	{	
		hdnRARInfo = document.getElementById('hdnRARInfo');
		if(hdnRARInfo != null && hdnRARInfo.value.length > 0)
		{
			var rarInfo = hdnRARInfo.value.split(",");
			if(rarInfo.length > 2)
			{
				if(rarInfo[2].length > 0)
				{
					resortCd= rarInfo[2] ;
					resortSelected=true;
				}
				else if(rarInfo[1].length > 0)
				{
					areaCd= rarInfo[1];
				}
				else if(rarInfo[0].length > 0)
				{
					regionCd=rarInfo[0];
				}
			}
			if(rarInfo.length > 3)
			    rarName = escape(PopulateRARName(rarInfo).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
			else if(rarInfo.length == 2 && rarInfo[0]==-1)
			{
			    rarName = rarInfo[1];
			}
		}	
		else
		{
		    var areaInfo = cmbArea.value.split(",");
		    areaCd= areaInfo[1];
		    areaNm=escape((cmbArea.options[cmbArea.selectedIndex].text).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		    areaInfo=cmbArea.value.replace(/&/g,'_**_').replace(/'/gi,'%quot%');
		}
	}
	else if(cmbRegion != null && cmbRegion.length > 0 && cmbRegion.value != "0")
	{	
		hdnRARInfo = document.getElementById('hdnRARInfo');
		if(hdnRARInfo != null && hdnRARInfo.value.length > 0)
		{			
			var rarInfo = hdnRARInfo.value.split(",");
			if(rarInfo.length > 2)
			{
				if(rarInfo[2].length > 0)
				{
					resortCd= rarInfo[2] ;
				}
				else if(rarInfo[1].length > 0)
				{
					areaCd= rarInfo[1];
				}
				else if(rarInfo[0].length > 0)
				{
					regionCd=rarInfo[0];;
				}
			}
			if(rarInfo.length > 3)
			    rarName = escape(PopulateRARName(rarInfo).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
			else if(rarInfo.length == 2 && rarInfo[0]==-1)
			{
			    rarName = rarInfo[1];
			}
		}			
	}
	if(cmbArea != null && cmbArea.length > 0 && cmbArea.value != "0")
	{	
		    areaInfo=escape(cmbArea.value.replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		    if(!resortSelected)
		        areaNm=escape((cmbArea.options[cmbArea.selectedIndex].text).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		    else
		        resortNm=escape((cmbArea.options[cmbArea.selectedIndex].text).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
			
	}
	if(cmbRegion != null && cmbRegion.length > 0 && cmbRegion.value != "0")
	{	
		regionInfo=escape(cmbRegion.value.replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		regionNm=escape((cmbRegion.options[cmbRegion.selectedIndex].text).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));					
	}
	userInput.push(regionCd);   
	userInput.push('~');   
	userInput.push(regionNm);   
	userInput.push('~');   
	userInput.push(areaCd);   
	userInput.push('~');   
	userInput.push(areaNm);   
	userInput.push('~');   
	userInput.push(resortCd);   
	userInput.push('~');   
	userInput.push(resortNm);   
	userInput.push('~');   
	userInput.push(rarName);   
	userInput.push('~~~~');   
	//end of RAR
	if(cmbPriceRange != null && cmbPriceRange.length > 0 && cmbPriceRange.value != "0")
	{	
		if(cmbPriceRange.value.indexOf(",1") > 0)
		{
			var priceRange = cmbPriceRange.value.replace(",1","");
			userInput.push(priceRange);   
			userInput.push('~');   
			userInput.push('Y');   
			userInput.push('~');   
		}
		else
		{
			userInput.push(cmbPriceRange.value);   
			userInput.push('~');   
			userInput.push('~');
		}
	}
	else
		userInput.push('~~');
	if(cmbGrading != null && cmbGrading.length > 0 && cmbGrading.value != "0")
	{	
		userInput.push(cmbGrading.value);   
		userInput.push('~');  
	}
	else
		userInput.push('~');  
	if( town!=null && town.value!=null && town.value.length>0)
	{	
	    userInput.push('%LAT~');
	    userInput.push('~');
	    userInput.push('%LON~');
	    userInput.push('~');	
	
	}
	else if(txtPeriphery != null && txtPeriphery.value.length > 0)
	{	
		var dynMapInfo = txtPeriphery.value.split(",");
		if(dynMapInfo.length > 5 && dynMapInfo[5].length > 0 && dynMapInfo[5].indexOf("un") <0)
		{
			userInput.push(dynMapInfo[5]);  
			userInput.push('~~');  
			
		}
		else
		    userInput.push('~~');  
		if(dynMapInfo.length > 4 && dynMapInfo[4].length > 0 && dynMapInfo[4].indexOf("un") <0)
		{
			userInput.push( dynMapInfo[4]);  
			userInput.push('~~');  
			
		}
		else
		    userInput.push('~~');  
		
	}
	else
		userInput.push('~~~~');
	if(cmbRadius != null && cmbRadius.length > 0 && cmbRadius.value != "0")
	{	
		userInput.push(cmbRadius.value);	
		userInput.push('~');	
		
	}
	else
		userInput.push('~');  
	//location name-undone
	if( town!=null && town.value!=null && town.value.length>0)
	{
		userInput.push('%TNM');
		userInput.push('~');
	}
	else
		userInput.push('~');  
	
	
	if(txtPartnerCode != null && txtPartnerCode.value.length > 0)
	{	
		userInput.push(escape(txtPartnerCode.value).replace(/&/g,'_**_').replace(/'/gi,'%quot%'));
		userInput.push('~');
		
	}
	else
		userInput.push('~');  
	if(selectedTravelOpt != "FLIGHTINCLUSIVE")
	{	
	    if(cmbSleeps != null && cmbSleeps.length > 0 && cmbSleeps.value != "0")
        {
            userInput.push(cmbSleeps.value);  
		    userInput.push('~');  
		}
		else if(cmbAdults != null && cmbAdults.length > 0 && cmbAdults.value != "0")
		 {
            userInput.push(cmbAdults.value);  
		    userInput.push('~');  
		}   
	}	
	else
		userInput.push('~');  
	
	if(selectedTravelOpt == "FLIGHTINCLUSIVE")
	{			
		if(cmbAdults != null && cmbAdults.length > 0 && cmbAdults.value != "0")
		{
		    if(userInput.length > 0)
		    {	
		        userInput.push(cmbAdults.value);
		        userInput.push('~');
    		
		    }
		}
		else if(cmbAdults != null && cmbSleeps.length > 0 && cmbSleeps.value != "0")
		{
		    if(userInput.length > 0)
		    {	
		        userInput.push(cmbSleeps.value);
		        userInput.push('~');
    		
		    }
		}
		else
			userInput.push('~');  
		
			
		if(cmbChildren != null && cmbChildren.length > 0 && cmbChildren.value != "0")
		{	
			userInput.push(cmbChildren.value);
		    userInput.push('~');
			
		}
		else
			userInput.push('~');  
		if(cmbInfants != null && cmbInfants.length > 0 && cmbInfants.value != "0")
		{	
			userInput.push(cmbInfants.value);
		    userInput.push('~');
			
		}
		else
			userInput.push('~');  
				
	}
	else
		userInput.push('~~~'); 
	if(cmbNoBedroom != null && cmbNoBedroom.length > 0 && cmbNoBedroom.value != "0")
	{	
		userInput.push(cmbNoBedroom.value);  
		userInput.push('~');  
		
	} 
	else
		userInput.push('~');  
	if(cmbFlyingFrom != null && cmbFlyingFrom.length > 0 && cmbFlyingFrom.value != "0")
	{	
		userInput.push(cmbFlyingFrom.value);  
		userInput.push('~');  
		
	} 
	else
		userInput.push('~');  
	if(cmbFlyingTo != null && cmbFlyingTo.length > 0 && cmbFlyingTo.value != "0")
	{	
		userInput.push(cmbFlyingTo.value);  
		userInput.push('~'); 
		
	}
	else
		userInput.push('~');   
		
   userInput.push(document.getElementById("hdnChildAge").value);  
   userInput.push('~~');	
			
	//populating selected search info
	selectedSearchInfo=selectedSearchInfo+escape(document.getElementById('hdnRARInfo').value.replace(/&/g,'_**_').replace(/'/gi,'%quot%'))+'^'+regionInfo+'^'+areaInfo+'^'+resortInfo+'^'+document.getElementById('hdnDynamicMapInfo').value.replace(/&/g,'_**_').replace(/'/gi,'%quot%')+'^'+document.getElementById('hdnDynamicMapScaleInfo').value+'^'+document.getElementById('txtPeriphery').value+'^'+selectedFeature+'^'+document.getElementById('hdnPsngrAgeIndicator').value+'^'+document.getElementById('hdnNoChildForEnterPsngrAge').value;
	
    //appending guid from Search page to avoid new search on browser back after opening a popup.
    var newGuid = guid();
	userInput.push('~~');
	userInput.push(newGuid);
	userInput.push('~1~~~Y~'); 
	userInput.push(selectedSearchInfo);  
	var queryStrng;
	if(hdnPropType != null && hdnPropType.value.length > 0)
	{
		if(rdbOnAMap != null && rdbOnAMap.checked)
		{
			queryStrng = "SearchResult_" + hdnPropType.value + "_Map.aspx?" + userInput.join('');
		}
		else
		{
			queryStrng = "SearchResult_" + hdnPropType.value + "_NoMap.aspx?" + userInput.join('');
		}
	}
	var finalQueryString = new Array();
	finalQueryString.push(queryStrng);	
	
	return finalQueryString.join('');
}
function getTravelOptForQueryStr(travelOpt)
{
	var returnTravelOpt = "";
	if(travelOpt == "ACCOMONLY")
		returnTravelOpt = "A";
	else if(travelOpt == "FERRYINCLUSIVE")
		returnTravelOpt = "FA";
	else if(travelOpt == "FLIGHTINCLUSIVE")
		returnTravelOpt = "FL";
	
	return returnTravelOpt;	
}
function getSelectedFeatures()
{
	var strPref = "";
	var staticPreferences = document.getElementById("staticPreferences");
	var selectedPrfCd = "";
	if(staticPreferences != null)
	{
		var lstCheckbox = staticPreferences.getElementsByTagName("INPUT")
		var isHierarchicalFeature = document.getElementById("hdnIsHierarchicalFeature");
		if(lstCheckbox.length > 0)
		{

			//Modification for filter and prioritiser
			var childTRFilter="";
			var childTRPrio="";
			var stepFilter="";
			var stepPrio="";
			
			var arrPrefInfo;
			selectedFeature = "";
			for (i=0;i<lstCheckbox.length;i++)
			{
				if(lstCheckbox[i].checked)
				{
					selectedFeature=selectedFeature+i+'|';
					arrPrefInfo = lstCheckbox[i].id.split("_");
					if(arrPrefInfo[1] == "F")
					{
						if(isHierarchicalFeature.value == "Y" || arrPrefInfo[2] == "S")
						{
						    if(arrPrefInfo[2] == "T")
						    {
							    if(arrPrefInfo[3] == "Y")
							    {
							        if(childTRFilter.length > 0)
								        childTRFilter = childTRFilter + "-" + arrPrefInfo[0].split("--")[1];
							        else
								        childTRFilter = arrPrefInfo[0].split("--")[1];
							    }
							    else
							    {
							        if(childTRPrio.length > 0)
								        childTRPrio = childTRPrio + "-" + arrPrefInfo[0].split("--")[1];
							        else
								        childTRPrio = arrPrefInfo[0].split("--")[1];
							    }
						    }
						    else if(arrPrefInfo[2] == "S")
						    {
							    if(arrPrefInfo[3] == "Y")
							    {
							        if(stepFilter.length > 0)
								        stepFilter = stepFilter + "-" + arrPrefInfo[0].split("--")[1];
							        else
								        stepFilter = arrPrefInfo[0].split("--")[1];
							    }
							    else
							    {
							        if(stepPrio.length > 0)
								        stepPrio = stepPrio + "-" + arrPrefInfo[0].split("--")[1];
							        else
								        stepPrio = arrPrefInfo[0].split("--")[1];
							    }
    							
						    }
						}
						else
						{
						    if(arrPrefInfo[arrPrefInfo.length - 2].length > 0)
							{
								if(childTRPrio.length > 0)
									    childTRPrio = childTRPrio + "-" + arrPrefInfo[arrPrefInfo.length - 2];
							    else
								    childTRPrio = arrPrefInfo[arrPrefInfo.length - 2];		
							}
							else if(arrPrefInfo[arrPrefInfo.length - 3].length > 0)
							{
								if(childTRFilter.length > 0)
									    childTRFilter = childTRFilter + "-" + arrPrefInfo[arrPrefInfo.length - 3];
							    else
								    childTRFilter = arrPrefInfo[arrPrefInfo.length - 3];
							}
						}
						
						//if(selectedPrfCd.lastIndexOf("-")==selectedPrfCd.length-1)
						//    selectedPrfCd =selectedPrfCd+arrPrefInfo[arrPrefInfo.length - 1];
						//else
						    selectedPrfCd =selectedPrfCd+arrPrefInfo[arrPrefInfo.length - 1]+'-';
					}
					else if(isHierarchicalFeature != null && isHierarchicalFeature.value == "N")
					{
						if(arrPrefInfo[1] == "P")
						{
							if(arrPrefInfo[arrPrefInfo.length - 2].length > 0)
							{
								if(arrPrefInfo[2] == "T")
								{
								    if(childTRPrio.length > 0)
									    childTRPrio = childTRPrio + "-" + arrPrefInfo[arrPrefInfo.length - 2];
								    else
									    childTRPrio = arrPrefInfo[arrPrefInfo.length - 2];
								}
								if(arrPrefInfo[2] == "S")
								{
								    if(stepPrio.length > 0)
									    stepPrio = stepPrio + "-" + arrPrefInfo[arrPrefInfo.length - 2];
								    else
									    stepPrio = arrPrefInfo[arrPrefInfo.length - 2];
								}										
							}
							if(arrPrefInfo[arrPrefInfo.length - 3].length > 0)
							{
								if(arrPrefInfo[2] == "T")
								{
								    if(childTRFilter.length > 0)
									    childTRFilter = childTRFilter + "-" + arrPrefInfo[arrPrefInfo.length - 3];
								    else
									    childTRFilter = arrPrefInfo[arrPrefInfo.length - 3];
								}
								if(arrPrefInfo[2] == "S")
								{
								    if(stepFilter.length > 0)
									    stepFilter = stepFilter + "-" + arrPrefInfo[arrPrefInfo.length - 3];
								    else
									    stepFilter = arrPrefInfo[arrPrefInfo.length - 3];
								}
							}
							selectedPrfCd =selectedPrfCd+arrPrefInfo[arrPrefInfo.length - 1];
						}
					} 
					arrPrefInfo = null;
				}
			}
			if(selectedPrfCd.lastIndexOf("-")==selectedPrfCd.length-1)
			    selectedPrfCd=selectedPrfCd.substring(0,selectedPrfCd.length-1);
			strPref=childTRFilter+'~'+childTRPrio+'~'+stepFilter+'~'+stepPrio+'~'+'~~'+selectedPrfCd+'~~';
			if(selectedFeature.length >0)
				    selectedFeature = selectedFeature.substring(0, selectedFeature.length-1);	
		}
	}
	return strPref;
}
//Function to populate the property reference search query string
function populatePropResSearchUrl(propRef)
{
    var url = new Array();
    var hdnSiteGuid = document.getElementById('hdnSiteGuid');
    var currencyCd = document.getElementById('hdnCurrencyCd');
    var countryCd = document.getElementById('cmbCountry');
    url.push("PropRefResult.aspx?QS=");
    // site guid
    if(hdnSiteGuid != null && hdnSiteGuid.value.length > 0)
	{	
		url.push(hdnSiteGuid.value);
		url.push('~'); 		
	}
	else
	    url.push('~');
	// property reference    
	url.push(propRef);
	url.push('~');	
	//Currency Code
	if(currencyCd != null && currencyCd.value.length > 0)
	{	
		url.push(currencyCd.value); 
		url.push('~'); 		
	}
	else
		url.push('~');  
	//IsMerChandising
	url.push('~');  	
	//Guid
	var newGuid = guid();
	url.push(newGuid);
	url.push('~');
	//From Search
	url.push('Y');	
	
	return url.join('');  
}
function ShowHideSBT()
{
    var los = document.getElementById("cmbLengthofStay");
    var sbt = document.getElementById("lblShortBrkMsg");
    if(los != null && sbt != null)
        sbt.style.display = (los.value != 7 && los.value != 14 && los.value != 21 && los.value != 28)?
         "block" : "none";
}
function populateSelectedFeature()
{
    if(selectedFeature==null ||Trim(selectedFeature).length==0) 
        return;
    var strPref = "";
	var staticPreferences = document.getElementById("staticPreferences");
	if(staticPreferences != null)
	{
		var lstCheckbox = staticPreferences.getElementsByTagName("INPUT")
		var isHierarchicalFeature = document.getElementById("hdnIsHierarchicalFeature");
		var arraryCount = new Array();
		arraryCount = selectedFeature.split("|");
		if(lstCheckbox.length > 0)
		{			
			var arrPrefInfo;
			for (i=0;i<lstCheckbox.length;i++)
			{
			   for( count = 0; count<arraryCount.length;count++)
			   {
			    if( i == arraryCount[count])
			        lstCheckbox[i].checked=true;
			   }
			}
		}
	}			
}
function SetChildrenAge(ages)
{
    document.getElementById("hdnChildAge").value = ages ;
}
function PopulateRARName(rarVal)
{
    var rarName = "";
    for (var i=3;i<rarVal.length; i++)
    {
        rarName += rarVal[i];
        rarName += ",";        
    }
    rarName = rarName.substring(0,rarName.length -1);
    return rarName;
}

var content_shield = null;
var modal_dialog = null;

function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}

function launch_file_upload_internal_dialog() {

var dialog_html = "<input type='image' src = '../images/close.gif' value='close' onclick='hide_modal_dialog()'/>";
show_modal_dialog(dialog_html);
}

function body_onscroll() {
window.status = getScrollXY();
}

function show_modal_dialog(dialog_html) {
if (content_shield == null) {
content_shield = document.createElement("div");
//content_shield.style.height = getPageSize()[1];
document.body.appendChild(content_shield);
content_shield.className = "content_faded";
window.status="disabled";
//Because the div is only ever going to be the height of the displayable area of the browser (100%),
//it needs to move with the scrollbars (width will always be 100%). We could instead explicitly set
//div height to the complete height of the page including non-visible scrollable areas, but then
//we would need to handle window resize events as well.
//eg. addEvent(document.body, "onscroll", body_onscroll);
}
modal_dialog = document.getElementById("divModalFrame");
modal_dialog.innerHTML = "<table><tr><td class='RARCloseButton'>"+ dialog_html + "</td></tr><tr><td>" + modal_dialog.innerHTML + "</td></tr><tr><td class='RARCloseButton'>" + dialog_html +"</tr></td></table>" ;
modal_dialog.style.display = "block";
modal_dialog.focus();
modal_dialog.className="RARModal";

}
function hide_modal_dialog() {
modal_dialog.style.display = "none";
if (content_shield != null) {
document.body.removeChild(content_shield);
content_shield = null;
}
}

function addEvent(obj, evType, fn, useCapture){
if (obj.addEventListener){
 obj.addEventListener(evType, fn, useCapture);
 return true;
} else if (obj.attachEvent){
 var r = obj.attachEvent("on"+evType, fn);
 return r;
} else {
 alert("Handler could not be attached");
}
}

function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
 //Netscape compliant
 scrOfY = window.pageYOffset;
 scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
 //DOM compliant
 scrOfY = document.body.scrollTop;
 scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
 //IE6 standards compliant mode
 scrOfY = document.documentElement.scrollTop;
 scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}

function S4()
{
    return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function guid() 
{
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()).toUpperCase();
}
