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.autocarhire.net/"; 
var allhttproot="http://autocarrental.net/";
//var allhttproot="http://localhost/autocarhire.net/work/autocarhire_promotions/"; 

function calculate_price() 
{ 

	xmlHttp=GetXmlHttpObject();
	var dir = document.getElementById("directory").value;

	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

	//Portugal-  Auto Jardim
	var general_link = document.getElementById("general_link").value; 
	var directory = document.getElementById("directory").value;

	var url_price = "http://"+general_link+"/"+"include/get_price.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("car_id").value;

	var location_from = document.getElementById("location_from").value;

	if(location_from == 1 || location_from == 2 || location_from == 3)
	{
		var tolerance_hours = document.getElementById("tolerance_hours_madeira").value; 
	}
	else
	{
		var tolerance_hours = document.getElementById("tolerance_hours_portugal").value;
	}

	var location_to = document.getElementById("location_to").value;

	var one_day_rental_mes = document.getElementById("one_day_rental_mes").value;

	if(document.getElementById("extra_taxes_type").value == "admin")
	{
		if (document.getElementById("check_excess_insurance").checked == true)
		{
			var check_excess_insurance = 1;
		}
		else
		{
			var check_excess_insurance = 0;
		}
	}
	else
	{
		if (document.getElementById("excess_insurance").checked == true)
		{
			var check_excess_insurance = 1;
		}
		else
		{
			var check_excess_insurance = 0;
		}
	}

	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 +
		"&check_excess_insurance=" + check_excess_insurance +
		"&dir=" + directory);*/
	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 +
		"&check_excess_insurance=" + check_excess_insurance +
		"&dir=" + directory, true); 
	

	if(document.getElementById("extra_taxes_type").value == "admin")
	{
		//for admin section
		xmlHttp.onreadystatechange = handleHttpResponse_price_admin;
	}
	else
	{
		xmlHttp.onreadystatechange = handleHttpResponse_price;
	}

	xmlHttp.send(null);
}

//============for PORTUGAL=================================================
function handleHttpResponse_price() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if(document.onlinequote.global_show_pound.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("tolerance_hours")[0].childNodes[0].nodeValue);
		//alert("nr_days = "+xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("loc_from = "+xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue);

		var final_price = document.getElementById("final_price").value;
		js_not_hire_car = 0;
		var in_lang = document.getElementById("in_lang").value;
		//==for pick-up outside office hours====
		if(xmlDoc.getElementsByTagName("not_hire_car_hour_from")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0) 
		{
			js_not_hire_car = 1;
			var pick_mes = document.onlinequote.pick_mes.value;
			pick_mes = pick_mes.replace("-", " - " + xmlDoc.getElementsByTagName("office_opening_hour")[0].childNodes[0].nodeValue + " - " + xmlDoc.getElementsByTagName("office_closing_hour")[0].childNodes[0].nodeValue);
			
			pick_mes = pick_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue);

			alert(pick_mes + "\n" + document.onlinequote.pick_mes_2.value);
			document.onlinequote.pickup_time.focus();
		}
		//==for drop-off outside office hours====
		else if(xmlDoc.getElementsByTagName("not_hire_car_hour_to")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_to")[0].childNodes[0].nodeValue > 0) 
		{
			js_not_hire_car = 1;
			var drop_mes = document.onlinequote.drop_mes.value;
			drop_mes = drop_mes.replace("-", " - " + xmlDoc.getElementsByTagName("office_opening_hour")[0].childNodes[0].nodeValue + " - " + xmlDoc.getElementsByTagName("office_closing_hour")[0].childNodes[0].nodeValue);
			drop_mes = drop_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue);

			alert(drop_mes + "\n" + document.onlinequote.drop_mes_2.value);
			document.onlinequote.dropoff_time.focus();
		}
		//=====for the 25 dec and 1 jan days
		else if(xmlDoc.getElementsByTagName("closed_office_from")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0)
		{
			js_not_hire_car = 1;

			var pick_closed_mes = document.onlinequote.pick_closed_mes.value;
			pick_closed_mes = pick_closed_mes.replace("-", " - " + xmlDoc.getElementsByTagName("pickup")[0].childNodes[0].nodeValue);
			pick_closed_mes = pick_closed_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue);

			alert(pick_closed_mes + "\n" + document.onlinequote.pick_closed_mes_2.value);
			document.onlinequote.pickup.focus();
		}
		//=====for the 25 dec and 1 jan days
		else if(xmlDoc.getElementsByTagName("closed_office_to")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_to")[0].childNodes[0].nodeValue > 0)
		{
			js_not_hire_car = 1;

			var drop_closed_mes = document.onlinequote.drop_closed_mes.value;
			drop_closed_mes = drop_closed_mes.replace("-", " - " + xmlDoc.getElementsByTagName("dropoff")[0].childNodes[0].nodeValue);
			drop_closed_mes = drop_closed_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue);

			alert(drop_closed_mes + "\n" + document.onlinequote.drop_closed_mes_2.value);
			document.onlinequote.dropoff.focus();
		}

		if(js_not_hire_car == 1)
		{
			document.onlinequote.nrdays.value = 0;
			document.onlinequote.total_price.value = 0;
			document.onlinequote.totalprice_euro.value = 0;
			document.onlinequote.total_price_no_excess.value = 0;
			document.onlinequote.excess_insurance_value.value = 0;
		}
		else
		{
			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.total_price_no_excess.value = xmlDoc.getElementsByTagName("total_price_no_excess")[0].childNodes[0].nodeValue;
			document.onlinequote.excess_insurance_value.value = xmlDoc.getElementsByTagName("excess_insurance_value")[0].childNodes[0].nodeValue;

			document.onlinequote.totalprice_euro.value = document.onlinequote.total_price.value;

			if(xmlDoc.getElementsByTagName("dropoff_time")[0].childNodes[0].nodeValue - xmlDoc.getElementsByTagName("pickup_time")[0].childNodes[0].nodeValue >= xmlDoc.getElementsByTagName("tolerance_hours")[0].childNodes[0].nodeValue && (xmlDoc.getElementsByTagName("pickup")[0].childNodes[0].nodeValue != xmlDoc.getElementsByTagName("dropoff")[0].childNodes[0].nodeValue && checkmyDates_ajax(xmlDoc.getElementsByTagName("pickup")[0].childNodes[0].nodeValue, xmlDoc.getElementsByTagName("dropoff")[0].childNodes[0].nodeValue)))
			{
				alert(document.onlinequote.one_day_rental_mes.value);
			}

			var final_price = document.getElementById("final_price").value;

			if((final_price == 'yes') && (document.onlinequote.email_valid.value == 'yes'))
			{
				document.onlinequote.submit();
			}
		}

	}	
}

//========================for the admin section===========================================
function handleHttpResponse_price_admin() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 

		xmlDoc=xmlHttp.responseXML;

		//alert("nr_days = "+xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("nr_days = "+xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue);
		//alert("loc_from = "+xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue);

		js_not_hire_car = 0;
		var in_lang = document.getElementById("in_lang").value;
		//==for pick-up outside office hours====
		if(xmlDoc.getElementsByTagName("not_hire_car_hour_from")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0) 
		{
			js_not_hire_car = 1;
			var pick_mes = document.booking.pick_mes.value;
			pick_mes = pick_mes.replace("-", " - " + xmlDoc.getElementsByTagName("office_opening_hour")[0].childNodes[0].nodeValue + " - " + xmlDoc.getElementsByTagName("office_closing_hour")[0].childNodes[0].nodeValue);
			
			pick_mes = pick_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue);

			alert(pick_mes + "\n" + document.booking.pick_mes_2.value);
			document.booking.pickup_time.focus();
		}
		//==for drop-off outside office hours====
		else if(xmlDoc.getElementsByTagName("not_hire_car_hour_to")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_to")[0].childNodes[0].nodeValue > 0) 
		{
			js_not_hire_car = 1;
			var drop_mes = document.booking.drop_mes.value;
			drop_mes = drop_mes.replace("-", " - " + xmlDoc.getElementsByTagName("office_opening_hour")[0].childNodes[0].nodeValue + " - " + xmlDoc.getElementsByTagName("office_closing_hour")[0].childNodes[0].nodeValue);
			drop_mes = drop_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue);

			alert(drop_mes + "\n" + document.booking.drop_mes_2.value);
			document.booking.dropoff_time.focus();
		}
		//=====for the 25 dec and 1 jan days
		else if(xmlDoc.getElementsByTagName("closed_office_from")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_from")[0].childNodes[0].nodeValue > 0)
		{
			js_not_hire_car = 1;

			var pick_closed_mes = document.booking.pick_closed_mes.value;
			pick_closed_mes = pick_closed_mes.replace("-", " - " + xmlDoc.getElementsByTagName("pickup")[0].childNodes[0].nodeValue);
			pick_closed_mes = pick_closed_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_to_name")[0].childNodes[0].nodeValue);

			alert(pick_closed_mes + "\n" + document.booking.pick_closed_mes_2.value);
			document.booking.pickup.focus();
		}
		//=====for the 25 dec and 1 jan days
		else if(xmlDoc.getElementsByTagName("closed_office_to")[0].childNodes[0].nodeValue == 1 && xmlDoc.getElementsByTagName("location_to")[0].childNodes[0].nodeValue > 0)
		{
			js_not_hire_car = 1;

			var drop_closed_mes = document.booking.drop_closed_mes.value;
			drop_closed_mes = drop_closed_mes.replace("-", " - " + xmlDoc.getElementsByTagName("dropoff")[0].childNodes[0].nodeValue);
			drop_closed_mes = drop_closed_mes.replace(in_lang, in_lang + " " + xmlDoc.getElementsByTagName("location_from_name")[0].childNodes[0].nodeValue);

			alert(drop_closed_mes + "\n" + document.booking.drop_closed_mes_2.value);
			document.booking.dropoff.focus();
		}

		if(js_not_hire_car != 1)
		{
			document.booking.nr_days.value = xmlDoc.getElementsByTagName("nr_days")[0].childNodes[0].nodeValue;
			document.booking.car_hire_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
			document.booking.total_price.value = Math.round((parseFloat(document.booking.car_hire_price.value) + parseFloat(document.booking.extra_options.value)) * 100) / 100;
			document.booking.old_total_price.value = document.booking.total_price.value;
			
		}

	}	
}

//==================================================================================================================


//===================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 url_img = "http://autocarhire.net/include/get_cars.php?location_from=";
	//var url_img = "../autocarhire/include/get_cars.php?location_from=";
	
	var location_from = document.getElementById("location_from").value; 
	var general_link = document.getElementById("general_link").value; 
	var directory = document.getElementById("directory").value;
	var loading = document.getElementById("loading").value;

	if(document.getElementById("extra_taxes_type").value == "admin")
	{
		var url_img = "http://"+general_link+"/"+"include/get_cars_admin.php?location_from=";
		var pickup = document.getElementById("pickup").value; 
	}
	else
	{
		var url_img = "http://"+general_link+"/"+"include/get_cars.php?location_from=";
	}

	curent_select_cars = document.getElementById("car_id");
	if(curent_select_cars.length > 0)
	{
		for (var i=0; i<curent_select_cars.length; i++)
		{
			 if(curent_select_cars.options[i].selected == true)
			 {
				var curr_car_id = curent_select_cars.options[i].value;
			 }
		}
	}
	
	curent_select_cars.options[0] = new Option(loading+" ...", "0");
	curent_select_cars.selectedIndex = 0;
	
	//alert(url_img + location_from + "&curr_car_id=" + curr_car_id + "&pickup=" + pickup + "&dir=" + directory);
	
	if(document.getElementById("extra_taxes_type").value == "admin")
	{
		//for admin section
		xmlHttp.open("GET", url_img + location_from + "&curr_car_id=" + curr_car_id + "&pickup=" + pickup + "&dir=" + directory, true); 
		xmlHttp.onreadystatechange = handleHttpResponse_cars_admin;
	}
	else
	{
		xmlHttp.open("GET", url_img + location_from + "&curr_car_id=" + curr_car_id + "&dir=" + directory, true); 
		xmlHttp.onreadystatechange = handleHttpResponse_cars;
	}
	
	xmlHttp.send(null);
}

//===================================================================================================================
function handleHttpResponse_cars()
{
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		xmlDoc=xmlHttp.responseXML;

		var select_a_car = xmlDoc.getElementsByTagName("select_car")[0].childNodes[0].nodeValue;

		curent_select_cars = document.getElementById("car_id");
		curent_select_cars.options[0] = new Option(select_a_car +" ...", "0");
		curent_select_cars.options.length  = 1;

		var respNode = xmlDoc.getElementsByTagName("response")[0];

		//alert(getElementsByTagName("test")[0].firstChild.nodeValue);

		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);

				//alert("val1 c= "+ getElementsByTagName("curr_car_id")[0].firstChild.nodeValue);
				//alert("val1 c2= "+ car_value);
				
				if(respNode.getElementsByTagName("curr_car_id")[0].firstChild.nodeValue != 0)
				{
					
					if(respNode.getElementsByTagName("curr_car_id")[0].firstChild.nodeValue == car_value)
					{
						curent_select_cars.options[i+1].selected = true;
					}
				}
				if(isNaN(car_value))
				{
					curent_select_cars.options[i+1].className="blue_bg";
				}
			}
			
		}
		//curent_select_cars.selectedIndex = 0;
	} 

}

//============================END in PORTUGAL we show the cars for MADEIRA / PORTUGAL Continental=====================

//============================================================================================
//====================PORTUGAL - Auto Jardim======================================================

function get_extra_options() 
{ 

	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_extra = "http://"+general_link+"/"+"include/get_price_extra.php?nr_days=";
	

    //=========1. pay exces insurance or not================
	if (document.getElementById("check_excess_insurance").checked == true)
	{
		var check_excess_insurance = 1;
	}
	else
	{
		var check_excess_insurance = 0;
	}

	var nr_days = document.getElementById("nr_days").value;
	var old_total_price = document.getElementById("old_total_price").value;
	var excess_insurance = document.getElementById("excess_insurance").value;
	var car_excess = document.getElementById("car_excess").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 booster_seat = document.getElementById("booster_seat").value;

	var baby_seat_tax = document.getElementById("baby_seat_tax").value;
	var child_seat_tax = document.getElementById("child_seat_tax").value;
	var booster_seat_tax = document.getElementById("booster_seat_tax").value;

	//=========5. having roof rack or not================
	var add_roof_rack = "";
	var car_roofrack = document.getElementById("car_roofrack").value;
	if(car_roofrack == 1)
	{
		//===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;

	//=========7. paying one way rental or not================
	if(document.getElementById("one_way_tax").value)
	{
		var one_way_tax = document.getElementById("one_way_tax").value;
	}

	//=========8. paying airport tax or not================
	if(document.getElementById("airport_tax").value)
	{
		var airport_tax = document.getElementById("airport_tax").value;
	}

	 //=========9. have GPS or not================
	if (document.getElementById("gps").checked == true)
	{
		var gps = 1;
	}
	else
	{
		var gps = 0;
	}
	var gps_tax = document.getElementById("gps_tax").value;


	xmlHttp.open("GET", url_price_extra + nr_days
		+ "&excess_insurance=" + excess_insurance 
		+ "&car_excess=" + car_excess 
		+ "&check_excess_insurance=" + check_excess_insurance 
		+ "&old_total_price=" + old_total_price 
		+ "&second_driver_name=" + second_driver_name 
		+ "&check_young_driver=" + check_young_driver 
		+ "&baby_seat=" + baby_seat 
		+ "&child_seat=" + child_seat 
		+ "&booster_seat=" + booster_seat 
		+ add_roof_rack 
		+ "&check_passenger_insurance=" + check_passenger_insurance
		+ "&one_way_tax=" + one_way_tax
		+ "&airport_tax=" + airport_tax
		+ "&second_driver_tax=" + second_driver_tax
		+ "&young_driver_tax=" + young_driver_tax
		+ "&baby_seat_tax=" + baby_seat_tax
		+ "&child_seat_tax=" + child_seat_tax
		+ "&booster_seat_tax=" + booster_seat_tax
		+ "&gps_tax=" + gps_tax
		+ "&passenger_insurance_tax=" + passenger_insurance_tax
		+ "&gps=" + gps
		+ "&dir=" +directory , true); 

		
	if(document.getElementById("extra_taxes_type").value == "admin")
	{
		xmlHttp.onreadystatechange = handleHttpResponse_price_extra_options_admin; 
	}
	else
	{
		xmlHttp.onreadystatechange = handleHttpResponse_price_extra_options; 
	}
	
	xmlHttp.send(null);
}

function handleHttpResponse_price_extra_options() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		//=========TOTAL PRICE================
		
		document.getElementById("span_total_price").innerHTML = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		

		//=========EXCESS INSURANCE===========
		document.getElementById("id_excess_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue);

		if(xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_excess_tax").style.display = "inline";
		}
		else
		{
			document.getElementById("div_excess_tax").style.display = "none";
		}
		

		//=========SECOND/ADDITIONAL DRIVER===========
		if(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_add_driver_tax").style.display = "block";
			document.getElementById("id_add_driver_seat_no").innerHTML = 1;
		}
		else
		{
			document.getElementById("div_add_driver_tax").style.display = "none";
			document.getElementById("id_add_driver_seat_no").innerHTML = 0;
		}

		document.getElementById("id_add_driver_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue);
		

		//=========YOUNG DRIVER===========
		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);
		
		//=========BABY SEAT===========
		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_no").innerHTML = parseFloat(xmlDoc.getElementsByTagName("baby_seat")[0].childNodes[0].nodeValue);
		

		//=========CHILD SEAT===========
		if(xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_child_seat_tax").style.display = "inline";
		}
		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_no").innerHTML = parseFloat(xmlDoc.getElementsByTagName("child_seat")[0].childNodes[0].nodeValue);

		//=========BOOSTER SEAT===========
		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_no").innerHTML = parseFloat(xmlDoc.getElementsByTagName("booster_seat")[0].childNodes[0].nodeValue);
		

		//=========GPS===========
		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);
		

		//=========ROOF RACK===========
		var car_roofrack = document.getElementById("car_roofrack").value;
		if(car_roofrack == 1)
		{
			if(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue != 0)
			{
				document.getElementById("div_roofrack_tax").style.display = "block";
			}
			else
			{
				document.getElementById("div_roofrack_tax").style.display = "none";
			}
			
			document.getElementById("id_roofrack_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue);
		}
		

		//=========PASSENGER INSURANCE===========
		if(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue != 0)
		{
			document.getElementById("div_pers_ins_tax").style.display = "block";
		}
		else
		{
			document.getElementById("div_pers_ins_tax").style.display = "none";
		}
		
		document.getElementById("id_pers_ins_tax").innerHTML = parseFloat(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue);
		
		//=================TEST ZONE - if we show or not the pound price================
		if(document.getElementById("global_show_pound").value == 1)
		{
			var pound = document.getElementById("pound").value;

			document.getElementById("span_total_price_pound").innerHTML = Math.round((xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue / pound) * 100) / 100;

			document.getElementById("id_excess_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

			document.getElementById("id_add_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

			document.getElementById("id_young_driver_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

			document.getElementById("id_baby_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

			document.getElementById("id_child_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;
			
			document.getElementById("id_booster_seat_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

			document.getElementById("id_gps_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;
		
			if(car_roofrack == 1)
			{
				document.getElementById("id_roofrack_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;
			}

			document.getElementById("id_pers_ins_tax_pound").innerHTML = Math.round((parseFloat(xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue) / pound) * 100) / 100;

		}

		//================THE HIDDEN INPUTS TO BE PASSED IN THE NEXT PAGE=============
		document.booking.excess_insurance.value = xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue;

		document.booking.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.booking.old_total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.booking.second_driver_tax.value = xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue;
		document.booking.young_driver_tax.value = xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue;

		document.booking.baby_seat_tax.value = xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.child_seat_tax.value = xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.booster_seat_tax.value = xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.gps_tax.value = xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue;

		document.booking.roof_rack_tax.value = xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue;
		document.booking.passenger_insurance_tax.value = xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue;

	} 
} 

//========for admin section - editing a booking==============
function handleHttpResponse_price_extra_options_admin() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;
		
		
		document.booking.excess_insurance.value = xmlDoc.getElementsByTagName("show_car_excess_insurance")[0].childNodes[0].nodeValue;
		document.booking.total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		document.booking.old_total_price.value = xmlDoc.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;

		document.booking.second_driver_tax.value = xmlDoc.getElementsByTagName("second_driver_tax")[0].childNodes[0].nodeValue;
		document.booking.young_driver_tax.value = xmlDoc.getElementsByTagName("young_driver_tax")[0].childNodes[0].nodeValue;

		document.booking.baby_seat_tax.value = xmlDoc.getElementsByTagName("baby_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.child_seat_tax.value = xmlDoc.getElementsByTagName("child_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.booster_seat_tax.value = xmlDoc.getElementsByTagName("booster_seat_tax")[0].childNodes[0].nodeValue;
		document.booking.gps_tax.value = xmlDoc.getElementsByTagName("gps_tax")[0].childNodes[0].nodeValue;

		document.booking.roof_rack_tax.value = xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue;

		//document.booking.one_way_tax.value = xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue;
		
		document.booking.passenger_insurance_tax.value = xmlDoc.getElementsByTagName("passenger_insurance_tax")[0].childNodes[0].nodeValue;

		document.booking.extra_options.value = Math.round((parseFloat(document.booking.total_price.value) - parseFloat(document.booking.car_hire_price.value)) * 100) / 100;

		/*if(document.getElementById("one_way_tax").value != 0)
		{
			document.booking.extra_options.value = Math.round((parseFloat(document.booking.extra_options.value) + parseFloat(document.getElementById("one_way_tax").value)) * 100) / 100;
		}*/

		if(document.booking.roof_rack_tax.value != 0)
		{
			document.getElementById("div_roofrack").style.display = "inline";
			document.getElementById("car_roofrack").value = 1;
			document.getElementById("span_roof_rack_value").innerHTML = document.booking.roof_rack_tax.value + " &euro;";
		}

		
	}
}


//===================END PORTUGAL - Auto Jardim=======================================================
//====================================================================================================


//=======================================================================================
//===============changes the car image in the booking form================================

function getimage() 
{ 
	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_img = "http://"+general_link+"/"+"include/get_image.php?car_id=";
	
	var my_car_id = document.getElementById("car_id").value; 

	//alert(url_img + my_car_id + "&dir=" + directory);
	xmlHttp.open("GET", url_img + my_car_id + "&dir=" + directory, true); 
	xmlHttp.onreadystatechange = handleHttpResponse; 
	xmlHttp.send(null);
}

function handleHttpResponse() 
{ 
	var general_link = document.getElementById("general_link").value; 
	var url_img = "http://"+general_link+"/";

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		if(xmlDoc.getElementsByTagName("car_type")[0].childNodes[0].nodeValue == 3)
		{
			document.getElementById("div_excess").style.display = "none";
		}
		else
		{
			document.getElementById("div_excess").style.display = "inline";
		}

		document.getElementById("image_car").src = url_img + xmlDoc.getElementsByTagName("image")[0].childNodes[0].nodeValue;
	} 
}


//=========================for admin section==================
//===================================================================================================================
function get_one_way_tax()
{
	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_img = "http://"+general_link+"/"+"include/get_one_way.php?location_from="; 
	var location_from = document.getElementById("location_from").value; 
	var location_to = document.getElementById("location_to").value; 
	var pickup = document.getElementById("pickup").value; 
	var nr_days = document.getElementById("nr_days").value; 
	

	xmlHttp.open("GET", url_img + location_from + "&location_to=" + location_to + "&pickup=" + pickup + "&nr_days=" + nr_days + "&dir=" + directory, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_one_way_tax; 
	xmlHttp.send(null);
}

function handleHttpResponse_one_way_tax()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		xmlDoc=xmlHttp.responseXML;

		
		document.getElementById("one_way_rental_tax").checked = false;
		document.getElementById("span_one_way_tax_value").innerHTML = "";

		if(document.getElementById("one_way_tax").value != 0)
		{
			//=====scadem vechea valoare din extra-options=======
			document.booking.extra_options.value = Math.round((parseFloat(document.booking.extra_options.value) - parseFloat(document.getElementById("one_way_tax").value)) * 100) / 100;

			//we modify the total price
			document.booking.total_price.value = Math.round((parseFloat(document.booking.total_price.value) - parseFloat(document.getElementById("one_way_tax").value)) * 100) / 100;
			document.booking.old_total_price.value = document.booking.total_price.value;
		}
		document.getElementById("one_way_tax").value = 0;

		if(xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue != 0)
		{
			
			document.getElementById("one_way_rental_tax").checked = true;
			document.getElementById("span_one_way_tax_value").innerHTML = xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue + " &euro;";

			document.booking.extra_options.value = Math.round((parseFloat(xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue) + parseFloat(document.booking.extra_options.value)) * 100) / 100;
			document.getElementById("one_way_tax").value = parseFloat(xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue);

			//we modify the total price
			document.booking.total_price.value = Math.round((parseFloat(document.booking.total_price.value) + parseFloat(xmlDoc.getElementsByTagName("one_way_tax")[0].childNodes[0].nodeValue)) * 100) / 100;
			document.booking.old_total_price.value = document.booking.total_price.value;
			
		}
		
		
	}
}


function get_car_info()
{

	//==========for showing or not the roof-rack option
	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_img = "http://"+general_link+"/"+"include/get_car_info.php?car_id="; 

	var my_car_id = document.getElementById("car_id").value; 
	var nr_days = document.getElementById("nr_days").value; 
	var pickup = document.getElementById("pickup").value; 

	xmlHttp.open("GET", url_img + my_car_id + "&nr_days=" + nr_days + "&pickup=" + pickup, true); 
	xmlHttp.onreadystatechange = handleHttpResponse_get_car_info; 
	xmlHttp.send(null);
}

function handleHttpResponse_get_car_info()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;

		if(xmlDoc.getElementsByTagName("car_roofrack")[0].childNodes[0].nodeValue == 1)
		{
			//car roofrack can be attached
			document.getElementById("div_roofrack").style.display = "inline";
			document.getElementById("car_roofrack").value = 1;
			document.getElementById("span_roof_rack_value").innerHTML = xmlDoc.getElementsByTagName("roof_rack_tax")[0].childNodes[0].nodeValue + " &euro;";
		}
		else
		{
			//car roofrack cannot be attached
			document.getElementById("div_roofrack").style.display = "none";
			document.getElementById("car_roofrack").value = 0;
			document.getElementById("span_roof_rack_value").innerHTML = "";

			if(document.getElementById("roof_rack_tax").value != 0)
			{
				//we will eliminate the roof rack tax from the price
				document.getElementById("extra_options").value = Math.round((parseFloat(document.getElementById("extra_options").value) - parseFloat(document.getElementById("roof_rack_tax").value)) * 100) / 100;

				document.getElementById("old_total_price").value = Math.round((parseFloat(document.getElementById("old_total_price").value) - parseFloat(document.getElementById("roof_rack_tax").value)) * 100) / 100;

				document.getElementById("total_price").value = Math.round(parseFloat(document.getElementById("old_total_price").value) * 100) / 100;

				document.getElementById("roof_rack_tax").value = 0;

			}
		}
		//=====we have to change the unitary and total excess insurance values=========
		document.getElementById("car_excess").value = Math.round(parseFloat(xmlDoc.getElementsByTagName("car_excess_unitary_value")[0].childNodes[0].nodeValue) * 100) / 100;

		if(document.getElementById("excess_insurance").value != 0)
		{
			//===we subtract the old value of total excess insurance from the extra options, old_total_price====
			document.getElementById("extra_options").value = Math.round((parseFloat(document.getElementById("extra_options").value) - parseFloat(document.getElementById("excess_insurance").value)) * 100) / 100;

			document.getElementById("old_total_price").value = Math.round((parseFloat(document.getElementById("old_total_price").value) - parseFloat(document.getElementById("excess_insurance").value)) * 100) / 100;

			//====we modify the excess insurance total value=====
			document.getElementById("excess_insurance").value = Math.round(parseFloat(xmlDoc.getElementsByTagName("excess_insurance")[0].childNodes[0].nodeValue) * 100) / 100;

			//====we add the new value of total excess insurance to the extra options, old_total_price=====
			document.getElementById("extra_options").value = Math.round((parseFloat(document.getElementById("extra_options").value) + parseFloat(document.getElementById("excess_insurance").value)) * 100) / 100;

			document.getElementById("old_total_price").value = Math.round((parseFloat(document.getElementById("old_total_price").value) + parseFloat(document.getElementById("excess_insurance").value)) * 100) / 100;

			document.getElementById("total_price").value = Math.round(parseFloat(document.getElementById("old_total_price").value) * 100) / 100;
		}
	}
}

function handleHttpResponse_cars_admin()
{
	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");
		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);

				//alert("val1 c= "+ getElementsByTagName("curr_car_id")[0].firstChild.nodeValue);
				//alert("val1 c2= "+ car_value);
				
				if(respNode.getElementsByTagName("curr_car_id")[0].firstChild.nodeValue != 0)
				{
					
					if(respNode.getElementsByTagName("curr_car_id")[0].firstChild.nodeValue == car_value)
					{
						curent_select_cars.options[i+1].selected = true;
					}
				}
				if(isNaN(car_value))
				{
					curent_select_cars.options[i+1].className="blue_bg";
				}
			}
			
		}

		if(xmlDoc.getElementsByTagName("airport_tax_status")[0].childNodes[0].nodeValue == "yes")
		{
			if(document.getElementById("airport_tax").value == 0)
			{
				document.getElementById("extra_options").value = Math.round((parseFloat(document.getElementById("extra_options").value) + parseFloat(xmlDoc.getElementsByTagName("global_airport_tax")[0].childNodes[0].nodeValue)) * 100) / 100;

				document.getElementById("old_total_price").value = Math.round((parseFloat(document.getElementById("old_total_price").value) + parseFloat(xmlDoc.getElementsByTagName("global_airport_tax")[0].childNodes[0].nodeValue)) * 100) / 100;

				document.getElementById("total_price").value = Math.round(parseFloat(document.getElementById("old_total_price").value) * 100) / 100;

				//check the airport tax checkbox
				document.getElementById("airport_tax_check").checked = true;

				document.getElementById("airport_tax").value = Math.round(parseFloat(xmlDoc.getElementsByTagName("global_airport_tax")[0].childNodes[0].nodeValue) * 100) / 100;
			}
		}
		else
		{
			if(document.getElementById("airport_tax").value > 0)
			{
				document.getElementById("extra_options").value = Math.round((parseFloat(document.getElementById("extra_options").value) - parseFloat(xmlDoc.getElementsByTagName("global_airport_tax")[0].childNodes[0].nodeValue)) * 100) / 100;

				document.getElementById("old_total_price").value = Math.round((parseFloat(document.getElementById("old_total_price").value) - parseFloat(xmlDoc.getElementsByTagName("global_airport_tax")[0].childNodes[0].nodeValue)) * 100) / 100;

				document.getElementById("total_price").value = Math.round(parseFloat(document.getElementById("old_total_price").value) * 100) / 100;

				//uncheck the airport tax checkbox
				document.getElementById("airport_tax_check").checked = false;

				document.getElementById("airport_tax").value = 0;
			}
		}
	} //end if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
}

function remove_one_way_tax()
{
	if(document.getElementById("one_way_tax").value != 0)
	{
		//=====scadem vechea valoare din extra-options=======
		document.booking.extra_options.value = Math.round((parseFloat(document.booking.extra_options.value) - parseFloat(document.getElementById("one_way_tax").value)) * 100) / 100;
	}
	document.getElementById("one_way_tax").value = 0;
	document.getElementById("one_way_rental_tax").checked = false;
	document.getElementById("span_one_way_tax_value").innerHTML = "";
	return true;
}

//=================================================

function calculate_admin_total_price()
{
	document.booking.total_price.value = Math.round((parseFloat(document.booking.car_hire_price.value) + parseFloat(document.booking.extra_options.value)) * 100) / 100;
	document.booking.old_total_price.value = document.booking.total_price.value;
}

