/***************** FECHA **************/
var pong;

function makeArray(n){
	this.length = n;
	for (i=1;i<=n;i++)
		this[i]=0;
	
	return this;
}



function displayDate() {
  var this_month = new makeArray(12);
  this_month[0]  = "Januar";
  this_month[1]  = "Februar";
  this_month[2]  = "März";
  this_month[3]  = "April";
  this_month[4]  = "Mai";
  this_month[5]  = "Juni";
  this_month[6]  = "Juli";
  this_month[7]  = "August";
  this_month[8]  = "September";
  this_month[9]  = "Oktober";
  this_month[10] = "November";
  this_month[11] = "Dezember";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Sonntag";
  this_day_e[1]  = "Montag";
  this_day_e[2]  = "Dienstag";
  this_day_e[3]  = "Mittwoch";
  this_day_e[4]  = "Donnerstag";
  this_day_e[5]  = "Freitag";
  this_day_e[6]  = "Samstag";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  return( "<span class='fecha-cab'> " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " " + year + "</span>");
}

/************************************************************************************************************/

/************************************************ añadir a favoritos ****************************************/

function favoritos()
{
	var direccion="http://www.solmar.es"; 
	var titulo="Sol-Mar, Alquiler de vehículos"; 
	var ns = "Um diese Seite zu Ihren Notizbuch hinzuzufügen, drücken Sie: <b>[Ctrl] + [ D ]</b> "; 
	var op = "Para añadir esta página a tus Preferidos de Opera, pulsa: <br><b>[Ctrl] + [Mays] + [T]</b>"; 
	
	if (navigator.userAgent.indexOf("Opera")!=-1) document.write(op) 
	else { if (navigator.appName == "Netscape") document.write(ns) 
	else { 
		document.write(' <a href="javascript:window.external.AddFavorite(direccion, titulo);" ') 
		document.write(' onMouseOver="window.status= ') 
		document.write(" 'Sol Mar zu Ihren Favoriten hinzufügen'; return true ") 
		document.write(' " onMouseOut="window.status= ') 
		document.write(" ' '; return true ") 
		document.write(' ">Sol Mar zu Ihren Favoriten hinzufügen</a>') } } 
}

/*************************************************************************************************************/

/******************************************* abre un pop up para oficinas ************************************/

function AbrirVentana(pagina,nombreventana) 
{
	myWin=window.open(pagina,nombreventana,'width=540,height=480,toolbar=si,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=no');
}

/*************************************************************************************************************/

/******************************************* abre un pop up para flota  **********************************/

function AbrirVentanaF(pagina,nombreventana) 
{
	myWin=window.open(pagina,nombreventana,'width=450,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,titlebar=no');
}

/*************************************************************************************************************/

/******************************************* abre un pop up para flota  **********************************/

function AbrirVentanaC(pagina,nombreventana) 
{
	myWin=window.open(pagina,nombreventana,'width=250,height=150,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,titlebar=no');
}
/*************************************************************************************************************/
 
 /******************************************* centra la ventana  **********************************/
 
function centrar() { 
    iz=(screen.width-document.body.clientWidth) / 2; 
    de=(screen.height-document.body.clientHeight) / 2; 
    moveTo(iz,de); 
}     
/*************************************************************************************************************/

/******************************************* calendario *****************************************************/
var ventanaCalendario=false 

function muestraCalendario(formulario_destino,campo_destino,boton, idioma, sender, mes, anyo, sucur){ 
	//funcion para abrir una ventana con un calendario. 
	if (typeof ventanaCalendario.document == "object") { 
	   ventanaCalendario.close();
	}
	ventanaCalendario = window.open("http://www.solmar.es/calendario/calendario/p_calendario.php?boton=" + boton + "&formulario=" + formulario_destino + "&nomcampo=" + campo_destino + "&idioma=" + idioma + "&sender=" + sender + "&nuevo_mes=" + mes + "&nuevo_ano=" + anyo + "&sucursal=" + sucur,"calendario", "width=250,height=250, left=100,top=100, scrollbars=no,menubars=no,statusbar=NO, status=NO, resizable=YES,location=NO") 
} 

function muestraCalendarioAgencia(formulario_destino,campo_destino,boton, idioma, sender){ 
	//funcion para abrir una ventana con un calendario. 
	if (typeof ventanaCalendario.document == "object") { 
	   ventanaCalendario.close();
	}
	ventanaCalendario = window.open("http://www.solmar.es/calendario/calendario/p_calendario.php?boton=" + boton + "&formulario=" + formulario_destino + "&nomcampo=" + campo_destino + "&idioma=" + idioma + "&sender=" + sender + "&sucursal=" + sucur,"calendario", "width=250,height=300, left=100,top=100, scrollbars=no,menubars=no,statusbar=NO, status=NO, resizable=YES,location=NO") 
} 

function muestraCalendarioprueba(formulario_destino,campo_destino,boton, idioma, sender, mes, anyo){ 
	//funcion para abrir una ventana con un calendario. 
	if (typeof ventanaCalendario.document == "object") { 
	   ventanaCalendario.close();
	}
	ventanaCalendario = window.open("http://www.solmar.es/calendario2/calendario/p_calendario.php?boton=" + boton + "&formulario=" + formulario_destino + "&nomcampo=" + campo_destino + "&idioma=" + idioma + "&sender=" + sender + "&nuevo_mes=" + mes + "&nuevo_ano=" + anyo,"calendario", "width=300,height=350, left=100,top=100, scrollbars=no,menubars=no,statusbar=NO, status=NO, resizable=YES,location=NO") 
} 
/*************************************************************************************************************/

/***************************** MUESTRA TABLA DE VEHÍCULOS ****************************************************/
function viewHide(id, origen) 
{
			var targetId, srcElement, targetElement;
			var targetElement;
			
			
				targetElement = document.getElementById('v7');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v1');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v2');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v3');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v4');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v6');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v8');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v9');
				targetElement.style.display = "none";
				targetElement = document.getElementById('v10');
				targetElement.style.display = "none";
				if(origen=='web')
				{
					targetElement = document.getElementById('v99');
					targetElement.style.display = "none";
				}
				
				targetElement = document.getElementById(id);
				if (targetElement.style.display == "none") 
				{
					targetElement.style.display = "";
				} 
				else 
				{	
					targetElement.style.display = "none";
				} 
}
		
/*************************************************************************************************************/
/*************************************************************************************************************/
/************************************ VALIDACIÓN DE DATOS ****************************************************/
/*************************************************************************************************************/
/*************************************************************************************************************/

//ANYOS BISIESTOS
function anyoBisiesto(anyo)
{
        if (anyo < 100)
            var fin = anyo + 1900;
        else
            var fin = anyo ;

        if (fin % 4 != 0)
            return false;
        else
        {
            if (fin % 100 == 0)
            {
                if (fin % 400 == 0)
                {
                    return true;
                }
               	else
                {
                    return false;
                }
            }
            else
            {
                return true;
            }
        }
}

//COMPARAR FECHAS
function Comparar_Fecha(String1,String2, anyohoy, sender) //devuelve true cuando
{
//alert("en comparar fecha:")
//alert(String1.value)
	if (String1.substring(1,2)=="/") {
		String1="0"+String1
	}
	
	if (String1.substring(4,5)=="/"){
		String1=String1.substring(0,3)+"0"+String1.substring(3,9)
	}
	
	if (String2.substring(1,2)=="/") {
		String2="0"+String2
	}
	if (String2.substring(4,5)=="/"){
		String2=String2.substring(0,3)+"0"+String2.substring(3,9)
	}
	
	dia1=String1.substring(0,2);
	mes1=String1.substring(3,5);
	anyo1=String1.substring(6,10);
	dia2=String2.substring(0,2);
	mes2=String2.substring(3,5);
	anyo2=String2.substring(6,10);
	anyo1=parseInt(anyo1, 10);
	if(anyo1<1900) anyo1=anyo1+1900;
	//VALIDAMOS FORMATO
	
	if( (isNaN(dia1)==true) || (isNaN(mes1)==true) || (isNaN(anyo1)==true) || (isNaN(dia2)==true) || (isNaN(mes2)==true) || (isNaN(anyo2)==true) )
    {
        	alert("Das eingegebene Datum darf lediglich aus Nummern bestehen");
     	return false;
    }
	//COMPROBAMOS SI ES AÑO BISIESTO
	if(anyoBisiesto(anyo1))
           febrero=29;
    else
           febrero=28;
	
	//COMPROBAMOS LOS DIAS DEL MES
	if ((mes1<1) || (mes1>12) || (mes2<1) || (mes2>12))
    {
           alert("Der eingegebene Monat is nicht gültig. Bitte geben Sie den korrekten Monat an");
        return false;
    }
       
    if ((mes1==2) && ((dia1<1) || (dia1>febrero)))
    {
           alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
        return;
    }
	if ((mes2==2) && ((dia2<1) || (dia2>febrero)))
    {
           alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
        return;
    }
	
	if (((mes1==1) || (mes1==3) || (mes1==5) || (mes1==7) || (mes1==8) || (mes1==10) || (mes1==12)) && ((dia1<1) || (dia1>31)))
    {
           alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
        return false;
    }
       
   if (((mes1==4) || (mes1==6) || (mes1==9) || (mes1==11)) && ((dia1<1) || (dia1>30)))
   {
	   	  alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
	   return false;
   }
   if (((mes2==1) || (mes2==3) || (mes2==5) || (mes2==7) || (mes2==8) || (mes2==10) || (mes2==12)) && ((dia2<1) || (dia2>31)))
    {
           alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
        return false;
    }
       
   if (((mes2==4) || (mes2==6) || (mes2==9) || (mes2==11)) && ((dia2<1) || (dia2>30)))
   {
   
	   	alert("Der angegebene Tag ist nicht gültig. Bitte geben Sie den richtigen Tag an.");
	    return false;
   }
   
   if (sender=='reserva' && ((anyo1<anyohoy) || (anyo1>anyohoy+2)))
   {		   
	    alert("Das angegebene Jahr ist nicht gültig.");
		return false;
   } 
	
	if (dia1 == "08") 
		dia1 = "8";
	if (dia1 == '09') 
		dia1 = "9";
	if (mes1 == "08") 
		mes1 = "8";
	if (mes1 == "09") 
		mes1 = "9";
	if (dia2 == "08") 
		dia2 = "8";
	if (dia2 == '09') 
		dia2 = "9";
	if (mes2 == "08") 
		mes2 = "8";
	if (mes2 == "09") 
		mes2 = "9";
	
	dia1=parseInt(dia1,10);
	dia2=parseInt(dia2,10);
	mes1=parseInt(mes1,10);
	mes2=parseInt(mes2,10);
	anyo1=parseInt(anyo1,10);
	anyo2=parseInt(anyo2,10);
	
	if ((anyo1>anyo2) || ((anyo1==anyo2) && (mes1>mes2)) || ((anyo1==anyo2) && (mes1==mes2) && (dia1>dia2)))
	{
		if (sender=="reserva")
			alert("Fecha de devolución anterior a la fecha de recogida del vehículo.");
		if(sender=="agencia")
			alert("La fecha inicial debe ser anterior a la fecha final");
		return false;	//fecha1>fecha2
	}
	
	return true;
}
/********************************************************/


function validacion_index(fecha1, fecha2, h1, h2, sender, sus, sue)
{		
			
	/**************************** VALIDACIÓN FECHAS *********************************/

			if (fecha1.length != 10) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("The pick up Date format is not correct");	//MENSAJE POR PANTALLA
				return false;
			}

			if (fecha2.length != 10) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("The drop off Date format is not correct");
				return false;
			}
			
			var separador1f1= fecha1.charAt(2)
			var separador2f1= fecha1.charAt(5)
			var separador1f2= fecha2.charAt(2)
			var separador2f2= fecha2.charAt(5)
			
			if (separador1f1!= '/' || separador2f1!= '/' || separador1f2!= '/' || separador2f2!= '/') 
			{
				//alert ("sep1f1" + separador1f1)
				alert("Date format is not correct");	//MENSAJE POR PANTALLA
				return false;
			}


			if (fecha1.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Please, introduce pick up date");	//MENSAJE POR PANTALLA
				return false;
			}

			if (fecha2.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Please, introduce drop off date");
				return false;
			}

			var today = new Date();
  			var day   = today.getDate();
  			var month = today.getMonth();
  			var year  = today.getYear();
  			var dia = today.getDay();
			var hora = today.getHours();
			var minutos = today.getMinutes();
			
			month=month+1;
			
			if (day == "1") 
				day = "01";
			if (day == "2") 
				day = "02";
			if (day == "3") 
				day = "03";
			if (day == "4") 
				day = "04";
			if (day == "5") 
				day = "05";
			if (day == "6") 
				day = "06";
			if (day == "7") 
				day = "07";
			if (day == "8") 
				day = "08";
			if (day == "9") 
				day = "09";
			if (month == "1") 
				month = "01";
			if (month == "2") 
				month = "02";
			if (month == "3") 
				month = "03";
			if (month == "4") 
				month = "04";
			if (month == "5") 
				month = "05";
			if (month == "6") 
				month = "06";
			if (month == "7") 
				month = "07";
			if (month == "8") 
				month = "08";
			if (month == "9") 
				month = "09";
			
			if(year<1900) year=year+1900;
			var hoy=day + "/" + month + "/" + year;
   			
			if (year < 1000) 
			{
     				year += 1900; 
			}
			
			var retorno1;
			retorno1 = Comparar_Fecha(fecha1, fecha2, year, sender);
			if (retorno1==false)
			{
				alert("The drop off date cannot be earlier than pick up date");
				return false;
			}
			else if(retorno1!=true)
			{
				return false;
			}
			
			h1i=parseInt(h1,10)
			h2i=parseInt(h2,10)
						
			if((fecha1==fecha2)&&(h1i>=h2i))
			{
				alert("date and time drop off should be after the picking up date and time.");
				return false;
			}
										
			var retorno2;
			retorno2 = Comparar_Fecha(hoy, fecha1, year, sender);
			
			if (retorno2==false)
			{
				alert("The pick up date cannot be prior/ before to today");
				return false;
			}
			else if(retorno2!=true)
				return false;
			
			if(minutos==0)
				hora=hora+1
			
			h=parseInt(hora,10)
		
			if ((fecha1==hoy) && (h>=h1i))
			{
				alert("Pick up time cannot be prior to the actual time");
				return false;
			}

			retorno2=Comparar_Fecha('23/10/2008',fecha1, year, 'nuevaapertura');

			if(((sus=='SG') || (sue=='SG') ) && (retorno2==false))
			{
				alert("According to the forecast of this year our Santiago de Compostela branch will be opened on the 23th of October, however any reservation starting from that date on will be accepted.");
				return false;
			}
			
			
			retorno2=Comparar_Fecha('20/08/2008',fecha1, year, 'nuevaapertura');
			var patron=/^ME/;
			if((patron.test(sus) || patron.test(sue)) && (retorno2==false))
			{
				alert("Lo sentimos. Hasta el 21 de Agosto no se podrán realizar reservas via web en Menorca. Actualmente aceptamos reservas a partir de esta fecha.");
				return false;
			}
} 

function validacion_empleo(nombre, poblacion, provincia, edad, nacionalidad, telf, email, idiomas)
{		
			
	/**************************** VALIDACIÓN FECHAS *********************************/

			if (nombre.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihren Namen an");	//MENSAJE POR PANTALLA
				return false;
			}

			if (poblacion.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihren Ort an");
				return false;
			}

			if (provincia.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihr Bundesland an");	//MENSAJE POR PANTALLA
				return false;
			}

			if (edad.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihr Alter an");
				return false;
			}
			if (nacionalidad.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihre Nationlität an");	//MENSAJE POR PANTALLA
				return false;
			}

			if (telf.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihre Telefonnummer an");
				return false;
			}
			
			if (email.length == 0) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie Ihr e-mail an");	//MENSAJE POR PANTALLA
				return false;
			}
			
			if (idiomas.length == 8) //SI ESTÁ VACIO MOSTRAMOS MENSAJE Y SALIMOS DE LA FUNCION
			{
				alert("Geben Sie die Sprachen, die Sie sprechen");
				return false;
			}
			
			/*var er_email = /^(.+\@.+\..+)$/
			
			if(!er_email.test(email)) 
			{ 
				alert('E-mail- Feld nicht gültig.')
				return false
    		}*/
} 
/****************************************  CALCULA LA EDAD **************************************************/
function calcular_edad(fecha){ 

    //calculo la fecha de hoy 
    hoy=new Date() 
    //alert(fecha) 

    //calculo la fecha que recibo 
    //La descompongo en un array 
    var array_fecha = fecha.split("/") 
    //si el array no tiene tres partes, la fecha es incorrecta 
    if (array_fecha.length!=3) 
	{
       return false 
	}
    //compruebo que los ano, mes, dia son correctos 
    var ano 
    ano = parseInt(array_fecha[2],10); 
    if (isNaN(ano)) 
	{
       return false 
	  }

    var mes 
    mes = parseInt(array_fecha[1],10); 
    if (isNaN(mes)) 
	{
       return false 
	}
    var dia 
    dia = parseInt(array_fecha[0],10); 
    if (isNaN(dia)) 
	{
       return false 
	}

    //si el año de la fecha que recibo solo tiene 2 cifras hay que cambiarlo a 4 
    if(ano<1900) ano=ano+1900;

    //resto los años de las dos fechas 
    aaaa=hoy.getYear();
	if(aaaa<1900) aaaa=aaaa+1900;
    edad=aaaa - ano - 1; //-1 porque no se si ha cumplido años ya este año  

    //si resto los meses y me da menor que 0 entonces no ha cumplido años. Si da mayor si ha cumplido 
    if (hoy.getMonth() + 1 - mes < 0) //+ 1 porque los meses empiezan en 0 
       return edad 
    if (hoy.getMonth() + 1 - mes > 0) 
       return edad+1 

    //entonces es que eran iguales. miro los dias 
    //si resto los dias y me da menor que 0 entonces no ha cumplido años. Si da mayor o igual si ha cumplido 
    if (hoy.getUTCDate() - dia >= 0) 
       return edad + 1 

    return edad 
} 



/******************* VALIDAMOS DATOS DEL CLIENTE ***********************************/
function validarfecha(fecha)
{
	var separador1f1= fecha.charAt(2)
	var separador2f1= fecha.charAt(5)
	
	if (separador1f1!= '/' || separador2f1!= '/') 
		return false;

	else
	{
		//La descompongo en un array 
		var array_fecha = fecha.split("/")
		anyo = parseInt(array_fecha[2])
		 
		//si el array no tiene tres partes, la fecha es incorrecta 
		if (array_fecha.length!=3 || anyo<=99) 
		   return false 
		else
			return true;
	}
 }
 
// SIN SEGUNDO CONDUCTOR
function validacion_cliente(pais, nom, ape, numper, tel, f_nac, email, dir, pob, cp, domp, pobp)
{
	var er_email = /^(.+\@.+\..+)$/
	
	
	if((nom.length == 0)||(ape.length == 0)||(numper.length == 0)||(tel.length == 0)||(email.length == 0)||(dir.length == 0)||(pob.length == 0)||(cp.length == 0)||(domp.length == 0)||(pobp.length == 0))
	{
		alert("Die obligatorischen Felder müssen ausgefüllt werden")
		return false
	}
	
	/*if(!er_email.test(email)) 
	{ 
       		alert('E-mail- Feld nicht gültig.')
       		return false
    }*/
	
	if(validarfecha(f_nac)==false)
	{
		alert("Das Format des geburtsdatum ist inkorrekt");	//MENSAJE POR PANTALLA
		return false
	}
	
	if(f_nac.length!=0)
	{
		anyos = calcular_edad(f_nac);
		if(anyos < 23)
		{
			alert ('Das Mindestalter für die Anmietung eines Fahrzeuges ist 23 Jahre');
			return false
		}
	}

}

// CON SEGUNDO CONDUCTOR
function validacion_cliente21(pais, nom, ape, numper, tel, f_nac, email, dir, pob, cp, domp, pobp, nom_seg, numper2)
{
	var er_email = /^(.+\@.+\..+)$/

	if((nom.length == 0)||(ape.length == 0)||(numper.length == 0)||(tel.length == 0)||(email.length == 0)||(dir.length == 0)||(pob.length == 0)||(cp.length == 0)||(domp.length == 0)||(pobp.length == 0)|| (nom_seg.length ==0) || (numper2.length== 0))
	{
		alert("Die obligatorischen Felder müssen ausgefüllt werden");
		return false;
	}

	/*if(!er_email.test(email)) 
	{ 
       		alert('E-mail- Feld nicht gültig.')
       		return false;
    	}*/
		
	if(validarfecha(f_nac)==false)
	{
		alert("Das Format des geburtsdatum ist inkorrekt");	//MENSAJE POR PANTALLA
		return false
	}
	if(f_nac.length!=0)
	{	
		anyos = calcular_edad(f_nac);
		if(anyos < 23)
		{alert(anyos)
			alert ('Das Mindestalter für die Anmietung eines Fahrzeuges ist 23 Jahre');
			return false
		}
	}
}

function validacion_cliente22(pais, nom, ape, numper, tel, f_nac, email, dir, pob, cp, domp, pobp, nom_seg, numper2, nom_seg2, numper22)
{
	var er_email = /^(.+\@.+\..+)$/

	if((nom.length == 0)||(ape.length == 0)||(numper.length == 0)||(tel.length == 0)||(email.length == 0)||(dir.length == 0)||(pob.length == 0)||(cp.length == 0)||(domp.length == 0)||(pobp.length == 0)|| (nom_seg.length ==0) || (numper2.length== 0) || (nom_seg2.length ==0) || (numper22.length== 0))
	{
		alert("Die obligatorischen Felder müssen ausgefüllt werden");
		return false;
	}

	/*if(!er_email.test(email)) 
	{ 
       		alert('E-mail- Feld nicht gültig.')
       		return false;
    	}*/
		
	if(validarfecha(f_nac)==false)
	{
		alert("Das Format des geburtsdatum ist inkorrekt");	//MENSAJE POR PANTALLA
		return false
	}	
	anyos = calcular_edad(f_nac);
	if(anyos < 23)
	{
		alert ('Das Mindestalter für die Anmietung eines Fahrzeuges ist 23 Jahre');
		return false
	}
}

function validacion_cliente23(pais, nom, ape, numper, tel, f_nac, email, dir, pob, cp, domp, pobp, nom_seg, numper2, nom_seg2, numper22, nom_seg3, numper23)
{
	var er_email = /^(.+\@.+\..+)$/

	if((nom.length == 0)||(ape.length == 0)||(numper.length == 0)||(tel.length == 0)||(email.length == 0)||(dir.length == 0)||(pob.length == 0)||(cp.length == 0)||(domp.length == 0)||(pobp.length == 0)|| (nom_seg.length ==0) || (numper2.length== 0) || (nom_seg2.length ==0) || (numper22.length== 0) || (nom_seg3.length ==0) || (numper23.length== 0))
	{
		alert("Die obligatorischen Felder müssen ausgefüllt werden");
		return false;
	}

	/*if(!er_email.test(email)) 
	{ 
       		alert('E-mail- Feld nicht gültig.')
       		return false;
    	}
	*/
	if(validarfecha(f_nac)==false)
	{
		alert("Das Format des geburtsdatum ist inkorrekt");	//MENSAJE POR PANTALLA
		return false
	}
	anyos = calcular_edad(f_nac);
	if(anyos < 23)
	{
		alert ('Das Mindestalter für die Anmietung eines Fahrzeuges ist 23 Jahre');
		return false
	}
}

/*****************************************************************************************************************/
/*****************************************************************************************************************/
/*****************************************************************************************************************/
/*****************************************************************************************************************/
/************************************************ AGENCIAS *******************************************************/
/*****************************************************************************************************************/
/*****************************************************************************************************************/
/*****************************************************************************************************************/
/*****************************************************************************************************************/

//validamos el registro de las agencias
function validacion_registroa(nom, tel, ema, dir, pob, cp, cif, nac, fax, con)
{
	var er_email = /^(.+\@.+\..+)$/
	
	if((nom.length == 0)||(tel.length == 0)||(ema.length == 0)||(dir.length == 0)||(pob.length == 0)||(cp.length == 0)||(cif.length == 0)||(fax.length == 0)|| (nac.length ==0)|| (con.length ==0))
	{
		alert("Die obligatorischen Felder müssen ausgefüllt werden");
		return false;
	}
	
	/*if(!er_email.test(ema)) 
	{ 
       	alert('E-mail- Feld nicht gültig.')
       	return false;
   	}*/
}

function validacion_agencia(codigo, clave)
{
/*	var er_agn = /^[0-9]{1,8}$/
	
	if(!er_agn.test(codigo)) 
	{ 
       		alert("Código de agencia no válido.")
       		return false;
    }
*/
	if(clave.length < 0 || clave.length > 8)
	{
		alert("Contraseña no válida.")
		
		return false
	}
}	


// CALCULAR LA FECHA ACTUAL EN FORMATO: DD/MM/AAAA

function devuelve_hoy()
{
	var today = new Date();
	var today = new Date();
  	var day   = today.getDate();
  	var month = today.getMonth();
  	var year  = today.getYear();
  	var dia = today.getDay();
	var hora = today.getHours();
	var minutos = today.getMinutes();
		
	month=month+1;
			
	if (day == "1") 
		day = "01";
	if (day == "2") 
		day = "02";
	if (day == "3") 
		day = "03";
	if (day == "4") 
		day = "04";
	if (day == "5") 
		day = "05";
	if (day == "6") 
		day = "06";
	if (day == "7") 
		day = "07";
	if (day == "8") 
		day = "08";
	if (day == "9") 
		day = "09";
	if (month == "1") 
		month = "01";
	if (month == "2") 
		month = "02";
	if (month == "3") 
		month = "03";
	if (month == "4") 
		month = "04";
	if (month == "5") 
		month = "05";
	if (month == "6") 
		month = "06";
	if (month == "7") 
		month = "07";
	if (month == "8") 
		month = "08";
	if (month == "9") 
		month = "09";
			
	if(year<1900) year=year+1900;
	var hoy=day + "/" + month + "/" + year;
			
	return hoy;
}

// CALCULAR LA FECHA ACTUAL EN FORMATO: DD/MM/AAAA + 7dias

/*function masSiete()
{
	var today = new Date();
	var today = new Date();
  	var day   = today.getDate();
  	var month = today.getMonth();
  	var year  = today.getYear();
  	var dia = today.getDay();
	var hora = today.getHours();
	var minutos = today.getMinutes();
	
	var day   = day+7;
	
	/*if(var day2>=31)
	{
		var day= var day2 - var day;
		
	}
		
	month=month+1;
			
	if (day == "1") 
		day = "01";
	if (day == "2") 
		day = "02";
	if (day == "3") 
		day = "03";
	if (day == "4") 
		day = "04";
	if (day == "5") 
		day = "05";
	if (day == "6") 
		day = "06";
	if (day == "7") 
		day = "07";
	if (day == "8") 
		day = "08";
	if (day == "9") 
		day = "09";
	if (month == "1") 
		month = "01";
	if (month == "2") 
		month = "02";
	if (month == "3") 
		month = "03";
	if (month == "4") 
		month = "04";
	if (month == "5") 
		month = "05";
	if (month == "6") 
		month = "06";
	if (month == "7") 
		month = "07";
	if (month == "8") 
		month = "08";
	if (month == "9") 
		month = "09";
			
	if(year<1900) year=year+1900;
	var hoy=day + "/" + month + "/" + year;
			
	return hoy;
}

*/
//carga las fechas de mañana y 7 dias despues en el formulario
function fechas() 
{ 
	window.document.reserva.f_recogida.value=manyana();
	window.document.reserva.f_devolucion.value=manyanamassiete();
} 

//NOS DEVUELVE LA FECHA DEL DIA SIGUIENTE + 7
function manyanamassiete()
{
	var today = new Date();
	var dev = new Date();
		
	var segundos=today.getTime()+(8*24*60*60*1000);
	dev.setTime(segundos);
	
	var day   = dev.getDate();
  	var month = dev.getMonth();
  	var year  = dev.getYear();
		
	month=month+1;
				
	if (day == "1") 
		day = "01";
	if (day == "2") 
		day = "02";
	if (day == "3") 
		day = "03";
	if (day == "4") 
		day = "04";
	if (day == "5") 
		day = "05";
	if (day == "6") 
		day = "06";
	if (day == "7") 
		day = "07";
	if (day == "8") 
		day = "08";
	if (day == "9") 
		day = "09";
	if (month == "1") 
		month = "01";
	if (month == "2") 
		month = "02";
	if (month == "3") 
		month = "03";
	if (month == "4") 
		month = "04";
	if (month == "5") 
		month = "05";
	if (month == "6") 
		month = "06";
	if (month == "7") 
		month = "07";
	if (month == "8") 
		month = "08";
	if (month == "9") 
		month = "09";
			
	if(year<1900) year=year+1900;
	var hoy=day + "/" + month + "/" + year;
			
	return hoy;
}

//funcion para obtener mañana

function manyana()
{
	var today = new Date();
	var dev = new Date();
		
	var segundos=today.getTime()+(24*60*60*1000);
	dev.setTime(segundos);
	
	var day   = dev.getDate();
  	var month = dev.getMonth();
  	var year  = dev.getYear();
		
	month=month+1;
				
	if (day == "1") 
		day = "01";
	if (day == "2") 
		day = "02";
	if (day == "3") 
		day = "03";
	if (day == "4") 
		day = "04";
	if (day == "5") 
		day = "05";
	if (day == "6") 
		day = "06";
	if (day == "7") 
		day = "07";
	if (day == "8") 
		day = "08";
	if (day == "9") 
		day = "09";
	if (month == "1") 
		month = "01";
	if (month == "2") 
		month = "02";
	if (month == "3") 
		month = "03";
	if (month == "4") 
		month = "04";
	if (month == "5") 
		month = "05";
	if (month == "6") 
		month = "06";
	if (month == "7") 
		month = "07";
	if (month == "8") 
		month = "08";
	if (month == "9") 
		month = "09";
			
	if(year<1900) year=year+1900;
	var hoy=day + "/" + month + "/" + year;
			
	return hoy;
}
