
var o;
var fs;
var o;
var fe;
var fdif;
var fow;


function entsub(event,ourform) {
if (navigator.appName == "Netscape") {
 if (event && event.which == 13) return false;
}
else
 if (window.event && window.event.keyCode == 13) return false;
}

function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}


function isNumber(inputVal) {
 var oneDecimal = false
 var digitCount = 0
 inputStr = inputVal.toString()
 for (var i = 0; i <inputStr.length; i++) {
 var oneChar = inputStr.charAt(i)
 if (i == 0 && oneChar == "-") {
 continue
 }
 if (oneChar == "." && !oneDecimal) {
 oneDecimal = true
 continue
 }
 if (oneChar <"0" || oneChar> "9") {
 return false
 } else {
 digitCount++
 }
 }
 return (digitCount> 0)
}


// IDIOMA INGLES
function checkdate_in(objName) {
var datefield = objName;
if (chkdate_in(objName) == false) {
datefield.select();
alert("The date is not valid. Try again.");
datefield.focus();
return false; }
else { return true; }
}
function chkdate_in(objName) {
var strDatestyle = "EU"; //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("/");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length <8)
if (strDate.length <1)
 return true;
else
 return false;
else
for (intElementNr = 0; intElementNr <strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
 }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
 }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
 }
}
if (isNaN(intMonth)) {
err = 3;
return false;
 }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday> 31 || intday <1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday> 30 || intday <1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday <1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday> 29) {
err = 9;
return false;
}
}
else {
if (intday> 28) {
err = 10;
return false;
}
}
}
return true;
}

function doDateCheck_in(from, to) {
// Compruebo que la fecha de entrega es mayor que la de recogida
if (from.value.length==0) { alert("You must introduce a Picking up Date."); from.focus; return false; }
if (to.value.length==0) { alert("You must introduce a Delivery Date"); to.focus; return false; }
var dia = "";
var ano = "";
var i=0;
var fecha=from.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-(i+1));
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha1=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
from.value=dia+'/'+mes+'/'+ano;
i=0;
fecha=to.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-i);
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha2=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
to.value=dia+'/'+mes+'/'+ano;
var hoy=new Date();
hoy=hoy.valueOf();
var hora_en_seg=document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
if (Date.parse(fecha1)+86400000 <= Date.parse(fecha2))
{ 
	if (Date.parse(fecha1)+hora_en_seg <(hoy + 3600000*document.forms['f'].horas_antelacion.value)) {
		alert("You must introduce a picking up date previous " + document.forms['f'].horas_antelacion.value + " hours.");
	} else {
		if (Date.parse(fecha1)+hora_en_seg <= (hoy + 86400000*document.forms['f'].dias_max_antelacion.value)) {

/*
 * OneWay - Start
 */
 
 
			var fs = Date.parse(fecha1)+ document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
			var fe = Date.parse(fecha2)+ document.forms['f'].h_fin.value * 3600000 + document.forms['f'].m_fin.value * 60000;
			var fow = ( (+document.forms['f'].horas_oneway.value) * 360000 ) * 10 ;	// convert hours to miliseconds

			o = document.forms['f'];
			if ( (o.id_sucursal.value != o.id_sucursal_fin.value)
				 && ((fe-fs) < fow) ) {
			
				if ( ((o.horas_oneway.value % 24) == 0) && (o.horas_oneway.value > 24) ) {
					var hd = 'days'
					var num = o.horas_oneway.value/24;
				} else {
					var hd = 'hours'
					var num = o.horas_oneway.value;
				}

				alert("For one way rentals, the minimum rental period is " + num + " "+hd+".");
/*
 * OneWay - End
 */

			} else {
	 
	 			document.forms['f'].submit();
	 		}
	
		} else {
			alert("You must introduce a picking up date less than " + document.forms['f'].dias_max_antelacion.value + " days in advance.");
		}
	}

} else {
if (from.value == "" || to.value == "")
 alert("You must introduce a picking up date and a delivery one.");
else
 alert("You must introduce a delivery date later than the one of the picking up.");
 }
}

function Reserva_in(){
with(document.forms['f']){
 if ((id_pais.value=="" || id_pais.value=="-1")){ alert("You must show a country."); id_pais.focus(); }
 else
 if ((id_sucursal.value=="" || id_sucursal.value=="-1")){ alert("You must show a city."); id_sucursal.focus(); }
 else
 if ((id_sucursal_fin.value=="" || id_sucursal_fin.value=="-1")){ alert("You must show a deliver city."); id_sucursal_fin.focus(); }
 else
 if ((edad.value=="") || (isNumber(edad.value)==false)){ alert("You must show a valid Age."); edad.focus(); }
 else
 if (edad.value <edad_min.value) { alert("You must be over " + edad_min.value + " minimum."); edad.focus(); }
 else
 if ((fecha_inicio.value=="")){ alert("You must show an starting date."); fecha_inicio.focus(); }
 else
 if ((fecha_fin.value=="")){ alert("You must show a final date."); fecha_fin.focus(); }
 else
 doDateCheck_in(fecha_inicio, fecha_fin);
 }
return false;
}



// IDIOMA ESPAÑOL
function checkdate_es(objName) {
var datefield = objName;
if (chkdate_es(objName) == false) {
datefield.select();
alert("La fecha no es válida. Inténtelo de nuevo.");
datefield.focus();
return false; }
else { return true; }
}
function chkdate_es(objName) {
var strDatestyle = "EU"; //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("/");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Ene";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Abr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Ago";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dic";
strDate = datefield.value;
if (strDate.length <8)
if (strDate.length <1)
 return true;
else
 return false;
else
for (intElementNr = 0; intElementNr <strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
 }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
 }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
 }
}
if (isNaN(intMonth)) {
err = 3;
return false;
 }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday> 31 || intday <1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday> 30 || intday <1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday <1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday> 29) {
err = 9;
return false;
}
}
else {
if (intday> 28) {
err = 10;
return false;
}
}
}
return true;
}

function doDateCheck_es(from, to) {
	// Compruebo que la fecha de entrega es mayor que la de recogida
	if (from.value.length==0) { alert("Debe introducir una Fecha de Recogida"); from.focus; return false; }
	if (to.value.length==0) { alert("Debe introducir una fecha de Entrega"); to.focus; return false; }
	var dia = "";
	var ano = "";
	var i=0;
	var fecha=from.value;
	while (fecha.substr(i,1)!='/') i++;
	dia=fecha.substr(0,i);
	fecha=fecha.substr(i+1,fecha.length-(i+1));
	i=0;
	while (fecha.substr(i,1)!='/') i++;
	mes=fecha.substr(0,i);
	ano=fecha.substr(i+1,fecha.length-i);
	var fecha1=mes + "/" + dia + "/" + ano;
	if (dia.length==1) dia='0'+dia;
	if (mes.length==1) mes='0'+mes;
	from.value=dia+'/'+mes+'/'+ano;
	
	i=0;
	fecha=to.value;
	while (fecha.substr(i,1)!='/') i++;
	dia=fecha.substr(0,i);
	fecha=fecha.substr(i+1,fecha.length-i);
	i=0;
	while (fecha.substr(i,1)!='/') i++;
	mes=fecha.substr(0,i);
	ano=fecha.substr(i+1,fecha.length-i);
	var fecha2=mes + "/" + dia + "/" + ano;
	if (dia.length==1) dia='0'+dia;
	if (mes.length==1) mes='0'+mes;
	to.value=dia+'/'+mes+'/'+ano;
	
	var hoy=new Date();
	hoy=hoy.valueOf();
	
	var hora_en_seg=document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;

	if (Date.parse(fecha1)+86400000 <= Date.parse(fecha2))
	{ 
		if (Date.parse(fecha1)+hora_en_seg <(hoy + 3600000*document.forms['f'].horas_antelacion.value)) {
			
			alert("Debe introducir una fecha de recogida con " + document.forms['f'].horas_antelacion.value + " horas de antelación.");
	 	
	 	} else if (Date.parse(fecha1)+hora_en_seg <= (hoy + 86400000*document.forms['f'].dias_max_antelacion.value) ) {

/*
 * OneWay - Start
 */
 
 
			var fs = Date.parse(fecha1)+ document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
			var fe = Date.parse(fecha2)+ document.forms['f'].h_fin.value * 3600000 + document.forms['f'].m_fin.value * 60000;
			var fow = ( (+document.forms['f'].horas_oneway.value) * 360000 ) * 10 ;	// convert hours to miliseconds

			o = document.forms['f'];
			if ( (o.id_sucursal.value != o.id_sucursal_fin.value)
				 && ((fe-fs) < fow) ) {
			
				if ( ((o.horas_oneway.value % 24) == 0) && (o.horas_oneway.value > 24) ) {
					var hd = 'días'
					var num = o.horas_oneway.value/24;
				} else {
					var hd = 'horas'
					var num = o.horas_oneway.value;
				}
				alert("Para devolver un vehículo en otra ciudad el alquiler debe de ser de al menos " + num + " "+hd+" de duración.");
/*
 * OneWay - End
 */

			} else {
	 
	 			document.forms['f'].submit();
	 		}
	
		} else {
		 alert("Debe introducir una fecha de recogida que no supere " + document.forms['f'].dias_max_antelacion.value + " dias de antelación.");
		}
	}
	else {
	if (from.value == "" || to.value == "")
	 alert("Debe introducir una fecha de recogida y de entrega.");
	else
	 alert("Debe introducir una fecha de entrega mayor que la de recogida.");
	 }
}

function Reserva_es(){
with(document.forms['f']){
 if ((id_pais.value=="" || id_pais.value=="-1")){ alert("Debe indicar un país."); id_pais.focus(); }
 else
 if ((id_sucursal.value=="" || id_sucursal.value=="-1")){ alert("Debe indicar una ciudad."); id_sucursal.focus(); }
 else
 if ((id_sucursal_fin.value=="" || id_sucursal_fin.value=="-1")){ alert("Debe indicar una ciudad de entrega."); id_sucursal_fin.focus(); }
 else
 if ((edad.value=="") || (isNumber(edad.value)==false)){ alert("Debe indicar una edad válida."); edad.focus(); }
 else
 if (edad.value <edad_min.value) { alert("La edad debe ser mayor o igual a " + edad_min.value ); edad.focus(); }
 else
 if ((fecha_inicio.value=="")){ alert("Debe indicar una fecha inicial."); fecha_inicio.focus(); }
 else
 if ((fecha_fin.value=="")){ alert("Debe indicar una fecha final."); fecha_fin.focus(); }
 else
 doDateCheck_es(fecha_inicio, fecha_fin);
 }
return false;
}



// IDIOMA ALEMAN
function checkdate_al(objName) {
var datefield = objName;
if (chkdate_al(objName) == false) {
datefield.select();
alert("Ungültiges Datum.");
datefield.focus();
return false; }
else { return true; }
}
function chkdate_al(objName) {
var strDatestyle = "EU"; //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("/");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mär";
strMonthArray[3] = "Apr";
strMonthArray[4] = "Mai";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Okt";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dez";
strDate = datefield.value;
if (strDate.length <8)
if (strDate.length <1)
 return true;
else
 return false;
else
for (intElementNr = 0; intElementNr <strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
 }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
 }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
 }
}
if (isNaN(intMonth)) {
err = 3;
return false;
 }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday> 31 || intday <1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday> 30 || intday <1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday <1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday> 29) {
err = 9;
return false;
}
}
else {
if (intday> 28) {
err = 10;
return false;
}
}
}
return true;
}

function doDateCheck_al(from, to) {
// Compruebo que la fecha de entrega es mayor que la de recogida
if (from.value.length==0) { alert("Bitte geben Sie den Abholtag an."); from.focus; return false; }
if (to.value.length==0) { alert("Bitte geben Sie den Rückgabetag an."); to.focus; return false; }
var dia = "";
var ano = "";
var i=0;
var fecha=from.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-(i+1));
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha1=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
from.value=dia+'/'+mes+'/'+ano;
i=0;
fecha=to.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-i);
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha2=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
to.value=dia+'/'+mes+'/'+ano;
var hoy=new Date();
hoy=hoy.valueOf();
var hora_en_seg=document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
if (Date.parse(fecha1)+86400000 <= Date.parse(fecha2))
{ 
	if (Date.parse(fecha1)+hora_en_seg <(hoy + 3600000*document.forms['f'].horas_antelacion.value)) {
		alert("Der Abholtag muss mind. " + document.forms['f'].horas_antelacion.value + " Stunden im Voraus liegen.");
	} else {
		if (Date.parse(fecha1)+hora_en_seg <= (hoy + 86400000*document.forms['f'].dias_max_antelacion.value)) {

/*
 * OneWay - Start
 */
 
 
			var fs = Date.parse(fecha1)+ document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
			var fe = Date.parse(fecha2)+ document.forms['f'].h_fin.value * 3600000 + document.forms['f'].m_fin.value * 60000;
			var fow = ( (+document.forms['f'].horas_oneway.value) * 360000 ) * 10 ;	// convert hours to miliseconds

			o = document.forms['f'];
			if ( (o.id_sucursal.value != o.id_sucursal_fin.value)
				 && ((fe-fs) < fow) ) {
			
				if ( ((o.horas_oneway.value % 24) == 0) && (o.horas_oneway.value > 24) ) {
					var hd = 'Tage'
					var num = o.horas_oneway.value/24;
				} else {
					var hd = 'Stunden'
					var num = o.horas_oneway.value;
				}

				alert("Die Anmietung muss mindestens " + num + " "+ hd +" dauern, um den Mietwagen in einer anderen Stadt abgeben zu können.");
/*
 * OneWay - End
 */

			} else {
	 
	 			document.forms['f'].submit();
	 		}
	
		} else {
			alert("Datum der Abholung kann nicht später als " + document.forms['f'].dias_max_antelacion.value + " Tage ab heute sein.");
		}
	}

} else {
if (from.value == "" || to.value == "")
 alert("Bitte geben Sie den Tag der Abholung sowie der Rückgabe an.");
else
 alert("Das Datum der Rückgabe muss nach dem der Abholung liegen.");
 }
}
function Reserva_al(){
with(document.forms['f']){
 if ((id_pais.value=="" || id_pais.value=="-1")){ alert("Bitte geben Sie ein Land an."); id_pais.focus(); }
 else
 if ((id_sucursal.value=="" || id_sucursal.value=="-1")){ alert("Wählen Sie Ihren Zielort"); id_sucursal.focus(); }
 else
 if ((id_sucursal_fin.value=="" || id_sucursal.value_fin=="-1")){ alert("Wählen Sie Ihren Zielort"); id_sucursal_fin.focus(); }
 else
 if ((edad.value=="") || (isNumber(edad.value)==false)){ alert("Bitte ein gültiges Alter angeben."); edad.focus(); }
 else
 if (edad.value <edad_min.value) { alert("Mindestalter " + edad_min.value + " Jahre."); edad.focus(); }
 else
 if ((fecha_inicio.value=="")){ alert("Bitte geben Sie ein Startdatum an."); fecha_inicio.focus(); }
 else
 if ((fecha_fin.value=="")){ alert("Bitte geben Sie ein Enddatum an."); fecha_fin.focus(); }
 else
 doDateCheck_al(fecha_inicio, fecha_fin);
 }
return false;
}


// FUNCIONES EN IDIOMA FRANCÉS
function checkdate_fr(objName) {
var datefield = objName;
if (chkdate_al(objName) == false) {
datefield.select();
alert("La date n'est pas valable. Essayer à nouveau.");
datefield.focus();
return false; }
else { return true; }
}

function doDateCheck_fr(from, to) {
// Compruebo que la fecha de entrega es mayor que la de recogida
if (from.value.length==0) { alert("Vous devez introduire une date de livraison"); from.focus; return false; }
if (to.value.length==0) { alert("Vous devez introduire une date de remise"); to.focus; return false; }
var dia = "";
var ano = "";
var i=0;
var fecha=from.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-(i+1));
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha1=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
from.value=dia+'/'+mes+'/'+ano;
i=0;
fecha=to.value;
while (fecha.substr(i,1)!='/') i++;
dia=fecha.substr(0,i);
fecha=fecha.substr(i+1,fecha.length-i);
i=0;
while (fecha.substr(i,1)!='/') i++;
mes=fecha.substr(0,i);
ano=fecha.substr(i+1,fecha.length-i);
var fecha2=mes + "/" + dia + "/" + ano;
if (dia.length==1) dia='0'+dia;
if (mes.length==1) mes='0'+mes;
to.value=dia+'/'+mes+'/'+ano;
var hoy=new Date();
hoy=hoy.valueOf();
var hora_en_seg=document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
if (Date.parse(fecha1)+86400000 <= Date.parse(fecha2))
{ 
	if (Date.parse(fecha1)+hora_en_seg <(hoy + 3600000*document.forms['f'].horas_antelacion.value)) {
		alert("Vous devez introduire une date de livraison avec " + document.forms['f'].horas_antelacion.value + " heures d'avance.");
	} else {
		if (Date.parse(fecha1)+hora_en_seg <= (hoy + 86400000*document.forms['f'].dias_max_antelacion.value)) {

/*
 * OneWay - Start
 */
 
 
			var fs = Date.parse(fecha1)+ document.forms['f'].h_inicio.value * 3600000 + document.forms['f'].m_inicio.value * 60000;
			var fe = Date.parse(fecha2)+ document.forms['f'].h_fin.value * 3600000 + document.forms['f'].m_fin.value * 60000;
			var fow = ( (+document.forms['f'].horas_oneway.value) * 360000 ) * 10 ;	// convert hours to miliseconds

			o = document.forms['f'];
			if ( (o.id_sucursal.value != o.id_sucursal_fin.value)
				 && ((fe-fs) < fow) ) {

				if ( ((o.horas_oneway.value % 24) == 0) && (o.horas_oneway.value > 24) ) {
					var hd = 'jours'
					var num = o.horas_oneway.value/24;
				} else {
					var hd = 'heures'
					var num = o.horas_oneway.value;
				}
			
				alert("Pour rendre un véhicule dans une ville différente, la location doit avoir une durée minimum de " + num + " "+hd+".");
/*
 * OneWay - End
 */

			} else {
	 
	 			document.forms['f'].submit();
	 		}
	
		} else {
			alert("Vous devez introduire une date de livraison qui ne dépasse pas " + document.forms['f'].dias_max_antelacion.value + " jours d'avance.");
		}
	}
} else {
	if (from.value == "" || to.value == "")
	 alert("Vous devez introduire une date de livraison et de remise.");
	else
	 alert("Vous devez introduire une date de remise postérieure à la livraison.");
}
}


function Reserva_fr(){
with(document.forms['f']){
 if ((id_pais.value=="" || id_pais.value=="-1")){ alert("Vous devez indiquer un pays."); id_pais.focus(); }
 else
 if ((id_sucursal.value=="" || id_sucursal.value=="-1")){ alert("Vous devez indiquer une ville."); id_sucursal.focus(); }
 else
 if ((id_sucursal_fin.value=="" || id_sucursal_fin.value=="-1")){ alert("Vous devez indiquer une ville de livraison."); 
id_sucursal_fin.focus(); }
 else
 if ((edad.value=="") || (isNumber(edad.value)==false)){ alert("Vous devez indiquer un âge valable."); edad.focus(); }
 else
 if (edad.value <edad_min.value) { alert("L'âge doit être supérieur ou égal à " + edad_min.value ); edad.focus(); }
 else
 if ((fecha_inicio.value=="")){ alert("Vous devez indiquer une date de début."); fecha_inicio.focus(); }
 else
 if ((fecha_fin.value=="")){ alert("Vous devez indiquer une date de fin."); fecha_fin.focus(); }
 else
 doDateCheck_fr(fecha_inicio, fecha_fin);
 }
return false;
}