var xmlHttp
var Airlince;
var DestFrom;
function showDestFrom(airlince, from)
{
//alert("HI")
Airlince=airlince;
DestFrom=from;

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var dept=document.getElementById(Airlince);
var selectedDept=dept.options[dept.selectedIndex].value;

var url="airlince.asp";
url=url+"?relines="+selectedDept;
xmlHttp.onreadystatechange=stateServer;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateServer() 
{ 
	if(xmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlHttp.status == 200)
		{		
		//window.alert("i am here");	
			WriteData(xmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}


}

function WriteData(countryNode)
{ 
var FromDest = document.getElementById(DestFrom);
	//Clears the state combo box contents.
	for (var count = FromDest.options.length-1; count >0; count--)
	{
		FromDest.options[count] = null;
	}

	var stateNode = countryNode.split("|");
	var len=(stateNode.length-1)/2;
	var v=0;
	var t=0;
	var stateText=new Array();
	var stateValue=new Array();
	for(var i=0;i<stateNode.length;i++)
		{
		if(i%2==0)
			{
			stateValue[v]=stateNode[i];
			v++;
			}
			else
			{
			stateText[t]=stateNode[i];
			t++;
			}
		}
	//window.alert(stateNodes) 
	var textValue; 
	var textText; 
	var optionItem;
	//Add new states list to the state combo box.
	for (var count = 0; count < stateValue.length-1; count++)
	{
	textValue = (stateValue[count]);
		textText = (stateText[count]);
		//textText=textText.toLowerCase();
		//arr=textText.split("");
		//pp=arr[0].toUpperCase();
		//tFromDest=textText.substr(1);
		//textText=pp+tFromDest;
		//textText=textText+"("+textValue.substr(0,3)+")";
		//textText=textText+"("+textValue.substr(0,3)+")";
		optionItem = new Option( textText, textValue, false);
		//window.alert(textValue); 
		//stateList.appendChild(textValue); 
		FromDest.options[FromDest.length] = optionItem;
	}
}




function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

