
//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);
}

//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);
}

function Getflightprice(data,searchval) 
{
    //alert(Reservationid);
    if (data.length > 0)
    {
        //alert(Reservationid);
	    var requestUrl = "Getflightpricedata.aspx" + "?pricedata=" + data + "&searchdata=" + searchval;
	    CreateXmlHttp();
	    XmlHttp.open("GET", requestUrl,  true);
	    if(XmlHttp)
	    {
    //	alert(MerchantURL);
		    XmlHttp.onreadystatechange = HandleResponseprice;
		    
	        XmlHttp.send(null);		
	    }
    }
}

//Called when response comes back from server
function HandleResponseprice()
{
if(XmlHttp.readyState != 4)
{
 return;
}
	// 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 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);		
	}
//}
}


function getagencyvalue(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 = "agencyAutoComplete.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleagencyResponseAutoComplete;
		
		//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 HandleagencyResponseAutoComplete()
{
	// 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)
		{			
			ClearAndSetAutoagencyComplete(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 ClearAndSetAutoagencyComplete(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 emp_detail(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 randomnumber=Math.floor(Math.random()*10001)
	var requestUrl = "empAutoComplete.aspx" + "?SelectedCountry=" + key + "&no=" + randomnumber;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = Handleemp_detail;
		
		//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 Handleemp_detail()
{
	// 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)
		{			
			ClearAndSetemp_detail(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 ClearAndSetemp_detail(countryNode)
{

     var stateList = document.getElementById("AutoCompleteBox_agency");
	//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 i =0;i<stateNodes.length-1;i+=1)
	{//alert("");
	var emt=stateNodes[i].split("~")
	for (var count = 0; count < emt.length - 1; count+=2)
	{
	
   		textValue = emt[count];
   		textValue1= emt[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_emp");
}

function getagencyname(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 = "agencynameautocomplete.aspx" + "?SelectedCountry=" + key;
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleagencynameResponseAutoComplete;
		
		//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 HandleagencynameResponseAutoComplete()
{
	// 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)
		{			
			ClearAndSetAutoagencynameComplete(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 ClearAndSetAutoagencynameComplete(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBox_agency");
   
	//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 i =0;i<stateNodes.length-1;i+=1)
	{//alert("");
	var emt=stateNodes[i].split(",")
	for (var count = 0; count < emt.length - 1; count+=2)
	{
	
   		textValue = emt[count];
   		textValue1= emt[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_emp");
	//alert(stateList.items);
}

function GetfareDetails(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 randomnumber=Math.floor(Math.random()*100001);
    var finalstr = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate + ',' + randomnumber;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv"+id+"").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);		
	}
//}
}
function GetfareDetails2(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv2"+id+"").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);		
	}
//}
}
function GetfareDetails3(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv3"+id+"").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);		
	}
//}
}
function GetfareDetails4(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv4"+id+"").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);		
	}
//}
}
function GetfareDetails5(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv5"+id+"").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);		
	}
//}
}
function GetfareDetails6(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv6"+id+"").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);		
	}
//}
}
function GetfareDetails7(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv7"+id+"").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);		
	}
//}
}
function GetfareDetails8(id,trsinno,trainname,selclas,qoute,sourccoe,destcode,deptim,arrtime,traintype,depdate) 
{//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 = id + ',' + trsinno + ',' + trainname + ',' + selclas + ',' + qoute + ',' + sourccoe + ',' + destcode + ',' + deptim + ',' + arrtime + ',' + traintype + ',' + depdate;
    var requestUrl = "Getrailfaredetail.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("fareandavailabiltydiv8"+id+"").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);		
	}
//}
}

function Getfaredata(searcheddata,paxdata,adultdata,brdingpt,SCMdata,SCFdata,Childdata,selclass) 
{//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 randomnumber=Math.floor(Math.random()*100001);
    var finalstr = searcheddata + '$' + paxdata + '$' + adultdata + '$' + brdingpt + '$' + SCMdata  + '$' + SCFdata + '$' + Childdata + '$' + selclass + '$' + randomnumber;
    var requestUrl = "Getfaredatadetails.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;
		        //alert(response);
		        //document.getElementById("moreinfo_preloader"+count+"").style.display='none';
//		        document.getElementById("loadingimage").style.visibility = "hidden";
//    document.getElementById("loadingimage").style.display = "none";
                document.getElementById("trainfare").innerHTML=response;
                //alert(document.getElementById("trainfare").innerHTML);
//		        }
                //document.getElementById("moreinfo_preloader"+count+"").style.display='none';
	        }
		}
		XmlHttp.open("GET", requestUrl,  false);
		//XmlHttp.open("GET","GetdesiaHoteldetail.aspx?SelectedHotel="+finalstr,true);
	    XmlHttp.send(null);		
	}
//}
}
function Category_detail(key) 
{
  
    document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
   var randomnumber=Math.floor(Math.random()*10001)
	var requestUrl = "CategoryAutoComplete.aspx" + "?SelectedCountry=" + key + "&no=" + randomnumber;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleCategory_detail;
		
		//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 HandleCategory_detail()
{
	// 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)
		{			
			ClearAndSetCategory_detail(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 ClearAndSetCategory_detail(countryNode)
{

     var stateList = document.getElementById("CategoryDetailsRcvd");
     stateList.value=countryNode;
     if (countryNode !="")
     {
     var stateNodes = countryNode.split("$");
     document.getElementById('comm').value = stateNodes[0];
     document.getElementById('markup').value = stateNodes[1];
     document.getElementById('yq').value = stateNodes[2];
     document.getElementById('amt').value = stateNodes[3];
     document.getElementById('cashback').value = stateNodes[4];
     document.getElementById('rmarkupN').value=stateNodes[5];
     document.getElementById('rcommN').value=stateNodes[6];
     }
     else
     {
     document.getelementById('rmarkupN').value = "";
     document.getelementById('rcommN').value = "";
     document.getElementById('comm').value = "";
     document.getElementById('markup').value = "";
     document.getElementById('yq').value = "";
     document.getElementById('amt').value = "";
     document.getElementById('cashback').value = "";

     }
	//Clears the state combo box contents.
	document.getElementById("loadingimage2").style.visibility = "hidden";
    document.getElementById("loadingimage2").style.display = "none";
}
function getagencynameAll(key) 
{
   document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
//var City = document.getElementById("ToSector");
if (key.length > 5)
{
	//Getting the selected country from country combo box.
	//var selectedCountry = Country.options[Country.selectedIndex].value;
	
	// URL to get states for a given country
	var randomnumber=Math.floor(Math.random()*100001);
	var requestUrl = "agencynameautocompleteAll.aspx" + "?SelectedCountry=" + key + "&rnd=" + randomnumber;
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleagencynameResponseAutoCompleteAll;
		
		//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 HandleagencynameResponseAutoCompleteAll()
{
	// 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)
		{			
			ClearAndSetAutoagencynameCompleteAll(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 ClearAndSetAutoagencynameCompleteAll(countryNode)
{

   var stateList = document.getElementById("AutoCompleteBox_agency");
   
	//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 i =0;i<stateNodes.length-1;i+=1)
	{//alert("");
	var emt=stateNodes[i].split("()")
	for (var count = 0; count < emt.length - 1; count+=2)
	{
	
   		textValue = emt[count];
   		textValue1= emt[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_emp");
}

// Get the Bank Deposit Amount
function getcreditdetail(key) 
{
   document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
//var City = document.getElementById("ToSector");
if (key.length > 10)
{
	//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 = "creditdetailautocomplete.aspx" + "?SelectedCountry=" + key;
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleCreditdetailResponseAutoComplete;
		
		//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 HandleCreditdetailResponseAutoComplete()
{
	// 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)
		{			
			ClearAndSetAutoCreditdetailComplete(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 ClearAndSetAutoCreditdetailComplete(countryNode)
{

   var stateList = document.getElementById("AutoCompleteBox_agency");
   
	//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 i =0;i<stateNodes.length-1;i+=1)
	{//alert("");
	var emt=stateNodes[i].split(",")
	for (var count = 0; count < emt.length - 1; count+=2)
	{
	
   		textValue = emt[count];
   		textValue1= emt[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_emp");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function getagencynamebal(key) 
{
   document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
//var City = document.getElementById("ToSector");
if (key.length > 5)
{
	//Getting the selected country from country combo box.
	//var selectedCountry = Country.options[Country.selectedIndex].value;
	
	// URL to get states for a given country
	var randomnumber=Math.floor(Math.random()*100001);
	var requestUrl = "agencynamebalautocomplete.aspx" + "?SelectedCountry=" + key + "&rnd=" + randomnumber;
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleagencynameResponseAutoCompleteAll;
		
		//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 HandleagencynamebalResponseAutoComplete()
{
	// 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)
		{			
			ClearAndSetAutoagencynameCompleteAll(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 ClearAndSetAutoagencynamebalComplete(countryNode)
{

   var stateList = document.getElementById("AutoCompleteBox_agency");
   
	//Clears the state combo box contents.
	stateList.options.length = 0;

	var stateNodes = countryNode.split("#");
	
	var textValue; 
	var textValue1; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var i =0;i<stateNodes.length-1;i+=1)
	{//alert("");
	var emt=stateNodes[i].split("()")
	for (var count = 0; count < emt.length - 1; count+=2)
	{
	
   		textValue = emt[count];
   		textValue1= emt[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_emp");
}
/////////////////////////////////////////////////////////////////

function getagencydistvalue(key) 
{
   document.getElementById("loadingimage2").style.visibility = "visible";
   document.getElementById("loadingimage2").style.display = "";
if (key.length > 4)
{
	var requestUrl = "agencyAutoCompleteDist.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	if(XmlHttp)
	{
		XmlHttp.onreadystatechange = HandleagencyDistResponseAutoComplete;
		XmlHttp.open("GET", requestUrl,  true);
		XmlHttp.send(null);		
	}
}
}

//Called when response comes back from server
function HandleagencyDistResponseAutoComplete()
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			ClearAndSetAutoagencyDistComplete(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 ClearAndSetAutoagencyDistComplete(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBox");
	//Clears the state combo box contents.
	stateList.options.length = 0;
	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];
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;
	}
	document.getElementById("loadingimage2").style.visibility = "hidden";
    	document.getElementById("loadingimage2").style.display = "none";
	ShowDiv("autocomplete");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////

function Getairlineonchange(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 = "airlineAutoComplete.aspx?Selectedairline=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseAutoCompleteairline;
		
		//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 HandleResponseAutoCompleteairline()
{
	// 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)
		{			
			ClearAndSetAutoCompleteairline(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 ClearAndSetAutoCompleteairline(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBoxFromIntl");

	//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);
}
function IntlCountryListOnChange(key) 
{
//alert();
    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;
	
	// URL to get states for a given country
  if (key.length > 1)
   {
	var requestUrl = "IntlGetCity.aspx" + "?SelectedCountry=" + key;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = IntlHandleResponse;
		
		//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 IntlHandleResponse()
{
	// 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)
		{			
			IntlClearAndSetCityNameItemsStr(XmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}


function IntlClearAndSetCityNameItemsStr(countryNode)
{
    var stateList = document.getElementById("AutoCompleteBoxCity");
	//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 textValue2; 
	var textValue3; 
	var optionItem;
	//alert('comes here');
	//Add new states list to the state combo box.
	for (var count = 0; count < stateNodes.length - 1; count+=4)
	{
		textValue = stateNodes[count];
   		textValue1= stateNodes[count+1];
   		textValue2= stateNodes[count+2];
   		textValue3= stateNodes[count+3];
   		//alert(textValue1);
   		optionItem = new Option (textValue1 + " ( " + textValue3 + " ) ", textValue + "@" + textValue1 +  "@" + textValue2,  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("loadingimage").style.visibility = "hidden";
    document.getElementById("loadingimage").style.display = "none";
	ShowDiv("autocompletecity");
	//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 Getroominfo(count,supplier,hotelid,sessionreq,seesionval,param) 
{
    var finalstr = count + ',' + supplier + ',' + hotelid ;
    var requestUrl = "GetRoomdetail.aspx" + "?Selectedhotel=" + finalstr + "&Session=" + sessionreq + "&sessionval=" + seesionval + "&paramval=" + param;
	//alert(requestUrl);
	CreateXmlHttp();
	XmlHttp.open("GET", requestUrl,  true);
	if(XmlHttp)
	{
		XmlHttp.onreadystatechange=function()
		{
		    if(XmlHttp.readyState == 4)
	        {
		        var response = XmlHttp.responseText;
                document.getElementById("roomtypeinfo"+count+"").innerHTML=response;
	        }
		}
		
	    XmlHttp.send(null);		
	}
}
