
//Global XMLHTTP Request object
var DisableDateArray = new Array();
var XmlHttp;
var selectedDesti;

var allcities = "All Cities/Regions";
var allcitiesValue = "All Cities/Regions,0"
var allActivities = "All Activities";
var allActivitiesValue = "All Activities,0"


//var leftbarCountry = "objSiteLeftBar_objQuickSearch_cmbRegions";
//var leftbarCity = "objSiteLeftBar_objQuickSearch_cmbDestinations";
//var leftbarActivites = "objSiteLeftBar_objQuickSearch_cmbActivity";
//var leftbarTempDestination = "objSiteLeftBar_objQuickSearch_txtTempDestination";
//var leftbarTempActivity = "objSiteLeftBar_objQuickSearch_txtTempActivity";
//var leftbarTempDestinationText = "objSiteLeftBar_objQuickSearch_txtTempDestinationText";
//var leftbarTempActivityText = "objSiteLeftBar_objQuickSearch_txtTempActivityText";

/////////////////////////////////////////////////////Start of common functions////////////////////////////////////////////////////////

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
	
}

//Returns the node text value 
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}

//////////////////////////////////////////////////End of common functions///////////////////////////////////////////////////////////////



//code done by ashish for destination pages
//Called when response comes back from server
function HandleResponseForDestination()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			ClearAndSetDestinationListItems(XmlHttp.responseXML.documentElement);
		}
		else
		{
			//alert("There was a problem retrieving data from the server." );
		}
	}
}


function DestinationListOnChangeSub() 
{
	DestinationOnChangeSub();
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedDesti);

	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForDestination;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
	}
}

function DestinationOnChangeSub() 
{
	
	var DestinationList = document.getElementById(destipageCity);
	var txtTempDestination = document.getElementById(destipageTempDestination);
	var txtTempActivity = document.getElementById(destipageTempActivity);
	
	var txtTempDestinationText = document.getElementById(destipageTempDestinationText);
	
	
	//alert(txtTempDestinationText.value);
	try
	{
	var DestinationIndex=txtTempDestinationText.value.split(',')[1];
	var DestinationText=txtTempDestinationText.value.split(',')[0];
	//alert(DestinationIndex);
	DestinationList.options[DestinationIndex].text=DestinationText;
	}
	catch(ex)
	{}
	//Getting the selected country from country combo box.
	selectedDesti = DestinationList.options[DestinationList.selectedIndex].value;
	var selectedtext=DestinationList.options[DestinationList.selectedIndex].text;
	
	txtTempDestinationText.value=DestinationList.options[DestinationList.selectedIndex].text;
	txtTempDestinationText.value+=','+DestinationList.selectedIndex;
	//alert(txtTempDestinationText.value);
	DestinationList.options[DestinationList.selectedIndex].text=DestinationList.options[DestinationList.selectedIndex].text.replace('---','');
	
	
	//var destinationReplace=DestinationList.options[DestinationList.selectedIndex].text;
	//selectedtext=selectedtext.replace('---','');
	//DestinationList.options[DestinationList.selectedIndex].text=selectedtext;
	//alert(selectedtext);
	txtTempDestination.value=selectedDesti;
	txtTempActivity.value=0;
	//to store original text of combo
		
}

function ActivityChangeSub() 
{
	var ActivityList = document.getElementById(destipageActivites);
	var txtTempActivity = document.getElementById(destipageTempActivity);
	
	var txtTempActivityText = document.getElementById(destipageTempActivityText);
	
	
	//alert(txtTempDestinationText.value);
	try{
	var ActivityIndex=txtTempActivityText.value.split(',')[1];
	var ActivityText=txtTempActivityText.value.split(',')[0];
	//alert(DestinationIndex);
	ActivityList.options[ActivityIndex].text=ActivityText;
	
	//Getting the selected country from country combo box.
	var activity = ActivityList.options[ActivityList.selectedIndex].value;
	txtTempActivity.value=activity;
	}
	catch(ex)
	{}
	var activitytext = ActivityList.options[ActivityList.selectedIndex].text;
	
	txtTempActivityText.value=ActivityList.options[ActivityList.selectedIndex].text;
	txtTempActivityText.value+=','+ActivityList.selectedIndex;
	
        activitytext=activitytext.replace('---','');
	ActivityList.options[ActivityList.selectedIndex].text=activitytext;
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetDestinationListItems(countryNode)
{
	
    var cmbDestinations= document.getElementById(destipageCity);
    var cmbActivities= document.getElementById(destipageActivites);
     var setIndex=cmbDestinations.selectedIndex;
    
	//Clears the state combo box contents.
	//for (var count = stateList.options.length-1; count >-1; count--)
	//{
		//stateList.options[count] = null;
	//}

	var NodesText = countryNode.getElementsByTagName('DestinationName');
    if(NodesText.length>0)
	{
		cmbDestinations.length=0;	
	
		var NodesValue = countryNode.getElementsByTagName('DestinationID');
		var textValue;
		var idValue;
		var optionItem;
		//Add new states list to the state combo box.
		optionItem = new Option( "All Cities/Regions", 0,  false, false);
		cmbDestinations[0]=optionItem;
		cmbDestinations.length=1
		for (var count = 0; count < NodesText.length; count++)
		{
			cmbDestinations.length=cmbDestinations.length+1;
   			textValue = GetInnerText(NodesText[count]);
			idValue=GetInnerText(NodesValue[count]);
			optionItem = new Option( textValue, idValue,  false, false);
			cmbDestinations[count+1]=optionItem ;
			//cmbDestinations.text=textValue;
	
			//optionItem = new Option( textValue, textValue,  false, false);
			//stateList.options[stateList.length] = optionItem;
		}
	  }
	
	//To Fill Activity Combo
	var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
 	if(NodesTextActivity.length>0)
		{
		cmbActivities.length=0;
		var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
		var NodesValueActivity = countryNode.getElementsByTagName('ActivityID');
		var textValueActivity;
		var idValueActivity;
		var optionItemActivity;
		//Add new states list to the state combo box.
		optionItemActivity = new Option( "All Activities", 0,  false, false);
		cmbActivities[0]=optionItemActivity;
		cmbActivities.length=1
		for (var countAct = 0; countAct < NodesTextActivity.length; countAct++)
			{
			cmbActivities.length=cmbActivities.length+1;
   			textValueActivity = GetInnerText(NodesTextActivity[countAct]);
			idValueActivity=GetInnerText(NodesValueActivity[countAct]);
			optionItemActivity = new Option( textValueActivity, idValueActivity,  false, false);
			cmbActivities[countAct+1]=optionItemActivity ;
			//cmbDestinations.text=textValue;
			//optionItem = new Option( textValue, textValue,  false, false);
			//stateList.options[stateList.length] = optionItem;
			}
		}	
}
//end of functions contProductSearch



//code for destination page ends here





function CountryListOnChange() 
{
    var countryList = document.getElementById(searchpageCountry);
	var DestinationList = document.getElementById(searchpageCity);
	var ActivityList = document.getElementById(searchpageActivites);
	
	var txtTempDestination = document.getElementById(searchpageTempDestination);
	var txtTempActivity = document.getElementById(searchpageTempActivity);
	var txtTempDestinationText = document.getElementById(searchpageTempDestinationText);
	var txtTempActivityText = document.getElementById(searchpageTempActivityText);
	
	txtTempDestinationText.value= allcitiesValue;
	txtTempActivityText.value= allActivitiesValue;
	
	txtTempDestination.value=0;
	txtTempActivity.value=0;

	//Getting the selected country from country combo box.
	var selectedCountry = countryList.options[countryList.selectedIndex].value;
	if(selectedCountry == 0)
	{	
		DestinationList.options.length=1;
		DestinationList.options[0].text= allcities;
		DestinationList.options[0].value=0;
	}
	else
	{
			// URL to get states for a given country
			var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedCountry);
			
			CreateXmlHttp();
			
			// If browser supports XMLHTTPRequest object
			if(XmlHttp)
			{
				//Setting the event handler for the response
				XmlHttp.onreadystatechange = HandleResponse;
				
				//Initializes the request object with GET (METHOD of posting), 
				//Request URL and sets the request as asynchronous.
				XmlHttp.open("GET", requestUrl,  true);
				
				//Sends the request to server
				XmlHttp.send(null);	
					
			}
	}
}

//Called when response comes back from server
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
	    
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			ClearAndSetStateListItems(XmlHttp.responseXML.documentElement);
		}
		else
		{
		
		}
	}
}


function DestinationListOnChange() 
{
	DestinationOnChange();
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedDesti);

	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
	}
}

function DestinationOnChange() 
{
	var DestinationList = document.getElementById(searchpageCity);
	var txtTempDestination = document.getElementById(searchpageTempDestination);
	var txtTempActivity = document.getElementById(searchpageTempActivity);
	var txtTempDestinationText = document.getElementById(searchpageTempDestinationText);
	
	try
	{
	var DestinationIndex=txtTempDestinationText.value.split(',')[1];
	var DestinationText=txtTempDestinationText.value.split(',')[0];
	DestinationList.options[DestinationIndex].text=DestinationText;
	}
	catch(ex)
	{}
	
	//Getting the selected country from country combo box.
	selectedDesti = DestinationList.options[DestinationList.selectedIndex].value;
	var selectedtext=DestinationList.options[DestinationList.selectedIndex].text;
	
	txtTempDestinationText.value=DestinationList.options[DestinationList.selectedIndex].text;
	txtTempDestinationText.value+=','+DestinationList.selectedIndex;
	DestinationList.options[DestinationList.selectedIndex].text=DestinationList.options[DestinationList.selectedIndex].text.replace('---','');
		
	txtTempDestination.value=selectedDesti;
	txtTempActivity.value=0;
		
}

function ActivityChange() 
{
    
	var ActivityList = document.getElementById(searchpageActivites);
	var txtTempActivity = document.getElementById(searchpageTempActivity);
	var txtTempActivityText = document.getElementById(searchpageTempActivityText);
		
	try
	{
	    var ActivityIndex=txtTempActivityText.value.split(',')[1];
	    var ActivityText=txtTempActivityText.value.split(',')[0];
	    ActivityList.options[ActivityIndex].text=ActivityText;
    	
	    //Getting the selected country from country combo box.
	    var activity = ActivityList.options[ActivityList.selectedIndex].value;
	    txtTempActivity.value=activity;
	}
	catch(ex)
	{
	 
	}
	var activitytext = ActivityList.options[ActivityList.selectedIndex].text;
	
	txtTempActivityText.value=ActivityList.options[ActivityList.selectedIndex].text;
	txtTempActivityText.value+=','+ActivityList.selectedIndex;
	
    activitytext=activitytext.replace('---','');
	ActivityList.options[ActivityList.selectedIndex].text=activitytext;
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItems(countryNode)
{
	
    var cmbDestinations= document.getElementById(searchpageCity);
    var cmbActivities= document.getElementById(searchpageActivites);
    var setIndex=cmbDestinations.selectedIndex;
    
	var NodesText = countryNode.getElementsByTagName('DestinationName');
    if(NodesText.length>0)
	{
		cmbDestinations.length=0;	
	
		var NodesValue = countryNode.getElementsByTagName('DestinationID');
		var textValue;
		var idValue;
		var optionItem;
		//Add new states list to the state combo box.
		optionItem = new Option( allcities, 0,  false, false);
		cmbDestinations[0]=optionItem;
		cmbDestinations.length=1
		for (var count = 0; count < NodesText.length; count++)
		{
			cmbDestinations.length=cmbDestinations.length+1;
   			textValue = GetInnerText(NodesText[count]);
			idValue=GetInnerText(NodesValue[count]);
			optionItem = new Option( textValue, idValue,  false, false);
			cmbDestinations[count+1]=optionItem ;
	
		}
	  }
	
	//To Fill Activity Combo
	var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
 	if(NodesTextActivity.length>0)
		{
		cmbActivities.length=0;
		var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
		var NodesValueActivity = countryNode.getElementsByTagName('ActivityID');
		var textValueActivity;
		var idValueActivity;
		var optionItemActivity;
		//Add new states list to the state combo box.
		optionItemActivity = new Option( allActivities, 0,  false, false);
		cmbActivities[0]=optionItemActivity;
		cmbActivities.length=1
		for (var countAct = 0; countAct < NodesTextActivity.length; countAct++)
			{
			    cmbActivities.length=cmbActivities.length+1;
   			    textValueActivity = GetInnerText(NodesTextActivity[countAct]);
			    idValueActivity=GetInnerText(NodesValueActivity[countAct]);
			    optionItemActivity = new Option( textValueActivity, idValueActivity,  false, false);
			    cmbActivities[countAct+1]=optionItemActivity ;
	
			}
		}	
}

//functions for Quick Search
//Gets called when country combo box selection changes
function CountryListOnChangeForQuickSearch() 
{

	var countryList = document.getElementById(leftbarCountry);
	var DestinationList = document.getElementById(leftbarCity);
	var ActivityList = document.getElementById(leftbarActivites);
	
	var txtTempDestination = document.getElementById(leftbarTempDestination);
	var txtTempActivity = document.getElementById(leftbarTempActivity);
	var txtTempDestinationText = document.getElementById(leftbarTempDestinationText);
	var txtTempActivityText = document.getElementById(leftbarTempActivityText);
	
	txtTempDestinationText.value= allcitiesValue;
	txtTempActivityText.value= allActivitiesValue;
	
	txtTempDestination.value=0;
	txtTempActivity.value=0;

	//Getting the selected country from country combo box.
	var selectedCountry = countryList.options[countryList.selectedIndex].value;
	if(selectedCountry == 0)
	{	
		DestinationList.options.length=1;
		DestinationList.options[0].text= allcities;
		DestinationList.options[0].value=0;
	}
	else
	{
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedCountry);
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForQuickSearch;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
  }
}

function DestinationListOnChangeForQuickSearch() 
{
	DestinationOnChangeForQuickSearch();
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedDesti);
	
	CreateXmlHttp();
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForQuickSearch;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
}
function DestinationOnChangeForQuickSearch() 
{
	var DestinationList = document.getElementById(leftbarCity);
	var txtTempDestination = document.getElementById(leftbarTempDestination);
	var txtTempActivity = document.getElementById(leftbarTempActivity);
	var txtTempDestinationText = document.getElementById(leftbarTempDestinationText);
	
	//alert(txtTempDestinationText.value);
	try
	{
		var DestinationIndex=txtTempDestinationText.value.split(',')[1];
		var DestinationText=txtTempDestinationText.value.split(',')[0];
		//alert(DestinationIndex);
		DestinationList.options[DestinationIndex].text=DestinationText;
	}
	catch(ex)
	{
	}
	//Getting the selected country from country combo box.
	selectedDesti = DestinationList.options[DestinationList.selectedIndex].value;
	var selectedtext=DestinationList.options[DestinationList.selectedIndex].text;
	
	txtTempDestinationText.value=DestinationList.options[DestinationList.selectedIndex].text;
	txtTempDestinationText.value+=','+DestinationList.selectedIndex;
	DestinationList.options[DestinationList.selectedIndex].text=DestinationList.options[DestinationList.selectedIndex].text.replace('---','');
	
	txtTempDestination.value=selectedDesti;
	txtTempActivity.value=0;

		
}

function ActivityOnChangeForQuickSearch() 
{
	var ActivityList = document.getElementById(leftbarActivites);
	var txtTempActivity = document.getElementById(leftbarTempActivity);
	var txtTempActivityText = document.getElementById(leftbarTempActivityText);
	
	try
	{
		var ActivityIndex=txtTempActivityText.value.split(',')[1];
		var ActivityText=txtTempActivityText.value.split(',')[0];
		ActivityList.options[ActivityIndex].text = ActivityText;
		
		//Getting the selected country from country combo box.
		var activity = ActivityList.options[ActivityList.selectedIndex].value;
		txtTempActivity.value=activity;
	}
	catch(ex)
	{
		
	}
		var activitytext = ActivityList.options[ActivityList.selectedIndex].text;
		
		txtTempActivityText.value=ActivityList.options[ActivityList.selectedIndex].text;
		txtTempActivityText.value+=','+ActivityList.selectedIndex;
		
		activitytext=activitytext.replace('---','');
		ActivityList.options[ActivityList.selectedIndex].text=activitytext;
}

//Called when response comes back from server
function HandleResponseForQuickSearch()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			ClearAndSetStateListItemsForQuickSearch(XmlHttp.responseXML.documentElement);
		}
	}
}


//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItemsForQuickSearch(countryNode)
{
	
    var cmbDestinations= document.getElementById(leftbarCity);
    var cmbActivities= document.getElementById(leftbarActivites);
    var setIndex=cmbDestinations.selectedIndex;
    
	var NodesText = countryNode.getElementsByTagName('DestinationName');
    if(NodesText.length>0)
	{
		cmbDestinations.length=0;	
	
		var NodesValue = countryNode.getElementsByTagName('DestinationID');
		var textValue;
		var idValue;
		var optionItem;
		//Add new states list to the state combo box.
		optionItem = new Option( allcities, 0,  false, false);
		cmbDestinations[0]=optionItem;
		cmbDestinations.length=1
		for (var count = 0; count < NodesText.length; count++)
		{
			cmbDestinations.length=cmbDestinations.length+1;
   			textValue = GetInnerText(NodesText[count]);
			idValue=GetInnerText(NodesValue[count]);
			optionItem = new Option( textValue, idValue,  false, false);
			cmbDestinations[count+1]=optionItem ;
		}
	  }
	
	//To Fill Activity Combo
	var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
 	if(NodesTextActivity.length>0)
		{
		cmbActivities.length=0;
		var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
		var NodesValueActivity = countryNode.getElementsByTagName('ActivityID');
		var textValueActivity;
		var idValueActivity;
		var optionItemActivity;
		//Add new states list to the state combo box.
		optionItemActivity = new Option( allActivities, 0,  false, false);
		cmbActivities[0]=optionItemActivity;
		cmbActivities.length=1
		for (var countAct = 0; countAct < NodesTextActivity.length; countAct++)
		{
			    cmbActivities.length=cmbActivities.length+1;
   			    textValueActivity = GetInnerText(NodesTextActivity[countAct]);
			    idValueActivity=GetInnerText(NodesValueActivity[countAct]);
			    optionItemActivity = new Option( textValueActivity, idValueActivity,  false, false);
			    cmbActivities[countAct+1]=optionItemActivity ;
		}
	}	
}


//functions for Home Search On Map(Default.aspx)
//Gets called when country combo box selection changes
function CountryListOnHomeSearch() 
{

	var countryList			= document.getElementById(homepageCountry);
	var txtTempDestination	= document.getElementById(homepageTempDestination);
	var txtTempActivity		= document.getElementById(homepageTempActivity);
	var txtTempDestinationText = document.getElementById(homepageTempDestinationText);
	var txtTempActivityText = document.getElementById(homepageTempActivityText);
	
	txtTempDestinationText.value= allcitiesValue;
	txtTempActivityText.value= allActivitiesValue;
	
	txtTempDestination.value=0;
	txtTempActivity.value=0;

	//Getting the selected country from country combo box.
	var selectedCountry = countryList.options[countryList.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedCountry);
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForHomeSearch;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
}

function DestinationListOnHomeSearch() 
{
	DestinationOnHomeSearch();
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedDesti);
	
	CreateXmlHttp();
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForHomeSearch;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
}
function DestinationOnHomeSearch() 
{
	var DestinationList = document.getElementById(homepageCity);
	var txtTempDestination = document.getElementById(homepageTempDestination);
	var txtTempActivity = document.getElementById(homepageTempActivity);
	var txtTempDestinationText = document.getElementById(homepageTempDestinationText);
	
	//alert(txtTempDestinationText.value);
	try
	{
		var DestinationIndex=txtTempDestinationText.value.split(',')[1];
		var DestinationText=txtTempDestinationText.value.split(',')[0];
		//alert(DestinationIndex);
		DestinationList.options[DestinationIndex].text=DestinationText;
	}
	catch(ex)
	{
	}
	//Getting the selected country from country combo box.
	selectedDesti = DestinationList.options[DestinationList.selectedIndex].value;
	var selectedtext=DestinationList.options[DestinationList.selectedIndex].text;
	
	txtTempDestinationText.value=DestinationList.options[DestinationList.selectedIndex].text;
	txtTempDestinationText.value+=','+DestinationList.selectedIndex;
	DestinationList.options[DestinationList.selectedIndex].text=DestinationList.options[DestinationList.selectedIndex].text.replace('---','');
	
	txtTempDestination.value=selectedDesti;
	txtTempActivity.value=0;
		
}

function ActivityOnHomeSearch() 
{
	var ActivityList		= document.getElementById(homepageActivities);
	var txtTempActivity		= document.getElementById(homepageTempActivity);
	var txtTempActivityText = document.getElementById(homepageTempActivityText);
	
	try
	{
		var ActivityIndex=txtTempActivityText.value.split(',')[1];
		var ActivityText=txtTempActivityText.value.split(',')[0];
		ActivityList.options[ActivityIndex].text = ActivityText;
		
		//Getting the selected country from country combo box.
		var activity = ActivityList.options[ActivityList.selectedIndex].value;
		txtTempActivity.value=activity;
	}
	catch(ex)
	{
		
	}
		var activitytext = ActivityList.options[ActivityList.selectedIndex].text;
		
		txtTempActivityText.value=ActivityList.options[ActivityList.selectedIndex].text;
		txtTempActivityText.value+=','+ActivityList.selectedIndex;
		
		activitytext=activitytext.replace('---','');
		ActivityList.options[ActivityList.selectedIndex].text=activitytext;
}

//Called when response comes back from server
function HandleResponseForHomeSearch()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			ClearAndSetStateListItemsForHomeSearch(XmlHttp.responseXML.documentElement);
		}
		
	}
}


//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItemsForHomeSearch(countryNode)
{
	
    var cmbDestinations	= document.getElementById(homepageCity);
    var cmbActivities	= document.getElementById(homepageActivities);
    var setIndex		= cmbDestinations.selectedIndex;
	var NodesText = countryNode.getElementsByTagName('DestinationName');
	
    if(NodesText.length>0)
	{
		cmbDestinations.length=0;	
	
		var NodesValue = countryNode.getElementsByTagName('DestinationID');
		var textValue;
		var idValue;
		var optionItem;
	
		optionItem = new Option( allcities, 0,  false, false);
		cmbDestinations[0]=optionItem;
		cmbDestinations.length=1
		
		for (var count = 0; count < NodesText.length; count++)
		{
			cmbDestinations.length=cmbDestinations.length+1;
   			textValue = GetInnerText(NodesText[count]);
			idValue=GetInnerText(NodesValue[count]);
			optionItem = new Option( textValue, idValue,  false, false);
			cmbDestinations[count+1]=optionItem ;
	
		}
	  }
	
	var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
	
 	if(NodesTextActivity.length>0)
		{
		cmbActivities.length=0;
		var NodesTextActivity = countryNode.getElementsByTagName('ActivityName');
		var NodesValueActivity = countryNode.getElementsByTagName('ActivityID');
		var textValueActivity;
		var idValueActivity;
		var optionItemActivity;
		
		optionItemActivity = new Option( allActivities, 0,  false, false);
		cmbActivities[0]=optionItemActivity;
		cmbActivities.length=1
		
		for (var countAct = 0; countAct < NodesTextActivity.length; countAct++)
			{
			cmbActivities.length=cmbActivities.length+1;
   			textValueActivity = GetInnerText(NodesTextActivity[countAct]);
			idValueActivity=GetInnerText(NodesValueActivity[countAct]);
			optionItemActivity = new Option( textValueActivity, idValueActivity,  false, false);
			cmbActivities[countAct+1]=optionItemActivity ;
			}
		}	
}


//for advance search
function CountryListOnAdvanceSearch() 
{

	var countryList			= document.getElementById(advancepageCountry);
	var txtTempDestination	= document.getElementById(advancepageTempDestination);
	var txtTempDestinationText = document.getElementById(advancepageTempDestinationText);
		
	txtTempDestinationText.value= allcitiesValue;
	txtTempDestination.value=0;
	

	//Getting the selected country from country combo box.
	var selectedCountry = countryList.options[countryList.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "/AjaxRequest.aspx" + "?RegionID=" + encodeURIComponent(selectedCountry);
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForAdvanceSearch;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
}

function DestinationListOnAdvanceSearch() 
{
	DestinationOnAdvanceSearch();
	
	
}
function DestinationOnAdvanceSearch() 
{
	var DestinationList = document.getElementById(advancepageCity);
	var txtTempDestination = document.getElementById(advancepageTempDestination);
	var txtTempDestinationText = document.getElementById(advancepageTempDestinationText);
	
	//alert(txtTempDestinationText.value);
	try
	{
		var DestinationIndex=txtTempDestinationText.value.split(',')[1];
		var DestinationText=txtTempDestinationText.value.split(',')[0];
		//alert(DestinationIndex);
		DestinationList.options[DestinationIndex].text=DestinationText;
	}
	catch(ex)
	{
	}
	//Getting the selected country from country combo box.
	selectedDesti = DestinationList.options[DestinationList.selectedIndex].value;
	var selectedtext=DestinationList.options[DestinationList.selectedIndex].text;
	
	txtTempDestinationText.value=DestinationList.options[DestinationList.selectedIndex].text;
	txtTempDestinationText.value+=','+DestinationList.selectedIndex;
	DestinationList.options[DestinationList.selectedIndex].text=DestinationList.options[DestinationList.selectedIndex].text.replace('---','');
	
	txtTempDestination.value=selectedDesti;
	
		
}


function HandleResponseForAdvanceSearch()
{
	// To make sure receiving response data from server is completed
	
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		 
		if(XmlHttp.status == 200)
		{	
		   
			ClearAndSetStateListItemsForAdvanceSearch(XmlHttp.responseXML.documentElement);
		}
		
	}
}


//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItemsForAdvanceSearch(countryNode)
{
	
    var cmbDestinations	= document.getElementById(advancepageCity);
    var setIndex		= cmbDestinations.selectedIndex;
	var NodesText = countryNode.getElementsByTagName('DestinationName');
	
    if(NodesText.length>0)
	{
		cmbDestinations.length=0;	
	
		var NodesValue = countryNode.getElementsByTagName('DestinationID');
		var textValue;
		var idValue;
		var optionItem;
	
		optionItem = new Option( allcities, 0,  false, false);
		cmbDestinations[0]=optionItem;
		cmbDestinations.length=1
		
		for (var count = 0; count < NodesText.length; count++)
		{
			cmbDestinations.length=cmbDestinations.length+1;
   			textValue = GetInnerText(NodesText[count]);
			idValue=GetInnerText(NodesValue[count]);
			optionItem = new Option( textValue, idValue,  false, false);
			cmbDestinations[count+1]=optionItem ;
	
		}
	  }
	
	
}
//end for advance search
function CheckAvailability(prevmonth,nextmonth,serviceid,optionId)
 {
 var requestUrl = "/CalendarAjaxRequest.aspx" + "?CurrMonth=" + encodeURIComponent(prevmonth)+"&NextMonth="+encodeURIComponent(nextmonth)+"&serviceid="+encodeURIComponent(serviceid)+"&optionid="+encodeURIComponent(optionId);
 
	
	CreateXmlHttp();
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseForCalendar;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);	
			
	}
 }
 function HandleResponseForCalendar()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			FormatAvailableDates(XmlHttp.responseXML.documentElement);
		}
		else
		{
			//alert("There was a problem retrieving data from the server." );
		}
	}
}
 
 function FormatAvailableDates(XMLDatenode)
 {
	var PriceDateID=XMLDatenode.getElementsByTagName('PriceDateID');
	var date = XMLDatenode.getElementsByTagName('date');
	var AvailStat=XMLDatenode.getElementsByTagName('AvailableState');
	var year=XMLDatenode.getElementsByTagName('year');
	var month=XMLDatenode.getElementsByTagName('month');
	var daystatus=XMLDatenode.getElementsByTagName('DayStatus');
	var dt;
	var mn;
	var yr;
	var Avstate;
    var dstat;
	
for (var count = 0; count < PriceDateID.length; count++)
{
		Avstate=GetInnerText(AvailStat[count]);
		dstat=GetInnerText(daystatus[count]);
    dt=GetInnerText(date[count]);
    mn=GetInnerText(month[count]);
    yr=GetInnerText(year[count]);
    if(dt.charAt(0)=="0"){
	dt = dt.replace(dt.charAt(0),"");
	}
	 if(mn.charAt(0)=="0"){
	mn = mn.replace(mn.charAt(0),"");
	}
	
    if(Avstate==1)
		{
		
    if(dstat=="True")
    fAddEvent(yr,mn,dt, "Product Available!", "", "#DFCE1B", "#FFFFFF",null,"gold","");
    if(dstat=="False")
    fAddEvent(yr,mn,dt, "Product Not Available!", "", "#87ceeb", "dodgerblue");
  
       }

  else if(Avstate==2)
  {
 
  fAddEvent(yr,mn,dt, "Product Not Available!", "", "#87ceeb", "dodgerblue");
  }
  else
  {
  if(dstat=="True")
  fAddEvent(yr,mn,dt, "Product On Request!", "", "#87ceeb", "dodgerblue");
      if(dstat=="False")
    fAddEvent(yr,mn,dt, "Product Not Available!", "", "#87ceeb", "dodgerblue");
  }
  }
 fRepaint();
}








