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;
}

/*
----Modifies the path of document.forms[0].action to the specific one depending on language
*/

var httproot=location.href;
var spanish="alquiler-de-coches";
var test_lang=httproot.indexOf(spanish);

var var_www = httproot.indexOf("www");

if (test_lang == -1)
        //var allhttproot1 ="localhost/iberiacarhire.com/";
        var allhttproot1="iberiacarhire.com/";
else
        //var allhttproot1 ="localhost/iberiacarhire.com/alquiler-de-coches/";
        var allhttproot1="iberiacarhire.com/alquiler-de-coches/";

if (var_www != -1)
        var allhttproot = "http://www." + allhttproot1;
else
        var allhttproot = "http://" + allhttproot1;
//alert(allhttproot);
//alert (httproot);

//=====================================================================================================
//===================calculates the price in the booking form===========================================
 
function calculate_price() 
{ 
	xmlHttp=GetXmlHttpObject();
	var dir = document.getElementById("directory").value;

	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var country_id = document.getElementById("country").value; 

	if(country_id == 2)
	{
		//Portugal-  Auto Jardim
		var url_price = allhttproot+"/include/get_price_2.php?pickup=";
		var return_function = handleHttpResponse_price_2;
		var tolerance_hours = document.getElementById("tolerance_hours_portugal").value; 
		
	}
	else
	{
		//Spain - Auriga Crown
		var url_price = allhttproot+"/include/get_price.php?pickup=";
		var return_function = handleHttpResponse_price;
		var tolerance_hours = document.getElementById("tolerance_hours_spain").value; 
		//alert("ok - handleHttpResponse_price");
	}
	
	
	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("car_id").value;

	var location_from = document.getElementById("location_from").value;

	var location_to = document.getElementById("location_to").value;

	var one_day_rental_mes = document.getElementById("one_day_rental_mes").value;

	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];

	if(dropoff_time_arr[0] - pickup_time_arr[0] >= tolerance_hours  && (pickup != dropoff && checkmyDates_ajax(pickup, dropoff)))
	{
		alert(one_day_rental_mes);
	}

	//alert("lala:"+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);

	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, true); 
	xmlHttp.onreadystatechange = return_function; 
	xmlHttp.send(null);
}

//============for SPAIN=================================================
function handleHttpResponse_price() 
{ 
	//alert("ok");
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		if(document.onlinequote.sess_language_id.value == 1)
		{
			document.onlinequote.current_currency.value = 'euro';
			document.onlinequote.currency.value = 'euro';
		}

		xmlDoc=xmlHttp.responseXML;


		//alert(xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("test = "+xmlDoc.getElementsByTagName("total_promo_days")[0].childNodes[0].nodeValue);

		document.onlinequote.nrdays.value = xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue;
		//alert(xmlDoc.getElementsByTagName("days")[0].childNodes[0].nodeValue);
		document.onlinequote.car_name.value = xmlDoc.getElementsByTagName("car_name")[0].childNodes[0].nodeValue;

		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.onlinequote.totalprice_euro.value = document.onlinequote.total_price.value;

		//-----start---- test--bogdan--values----------
		//alert(xmlDoc.getElementsByTagName("test")[0].childNodes[0].nodeValue);
		//-----end---test-----

		if(xmlDoc.getElementsByTagName("not_hire_car_hour")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0) 
		{
			var open_hours_from = xmlDoc.getElementsByTagName("open_hours_from")[0].childNodes[0].nodeValue;
			var close_hours_from = xmlDoc.getElementsByTagName("close_hours_from")[0].childNodes[0].nodeValue;
			var open_hours_from_2 = xmlDoc.getElementsByTagName("open_hours_from_2")[0].childNodes[0].nodeValue;
			var close_hours_from_2 = xmlDoc.getElementsByTagName("close_hours_from_2")[0].childNodes[0].nodeValue;

			var week_day_pickup = xmlDoc.getElementsByTagName("week_day_pickup")[0].childNodes[0].nodeValue;

			var open_hours_to = xmlDoc.getElementsByTagName("open_hours_to")[0].childNodes[0].nodeValue;
			var close_hours_to = xmlDoc.getElementsByTagName("close_hours_to")[0].childNodes[0].nodeValue;
			var open_hours_to_2 = xmlDoc.getElementsByTagName("open_hours_to_2")[0].childNodes[0].nodeValue;
			var close_hours_to_2 = xmlDoc.getElementsByTagName("close_hours_to_2")[0].childNodes[0].nodeValue;

			var week_day_dropoff = xmlDoc.getElementsByTagName("week_day_dropoff")[0].childNodes[0].nodeValue;

			var location_from_name = xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue;
			var location_to_name = xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue;

			var closed_day_pick_up = xmlDoc.getElementsByTagName("closed_day_pick_up")[0].childNodes[0].nodeValue;
			var closed_day_drop_off = xmlDoc.getElementsByTagName("closed_day_drop_off")[0].childNodes[0].nodeValue;
						

			if(close_hours_from == open_hours_from_2)
			{
				draw_pick_mes = location_from_name + ' - ' + week_day_pickup + ' ( '+open_hours_from+' - '+close_hours_from_2 + ' )';
			}
			else
			{
				draw_pick_mes = location_from_name + ' - ' + week_day_pickup + ' ( '+open_hours_from+' - '+close_hours_from+'; '+open_hours_from_2+' - '+close_hours_from_2 + ' )';
			}
			
			if(close_hours_to == open_hours_to_2)
			{
				draw_drop_mes = location_to_name + ' - ' + week_day_dropoff + ' ( '+open_hours_to+' - '+close_hours_to_2 + ' )';
			}
			else
			{
				draw_drop_mes = location_to_name + ' - ' + week_day_dropoff + ' ( '+open_hours_to+' - '+close_hours_to+'; '+open_hours_to_2+' - '+close_hours_to_2 + ' )';
			}

			mesaj = '';

			if(xmlDoc.getElementsByTagName("not_hire_car_hour_from")[0].childNodes[0].nodeValue == 1)
			{
				if(closed_day_pick_up == 1)
				{
					//the office is closed in that day
					draw_pick_mes = " - " + week_day_pickup;
					var mesaj = document.onlinequote.pick_closed_mes.value+draw_pick_mes+document.onlinequote.pick_closed_mes_2.value + "\n\n";
				}
				else
				{
					//the office is closed at pick-up day and hour
					var mesaj = document.onlinequote.pick_mes.value+draw_pick_mes+document.onlinequote.pick_mes_2.value + "\n\n";
				}
			}
			if(xmlDoc.getElementsByTagName("not_hire_car_hour_to")[0].childNodes[0].nodeValue == 1)
			{
				if(closed_day_drop_off == 1)
				{
					//the office is closed in that day
					draw_drop_mes = " - " + week_day_dropoff;
					var mesaj = mesaj + document.onlinequote.drop_closed_mes.value+draw_drop_mes+document.onlinequote.drop_closed_mes_2.value;
				}
				else
				{
					//the office is closed at drop-off day and hour
					var mesaj = mesaj + document.onlinequote.drop_mes.value+draw_drop_mes+document.onlinequote.drop_mes_2.value;
				}
			}
			alert(mesaj);
			
		}
		else
		{
			if(xmlDoc.getElementsByTagName("not_hire_car")[0].childNodes[0].nodeValue == 1)
			{
				alert(document.onlinequote.car_not_available.value)
			}
			else
			{
				if(((xmlDoc.getElementsByTagName("compare")[0].childNodes[0].nodeValue == 1) || (xmlDoc.getElementsByTagName("compare2")[0].childNodes[0].nodeValue == 1)) && (document.onlinequote.total_price.value == 0))
				{
					alert('The price will be confirmed');					
				}
				
				var final_price = document.getElementById("final_price").value;

				if((final_price == 'yes') && (document.onlinequote.email_valid.value == 'yes'))
				{
					document.onlinequote.submit();
				}
			}
		}


	} 
	
} 
//==============================================================================

//============for PORTUGAL=================================================
function handleHttpResponse_price_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 

		if(document.onlinequote.sess_language_id.value == 1)
		{
			document.onlinequote.current_currency.value = 'euro';
			document.onlinequote.currency.value = 'euro';
		}
		xmlDoc=xmlHttp.responseXML;
		//alert(xmlDoc.getElementsByTagName("testing")[0].childNodes[0].nodeValue);
		//alert("nr_days = "+xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("testing = "+xmlDoc.getElementsByTagName("testing")[0].childNodes[0].nodeValue);
		//alert("loc_from = "+xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue);
		document.onlinequote.nrdays.value = xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue;
		document.onlinequote.car_name.value = xmlDoc.getElementsByTagName("car_name")[0].childNodes[0].nodeValue;
		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.onlinequote.totalprice_euro.value = document.onlinequote.total_price.value;

		var final_price = document.getElementById("final_price").value;

		if(xmlDoc.getElementsByTagName("not_hire_car_hour")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0) 
		{
			alert(document.onlinequote.pick_mes.value)
		}
		else
		{
			var final_price = document.getElementById("final_price").value;

			if((final_price == 'yes') && (document.onlinequote.email_valid.value == 'yes'))
			{
				document.onlinequote.submit();
			}
		}

	}	
}
//==================================================================================================================


//===================in PORTUGAL we show the cars for MADEIRA / PORTUGAL Continental=================================
function get_cars()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	var url_img = allhttproot+"include/get_cars.php?location_from="; 
	var location_from = document.getElementById("location_from").value; 

	curent_select_cars = document.getElementById("car_id");
	curent_select_cars.options[0] = new Option("Loading ...", "0|0");
	curent_select_cars.selectedIndex = 0;
	

	xmlHttp.open("GET", url_img + location_from, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_cars; 
	xmlHttp.send(null);
}

//===================================================================================================================
function handleHttpResponse_cars()
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		xmlDoc=xmlHttp.responseXML;

		curent_select_cars = document.getElementById("car_id");
		curent_select_cars.options[0] = new Option("Select a car ...", "0|0");
		curent_select_cars.options.length  = 1;

		var respNode = xmlDoc.getElementsByTagName("response")[0];
		var cars = respNode.getElementsByTagName("car");
		if(cars.length > 0)
		{
			for (var i=0; i<cars.length; i++)
			{
				var car_name = cars[i].getElementsByTagName("car_name")[0].firstChild.nodeValue;
				var car_value = cars[i].getElementsByTagName("car_value")[0].firstChild.nodeValue;
				
				curent_select_cars.options[i+1] = new Option(car_name, car_value);
				if(isNaN(car_value))
				{
					curent_select_cars.options[i+1].className="orange_bg";
				}
			}
			
		}
		curent_select_cars.selectedIndex = 0;
	} 

}
//============================END in PORTUGAL we show the cars for MADEIRA / PORTUGAL Continental=====================



//============================================================================================
//====================SPAIN - Auriga Crown======================================================
//====================calculates the price in iberia_book_personal.php================================
 
function calculate_price_extra() 
{ 
	var url_price_extra = allhttproot+"include/get_price_extra.php?nr_days=";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	
	var nr_days = document.getElementById("nr_days").innerHTML;
	var old_total_price = document.getElementById("old_total_price").value;


	//=========1. having second additional driver or not================
	var second_driver = document.getElementById("second_driver").value;
	//var second_add_driver_name = document.getElementById("second_add_driver_name").value;
	var second_add_driver_tax = document.getElementById("second_add_driver_tax").value;

	//=========2. having baby seat/child seat or not================
	var baby_seat = document.getElementById("baby_seat").value;
	var booster_seat = document.getElementById("booster_seat").value;

	var baby_seat_tax = document.getElementById("baby_seat_tax").value;
	var booster_seat_tax = document.getElementById("booster_seat_tax").value;

	//=========3. paying France insurance or not================
	if (document.getElementById("check_france_insurance").checked == true)
	{
		var check_france_insurance = 1;
	}
	else
	{
		var check_france_insurance = 0;
	}
	var france_insurance_tax = document.getElementById("france_insurance_tax").value;


	//alert("lala:"+url_price + pickup + "&dropoff=" + dropoff + "&pickup_time=" + pickup_time + "&dropoff_time=" + dropoff_time + "&car_id=" + car_id);
	//xmlHttp.open("GET", url_price_extra + baby_seat + "&booster_seat=" + booster_seat + "&child_seat=" + child_seat + "&nr_days=" + nr_days + "&old_total_price=" + old_total_price 
	//	+ "&old_extra=" + old_extra + "&additional_drivers=" + additional_drivers, true); 

	/*alert("lalalal = "+url_price_extra + nr_days + "&car_excess=" + car_excess + "&excess_insurance=" + excess_insurance + "&old_total_price=" + old_total_price 
		+ "&check_excess_insurance=" + check_excess_insurance 
		+ "&second_driver_name=" + second_driver_name + "&second_driver_tax=" + second_driver_tax 
		+ "&check_young_driver=" + check_young_driver + "&young_driver_tax=" + young_driver_tax 
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&child_seat=" + child_seat + "&child_seat_tax=" + child_seat_tax);*/

	xmlHttp.open("GET", url_price_extra + nr_days + "&old_total_price=" + old_total_price 
		+ "&second_driver=" + second_driver + "&second_add_driver_tax=" + second_add_driver_tax
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&booster_seat=" + booster_seat + "&booster_seat_tax=" + booster_seat_tax 
		+ "&check_france_insurance=" + check_france_insurance + "&france_insurance_tax=" + france_insurance_tax , true); 

	xmlHttp.onreadystatechange = handleHttpResponse_price_extra; 
	xmlHttp.send(null);
}

function handleHttpResponse_price_extra() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		//alert(xmlDoc.getElementsByTagName("cuc")[0].childNodes[0].nodeValue);

		var pound = document.getElementById("pound").value;
		document.getElementById("span_total_price").innerHTML = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.getElementById("span_total_price_pound").innerHTML = Math.round((xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue / pound) * 100) / 100;
			
		if(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_second_add_driver_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_second_add_driver_tax").style.display = "none";
		}
		
		document.getElementById("id_second_add_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_second_add_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		if(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_baby_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_baby_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_baby_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_baby_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_booster_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_booster_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_booster_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_booster_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		if(xmlDoc.getElementsByTagName("france_insurance_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_france_insurance_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_france_insurance_tax").style.display = "none";
		}
		
		document.getElementById("id_france_insurance_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("france_insurance_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_france_insurance_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("france_insurance_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.onlinequote.old_total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.onlinequote.second_add_driver_tax.value = xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.baby_seat_tax.value = xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.booster_seat_tax.value = xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.france_insurance_tax.value = xmlDoc.getElementsByTagName("france_insurance_tax")[0].childNodes[0].nodeValue;


		//document.onlinequote.extras.value = document.getElementById("span_extras").innerHTML;
		//document.onlinequote.old_extra.value = xmlDoc.getElementsByTagName("old_extra")[0].childNodes[0].nodeValue;
		//alert(xmlDoc.getElementsByTagName("cuc")[0].childNodes[0].nodeValue);
	} 
} 



//===================in PORTUGAL we show the cars for FARO PORTUGAL - for Auriga Crown=================================
function get_cars_faro()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	var url_img = allhttproot+"include/get_cars_faro.php?location_from="; 
	var location_from = document.getElementById("location_from").value; 

	if(location_from == 57)
	{
		//Faro
		//document.forms[0].action = 'http://192.168.2.4/iberiacarhire.com/work/iberia_book_personal_3.php';
		document.forms[0].action = allhttproot+'iberia_book_personal_3.php';
	}
	else
	{
		//document.forms[0].action = 'http://192.168.2.4/iberiacarhire.com/work/iberia_book_personal.php';
		document.forms[0].action = allhttproot+'iberia_book_personal.php';
	}

	curent_select_cars = document.getElementById("car_id");
	curent_select_cars.options[0] = new Option("Loading ...", "0|0");
	curent_select_cars.selectedIndex = 0;
	

	xmlHttp.open("GET", url_img + location_from, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_cars_faro; 
	xmlHttp.send(null);
}

//===================================================================================================================
function handleHttpResponse_cars_faro()
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		xmlDoc=xmlHttp.responseXML;

		curent_select_cars = document.getElementById("car_id");
		curent_select_cars.options[0] = new Option("Select a car ...", "0|0");
		curent_select_cars.options.length  = 1;

		var respNode = xmlDoc.getElementsByTagName("response")[0];
		var cars = respNode.getElementsByTagName("car");
		if(cars.length > 0)
		{
			for (var i=0; i<cars.length; i++)
			{
				var car_name = cars[i].getElementsByTagName("car_name")[0].firstChild.nodeValue;
				var car_value = cars[i].getElementsByTagName("car_value")[0].firstChild.nodeValue;
				
				curent_select_cars.options[i+1] = new Option(car_name, car_value);
				if(isNaN(car_value))
				{
					curent_select_cars.options[i+1].className="orange_bg";
				}
			}
			
		}
		curent_select_cars.selectedIndex = 0;
	} 

}
//============================END in PORTUGAL we show the cars for FARO, IBIZA at AurigaCrown=====================

//===================END SPAIN - Auriga Crown=======================================================
//====================================================================================================



//============================================================================================
//====================PORTUGAL - Auto Jardim======================================================
//====================calculates the price in iberia_book_personal_2.php================================

function calculate_price_extra_2() 
{ 
	var url_price_extra = allhttproot+"include/get_price_extra_2.php?nr_days="; 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	
	/*var baby_seat = document.getElementById("baby_seat").value;
	var booster_seat = document.getElementById("booster_seat").value;
	var child_seat = document.getElementById("child_seat").value;
	var old_total_price = document.getElementById("old_total_price").value;
	var old_extra = document.getElementById("old_extra").value;
	var additional_drivers = document.getElementById("additional_drivers").value;*/

    //=========1. pay exces insurance or not================
	if (document.getElementById("check_excess_insurance0").checked == true)
	{
		var check_excess_insurance = 0;
	}
	else
	{
		var check_excess_insurance = 1;
	}
	var car_excess = document.getElementById("car_excess").value;
	var nr_days = document.getElementById("nr_days").innerHTML;
	var old_total_price = document.getElementById("old_total_price").value;
	var excess_insurance = document.getElementById("excess_insurance").value;


	//=========2. having additional driver or not================
	var second_driver_name = document.getElementById("second_driver_name").value;
	var second_driver_tax = document.getElementById("second_driver_tax").value;

	//========3. pay young driver or not========================
	if (document.getElementById("check_young_driver").checked == true)
	{
		var check_young_driver = 1;
	}
	else
	{
		var check_young_driver = 0;
	}
	var young_driver_tax = document.getElementById("young_driver_tax").value;


	//=========4. having baby seat/child seat or not================
	var baby_seat = document.getElementById("baby_seat").value;
	var child_seat = document.getElementById("child_seat").value;

	var baby_seat_tax = document.getElementById("baby_seat_tax").value;
	var child_seat_tax = document.getElementById("child_seat_tax").value;

	//=========5. having roof rack or not================
	var add_roof_rack = "";
	var car_roofrack = document.getElementById("car_roofrack").value;
	if(car_roofrack != 0)
	{
		//===the roofrack can be fitted to this car============
		if (document.getElementById("check_roof_rack").checked == true)
		{
			var check_roof_rack = 1;
		}
		else
		{
			var check_roof_rack = 0;
		}
		var roof_rack_tax = document.getElementById("roof_rack_tax").value;
		var add_roof_rack = "&check_roof_rack=" + check_roof_rack + "&roof_rack_tax=" + roof_rack_tax;
	}

	//=========6. paying passenger insurance or not================
	if (document.getElementById("check_passenger_insurance").checked == true)
	{
		var check_passenger_insurance = 1;
	}
	else
	{
		var check_passenger_insurance = 0;
	}
	var passenger_insurance_tax = document.getElementById("passenger_insurance_tax").value;


	//alert("lala:"+url_price + pickup + "&dropoff=" + dropoff + "&pickup_time=" + pickup_time + "&dropoff_time=" + dropoff_time + "&car_id=" + car_id);
	//xmlHttp.open("GET", url_price_extra + baby_seat + "&booster_seat=" + booster_seat + "&child_seat=" + child_seat + "&nr_days=" + nr_days + "&old_total_price=" + old_total_price 
	//	+ "&old_extra=" + old_extra + "&additional_drivers=" + additional_drivers, true); 

	/*alert("lalalal = "+url_price_extra + nr_days + "&car_excess=" + car_excess + "&excess_insurance=" + excess_insurance + "&old_total_price=" + old_total_price 
		+ "&check_excess_insurance=" + check_excess_insurance 
		+ "&second_driver_name=" + second_driver_name + "&second_driver_tax=" + second_driver_tax 
		+ "&check_young_driver=" + check_young_driver + "&young_driver_tax=" + young_driver_tax 
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&child_seat=" + child_seat + "&child_seat_tax=" + child_seat_tax);*/

	xmlHttp.open("GET", url_price_extra + nr_days + "&car_excess=" + car_excess + "&excess_insurance=" + excess_insurance + "&old_total_price=" + old_total_price 
		+ "&check_excess_insurance=" + check_excess_insurance 
		+ "&second_driver_name=" + second_driver_name + "&second_driver_tax=" + second_driver_tax 
		+ "&check_young_driver=" + check_young_driver + "&young_driver_tax=" + young_driver_tax 
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&child_seat=" + child_seat + "&child_seat_tax=" + child_seat_tax 
		+ add_roof_rack 
		+ "&check_passenger_insurance=" + check_passenger_insurance + "&passenger_insurance_tax=" + passenger_insurance_tax , true); 

	xmlHttp.onreadystatechange = handleHttpResponse_price_extra_2; 
	xmlHttp.send(null);
}

function handleHttpResponse_price_extra_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;
		var pound = document.getElementById("pound").value;
		document.getElementById("span_total_price").innerHTML = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.getElementById("span_total_price_pound").innerHTML = Math.round((xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue / pound) * 100) / 100;

		document.getElementById("span_excess").innerHTML = parseFloat(xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue);
		document.getElementById("span_excess_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_second_driver_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_second_driver_tax").style.display = "none";
		}
		
		document.getElementById("id_second_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_second_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		if(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_young_driver_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_young_driver_tax").style.display = "none";
		}
		
		document.getElementById("id_young_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_young_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		if(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_baby_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_baby_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_baby_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_baby_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_child_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_child_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_child_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_child_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_roof_rack_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_roof_rack_tax").style.display = "none";
		}
		
		document.getElementById("id_roof_rack_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_roof_rack_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_passenger_insurance_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_passenger_insurance_tax").style.display = "none";
		}
		
		document.getElementById("id_passenger_insurance_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_passenger_insurance_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		document.onlinequote.excess_insurance.value = xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue;

		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.onlinequote.old_total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.onlinequote.second_driver_tax.value = xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.young_driver_tax.value = xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.baby_seat_tax.value = xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.child_seat_tax.value = xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.roof_rack_tax.value = xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.passenger_insurance_tax.value = xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue;


		//document.onlinequote.extras.value = document.getElementById("span_extras").innerHTML;
		//document.onlinequote.old_extra.value = xmlDoc.getElementsByTagName("old_extra")[0].childNodes[0].nodeValue;
		//alert(xmlDoc.getElementsByTagName("cuc")[0].childNodes[0].nodeValue);
	} 
} 
//===================END PORTUGAL - Auto Jardim=======================================================
//====================================================================================================



//============================================================================================
//====================START PORTUGAL - FARO - Auriga Crown======================================================
//====================calculates the price in iberia_book_personal_3.php================================
 
function calculate_price_extra_3() 
{ 
	var url_price_extra = allhttproot+"include/get_price_extra_3.php?nr_days=";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	
	var nr_days = document.getElementById("nr_days").innerHTML;
	var old_total_price = document.getElementById("old_total_price").value;


	//=========1. having second additional driver or not================
	var second_driver = document.getElementById("second_driver").value;
	//var second_add_driver_name = document.getElementById("second_add_driver_name").value;
	var second_add_driver_tax = document.getElementById("second_add_driver_tax").value;

	//=========2. having baby seat/child seat or not================
	var baby_seat = document.getElementById("baby_seat").value;
	var booster_seat = document.getElementById("booster_seat").value;

	var baby_seat_tax = document.getElementById("baby_seat_tax").value;
	var booster_seat_tax = document.getElementById("booster_seat_tax").value;

	//=========3. paying young driver or not================
	if (document.getElementById("check_young_driver").checked == true)
	{
		var check_young_driver = 1;
	}
	else
	{
		var check_young_driver = 0;
	}
	var young_driver_tax = document.getElementById("young_driver_tax").value;


	//=========4. paying PAI insurance or not================
	if (document.getElementById("check_pai_insurance").checked == true)
	{
		var check_pai_insurance = 1;
	}
	else
	{
		var check_pai_insurance = 0;
	}
	var pai_insurance_tax = document.getElementById("pai_insurance_tax").value;

	//=========5. paying GPS or not================
	if (document.getElementById("check_gps").checked == true)
	{
		var check_gps = 1;
	}
	else
	{
		var check_gps = 0;
	}
	var gps_tax = document.getElementById("gps_tax").value;

	//=========6. having additional driver or not================
	var second_driver = document.getElementById("second_driver").value;

	var second_add_driver_tax = document.getElementById("second_add_driver_tax").value;




	//alert("lala:"+url_price + pickup + "&dropoff=" + dropoff + "&pickup_time=" + pickup_time + "&dropoff_time=" + dropoff_time + "&car_id=" + car_id);
	//xmlHttp.open("GET", url_price_extra + baby_seat + "&booster_seat=" + booster_seat + "&child_seat=" + child_seat + "&nr_days=" + nr_days + "&old_total_price=" + old_total_price 
	//	+ "&old_extra=" + old_extra + "&additional_drivers=" + additional_drivers, true); 

	/*alert("lalalal = "+url_price_extra + nr_days + "&car_excess=" + car_excess + "&excess_insurance=" + excess_insurance + "&old_total_price=" + old_total_price 
		+ "&check_excess_insurance=" + check_excess_insurance 
		+ "&second_driver_name=" + second_driver_name + "&second_driver_tax=" + second_driver_tax 
		+ "&check_young_driver=" + check_young_driver + "&young_driver_tax=" + young_driver_tax 
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&child_seat=" + child_seat + "&child_seat_tax=" + child_seat_tax);*/

	xmlHttp.open("GET", url_price_extra + nr_days + "&old_total_price=" + old_total_price 
		+ "&second_driver=" + second_driver + "&second_add_driver_tax=" + second_add_driver_tax
		+ "&baby_seat=" + baby_seat + "&baby_seat_tax=" + baby_seat_tax 
		+ "&booster_seat=" + booster_seat + "&booster_seat_tax=" + booster_seat_tax 
		+ "&check_pai_insurance=" + check_pai_insurance + "&pai_insurance_tax=" + pai_insurance_tax+ "&check_gps=" + check_gps + "&gps_tax=" + gps_tax + "&check_young_driver=" + check_young_driver + "&young_driver_tax=" + young_driver_tax + "&second_driver=" + second_driver + "&second_add_driver_tax=" + second_add_driver_tax, true); 

	xmlHttp.onreadystatechange = handleHttpResponse_price_extra_3; 
	xmlHttp.send(null);
}

function handleHttpResponse_price_extra_3() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		//alert(xmlDoc.getElementsByTagName("cuc")[0].childNodes[0].nodeValue);

		var pound = document.getElementById("pound").value;
		document.getElementById("span_total_price").innerHTML = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.getElementById("span_total_price_pound").innerHTML = Math.round((xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue / pound) * 100) / 100;

		
		if(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_second_add_driver_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_second_add_driver_tax").style.display = "none";
		}
		
		document.getElementById("id_second_add_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_second_add_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		if(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_baby_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_baby_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_baby_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_baby_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		if(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_booster_seat_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_booster_seat_tax").style.display = "none";
		}
		
		document.getElementById("id_booster_seat_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_booster_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		//=======young driver div========================================================
		if(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_young_driver_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_young_driver_tax").style.display = "none";
		}
		
		document.getElementById("id_young_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_young_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;


		//=====PAI insurance div===========================================================
		if(xmlDoc.getElementsByTagName("pai_insurance_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_pai_insurance_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_pai_insurance_tax").style.display = "none";
		}
		
		document.getElementById("id_pai_insurance_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("pai_insurance_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_pai_insurance_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("pai_insurance_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		//=======GPS tax div========================================================
		if(xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_gps_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_gps_tax").style.display = "none";
		}
		
		document.getElementById("id_gps_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue);
		document.getElementById("id_gps_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;
		//==================================================================================================


		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.onlinequote.old_total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.onlinequote.second_add_driver_tax.value = xmlDoc.getElementsByTagName("second_add_driver_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.baby_seat_tax.value = xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.booster_seat_tax.value = xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue;

		document.onlinequote.young_driver_tax.value = xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.pai_insurance_tax.value = xmlDoc.getElementsByTagName("pai_insurance_tax")[0].childNodes[0].nodeValue;
		document.onlinequote.gps_tax.value = xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue;


		//document.onlinequote.extras.value = document.getElementById("span_extras").innerHTML;
		//document.onlinequote.old_extra.value = xmlDoc.getElementsByTagName("old_extra")[0].childNodes[0].nodeValue;
		//alert(xmlDoc.getElementsByTagName("cuc")[0].childNodes[0].nodeValue);
	} 
} 
//============================================================================================
//====================END PORTUGAL - FARO - Auriga Crown======================================================
//============================================================================================




//=======================================================================================
//===============changes the car image in the booking form================================

function getimage() 
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url_img = allhttproot+"include/get_image.php?car_id="; 
	var my_car_id = document.getElementById("car_id").value; 

	xmlHttp.open("GET", url_img + my_car_id, true); 
	xmlHttp.onreadystatechange = handleHttpResponse; 
	xmlHttp.send(null);
}

function handleHttpResponse() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;
		
		document.getElementById("image_car").src = xmlDoc.getElementsByTagName("image")[0].childNodes[0].nodeValue;
	} 
}

//==================================================================================
//====================shows the locations in the selected country=====================
var url = allhttproot+'include/get_locations.php?country_id=';
function getlocations()
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

	curent_select = document.getElementById("location_from");
	curent_select.options[0] = new Option("Loading ...", "0|0");
	curent_select.selectedIndex = 0;

	curent_select_to = document.getElementById("location_to");
	curent_select_to.options[0] = new Option("Loading ...", "0|0");
	curent_select_to.selectedIndex = 0;

	curent_select_cars = document.getElementById("car_id");
	curent_select_cars.options[0] = new Option("Loading ...", "0|0");
	curent_select_cars.selectedIndex = 0;

	var country_id = document.getElementById("country").value; 

	if(country_id == 1)
	{
		//document.forms[0].action = 'http://www.iberiacarhire.com/iberia_book_personal.php';
		document.forms[0].action = allhttproot+'iberia_book_personal.php';
	}
	else if(country_id == 2)
	{
		//document.forms[0].action = 'http://www.iberiacarhire.com/iberia_book_personal_2.php';
		document.forms[0].action = allhttproot+'iberia_book_personal_2.php';
	}

	xmlHttp.open("GET", url + country_id, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_locations; 
	xmlHttp.send(null);
}

//======================================================================================
function handleHttpResponse_locations()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		curent_select = document.getElementById("location_from");
		curent_select.options[0] = new Option("Select Location ...", "0|0");
		curent_select.options.length  = 1;

		curent_select_to = document.getElementById("location_to");
		curent_select_to.options[0] = new Option("Select Location ...", "0|0");
		curent_select_to.options.length  = 1;

		curent_select_cars = document.getElementById("car_id");
		curent_select_cars.options[0] = new Option("Select a car ...", "0|0");
		curent_select_cars.options.length  = 1;

		var respNode = xmlDoc.getElementsByTagName("response")[0];
		var items = respNode.getElementsByTagName("item");
		if(items.length > 0)
		{
			for (var i=0; i<items.length; i++)
			{
				var name = items[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				var value = items[i].getElementsByTagName("value")[0].firstChild.nodeValue;

				if(name == '=====AIRPORTS=====')
				{
					value = "<span class='title_text'>"+value+"</span>";
				}

				if(name == '=====DOWN_TOWN=====')
				{
					value = "<span class='title_text'>"+value+"</span>";
				}
				curent_select.options[i+1] = new Option(name, value);
				curent_select_to.options[i+1] = new Option(name, value);
				if(isNaN(value))
				{
					curent_select.options[i+1].className = "orange_bg";
					curent_select_to.options[i+1].className = "orange_bg"; 
				}

			}
		}

		curent_select.selectedIndex = 0;
		curent_select_to.selectedIndex = 0;

		var cars = respNode.getElementsByTagName("car");
		if(cars.length > 0)
		{
			for (var i=0; i<cars.length; i++)
			{
				var car_name = cars[i].getElementsByTagName("car_name")[0].firstChild.nodeValue;
				var car_value = cars[i].getElementsByTagName("car_value")[0].firstChild.nodeValue;
				//alert("Car name = "+car_name);

				curent_select_cars.options[i+1] = new Option(car_name, car_value);
				if(isNaN(car_value))
				{
					curent_select_cars.options[i+1].className="orange_bg";
				}
			}
			
		}
		curent_select_cars.selectedIndex = 0;
	} 
	
}

//===============FOR THE ADMINISTRATION SECTION============================
//===============used for Edit Booking - edit_booking.php - added by Irina on 2 March 2010==========
//=====================================================================================================
//===================calculates the price in the booking form===========================================
 
/*function calculate_price_admin() 
{ 
	xmlHttp=GetXmlHttpObject();
	var dir = document.getElementById("directory").value;
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var country_id = document.getElementById("country").value; 

	if(country_id == 2)
	{
		//Portugal-  Auto Jardim
		var url_price = allhttproot+"/include/get_price_2.php?pickup=";
		var return_function = handleHttpResponse_price_2;
		var tolerance_hours = document.getElementById("tolerance_hours_portugal").value; 
		
	}
	else
	{
		//Spain - Auriga Crown
		var url_price = allhttproot+"/include/get_price.php?pickup=";
		var return_function = handleHttpResponse_price;
		var tolerance_hours = document.getElementById("tolerance_hours_spain").value; 
		//alert("ok - handleHttpResponse_price");
	}
	
	
	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("car_id").value;

	var location_from = document.getElementById("location_from").value;

	var location_to = document.getElementById("location_to").value;

	var one_day_rental_mes = document.getElementById("one_day_rental_mes").value;

	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];

	if(dropoff_time_arr[0] - pickup_time_arr[0] >= tolerance_hours  && (pickup != dropoff && checkmyDates_ajax(pickup, dropoff)))
	{
		alert(one_day_rental_mes);
	}

	//alert("lala:"+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);

	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, true); 
	xmlHttp.onreadystatechange = return_function; 
	xmlHttp.send(null);
}

//============for SPAIN=================================================
function handleHttpResponse_price() 
{ 
	//alert("ok");
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		if(document.onlinequote.sess_language_id.value == 1)
		{
			document.onlinequote.current_currency.value = 'euro';
			document.onlinequote.currency.value = 'euro';
		}

		xmlDoc=xmlHttp.responseXML;


		//alert(xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("test = "+xmlDoc.getElementsByTagName("total_promo_days")[0].childNodes[0].nodeValue);

		document.onlinequote.nrdays.value = xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue;
		//alert(xmlDoc.getElementsByTagName("days")[0].childNodes[0].nodeValue);
		document.onlinequote.car_name.value = xmlDoc.getElementsByTagName("car_name")[0].childNodes[0].nodeValue;

		document.onlinequote.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.onlinequote.totalprice_euro.value = document.onlinequote.total_price.value;

		//-----start---- test--bogdan--values----------
		//alert(xmlDoc.getElementsByTagName("test")[0].childNodes[0].nodeValue);
		//-----end---test-----

		if(xmlDoc.getElementsByTagName("not_hire_car_hour")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0) 
		{
			var open_hours_from = xmlDoc.getElementsByTagName("open_hours_from")[0].childNodes[0].nodeValue;
			var close_hours_from = xmlDoc.getElementsByTagName("close_hours_from")[0].childNodes[0].nodeValue;
			var open_hours_from_2 = xmlDoc.getElementsByTagName("open_hours_from_2")[0].childNodes[0].nodeValue;
			var close_hours_from_2 = xmlDoc.getElementsByTagName("close_hours_from_2")[0].childNodes[0].nodeValue;

			var week_day_pickup = xmlDoc.getElementsByTagName("week_day_pickup")[0].childNodes[0].nodeValue;

			var open_hours_to = xmlDoc.getElementsByTagName("open_hours_to")[0].childNodes[0].nodeValue;
			var close_hours_to = xmlDoc.getElementsByTagName("close_hours_to")[0].childNodes[0].nodeValue;
			var open_hours_to_2 = xmlDoc.getElementsByTagName("open_hours_to_2")[0].childNodes[0].nodeValue;
			var close_hours_to_2 = xmlDoc.getElementsByTagName("close_hours_to_2")[0].childNodes[0].nodeValue;

			var week_day_dropoff = xmlDoc.getElementsByTagName("week_day_dropoff")[0].childNodes[0].nodeValue;

			var location_from_name = xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue;
			var location_to_name = xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue;

			var closed_day_pick_up = xmlDoc.getElementsByTagName("closed_day_pick_up")[0].childNodes[0].nodeValue;
			var closed_day_drop_off = xmlDoc.getElementsByTagName("closed_day_drop_off")[0].childNodes[0].nodeValue;
						

			if(close_hours_from == open_hours_from_2)
			{
				draw_pick_mes = location_from_name + ' - ' + week_day_pickup + ' ( '+open_hours_from+' - '+close_hours_from_2 + ' )';
			}
			else
			{
				draw_pick_mes = location_from_name + ' - ' + week_day_pickup + ' ( '+open_hours_from+' - '+close_hours_from+'; '+open_hours_from_2+' - '+close_hours_from_2 + ' )';
			}
			
			if(close_hours_to == open_hours_to_2)
			{
				draw_drop_mes = location_to_name + ' - ' + week_day_dropoff + ' ( '+open_hours_to+' - '+close_hours_to_2 + ' )';
			}
			else
			{
				draw_drop_mes = location_to_name + ' - ' + week_day_dropoff + ' ( '+open_hours_to+' - '+close_hours_to+'; '+open_hours_to_2+' - '+close_hours_to_2 + ' )';
			}

			mesaj = '';

			if(xmlDoc.getElementsByTagName("not_hire_car_hour_from")[0].childNodes[0].nodeValue == 1)
			{
				if(closed_day_pick_up == 1)
				{
					//the office is closed in that day
					draw_pick_mes = " - " + week_day_pickup;
					var mesaj = document.onlinequote.pick_closed_mes.value+draw_pick_mes+document.onlinequote.pick_closed_mes_2.value + "\n\n";
				}
				else
				{
					//the office is closed at pick-up day and hour
					var mesaj = document.onlinequote.pick_mes.value+draw_pick_mes+document.onlinequote.pick_mes_2.value + "\n\n";
				}
			}
			if(xmlDoc.getElementsByTagName("not_hire_car_hour_to")[0].childNodes[0].nodeValue == 1)
			{
				if(closed_day_drop_off == 1)
				{
					//the office is closed in that day
					draw_drop_mes = " - " + week_day_dropoff;
					var mesaj = mesaj + document.onlinequote.drop_closed_mes.value+draw_drop_mes+document.onlinequote.drop_closed_mes_2.value;
				}
				else
				{
					//the office is closed at drop-off day and hour
					var mesaj = mesaj + document.onlinequote.drop_mes.value+draw_drop_mes+document.onlinequote.drop_mes_2.value;
				}
			}
			alert(mesaj);
			
		}
		else
		{
			if(xmlDoc.getElementsByTagName("not_hire_car")[0].childNodes[0].nodeValue == 1)
			{
				alert(document.onlinequote.car_not_available.value)
			}
			else
			{
				if(((xmlDoc.getElementsByTagName("compare")[0].childNodes[0].nodeValue == 1) || (xmlDoc.getElementsByTagName("compare2")[0].childNodes[0].nodeValue == 1)) && (document.onlinequote.total_price.value == 0))
				{
					alert('The price will be confirmed');					
				}
				
				var final_price = document.getElementById("final_price").value;

				if((final_price == 'yes') && (document.onlinequote.email_valid.value == 'yes'))
				{
					document.onlinequote.submit();
				}
			}
		}


	} 
	
} */
//==============================================================================