/*==============================================================================*/
/*=====================Lists the countries======================================*/
var _global = this;

function single_return()
{
	if (document.lbBO.triptype.value == 'S')	
		document.lbBO.dropofftime.disabled = true;
	else if(document.lbBO.triptype.value == 'R')
		document.lbBO.dropofftime.disabled = false;
}

/*==============================================================================*/

function list_postcodes(postcodeid)//regionid is used for when the form is loaded on an edit screen and we know the regionid
{	
	getData('/files/quotes/ajax-forms/drop-ajax.php?list_postcodes=1&postcodeid=' + postcodeid, 'postcodes'); 
}

function list_postcodes_destination(postcodeid_destination)//regionid is used for when the form is loaded on an edit screen and we know the regionid
{	
	getData('/files/quotes/ajax-forms/drop-ajax.php?list_postcodes_destination=1&postcodeid_destination=' + postcodeid_destination, 'postcodes_destination'); 
}

function postcode_exclude()//regionid is used for when the form is loaded on an edit screen and we know the regionid
{	
	postcodeid_destination = document.lbBO.postcodeid_destination.value;
	postcodeid = document.lbBO.postcodeid.value;
	if (postcodeid_destination != '' && postcodeid != '')	
	{
		return_result('ajax-forms/drop-ajax.php?postcode_exclude=1&postcodeid=' + postcodeid + '&postcodeid_destination=' + postcodeid_destination, 'quote_form', 'finished'); 
	}
}

function finished(result, divname)
{
	if(result != 1)
		document.getElementById(divname).innerHTML = result;

/*'<div style="margin-left:20px; position:absolute; border: 1px #000000 solid; top:250px; width:738px; height:200px; font-size:24px; z-index:100; color:#FF0000"><iframe src="http://limobroker/push/files/blank/blank.php" width="738px" height="250" scrolling="no" frameborder="0" /></div>';*/
	
}
/*==============================================================================*/
/*=====================Main xmlHTTP Function====================================*/

function newXmlHttpRequest() {
// we first try to use ActiveX, because IE7 has a direct support for XmlHttpRequest object, 
// but which doesn't work with file urls
 req = false;
 if(window.ActiveXObject)
 {
  try { req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
   try { req = new ActiveXObject("Microsoft.XMLHTTP");
   } catch(e) { req = false; }
  }
 }
 else if(window.XMLHttpRequest) {
  try { req = new XMLHttpRequest();
  } catch(e) { req = false; }
 }

 return req; 
}

function getData(query, divname) 
{

	var xmlhttp = false;	
	xmlhttp = newXmlHttpRequest();
	
	if(query != "") 
	{
		var timer = + new Date().getTime();
		var url = query + "&r=" + timer;
		document.getElementById(divname).innerHTML = "Updating...";		
		xmlhttp.open('GET', url, true);	
			xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 									
				document.getElementById(divname).innerHTML = xmlhttp.responseText + ' ';							
			else 
				document.getElementById(divname).innerHTML = '<p class="text">Processing..</p>';			
		};
		
		xmlhttp.send(null);  
	}
}

function getData(query, divname) 
{
	var xmlhttp = false;	
	
	xmlhttp = newXmlHttpRequest();
	
	if(query != "") 
	{
		var timer = + new Date().getTime();
		var url = query + "&r=" + timer;
		document.getElementById(divname).innerHTML = "Updating...";		
		xmlhttp.open('GET', url, true);	
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 									
				document.getElementById(divname).innerHTML = xmlhttp.responseText + ' ';							
			else 
				document.getElementById(divname).innerHTML = '<p class="text">Processing..</p>';			
		};
		
		xmlhttp.send(null);  
	}
}

function return_result (query, divname, function_name) 
{
	var xmlhttp = false;	
	
	xmlhttp = newXmlHttpRequest();
	
	if(query != "") 
	{
		var timer = + new Date().getTime();
		var url = query + "&r=" + timer;
		xmlhttp.open('GET', url, true);	
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 													
				_global[function_name](xmlhttp.responseText, divname);		
		};				
		xmlhttp.send(null);  
		
	}
}
