var xmlHttp
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;
}

//=====================================================================================================
//===================calculates the price in the booking form===========================================
var allhttproot = "http://www.lagoscarhire.com/";

function quote_ajax() 
{ 

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	//var general_link = document.getElementById("general_link").value; 
	//var directory = document.getElementById("directory").value;
	var url_price = allhttproot + "include/quote_ajax.php?pickup=";
	var pickup = document.getElementById("pickup").value;
	var dropoff = document.getElementById("dropoff").value;
	var pickup_time = document.getElementById("pickup_time").value; 
	var dropoff_time = document.getElementById("dropoff_time").value;
	var car_id = document.getElementById("booking_car").value;
	var location_from = document.getElementById("location_from").value;
	var location_to = document.getElementById("location_to").value;
	var quote_id = document.getElementById("quote_id").value;
	
	
	if (quote_id == 0) {
		var additional_quote_param = "&quote_id=0";
	} else {
		var additional_quote_param = "&quote_id=" + quote_id;
	}
	
	pickup_time_arr = pickup_time.split(':');
	dropoff_time_arr = dropoff_time.split(':');
	pickup_time_arr[0] = parseFloat(pickup_time_arr[0]);
	dropoff_time_arr[0] = parseFloat(dropoff_time_arr[0]);
	valoare = pickup_time_arr[0] - dropoff_time_arr[0];

	/*alert(url_price + pickup + 
		"&dropoff=" + dropoff + 
		"&pickup_time=" + pickup_time + 
		"&dropoff_time=" + dropoff_time + 
		"&car_id=" + car_id + 
		"&location_from=" + location_from + 
		"&location_to=" + location_to + additional_quote_param);*/
	
	//alert(additional_quote_param);	
		
	xmlHttp.open("GET", url_price + pickup + 
		"&dropoff=" + dropoff + 
		"&pickup_time=" + pickup_time + 
		"&dropoff_time=" + dropoff_time + 
		"&car_id=" + car_id + 
		"&location_from=" + location_from + 
		"&location_to=" + location_to +  additional_quote_param, true); 
	
	xmlHttp.onreadystatechange = handleHttpResponse_quote_ajax;
	xmlHttp.send(null);
}

//============for PORTUGAL=================================================
function handleHttpResponse_quote_ajax() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	

		xmlDoc=xmlHttp.responseXML;
		document.onlinequote.quote_id.value = xmlDoc.getElementsByTagName("quote_id")[0].childNodes[0].nodeValue;
	}	
}

