function one_way(chk_box)
{
	if(chk_box)
	{
		document.frmsearch.txt_return.value = 'one way';	
	}
	else
	{
		document.frmsearch.txt_return.value = '';	
	}
}

function one_way_checked()
{
	document.frmsearch.txt_oneway.checked = false;
	if(document.frmsearch.txt_return.value == 'one way')
	{
		document.frmsearch.txt_return.value = '';
	}
}

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;
		}
		function fill_source(txt_search,div_id,loc_id)
		{	
			xmlHttp=GetXmlHttpObject();
			if(xmlHttp==null)
			{
				alert("Browser does not support HTTP Request");
				return;
			}
			var url='search_address.php?search_name='+txt_search.name+'&s='+txt_search.value+'&loc_id='+loc_id;
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{
					
					
					if(xmlHttp.responseText.length>0)
					{
						document.getElementById(div_id).style.width='auto';
						document.getElementById(div_id).innerHTML = xmlHttp.responseText;
						document.getElementById(div_id).style.display = 'block';
						document.getElementById(loc_id).value = '';
					}
					else
					{
						document.getElementById(div_id).style.display = 'none';
					}
				}
				else
				{
					document.getElementById(div_id).style.width='323';
					document.getElementById(div_id).innerHTML = "Searching...";
					document.getElementById(div_id).style.display = 'block';
				}
			}
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		function check_airport(tmp_source_airport,tmp_dest_airport,tmp_depart_dt,tmp_return_dt)
		{	
			document.getElementById('div_source').innerHTML = '';
			document.getElementById('div_source').style.display = 'none';
			document.getElementById('div_dest').innerHTML = '';
			document.getElementById('div_dest').style.display = 'none';
			var resultarr;
			var result;
			result							= true;
			xmlHttp=GetXmlHttpObject();
			if(xmlHttp==null)
			{
				alert("Browser does not support HTTP Request");
				return;
			}
			var url='search_airport.php?sa='+tmp_source_airport+'&da='+tmp_dest_airport+'&depdt='+tmp_depart_dt+'&redt='+tmp_return_dt;
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{
					if(document.frmsearch.txt_depart.value == '')	
					{
						document.getElementById('depart_error').innerHTML = 'Please enter date';
						document.getElementById('depart_error').style.display = 'block';
						result				= false;
					}
					else
					{
						document.getElementById('depart_error').style.display = 'none';
					}
					if(document.frmsearch.txt_return.value == '')	
					{
						document.getElementById('return_error').innerHTML = 'Please enter date';
						document.getElementById('return_error').style.display = 'block';
						result				= false;
					}
					else
					{
						document.getElementById('return_error').style.display = 'none';	
					}
					resultarr		= xmlHttp.responseText.split('-');
					if(resultarr[0] == 'Y' && resultarr[1] == 'Y' && result == true)
					{
						document.frmsearch.submit();
					}
					else
					{	
						if(resultarr[3]	== 'N')
						{
							document.getElementById('dep_error').innerHTML = 'Departure date should be greater/equal to current date...';
							document.getElementById('dep_error').style.display = 'block';	
						}
						else
						{
							document.getElementById('dep_error').innerHTML = "";
							document.getElementById('dep_error').style.display = 'none';
						}
						
						if(resultarr[2]	== 'N')
						{
							document.getElementById('dt_error').innerHTML = 'Return date should be greater/equal to departure date...';
							document.getElementById('dt_error').style.display = 'block';
						}else
							{
								document.getElementById('dt_error').innerHTML = '';
								document.getElementById('dt_error').style.display = 'none';
							}
						if(resultarr[0] == 'N')
						{
							document.getElementById('s_error').innerHTML = 'Airport does not exist...';
							document.getElementById('s_error').style.display = 'block';
						}
						else
						{
							document.getElementById('s_error').innerHTML = '';
							document.getElementById('s_error').style.display = 'none';
						}
						if(resultarr[1] == 'N')
						{
							document.getElementById('d_error').innerHTML = 'Airport does not exist...';
							document.getElementById('d_error').style.display = 'block';
						}
						else
						{
							document.getElementById('d_error').innerHTML = '';
							document.getElementById('d_error').style.display = 'none';
						}
					}
				}
			}
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		function show_value(tmp_text_box,tmp_value,tmp_id,tmp_loc_id)
		{
			var hide_div;
			if(tmp_loc_id == "source_loc_id")
			{
				hide_div		= 'div_source';
			}
			else
			{
				hide_div		= 'div_dest';
			}
			document.getElementById(tmp_text_box).value = tmp_value;
			document.getElementById(hide_div).style.display = 'none';
			document.getElementById(tmp_loc_id).value = tmp_id;
			//document.getElementById('txt_dest').focus();
		}
		
		function show_airport(tmp_text_box,tmp_value,tmp_id,tmp_loc_id)
		{
			document.getElementById(tmp_text_box).value = tmp_value;
			document.getElementById(tmp_loc_id).value = tmp_id;
			//document.getElementById('txt_dest').focus();
		}
		function hide_div(div_id)
		{
			document.getElementById(div_id).style.display='none';
		}
		
		
		function mycenteralpopwinVHS(fname,width,height)
{
	var file
	var sWidth	= 200
	var sHeight = 200
	
	if(width.length > 0)
	{
		sWidth = width;
	}
	else
	{
		width =100;
	}
	
	if(height.length > 0)
	{
		sHeight = height;
	}
	else
	{
		height =100;
	}
	
	file = fname
	file =file	
	
	var wintop  =window.screen.availHeight;
	var winleft =window.screen.availWidth;
	wintop  =(wintop/2) -(height/2)
	winleft =(winleft/2) -(width/2)
	//wintop  = 0
	//winleft = 0
	
	if ( sWidth > window.screen.availWidth )
		{ sWidth = window.screen.availWidth; }
	if (sHeight > window.screen.availHeight )
		{ sHeight = window.screen.availHeight; }
	if ( parseInt(sWidth) < width )
		{ sWidth = width; }
	if ( parseInt(sHeight) < height )
		{ sHeight = height; }
	
	if ( navigator.appName == "Microsoft Internet Explorer" )
		{ window.open(file, "_blank", "status=no, scrollbars=yes, toolbar=no, resizable=yes, location=no, menubar=no, top=" + wintop + ", left= "+ winleft +", height=" + sHeight + ", width=" + sWidth); 
		}
	if ( navigator.appName == "Netscape" ) 
		{ 
		window.open(file,"_blank","scrollbars=yes,alwaysRaised,resizable=yes,dependant,innerheight=" + sHeight + ",innerwidth=" + sWidth); 		 
		//window.open(file,"_blank","alwaysRaised,dependant,scrollbars=yes,innerheight=" + sHeight + ",innerwidth=" + sWidth); 
		}
}
