type=null;
function journeyTypeCheck(type){
	//alert('');
	returnJourney=document.getElementById("secondLocation");
	if(type=='oneway'){
		returnJourney.style.display='none';
	}
	else{
		returnJourney.style.display='block';
		locations = new XmlConnector("http://www.ontimeairporttransfers.com/xmlWebServices/xml/all.php");
		locations.XMLReq.onreadystatechange = loadAll_onLoad;
	}
}

function removeAllChild(id)
{
	var chNodes = document.getElementById(id).childNodes; 
	var i = chNodes.length; 
	while(i-- >0) 
	{ 
		chNodes[i].parentNode.removeChild(chNodes[i]); 
	}
}

function loadAll_onLoad(){
	removeAllChild('allFrom');
	removeAllChild('allDrop');
	if (locations.XMLReq.readyState == 4) 
	{				
        if (locations.XMLReq.status  == 200) 
		{
			var location = locations.XMLReq.responseXML.getElementsByTagName("location");
			for(i=0;i<location.length;i++)
			{		
				//alert('');
				var opt = document.createElement("option");
				opt.setAttribute("value",location[i].attributes[0].value);
				var txt = document.createTextNode(location[i].attributes[0].value);
				opt.appendChild(txt);
				
				var opt1 = document.createElement("option");
				opt1.setAttribute("value",location[i].attributes[0].value);
				var txt1 = document.createTextNode(location[i].attributes[0].value);
				opt1.appendChild(txt1);
				
				document.getElementById("allDrop").appendChild(opt);
				document.getElementById("allFrom").appendChild(opt1);
			}
			locations=null;
		}
	}
}
function loadPickupLocations_onLoad(){
	
	if (locations.XMLReq.readyState == 4) 
	{			
		//alert('');
        if (locations.XMLReq.status  == 200) 
		{
			var location = locations.XMLReq.responseXML.getElementsByTagName("location");
			for(i=0;i<location.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",location[i].attributes[0].value);
				var txt = document.createTextNode(location[i].attributes[0].value);
				opt.appendChild(txt);
			
				document.getElementById("pickUp").appendChild(opt);

			}
			locations=null;
		}
	}
}
function airportToCity_onLoad(){
	removeAllChild('dropOff');
	removeAllChild('pickUp');
	if (locations.XMLReq.readyState == 4) 
	{				
        if (locations.XMLReq.status  == 200) 
		{
			var city = locations.XMLReq.responseXML.getElementsByTagName("city");
			var airport = locations.XMLReq.responseXML.getElementsByTagName("airport");
			for(i=0;i<airport.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",airport[i].attributes[0].value);
				var txt = document.createTextNode(airport[i].attributes[0].value);
				opt.appendChild(txt);
				document.getElementById("pickUp").appendChild(opt);

			}
			for(i=0;i<city.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",city[i].attributes[0].value);
				var txt = document.createTextNode(city[i].attributes[0].value);
				opt.appendChild(txt);
				document.getElementById("dropOff").appendChild(opt);

			}
			locations=null;
		}
	}
}
function cityToAirport_onLoad(){
	removeAllChild('dropOff');
	removeAllChild('pickUp');
	if (locations.XMLReq.readyState == 4) 
	{				
        if (locations.XMLReq.status  == 200) 
		{
			var city = locations.XMLReq.responseXML.getElementsByTagName("city");
			var airport = locations.XMLReq.responseXML.getElementsByTagName("airport");
			for(i=0;i<airport.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",airport[i].attributes[0].value);
				var txt = document.createTextNode(airport[i].attributes[0].value);
				opt.appendChild(txt);
				document.getElementById("dropOff").appendChild(opt);

			}
			for(i=0;i<city.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",city[i].attributes[0].value);
				var txt = document.createTextNode(city[i].attributes[0].value);
				opt.appendChild(txt);
				document.getElementById("pickUp").appendChild(opt);

			}
			locations=null;
		}
	}
}
function airportToAirport_onLoad(){
	removeAllChild('dropOff');
	removeAllChild('pickUp');
	if (locations.XMLReq.readyState == 4) 
	{				
        if (locations.XMLReq.status  == 200) 
		{
			
			var airport = locations.XMLReq.responseXML.getElementsByTagName("airport");
			for(i=0;i<airport.length;i++)
			{		
				var opt = document.createElement("option");
				opt.setAttribute("value",airport[i].attributes[0].value);
				var txt = document.createTextNode(airport[i].attributes[0].value);
				opt.appendChild(txt);
				document.getElementById("dropOff").appendChild(opt);
				
				var opt1 = document.createElement("option");
				opt1.setAttribute("value",airport[i].attributes[0].value);
				var txt1 = document.createTextNode(airport[i].attributes[0].value);
				opt1.appendChild(txt1);
				document.getElementById("pickUp").appendChild(opt1);

			}
			
			locations=null;
		}
	}
}
///////////////////pick 1/////////
function airportToCity(){
		locations = new XmlConnector("http://www.ontimeairporttransfers.com/xmlWebServices/xml/airport_to_city.php");
		locations.XMLReq.onreadystatechange = airportToCity_onLoad;
}
function cityToAirport(){
		locations = new XmlConnector("http://www.ontimeairporttransfers.com/xmlWebServices/xml/airport_to_city.php");
		locations.XMLReq.onreadystatechange = cityToAirport_onLoad;
}
function airportToAirport(){
		locations = new XmlConnector("http://www.ontimeairporttransfers.com/xmlWebServices/xml/airport_to_city.php");
		locations.XMLReq.onreadystatechange = airportToAirport_onLoad;
}