////////////////////////////////////////////////////////////////////////////////////////////////////
// Averiguamos el entorno donde nos encontramos
////////////////////////////////////////////////////////////////////////////////////////////////////

var url_encuentro = document.URL.substr(0,14);
if (url_encuentro == 'http://pruebas') {
	var servidor = "pruebas";
} else { 
	var servidor = "www";
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

function expandSELECT(sel) {
  sel.style.width = '325px';
}
function contractSELECT(sel) {
  sel.style.width = '200px';
}


function letra(e) {

	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==8) return true;//Tecla de retroceso (para poder borrar)
	patron =/[A-Z a-z &aacute;&eacute;&iacute;&oacute;&uacute;]/; // Solo acepta letras
	te = String.fromCharCode(tecla);
	return patron.test(te);

}
				
// function validar(e) {
// 	tecla = (document.all) ? e.keyCode : e.which;
// 	if (tecla==8) return true; //Tecla de retroceso (para poder borrar)
// 	patron = /[0-9.\t]/; // Solo acepta n&uacute;meros
// 	te = String.fromCharCode(tecla);
// 	return patron.test(te);
// }

function validar(e) { 
   tecla = e.which || e.keyCode; 
   patron = /[0-9.\t]/; // Solo acepta n&uacute;meros 
   te = String.fromCharCode(tecla); 
   return (patron.test(te) || tecla == 9 || tecla == 8);  
 }

function validarcc(e) { 	// Para validacion de cuenta corriente
   tecla = e.which || e.keyCode; 
   patron = /[0-9\t]/; // Solo acepta n&uacute;meros 
   te = String.fromCharCode(tecla); 
   return (patron.test(te) || tecla == 9 || tecla == 8);  
 }


function rellena_nif(Nif, Tipo, iDen){

	respu = false;
//	alert ("entro en rellena_nif: " + Tipo + " / " + Nif );
// 	var Nif = Nif.toUpperCase();
	var Tipo = Tipo.toUpperCase();
//	alert ("entro en rellena_nif 2222: " + Tipo + " / " + Nif );
	respu = comprueba_nif_cif(Nif, Tipo.toLowerCase());
//	alert ("al volver de compruebanif: " + respu);
	var nif = Nif;

	if (respu == true) {
	
		if ((nif != '') && ((Tipo == "NIF") || 
			(Tipo == "NIE" &&
			 nif.substring(0, 1) == "X") || 
			(Tipo == "NIE" &&
			 nif.substring(0, 1) == "Y") ||
			(Tipo == "NIE" &&
			 nif.substring(0, 1) == "Z"))) {
	
			var letra1 = '';
	
			if (Tipo == "NIE") {
				var letra1 = nif.substring(0, 1);
				var nif = nif.substring(1,(nif.length));
			}
	
			var letra2 = nif.substr((nif.length - 1), 1);
			var nif2 = nif.substr(0, (nif.length - 1));
	
			if (Tipo == "NIF") {
				var y = 8;
			} else {
				var y = 7;
			}
	
			var aux = '';
	
			for (var i=0; i < (y - nif2.length); i++) {
				var ch = 0;
				aux += ch;
			}
	
			nif2 = aux + nif2;
	
// 			Nif = letra1 + nif2 + letra2;
			document.getElementById(iDen).value = letra1 + nif2 + letra2;
		}
		return respu;
	} else {
		if (nif != '') {
			return false;
		} else {
			return true;
		}
	}	
}
				
function comprueba_nif(nif, nif_nie){	//funcion para el evento onblur de la validacion del nif
								
	var respu=true;

	letranie = nif.substr(0, 1);
			
	if ( nif_nie == "nie" ) { 
			
		if ( nif.substr(0, 1).toUpperCase() != "X" && nif.substr(0, 1).toUpperCase() != "Y" ) {
														
			if(nif == ''){
			
				respu = true;
			
			}else{
			
				Sexy.alert("&bull; La primera letra del NIE debe ser una X/Y.<br>");
				respu = false;	
				
			}								
		}
	}
			
	if (!/^[0123456789]/.test(letranie) && nif_nie == 'nif') { // para NIF, el primer digito debe ser un numero
			
		if(nif == ''){
		
			respu = true;
			
		}else{
		
			Sexy.alert("&bull; El primer d&iacute;gito del NIF no puede ser una letra.<br>");
			respu = false;
	
		}
	
	}
			
	if ( nif_nie == 'nie' ){
						
		nif = nif.substr(1,(nif.length));  //pilla a partir del segundo caracter  del nie
	}
			
	var letra2 = nif.substr((nif.length - 1), 1); //pilla el ultimo caracter del nif
	
	letra2 = letra2.toUpperCase();
												
				
	if (!/^[0123456789]/.test(letra2)) { //si el ultimo caracter no es un numero
						
		var nif2 = nif.substr(0, (nif.length - 1));
				
	} else {
					 
		var nif2 = nif;
				
	}
			
	if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
	
		nif2 = Number(nif2);
	
		diezmilliones=parseInt(10000000);
	
		nif2 += diezmilliones;
																
	}
			
	//cuando los nies empiezen por Z se le tiene que sumar 20 millones
																
	if (nif2 !='') {
																			
		letra = (nif2 %= 23) + 1;
		if (letra == 1) {letra='T'};
		if (letra == 2) {letra='R'};
		if (letra == 3) {letra='W'};
		if (letra == 4) {letra='A'};
		if (letra == 5) {letra='G'};
		if (letra == 6) {letra='M'};
		if (letra == 7) {letra='Y'};
		if (letra == 8) {letra='F'};
		if (letra == 9) {letra='P'};
		if (letra == 10) {letra='D'};
		if (letra == 11) {letra='X'};
		if (letra == 12) {letra='B'};
		if (letra == 13) {letra='N'};
		if (letra == 14) {letra='J'};
		if (letra == 15) {letra='Z'};
		if (letra == 16) {letra='S'};
		if (letra == 17) {letra='Q'};
		if (letra == 18) {letra='V'};
		if (letra == 19) {letra='H'};
		if (letra == 20) {letra='L'};
		if (letra == 21) {letra='C'};
		if (letra == 22) {letra='K'};
		if (letra == 23) {letra='E'};
		
		if ( letra != letra2 ) {
		
			if ( nif_nie == 'nie' ) {
			
				Sexy.alert("&bull; El NIE es err&oacute;neo.<br>");
				respu = false;
					
			} else {
			
				Sexy.alert("&bull; El NIF es err&oacute;neo.<br>"); 
				respu = false;
														
			}
		
		}
				
	}
			
return respu;

}


function comprueba_nif_cif(nif, nif_nie){	//funcion para el evento onblur de la validacion del nif
	var respu=true;
	letranie = nif.substr(0, 1);
			
	if ( nif_nie == "nie" ) { 	
		if ( nif.substr(0, 1).toUpperCase() != "X" && nif.substr(0, 1).toUpperCase() != "Y"  && nif.substr(0, 1).toUpperCase() != "Z") {												
			if (nif == '') {			
				respu = true;
			} else {
				Sexy.alert("&bull; La primera letra del NIE debe ser una X/Y/Z.<br>");
				respu = false;		
			}								
		}
	}
			
	if (!/^[0123456789]/.test(letranie) && nif_nie == 'nif') { // para NIF, el primer digito debe ser un numero
		if (nif == '') {
			respu = true;		
		} else {
			Sexy.alert("&bull; El primer d&iacute;gito del NIF no puede ser una letra.<br>");
			respu = false;
		}
	}
	
	if ( nif_nie == 'cif' ) {//si es cif
		var pares = 0;
		var impares = 0;
		var suma;
		var ultima;
		var unumero;
		var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
		var xxx;
		var texto = nif.toUpperCase();
		
		ultima = texto.substr(8,1);
		
		for (var cont = 1 ; cont < 7 ; cont ++){	
			xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
			impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
			pares += parseInt(texto.substr(cont,1));
		}
		
		xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
		impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
		suma = (pares + impares).toString();
		unumero = parseInt(suma.substr(suma.length - 1, 1));
		unumero = (10 - unumero).toString();
		
		if (unumero == 10) unumero = 0;
		
		//console.log(unumero +' || '+ uletra[unumero]);
		//console.log(ultima);
		
		if ((ultima == unumero) || (ultima == uletra[unumero])){
		
		} else {
			if (nif != '') {	//para que cuando este vacio no saque el horror ;)
				Sexy.alert("&bull; El CIF es err&oacute;neo.<br>");
				respu = false;
			}	
		}
		
	} else {
		if ( nif_nie == 'nie' ) {						
			nif = nif.substr(1,(nif.length));  //pilla a partir del segundo caracter  del nie
		}
				
		var letra2 = nif.substr((nif.length - 1), 1); //pilla el ultimo caracter del nif
		letra2 = letra2.toUpperCase();									
					
		if (!/^[0123456789]/.test(letra2)) { //si el ultimo caracter no es un numero
			var nif2 = nif.substr(0, (nif.length - 1));				
		} else {
			var nif2 = nif;	
		}
				
		if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
			nif2 = Number(nif2);
			diezmilliones=parseInt(10000000);
			nif2 += diezmilliones;
		}
				
		//cuando los nies empiezen por Z se le tiene que sumar 20 millones
																	
		if (nif2 !='') {
																				
			letra = (nif2 %= 23) + 1;
			if (letra == 1) {letra='T'};
			if (letra == 2) {letra='R'};
			if (letra == 3) {letra='W'};
			if (letra == 4) {letra='A'};
			if (letra == 5) {letra='G'};
			if (letra == 6) {letra='M'};
			if (letra == 7) {letra='Y'};
			if (letra == 8) {letra='F'};
			if (letra == 9) {letra='P'};
			if (letra == 10) {letra='D'};
			if (letra == 11) {letra='X'};
			if (letra == 12) {letra='B'};
			if (letra == 13) {letra='N'};
			if (letra == 14) {letra='J'};
			if (letra == 15) {letra='Z'};
			if (letra == 16) {letra='S'};
			if (letra == 17) {letra='Q'};
			if (letra == 18) {letra='V'};
			if (letra == 19) {letra='H'};
			if (letra == 20) {letra='L'};
			if (letra == 21) {letra='C'};
			if (letra == 22) {letra='K'};
			if (letra == 23) {letra='E'};
			
			if ( letra != letra2 ) {
			
				if ( nif_nie == 'nie' ) {
				
					Sexy.alert("&bull; El NIE es err&oacute;neo.<br>");
					respu = false;
						
				} else {
				
					Sexy.alert("&bull; El NIF Es err&oacute;neo.<br>"); 
					respu = false;
															
				}
			
			}
					
		}
	
	}

	return respu;

}


				
function valida_matricula(matricula,id){
	var reg = new RegExp ("^(([0-9]{4}[B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z]{3})|([a-zA-Z]{1,2}[0-9]{4}[a-zA-z]{1,2})|([P]{1}[0-9]{4}[a-zA-Z]{3})|([E]{1}[0-9]{4}[a-zA-Z]{3})|([C]{1}[0-9]{4}[a-zA-Z]{3})|([a-zA-Z]{1,2}[0-9]{5}[VE]{2}))$","g");//expresion regular para todas las matriculas

	provincias = new Array ("VI","AB ","AL","AV","BA","IB","PM","BU","CC","CA","CS","CE","CR","CO","CU","GI","GE","GR","GU","SS","HU","LE","LO","LU","MA","ML","MU","NA","OR","OU","GC","PO","SA","TF","SG","SE","SO","TE","TO","VA","BI","ZA");//array de provincias para las matriculas antiguas

	provincias2 = new Array ("A","B","C","H","J","L","M","O","P","S","T","V","Z")
					
	remplazo=matricula.replace("-","");//se remplazan los guiones por nada
	remplazo=remplazo.replace("-","");
	
	
	
	remplazo=remplazo.toUpperCase();//cambia a mayusculas
    
	provin_matri=remplazo.substring(0,2);//2 primeros caracteres de la matricula
	provin_matri_segunda_letra=provin_matri.substring(1,2);//segundo caracter de la matricula
	provin_matri_primera_letra=provin_matri.substring(0,1);//primer caracter de la matricula

	if(matricula != '' ){//si la matricula no viene vacia
						
		if (reg.test(remplazo) == 0) {//si es err&oacute;nea
						   
		    Sexy.alert("&bull; Matr&iacute;cula err&oacute;nea.<br>");
		    document.getElementById(id).value="";
						   
			patron = /[0-9.]/; // Solo acepta n&uacute;meros
			var pos = remplazo.search(patron) ;
							
			if(pos > 0){
			
				switch(pos){ 
			
					case 1: //posicion cuando solo es provincia con una letra
							
						for(z=0;z< provincias2.length;z++){//recorro el array de provincias para ver si la provincia que han metido es correcta

								var encontrado2 = provincias2[z].search(provin_matri_primera_letra);//busqueda de la primera letras
								
								if(encontrado2==0){//si no lo a encontrado salgo del bucle
								
								 break;
								 
								 }	

						}
							
						if(encontrado2==-1){//si no lo a encontrado en el array sacamos el alert
						
							Sexy.alert("&bull; Provincia err&oacute;nea.<br>");	
							document.getElementById(id).value="";
						
						}
							
					break;
					
					case 2: //posicion cuando 									
				
						for(i=0;i< provincias.length;i++){//recorro el array de provincias para ver si la provincia que han metido es correcta

								var encontrado = provincias[i].search(provin_matri);//busqueda de las 2 primeras letras
								
								if(encontrado==0){
								
								 break;
								 
								 }	

						}

						if(encontrado==-1){
						
							Sexy.alert("&bull; Provincia err&oacute;nea.<br>");	
							document.getElementById(id).value="";
						
						}
							
					break;
			
				}
			}

																
		}else{
	
			patron = /[0-9.]/; // Solo acepta n&uacute;meros
			var pos = remplazo.search(patron) ;
							
			if(pos > 0){
								
				switch(pos){ 
								
					case 1: 
												
					for(z=0;z< provincias2.length;z++){//recorro el array de provincias para ver si la provincia que han metido es correcta

						var encontrado2 = provincias2[z].search(provin_matri_primera_letra);//busqueda de la primera letras
						
						if(encontrado2==0){
						
							 break;
						 
						}	

					}
					
					if(provin_matri_primera_letra != 'E'){
					
						if(encontrado2==-1){
						
							Sexy.alert("&bull; Provincia err&oacute;nea.<br>");		
							document.getElementById(id).value="";
						}
					}
					
					break;
										
					case 2:									
									
					for(i=0;i< provincias.length;i++){//recorro el array de provincias para ver si la provincia que han metido es correcta
	
							var encontrado = provincias[i].search(provin_matri);//busqueda de las 2 primeras letras
							
							if(encontrado==0){
							
								break;
							 
							}	

					}

					if(encontrado==-1){
												
						Sexy.alert("&bull; Provincia err&oacute;nea.<br>");		
						document.getElementById(id).value="";						
					}
												
					break;
								
				}
	
			}
						
		}
	
	}

}
				
				
function comprueba_codigo_postal(cod_post){
	var respu;		
	if(cod_post != ''){//si esta vacio que no saque ningun mensaje de error			 
		if(cod_post.length != 5){ //se valida que el codigo postal tenga 5 digitos
			Sexy.alert("&bull; El C&oacute;digo Postal debe tener 5 d&iacute;gitos.<br>");
			respu = false;												
		}else{
			if(cod_post > 52999){
				Sexy.alert("&bull; C&oacute;digo Postal err&oacute;neo.<br>");
				respu = false;
			}else{
				respu = true;
			}
		}
	}					
	return respu;				
}

function fourdigitos(anio){
	var respu;		
	if(anio != ''){				 //si esta vacio que no saque ningun mensaje de error			 
		if(anio.length != 4) {   //se valida que el codigo postal tenga 5 digitos
			Sexy.alert("&bull; Este campo debe tener 4 d&iacute;gitos.<br>");
			respu = false;												
		}
	}					
	return respu;				
}
	
function sixdigitos(np){
	var respu = 1;	
	if(np.length != 6) {   //se valida que el codigo postal tenga 5 digitos
		Sexy.alert("<span class='numpaso'>&bull; El N&uacute;mero de Presupuesto debe constar de 6 d&iacute;gitos.<br></span>");
		respu = 0;												
	}
	if (respu == 1) {
		return true;
	} else {
		return false;
	}
}

function buscarbanco(lstBancos, codBanco){
					
	var encontrado=false;
	var bancos = document.getElementById(lstBancos);

		for(var i=0;i < bancos.length;i++){

			codigo = codBanco.substring(0,4);

				if(codigo == bancos[i].value){

							bancos[i].selected=true;
							encontrado=true;
				}//end if codigo
		
		}//end bucle for
					
		if(! encontrado) {
		
			bancos[bancos.length-1].selected=true; bancos.value = '0000';

		}

		bancos.form.focus();
}//end funcion buscarbanco
				

function cargaCodigo(codBanco, txtBanco){	// Funcion que carga el codigo del banco en la variable de la entidad
					
	var banco = document.getElementById(txtBanco);
	banco.value=codBanco;
	banco.focus();

}
				
function calculaDC(Entidad, Agencia, Ncuenta, Dc) {// Funcion que comprueba que el numero de cuenta es correcto. En caso de ser erroneo, indica cual es el correcto.
												   // se le pasan el codigo de banco, oficina, dc a validar y el numero de cuenta.

	// alert (Entidad+"//"+Agencia+"//"+Ncuenta+"//"+Dc);
	var dc = 0;
							
	for (cont2=0; cont2 < 2 ;cont2++) {
		
		var aux = "";
		
		if (cont2 == 1)
		
			dc = dc*10;

		if (cont2 == 0) {

			for (var i=0; i < Entidad.length; i++) {

				var ch = Entidad.substring (i, i+1);
				aux += ch;

			}

			for (var i=0; i < Agencia.length; i++) {

				var ch = Agencia.substring (i, i+1);
				aux += ch;

			}

		} else {
		
			for (var i=0; i < Ncuenta.length; i++) {

				var ch = Ncuenta.substring (i, i+1);
				aux += ch;

			}

		}
						
		var cont3 = 0;
		var suma = 0;
		
		for (var cont1 = aux.length-1; cont1 >= 0; cont1--) {
			
			dig_buf = aux.substring (cont1, cont1+1);
			digito = parseFloat (dig_buf);
			
			if (cont3 == 0)
				suma = suma + (digito*6);
			else if (cont3 == 1)
				suma = suma + (digito*3);
			else if (cont3 == 2)
				suma = suma + (digito*7);
			else if (cont3 == 3)
				suma = suma + (digito*9);
			else if (cont3 == 4)
				suma = suma + (digito*10);
			else if (cont3 == 5)
				suma = suma + (digito*5);
			else if (cont3 == 6)
				suma = suma + (digito*8);
			else if (cont3 == 7)
				suma = suma + (digito*4);
			else if (cont3 == 8)
				suma = suma + (digito*2);
			else if (cont3 == 9)
				suma = suma + (digito*1);
				cont3++;
		}
						
		suma = suma % 11;
					
		digito = 11 - suma;
						
		if (digito == 10)

			dc++;

		else if (digito == 11)
							;
    		 else
			
				dc+= digito;
					
	}
				
	if (dc < 10)
		dc = "0" + dc;
		if (Dc != dc) {
			if (suma > 0) {
				Sexy.alert("&bull; El D&iacute;gito de Control no es correcto.<br>");
				return false;
			}
		} else {
			return true;
		}
							
}//end function calculaDC
				
function IsMail(YourMail){
        
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(YourMail))){
	
		Sexy.alert("&bull; Hay un error en el email.<br>");
		
	} 

}
				
function emailIgual(){

	if (document.getElementById('Email').value == document.getElementById('Repetir Email').value){

		mail=true;

	}else{

		if(document.getElementById('Repetir Email').value == ""){
		
			mail=false;
		
		}else{
		
			Sexy.alert('&bull; Los mails no son iguales.<br>');
			mail=false;
		
		}

	}

return mail;

}
			
// Funcion chequeo de radiobutons
function checkradiobuton() {
	var vid_rate = "";
	var longtd = document.formulario.producto.length;
	if (longtd==undefined) {
		longtd=1;
		if (document.formulario.producto.checked) {
			vid_rate = document.formulario.producto.value;
		}
	} else {
		for (i=0; i<longtd; i++) {
			if (document.formulario.producto[i].checked == true) {
				vid_rate = document.formulario.producto[i].value;
			}
		}
	}
	

	if (!vid_rate) {
		return false;
	}
	else if (vid_rate) {
		if (vid_rate != "") {
			return true;
		} else {
			return false;
		}
	}
}


				
function validarFormInfo(form){				
	//Sexy.alert('uu');	
	var errores = new Array(); 
	var val_txt = new Array(); 
	var camposerror = new Array();
	var cuentaerrores = 0;
	var cont2 = 0;	
	var mostrar;
	var cod;
	var longitud;
	var paso;
	var codigo_postal;
	var nif;
	var nifc;
	var resul;
	var mostrarerrores;
	var nif_nie;
	var letranie;
	var cadenaletranie = 'x';
	var resul = false;
	var letra;
    var producto;
    var bmw;
    var paso_anterior;
    var productoclick;
/*---------------------------------- validacion de campos requeridos-----------------------------------------------*/

// Sexy.alert(form.elements.length);

	for (i=0; ele=form.elements[i]; i++){	
							
// Sexy.alert(ele.id);	
/*---------------------------------- validacion de fecha de efecto---------------------------------------------------*/		
		
		if((ele.id == "dia_efe") || (ele.id == "dia de efecto")){
			dia_efe = ele.value; // si es el dia de efecto
		}
		
		if((ele.id == "mes_efe") || (ele.id == "mes de efecto")){
			mes_efe = ele.value; // si es el mes de efecto
		}
		
		if((ele.id == "ano_efe") || (ele.id == "ano de efecto")){
			ano_efe = ele.value; // si es el ano de efecto
		}
		
		switch (ele.id) {
			case "dia nacimiento":
			case "dia nacimiento conductor":
			case "dia nacimiento tomador":
			case "dia nacimiento propietario":
			case "dia nacimiento conductor2":
				DiaN = ele.value;
				break;
			case "mes nacimiento":
			case "mes nacimiento conductor":
			case "mes nacimiento tomador":
			case "mes nacimiento propietario":
			case "mes nacimiento conductor2":
				MesN = ele.value;
				break;
			case "ano nacimiento":
			case "ano nacimiento conductor":
			case "ano nacimiento tomador":
			case "ano nacimiento propietario":
			case "ano nacimiento conductor2":
				AnoN = ele.value;
				break;	
			case "dia carnet":
			case "dia carnet conductor":
			case "dia carnet tomador":
			case "dia carnet propietario":
			case "dia carnet conductor2":
				DiaC = ele.value;
				break;
			case "mes carnet":
			case "mes carnet conductor":
			case "mes carnet tomador":
			case "mes carnet propietario":
			case "mes carnet conductor2":
				MesC = ele.value;
				break;
			case "ano carnet":
			case "ano carnet conductor":
			case "ano carnet tomador":
			case "ano carnet propietario":
			case "ano carnet conductor2":
				AnoC = ele.value;
				break;	
			case "Dia de Matriculacion":
				DiaM = ele.value;
				break;
			case "Mes de Matriculacion":
				MesM = ele.value;
				break;
			case "Ano de Matriculacion":
				AnoM = ele.value;
				break;	
		}

		
/*---------------------------------- validacion de fecha de efecto---------------------------------------------------*/		


		
/*---------------------------------- validacion de codigo postal---------------------------------------------------*/		
		
		if(ele.id == "codigo postal"){
			codigo_postal = ele.value; // si es el codigo postal
			if(codigo_postal == ''){//si viene vacia no meto nada en el array de errores
				errores[0] = '';
				errores[10] = '';
			}else{
				if(codigo_postal.length != 5){//si no son 2 digitos meto en el array de errores el error
					cuentaerrores=cuentaerrores+1;
					errores[0] = '&bull; El C&oacute;digo Postal debe tener 5 d&iacute;gitos.<br>';
				}
				if(codigo_postal >= 52999){
					cuentaerrores=cuentaerrores+1;
					errores[10] = '&bull; C&oacute;digo Postal err&oacute;neo.<br>';
				}
		   }	
		}
		
/*---------------------------------- fin validacion de codigo postal-----------------------------------------------*/				

/*---------------------------------- validacion marca - modelo  -----------------------------------------------*/

		if (ele.id == "marca1") {
			marca = ele.value;
			if(marca == '') {
				errores[90] = '&bull; Debe seleccionar marca.<br>';
				cuentaerrores=cuentaerrores+1;
			}
		}
		if (ele.id == "modelo1") {
			modelo = ele.value;
			if((modelo == '') || (modelo == 0) || (modelo == 1)) {
				errores[91] = '&bull; Debe seleccionar un modelo.<br>';
				cuentaerrores=cuentaerrores+1;
			}
		}
		if (ele.id == "version1") {
			version = ele.value;
			if((version == '') || (version == 0) || (version == 1)) {
				errores[92] = '&bull; Debe seleccionar una versi&oacute;n.<br>';
				cuentaerrores=cuentaerrores+1;
			}
		}
/*---------------------------------- fin validacion marca - modelo  -----------------------------------------------*/

		
		if(ele.id=="nif_o_nie"){
													
			nif_nie = ele.value;
			
		}		
		
/*---------------------------------- VALIDACION DNI CONDUCTOR -------------------------------------------------------------*/		
		if(ele.id=="nifc"){	
			cif_tomador = ele.value;
			letranie = cif_tomador.substr(0, 1);
			if(document.getElementById("nifc").disabled == false){//si esta disabled que no valide
			if ( document.getElementById("nif_o_nie").value == "nie" || document.getElementById("nif_o_nie").value == "nif" ){//validacion de nif o nie
				if ( document.getElementById("nif_o_nie").value == "nie" ){ 
					if ( cif_tomador.substr(0, 1).toUpperCase() != "X" && cif_tomador.substr(0, 1).toUpperCase() != "Y") {
						errores[24] = '&bull; La primera letra del NIE del conductor  debe ser una X/Y.<br>';
						cuentaerrores=cuentaerrores+1;
					}
				}
				if (!/^[0123456789]/.test(letranie) && document.getElementById("nif_o_nie").value == "nif"){//para NIF, el primer digito debe ser un numero
					errores[25] = '&bull; El primer d&iacute;gito del NIF del conductor no puede ser una letra.<br>';
					cuentaerrores=cuentaerrores+1;
				}
				if ( document.getElementById("nif_o_nie").value == 'nie' ){
					cif_tomador = cif_tomador.substr(1,(cif_tomador.length));  //pilla a partir del segundo caracter  del nie									
				}
				var letra2 = cif_tomador.substr((cif_tomador.length - 1), 1); //pilla el ultimo caracter del nif
				letra2 = letra2.toUpperCase();
				if (!/^[0123456789]/.test(letra2)){//si el ultimo caracter no es un numero
					var nif2 = cif_tomador.substr(0, (cif_tomador.length - 1));
				} else {
					var nif2 = cif_tomador;
				}	
				if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
								nif2 = Number(nif2);
								diezmilliones=parseInt(10000000);
								nif2 += diezmilliones;
				}
				if (nif2 !='') {
					letra = (nif2 %= 23) + 1;
					if (letra == 1) {letra='T'};
					if (letra == 2) {letra='R'};
					if (letra == 3) {letra='W'};
					if (letra == 4) {letra='A'};
					if (letra == 5) {letra='G'};
					if (letra == 6) {letra='M'};
					if (letra == 7) {letra='Y'};
					if (letra == 8) {letra='F'};
					if (letra == 9) {letra='P'};
					if (letra == 10) {letra='D'};
					if (letra == 11) {letra='X'};
					if (letra == 12) {letra='B'};
					if (letra == 13) {letra='N'};
					if (letra == 14) {letra='J'};
					if (letra == 15) {letra='Z'};
					if (letra == 16) {letra='S'};
					if (letra == 17) {letra='Q'};
					if (letra == 18) {letra='V'};
					if (letra == 19) {letra='H'};
					if (letra == 20) {letra='L'};
					if (letra == 21) {letra='C'};
					if (letra == 22) {letra='K'};
					if (letra == 23) {letra='E'};
					if ( letra != letra2 ) {
						if ( document.getElementById("nif_o_nie").value == 'nie' ) {
							errores[26] = '&bull; El NIE del conductor es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;
						} else {
							errores[27] = '&bull; El NIF del conductor es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;
						}
					}
				}
			}else{//validacion del cif
					if(cif_tomador == ''){//si viene vacia no meto nada en el array de errores
						errores[28] = ' ';
					}else{
						var pares = 0;
						var impares = 0;
						var suma;
						var ultima;
						var unumero;
						var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
						var xxx;
						var texto = cif_tomador.toUpperCase();
						ultima = texto.substr(8,1);
						for (var cont = 1 ; cont < 7 ; cont ++){
							xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
							impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
							pares += parseInt(texto.substr(cont,1));
						}
						xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
						impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
						suma = (pares + impares).toString();
						unumero = parseInt(suma.substr(suma.length - 1, 1));
						unumero = (10 - unumero).toString();
						if(unumero == 10) unumero = 0;
						//console.log(unumero +' || '+ uletra[unumero]);
						//console.log(ultima);
						if ((ultima == unumero) || (ultima == uletra[unumero])){					
						}else{
							errores[28] = '&bull; El CIF del conductor es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;	
						}
					}
				}
			}	
		}




/*---------------------------------- VALIDACION DNI CONDUCTOR 2 -------------------------------------------------------------*/		
// 		if(ele.id=="nif_nie_cif_cond2"){	
// 			cif_tomador = ele.value;
// 			letranie = cif_tomador.substr(0, 1);
// 			if(document.getElementById("nif_nie_cif_cond2").disabled == false){//si esta disabled que no valide
// 			if ( document.getElementById("nif_o_nie_cond2").value == "nie" || document.getElementById("nif_o_nie_cond2").value == "nif" ){//validacion de nif o nie
// 				if ( document.getElementById("nif_o_nie_cond2").value == "nie" ){ 
// 					if ( cif_tomador.substr(0, 1).toUpperCase() != "X" && cif_tomador.substr(0, 1).toUpperCase() != "Y") {
// 						errores[24] = '&bull; La primera letra del Nie del segundo conductor  debe ser una X/Y\n';
// 						cuentaerrores=cuentaerrores+1;
// 					}
// 				}
// 				if (!/^[0123456789]/.test(letranie) && document.getElementById("nif_o_nie_cond2").value == "nif"){//para NIF, el primer digito debe ser un numero
// 					errores[25] = '&bull; El primer digito del nif del segundo conductor no puede ser una letra\n';
// 					cuentaerrores=cuentaerrores+1;
// 				}
// 				if ( document.getElementById("nif_o_nie_cond2").value == 'nie' ){
// 					cif_tomador = cif_tomador.substr(1,(cif_tomador.length));  //pilla a partir del segundo caracter  del nie									
// 				}
// 				var letra2 = cif_tomador.substr((cif_tomador.length - 1), 1); //pilla el ultimo caracter del nif
// 				letra2 = letra2.toUpperCase();
// 				if (!/^[0123456789]/.test(letra2)){//si el ultimo caracter no es un numero
// 					var nif2 = cif_tomador.substr(0, (cif_tomador.length - 1));
// 				} else {
// 					var nif2 = cif_tomador;
// 				}	
// 				if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
// 								nif2 = Number(nif2);
// 								diezmilliones=parseInt(10000000);
// 								nif2 += diezmilliones;
// 				}
// 				if (nif2 !='') {
// 					letra = (nif2 %= 23) + 1;
// 					if (letra == 1) {letra='T'};
// 					if (letra == 2) {letra='R'};
// 					if (letra == 3) {letra='W'};
// 					if (letra == 4) {letra='A'};
// 					if (letra == 5) {letra='G'};
// 					if (letra == 6) {letra='M'};
// 					if (letra == 7) {letra='Y'};
// 					if (letra == 8) {letra='F'};
// 					if (letra == 9) {letra='P'};
// 					if (letra == 10) {letra='D'};
// 					if (letra == 11) {letra='X'};
// 					if (letra == 12) {letra='B'};
// 					if (letra == 13) {letra='N'};
// 					if (letra == 14) {letra='J'};
// 					if (letra == 15) {letra='Z'};
// 					if (letra == 16) {letra='S'};
// 					if (letra == 17) {letra='Q'};
// 					if (letra == 18) {letra='V'};
// 					if (letra == 19) {letra='H'};
// 					if (letra == 20) {letra='L'};
// 					if (letra == 21) {letra='C'};
// 					if (letra == 22) {letra='K'};
// 					if (letra == 23) {letra='E'};
// 					if ( letra != letra2 ) {
// 						if ( document.getElementById("nif_o_nie_cond2").value == 'nie' ) {
// 							errores[26] = '&bull; El Nie del segundo conductor es erroneo \n';
// 							cuentaerrores=cuentaerrores+1;
// 						} else {
// 							errores[27] = '&bull; El Nif del segundo conductor Es erroneo \n';
// 							cuentaerrores=cuentaerrores+1;
// 						}
// 					}
// 				}
// 			}else{//validacion del cif
// 					if(cif_tomador == ''){//si viene vacia no meto nada en el array de errores
// 						errores[28] = ' ';
// 					}else{
// 						var pares = 0;
// 						var impares = 0;
// 						var suma;
// 						var ultima;
// 						var unumero;
// 						var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
// 						var xxx;
// 						var texto = cif_tomador.toUpperCase();
// 						ultima = texto.substr(8,1);
// 						for (var cont = 1 ; cont < 7 ; cont ++){
// 							xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
// 							impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
// 							pares += parseInt(texto.substr(cont,1));
// 						}
// 						xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
// 						impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
// 						suma = (pares + impares).toString();
// 						unumero = parseInt(suma.substr(suma.length - 1, 1));
// 						unumero = (10 - unumero).toString();
// 						if(unumero == 10) unumero = 0;
// 						//console.log(unumero +' || '+ uletra[unumero]);
// 						//console.log(ultima);
// 						if ((ultima == unumero) || (ultima == uletra[unumero])){					
// 						}else{
// 							errores[28] = '&bull; El Cif del segundo conductor es erroneo \n';
// 							cuentaerrores=cuentaerrores+1;	
// 						}
// 					}
// 				}
// 			}	
// 		}







		if(ele.id=="tomador_nif"){	
		
			cif_tomador = ele.value;
			
			letranie = cif_tomador.substr(0, 1);
			
			if(document.getElementById("tomador_nif").disabled == false){//si esta disabled que no valide
			
			if ( document.getElementById("tomador_nif_o_nie").value == "nie" || document.getElementById("tomador_nif_o_nie").value == "nif" ){//validacion de nif o nie
			
				if ( document.getElementById("tomador_nif_o_nie").value == "nie" ){ 
	
					if ( cif_tomador.substr(0, 1).toUpperCase() != "X" && cif_tomador.substr(0, 1).toUpperCase() != "Y") {
																	
						errores[24] = '&bull; La primera letra del NIE del tomador debe ser una X/Y.<br>';
						cuentaerrores=cuentaerrores+1;
						
					}
				}
							
				
				if (!/^[0123456789]/.test(letranie) && document.getElementById("tomador_nif_o_nie").value == "nif"){//para NIF, el primer digito debe ser un numero
								
					errores[25] = '&bull; El primer d&iacute;gito del NIF del tomador no puede ser una letra.<br>';
					cuentaerrores=cuentaerrores+1;
																
				}
				
				if ( document.getElementById("tomador_nif_o_nie").value == 'nie' ){
											
					cif_tomador = cif_tomador.substr(1,(cif_tomador.length));  //pilla a partir del segundo caracter  del nie									
												
				}
				
				
				var letra2 = cif_tomador.substr((cif_tomador.length - 1), 1); //pilla el ultimo caracter del nif
				letra2 = letra2.toUpperCase();
								
				if (!/^[0123456789]/.test(letra2)){//si el ultimo caracter no es un numero
											
					var nif2 = cif_tomador.substr(0, (cif_tomador.length - 1));
										
				} else {

					var nif2 = cif_tomador;
										
				}	
															
				if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
							
								nif2 = Number(nif2);
								diezmilliones=parseInt(10000000);
								nif2 += diezmilliones;
																						
				}
				
				if (nif2 !='') {
												
					letra = (nif2 %= 23) + 1;
					if (letra == 1) {letra='T'};
					if (letra == 2) {letra='R'};
					if (letra == 3) {letra='W'};
					if (letra == 4) {letra='A'};
					if (letra == 5) {letra='G'};
					if (letra == 6) {letra='M'};
					if (letra == 7) {letra='Y'};
					if (letra == 8) {letra='F'};
					if (letra == 9) {letra='P'};
					if (letra == 10) {letra='D'};
					if (letra == 11) {letra='X'};
					if (letra == 12) {letra='B'};
					if (letra == 13) {letra='N'};
					if (letra == 14) {letra='J'};
					if (letra == 15) {letra='Z'};
					if (letra == 16) {letra='S'};
					if (letra == 17) {letra='Q'};
					if (letra == 18) {letra='V'};
					if (letra == 19) {letra='H'};
					if (letra == 20) {letra='L'};
					if (letra == 21) {letra='C'};
					if (letra == 22) {letra='K'};
					if (letra == 23) {letra='E'};
												
											
					if ( letra != letra2 ) {
					
						if ( document.getElementById("tomador_nif_o_nie").value == 'nie' ) {
						
							errores[26] = '&bull; El NIE del tomador es err&oacute;neo \n';
							cuentaerrores=cuentaerrores+1;
															
						} else {
						
							errores[27] = '&bull; El NIF del tomador es err&oacute;neo \n';
							cuentaerrores=cuentaerrores+1;
																	
						}
					
					}
				}
				
				
			}else{//validacion del cif
						
							
					if(cif_tomador == ''){//si viene vacia no meto nada en el array de errores
					
						errores[28] = ' ';
		
					}else{
					
						var pares = 0;
						var impares = 0;
						var suma;
						var ultima;
						var unumero;
						var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
						var xxx;
						var texto = cif_tomador.toUpperCase();
						
						ultima = texto.substr(8,1);
						
						for (var cont = 1 ; cont < 7 ; cont ++){
						
							xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
						
							impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
							
							pares += parseInt(texto.substr(cont,1));
						
						}
						
						xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
						
						impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
						
						suma = (pares + impares).toString();
						
						unumero = parseInt(suma.substr(suma.length - 1, 1));
						
						unumero = (10 - unumero).toString();
						
						if(unumero == 10) unumero = 0;
						
						//console.log(unumero +' || '+ uletra[unumero]);
						//console.log(ultima);
						
						if ((ultima == unumero) || (ultima == uletra[unumero])){
															
						
						}else{
											
							errores[28] = '&bull; El CIF del tomador es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;	
						}
							
					}
				}
			}	
		}

/*******************************/

		if(ele.id=="propietario_nif"){	
	    
	    	cif_propietario = ele.value; 
	    	    	
	    	letranie = cif_propietario.substr(0, 1);
	    	
	    	if(document.getElementById("propietario_nif").disabled == false){//si esta disabled que no valide
	    	
	    	if ( document.getElementById("propietario_nif_o_nie").value == "nie" || document.getElementById("propietario_nif_o_nie").value == "nif" ){//validacion de nif o nie
	    	
				if ( document.getElementById("propietario_nif_o_nie").value == "nie" ){ 
	
					if ( cif_propietario.substr(0, 1).toUpperCase() != "X" && cif_propietario.substr(0, 1).toUpperCase() != "Y") {
																	
						errores[20] = '&bull; La primera letra del NIE del propietario debe ser una X/Y.<br>';
						cuentaerrores=cuentaerrores+1;
						
					}
				}
							
				
				if (!/^[0123456789]/.test(letranie) && document.getElementById("propietario_nif_o_nie").value == "nif"){//para NIF, el primer digito debe ser un numero
								
					errores[21] = '&bull; El primer d&iacute;gito del NIF del propietario no puede ser una letra.<br>';
					cuentaerrores=cuentaerrores+1;
																
				}
				
				if ( document.getElementById("propietario_nif_o_nie").value == 'nie' ){
											
					cif_propietario = cif_propietario.substr(1,(cif_propietario.length));  //pilla a partir del segundo caracter  del nie									
												
				}
				
				
				var letra2 = cif_propietario.substr((cif_propietario.length - 1), 1); //pilla el ultimo caracter del nif
				letra2 = letra2.toUpperCase();
								
				if (!/^[0123456789]/.test(letra2)){//si el ultimo caracter no es un numero
											
					var nif2 = cif_propietario.substr(0, (cif_propietario.length - 1));
										
				} else {

					var nif2 = cif_propietario;
										
				}	
															
				if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
							
								nif2 = Number(nif2);
								diezmilliones=parseInt(10000000);
								nif2 += diezmilliones;
																						
				}
				
				if (nif2 !='') {
												
					letra = (nif2 %= 23) + 1;
					if (letra == 1) {letra='T'};
					if (letra == 2) {letra='R'};
					if (letra == 3) {letra='W'};
					if (letra == 4) {letra='A'};
					if (letra == 5) {letra='G'};
					if (letra == 6) {letra='M'};
					if (letra == 7) {letra='Y'};
					if (letra == 8) {letra='F'};
					if (letra == 9) {letra='P'};
					if (letra == 10) {letra='D'};
					if (letra == 11) {letra='X'};
					if (letra == 12) {letra='B'};
					if (letra == 13) {letra='N'};
					if (letra == 14) {letra='J'};
					if (letra == 15) {letra='Z'};
					if (letra == 16) {letra='S'};
					if (letra == 17) {letra='Q'};
					if (letra == 18) {letra='V'};
					if (letra == 19) {letra='H'};
					if (letra == 20) {letra='L'};
					if (letra == 21) {letra='C'};
					if (letra == 22) {letra='K'};
					if (letra == 23) {letra='E'};
												
											
					if ( letra != letra2 ) {
					
						if ( document.getElementById("propietario_nif_o_nie").value == 'nie' ) {
						
							errores[21] = '&bull; El NIE del propietario es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;
															
						} else {
						
							errores[22] = '&bull; El NIF del propietario Es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;
																	
						}
					
					}
				}
				
	    	    
	    	}else{// validacion del cif
	    
	    	    	if(cif_propietario == ''){//si viene vacia no meto nada en el array de errores
		
						errores[23] = ' ';
							
					}else{	
					
						var pares = 0;
						var impares = 0;
						var suma;
						var ultima;
						var unumero;
						var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
						var xxx;
						var texto = cif_propietario.toUpperCase();
						
						ultima = texto.substr(8,1);
						
						for (var cont = 1 ; cont < 7 ; cont ++){
						
							xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
						
							impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
							
							pares += parseInt(texto.substr(cont,1));
						
						}
						
						xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
						
						impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
						
						suma = (pares + impares).toString();
						
						unumero = parseInt(suma.substr(suma.length - 1, 1));
						
						unumero = (10 - unumero).toString();
						
						if(unumero == 10) unumero = 0;
						
						//console.log(unumero +' || '+ uletra[unumero]);
						//console.log(ultima);
						
						if ((ultima == unumero) || (ultima == uletra[unumero])){
													
						
						}else{
												
							
							errores[23] = '&bull; El CIF del propietario es err&oacute;neo.<br>';
							cuentaerrores=cuentaerrores+1;	
						}
										
					}	
				}
		 	}	
		}
		
/*******************************/

		if(ele.id=="nif"){	
						
			nif = ele.value; 
	
			 if(nif == ''){//si viene vacia no meto nada en el array de errores

					errores[1] = '';
					errores[2] = '';
					errores[3] = '';
					errores[4] = '';

			 }else{	

					letranie = nif.substr(0, 1);
					if ( nif_nie == "nie" ){ 

									if ( nif.substr(0, 1).toUpperCase() != "X" && nif.substr(0, 1).toUpperCase() != "Y") {
																					
										errores[1] = '&bull; La primera letra del NIE debe ser una X/Y.<br>';
										cuentaerrores=cuentaerrores+1;
										
									}
					}
								
					if (!/^[0123456789]/.test(letranie) && nif_nie == 'nif'){//para NIF, el primer digito debe ser un numero
							
						errores[2] = '&bull; El primer d&iacute;gito del NIF no puede ser una letra.<br>';
						cuentaerrores=cuentaerrores+1;
																	
					}
	
					if ( nif_nie == 'nie' ){
											
						nif = nif.substr(1,(nif.length));  //pilla a partir del segundo caracter  del nie									
												
					}
								
					var letra2 = nif.substr((nif.length - 1), 1); //pilla el ultimo caracter del nif
					letra2 = letra2.toUpperCase();
									
					if (!/^[0123456789]/.test(letra2)){//si el ultimo caracter no es un numero
												
						var nif2 = nif.substr(0, (nif.length - 1));
											
					} else {

						var nif2 = nif;
											
					}	
																
					if ( letranie.toUpperCase() == "Y" ) {//si el nie empieza por Y se e tiene que sumar 10 millones a la variable nif2
								
									nif2 = Number(nif2);
									diezmilliones=parseInt(10000000);
									nif2 += diezmilliones;
																							
					}
								
								
					if (nif2 !='') {
												
						letra = (nif2 %= 23) + 1;
						if (letra == 1) {letra='T'};
						if (letra == 2) {letra='R'};
						if (letra == 3) {letra='W'};
						if (letra == 4) {letra='A'};
						if (letra == 5) {letra='G'};
						if (letra == 6) {letra='M'};
						if (letra == 7) {letra='Y'};
						if (letra == 8) {letra='F'};
						if (letra == 9) {letra='P'};
						if (letra == 10) {letra='D'};
						if (letra == 11) {letra='X'};
						if (letra == 12) {letra='B'};
						if (letra == 13) {letra='N'};
						if (letra == 14) {letra='J'};
						if (letra == 15) {letra='Z'};
						if (letra == 16) {letra='S'};
						if (letra == 17) {letra='Q'};
						if (letra == 18) {letra='V'};
						if (letra == 19) {letra='H'};
						if (letra == 20) {letra='L'};
						if (letra == 21) {letra='C'};
						if (letra == 22) {letra='K'};
						if (letra == 23) {letra='E'};
													
												
						if ( letra != letra2 ) {
						
							if ( nif_nie == 'nie' ) {
							
								errores[3] = '&bull; El NIE es err&oacute;neo.<br>';
								cuentaerrores=cuentaerrores+1;
																
							} else {
							
								errores[4] = '&bull; El NIF es err&oacute;neo.<br>';
								cuentaerrores=cuentaerrores+1;
																		
							}
						
						}
					}
			}	
		}	

/*---------------------------------- validacion de dni-------------------------------------------------------------*/		
				
		if(ele.id=="Email"){
			
			mail = ele.value;
		
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))){
		
				errores[17] = '&bull; Hay un error en el email.<br>';
				cuentaerrores=cuentaerrores+1;
			
			} 
			
		}	

/*---------------------------------- validacion de matricula-------------------------------------------------------------*/	
					
		if(ele.id=="Matricula"){
					
			matricula = ele.value;
							
			//Sexy.error(matricula);
					
			var reg = new RegExp ("^(([0-9]{4}[B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z]{3})|([a-zA-Z]{1,2}[0-9]{4}[a-zA-z]{1,2})|([P]{1}[0-9]{4}[a-zA-Z]{3})|([E]{1}[0-9]{4}[a-zA-Z]{3})|([C]{1}[0-9]{4}[a-zA-Z]{3})|([a-zA-Z]{1,2}[0-9]{5}[VE]{2}))$","g");//expresion regular para todas las matriculas
			provincias = new Array ("VI","AB ","AL","AV","BA","AV","IB","PM","BU","CC","CA","CS","CE","CR","CO","CU","GI","GE","GR","GU","SS","HU","LE","LO","LU","MA","ML","MU","NA","OR","OU","GC","PO","SA","TF","SG","SE","SO","TE","TO","VA","BI","ZA");//array de provincias para las matriculas antiguas
			provincias2 = new Array ("A","B","C","H","J","L","M","O","P","S","T","V","Z")
							
			remplazo=matricula.replace("-","", 'g');//se remplazan los guiones por nada
			remplazo=remplazo.toUpperCase();//cambia a mayusculas
							
			provin_matri=remplazo.substring(0,2);//2 primeros caracteres de la matricula
			provin_matri_segunda_letra=provin_matri.substring(1,2);//segundo caracter de la matricula
			provin_matri_primera_letra=provin_matri.substring(0,1);//primer caracter de la matricula
						
			if(matricula != '' ){//si la matricula no viene vacia
								
				if (reg.test(remplazo) == 0) {//si es err&oacute;nea
								   
				    errores[11] = '&bull; Matr&iacute;cula err&oacute;nea.<br>';
				    cuentaerrores=cuentaerrores+1;
								   
					patron = /[0-9.]/;//Solo acepta n&uacute;meros
					var pos = remplazo.search(patron) ;
									
					if(pos > 0){
					
						switch(pos){ 
					
							case 1://posicion cuando solo es provincia con una letra
									
									for(z=0;z< provincias2.length;z++){//recorro el array de provincias para ver si la provincia que han metido es correcta

											var encontrado2 = provincias2[z].search(provin_matri_primera_letra);//busqueda de la primera letras
											
											if(encontrado2==0){//si no lo a encontrado salgo del bucle
											
											 break;
											 
											 }	

									}
									
									if(encontrado2==-1){//si no lo a encontrado en el array sacamos el alert
									
										errores[12] = '&bull; Provincia err&oacute;nea.<br>';
										cuentaerrores=cuentaerrores+1;
																	
									}
									
									break;
							
							case 2://posicion cuando es provincia con 2 letras							
						
									for(d=0;d< provincias.length;d++){//recorro el array de provincias para ver si la provincia que han metido es correcta

											var encontrado = provincias[d].search(provin_matri);//busqueda de las 2 primeras letras
											
											if(encontrado==0){//si no lo a encontrado salgo del bucle
											
											 break;
											 
											 }	
									}
							
									if(encontrado==-1){//si no lo a encontrado en el array sacamos el alert
									
										errores[13] = '&bull; Provincia err&oacute;nea.<br>';
										cuentaerrores=cuentaerrores+1;	
									
									}
									
									break;
					
						}

					}
							
																		
				} else {//si no es err&oacute;nea
								
					patron = /[0-9.]/; // Solo acepta n&uacute;meros
					var pos = remplazo.search(patron) ;
									
					if(pos > 0){
					
						switch(pos){ 
					
							case 1://posicion cuando solo es provincia con una letra
									
									for(z=0;z< provincias2.length;z++){//recorro el array de provincias para ver si la provincia que han metido es correcta

											var encontrado2 = provincias2[z].search(provin_matri_primera_letra);//busqueda de la primera letras
											
											if(encontrado2==0){
											
											 break;
											 
											 }	

									}
									
									
									if(provin_matri_primera_letra != 'E'){
									
										if(encontrado2==-1){//si no lo a encontrado en el array sacamos el alert
										
											errores[14] = '&bull; Provincia err&oacute;nea.<br>';
											cuentaerrores=cuentaerrores+1;	
										
										}
										
									}	
									
									break;
							
							case 2://posicion cuando es provincia con 2 letras 									
						
									for(d=0;d< provincias.length;d++){//recorro el array de provincias para ver si la provincia que han metido es correcta

											var encontrado = provincias[d].search(provin_matri);//busqueda de las 2 primeras letras
											
											if(encontrado==0){//si no lo a encontrado salgo del bucle
											
											 break;
											 
											 }	
									}
							
									if(encontrado==-1){//si no lo a encontrado en el array sacamos el alert
									
										errores[15] = '&bull; Provincia err&oacute;nea.<br>';
										cuentaerrores=cuentaerrores+1;	
									
									}
									
									break;
					
						}
				
						
					}
								
				}
		
			}
								
		}

/*---------------------------------- fin de validacion de matricula-------------------------------------------------------------*/

	
/*---------------------------------- validacion digitos de entidad-------------------------------------------------------------*/		 
						  
		 if(ele.id=="Entidad"){
		 
			entidad = ele.value;
				
				if(entidad == ''){//si viene vacia no meto nada en el array de errores

					errores[5] = '';

				}else{

					if(entidad.length != 4){//si no son 4 digitos meto en el array de errores el error
					
						errores[5] = '&bull; La Entidad debe tener 4 d&iacute;gitos.<br>';
					
						cuentaerrores=cuentaerrores+1;
					
					}else{
					
						errores[5] = '';

					}
					
			   }
				
		}	
						  
/*---------------------------------- validacion digitos de entidad-------------------------------------------------------------*/		 
	  


/*---------------------------------- validacion digitos de la sucursal-------------------------------------------------------------*/		 
						  
		if(ele.id=="Sucursal"){
																		
			sucursal = ele.value;
				
				if(sucursal == ''){//si viene vacia no meto nada en el array de errores

					errores[6] = '';

				}else{
	
					if(sucursal.length != 4){//si no son 4 digitos meto en el array de errores el error
					
						errores[6] = '&bull; La Sucursal debe tener 4 d&iacute;gitos.<br>';
						cuentaerrores=cuentaerrores+1;
					
					}else{
					
						errores[6] = '';

					}
			   }
		}	
						  
/*---------------------------------- validacion digitos de la sucursal-------------------------------------------------------------*/		 


/*---------------------------------- validacion digitos del numero de cuenta-------------------------------------------------------------*/		 
						  
		if(ele.id=="Numero Cuenta"){
																		
			num_cuenta = ele.value;

				if(num_cuenta == ''){//si viene vacia no meto nada en el array de errores
				
					errores[8] = '';
																						
				}else{
				
					if(num_cuenta.length != 10){//si no son 10 digitos meto en el array de errores el error
					
						errores[8] = '&bull; El N&uacute;mero de Cuenta debe tener 10 d&iacute;gitos.<br>';
						cuentaerrores=cuentaerrores+1;

					}else{
						
						errores[8] = '';
					
					}
			   }
		}	
						  
/*---------------------------------- validacion digitos del numero de cuenta-------------------------------------------------------------*/	



/*---------------------------------- validacion digitos del dc-------------------------------------------------------------*/		 
	 
		if(ele.id=="Dc") {
																		
			dc = ele.value;
				if(dc == '')//si viene vacia no meto nada en el array de errores
				{
					
					errores[7] = '';
				
					
				
				}else{
				
				
				
					if(dc.length != 2){//si no son 2 digitos meto en el array de errores el error
					
						errores[7] = '&bull; El DC debe tener 2 d&iacute;gitos.<br>';
					
						cuentaerrores=cuentaerrores+1;
					
					}else{
					
						errores[7] = '';
																																
					
					}

					
			   }
				
		}	


/*-----------------------------------  Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas ----------------------------------------*/		
/*-----------------------------------  Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas ----------------------------------------*/		
/*-----------------------------------  Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas ----------------------------------------*/		
/*-----------------------------------------------------   T O M A D O R   ----------------------------------------------------------------*/

if (ele.id == "nif_nie_cif_tomador") {

	nif_nie_cif_tomador = ele.value;
	
	if (nif_nie_cif_tomador != "") {		// Puede ser un NIF CIF NIE (Persona F&iacute;sica o Jur&iacute;dica)

		tipo_doc = document.getElementById("nif_o_nie_tomador").value;
		switch (tipo_doc) {

			case "nif":
			case "nie":
				t_ele = form.elements.length;
				for (h=0; t_ele=form.elements[h]; h++){						// Recorro los elementos del formulario
					if (t_ele.id.search(/tomador Fisico/i) != -1) {			// Busco en el id la cadena tomador Fisico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							if ((t_ele.id == "Email tomador Fisico") || 
								(t_ele.id == "Piso tomador Fisico")) {
									document.getElementById(t_ele.id).setAttribute("className", "");
							} else {
									document.getElementById(t_ele.id).setAttribute("className", "obli");
							}
						} else {
  							if ((t_ele.id == "Email tomador Fisico") || 
								(t_ele.id == "Piso tomador Fisico")) {
									document.getElementById(t_ele.id).setAttribute("class", "");
							} else {
									document.getElementById(t_ele.id).setAttribute("class", "obli");
							}
						}
					} 
					if (t_ele.id.search(/tomador Juridico/i) != -1) {		//	Busco en el id la cadena tomador Juridico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							document.getElementById(t_ele.id).setAttribute("className", "");
						} else {
 							document.getElementById(t_ele.id).setAttribute("class", "");
						}
					}		
				}	
				break;
			case "cif":
				t_ele = form.elements.length;
				for (h=0; t_ele=form.elements[h]; h++){	
					if (t_ele.id.search(/tomador Juridico/i) != -1) {			// Busco en el id la cadena tomador Juridico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
							if ((t_ele.id == "Email tomador Juridico") || 
								(t_ele.id == "Fax tomador Juridico") ||
								(t_ele.id == "Telefono2 tomador Juridico") ||
								(t_ele.id == "Piso tomador Juridico")) {
 									document.getElementById(t_ele.id).setAttribute("className", "");
 							} else {
 									document.getElementById(t_ele.id).setAttribute("className", "obli");
 							}
						} else {
							if ((t_ele.id == "Email tomador Juridico") || 
								(t_ele.id == "Fax tomador Juridico") ||
								(t_ele.id == "Telefono2 tomador Juridico") ||
								(t_ele.id == "Piso tomador Juridico")) {
 									document.getElementById(t_ele.id).setAttribute("class", "");
							} else {
	 								document.getElementById(t_ele.id).setAttribute("class", "obli");
	 						}
						}
					} 
					if (t_ele.id.search(/tomador Fisico/i) != -1) {		//	Busco en el id la cadena tomador Fisico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							document.getElementById(t_ele.id).setAttribute("className", "");
						} else {
 							document.getElementById(t_ele.id).setAttribute("class", "");
						}
					}		
				}		
				break;

		}
	
	}

}
/*-------------------------------------------------   P R O P I E T A R I O  ----------------------------------------------------------------*/
if (ele.id == "nif_nie_cif_propietarioietario") {

	nif_nie_cif_propietarioietario = ele.value;
	
	if (nif_nie_cif_propietarioietario != "") {		// Puede ser un NIF CIF NIE (Persona F&iacute;sica o Jur&iacute;dica)

		tipo_doc2 = document.getElementById("nif_o_nie_prop").value;
		switch (tipo_doc2) {

			case "nif":
			case "nie":
				t_ele2 = form.elements.length;
				for (h=0; t_ele2=form.elements[h]; h++){						// Recorro los elementos del formulario
					if (t_ele2.id.search(/propietario Fisico/i) != -1) {			// Busco en el id la cadena propietario Fisico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							document.getElementById(t_ele2.id).setAttribute("className", "obli");
						} else {
 							document.getElementById(t_ele2.id).setAttribute("class", "obli");
						}
					} 
					if (t_ele2.id.search(/propietario Juridico/i) != -1) {		//	Busco en el id la cadena propietario Juridico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							document.getElementById(t_ele2.id).setAttribute("className", "");
						} else {
 							document.getElementById(t_ele2.id).setAttribute("class", "");
						}
					}		
				}	
				break;
			case "cif":
				t_ele2 = form.elements.length;
				for (h=0; t_ele2=form.elements[h]; h++){	
					if (t_ele2.id.search(/propietario Juridico/i) != -1) {			// Busco en el id la cadena propietario Juridico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
							if ((t_ele2.id == "Email propietario Juridico") || 
								(t_ele2.id == "Fax propietario Juridico") ||
								(t_ele2.id == "Telefono2 propietario Juridico") ||
								(t_ele2.id == "Piso propietario Juridico")) { 
	 								document.getElementById(t_ele2.id).setAttribute("className", "");
	 						} else {
	 								document.getElementById(t_ele2.id).setAttribute("className", "obli");
	 						}
						} else {
							if ((t_ele2.id == "Email propietario Juridico") || 
								(t_ele2.id == "Fax propietario Juridico") ||
								(t_ele2.id == "Telefono2 propietario Juridico") ||
								(t_ele2.id == "Piso propietario Juridico")) { 
 									document.getElementById(t_ele2.id).setAttribute("class", "");
 							} else {
 									document.getElementById(t_ele2.id).setAttribute("class", "obli");
 							}
						}
					} 
					if (t_ele2.id.search(/propietario Fisico/i) != -1) {		//	Busco en el id la cadena propietario Fisico - si hay resultados
						if(navigator.appName == "Microsoft Internet Explorer"){
 							document.getElementById(t_ele2.id).setAttribute("className", "");
						} else {
 							document.getElementById(t_ele2.id).setAttribute("class", "");
						}
					}		
				}		
				break;

		}
	
	}

}

/*-------------------------------  FIN DE Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas -------------------------------------*/		
/*-------------------------------  FIN DE Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas -------------------------------------*/		
/*-------------------------------  FIN DE Validaci&oacute;n de campos nuevos - Personas F&iacute;sicas o Jur&iacute;dicas -------------------------------------*/		
						  
		if ((ele.id == "mes de vencimiento") && (ele.value != "")) {
			mes_vto = ele.value;
			var fvto = "ok";
		}
		if ((ele.id == "ano de vencimiento") && (ele.value != "")) {
			ano_vto = ele.value;
			var fvto = "ok";
		}


		if(ele.className == 'obli2' && ele.value=='' ){
			campo = i;							
			val_txt[cont2] = '&bull; Debe rellenar el campo ' +ele.id+'.<br>';	// junto todos los requeridos que no estan rellenos
			camposerror[cont2] = ele.id;
			cont2 = cont2+1;						
		
		}		
							
													
		if ( ele.className == 'obli' && ele.value=='' ){
		
			campo = i;
			//Sexy.error(cont2+" "+ele.id);
			val_txt[cont2] = '&bull; Debe rellenar el campo ' +ele.id+'.<br>';	// junto todos los requeridos que no estan rellenos
			camposerror[cont2] = ele.id;
			cont2 = cont2+1;
		
		} 

		if (ele.id == "bmw") {		// Si es BMW hace validaci&oacute;n de fechas un poquito m&aacute;s abajo .... Para el resto habr&iacute;a que realizarlo en un futuro muy pr&oacute;ximo
			bmw = form.bmw.value;
		}

		if (ele.id == "paso_anterior") {		// Si es desde la Red de Eurolloyd existe este paso que es especial
			paso_anterior = form.paso_anterior.value;
		}
			
	}//fin del for que recorre todos los elementos
			
	paso = form.paso.value;

	if (paso=="2" || paso=="2_operadores") {
		fecha_ok_matricula = anosmoto(DiaM, MesM, AnoM);
		if(fecha_ok_matricula == true){	
			errores[18] = '&bull; Revise por favor la fecha de matriculaci&oacute;n.<br>';
			cuentaerrores=cuentaerrores+1;
		}	
	}

	if (fvto == "ok") {		// Si lleva fecha de vencimiento por bonificacion
		valida_vto = valida_vencimiento(mes_vto, ano_vto);
		if (valida_vto == true) {
			errores[355] = '&bull; La fecha de vencimiento no puede ser inferior a la actual.<br>';
			cuentaerrores=cuentaerrores+1;
		}
	}
	
	if (paso==3) {
		if (paso_anterior != "2_operadores") {
			fecha_ok = valida_fecha(DiaN, MesN, AnoN); // Fecha nacimiento
			if(fecha_ok == false){	
				errores[55] = '&bull; Revise por favor la fecha de nacimiento.<br>';
				cuentaerrores=cuentaerrores+1;
			}
			fecha_ok = valida_fecha(DiaC, MesC, AnoC); // Fecha carnet
			if(fecha_ok == false){	
				errores[56] = '&bull; Revise por favor la fecha de carnet.<br>';
				cuentaerrores=cuentaerrores+1;
			}
		}
	}
	

	if (bmw==4) {
		
		fecha_ok = valida_fecha_efecto(ano_efe, mes_efe, dia_efe);
		if(fecha_ok == true){	
			errores[54] = '&bull; La fecha de efecto no puede ser inferior a la actual ni superior en 30 d&iacute;as.<br>';
			cuentaerrores=cuentaerrores+1;
		}

		fecha_ok = valida_fecha(DiaN, MesN, AnoN); // Fecha nacimiento
		if(fecha_ok == false){	
			errores[55] = '&bull; Revise por favor la fecha de nacimiento.<br>';
			cuentaerrores=cuentaerrores+1;
		}

		fecha_ok = valida_fecha(DiaC, MesC, AnoC); // Fecha carnet
		if(fecha_ok == false){	
			errores[56] = '&bull; Revise por favor la fecha de carnet.<br>';
			cuentaerrores=cuentaerrores+1;
		}

		fecha_ok = valida_fecha(DiaM, MesM, AnoM); // Fecha matriculacion
		if(fecha_ok == false){	
			errores[57] = '&bull; Revise por favor la fecha de matriculaci&oacute;n.<br>';
			cuentaerrores=cuentaerrores+1;
		}

		difer_fechas = fechas(dia_efe, mes_efe, ano_efe, DiaM, MesM, AnoM);
		if(difer_fechas == false){
			errores[53] = '&bull; La fecha de efecto no puede ser inferior a la fecha de matriculaci&oacute;n.<br>';
			cuentaerrores=cuentaerrores+1;
		}

	}

	if (bmw==7) {
		alo_cubano = valida_fecha_efecto(ano_efe, mes_efe, dia_efe);//validacion de  la fecha de efecto
		if(alo_cubano == true){	
			errores[58] = '&bull; La fecha de efecto no puede ser inferior a la actual ni superior en 30 d&iacute;as.<br>';
			cuentaerrores=cuentaerrores+1;
		}

		difer_fechas = fechas(dia_efe, mes_efe, ano_efe, DiaM, MesM, AnoM);
		if(difer_fechas == false){
			errores[53] = '&bull; La fecha de efecto no puede ser inferior a la fecha de matriculaci&oacute;n.<br>';
			cuentaerrores=cuentaerrores+1;
		}

	}
	
	if(paso==7){//si no especifico en que paso quiero esta validacion no deja avanzar en los demas pasos
	
		valida_ya = calculaDC(entidad, sucursal, num_cuenta, dc);//validacion del dc en el submit se hace llamando a la funcion que se utiliza en el onblur
		//Sexy.error(entidad+" "+sucursal+" "+num_cuenta+" "+dc+" "+valida_ya);
	
		if (valida_ya == false && entidad != '' && sucursal != '' && num_cuenta != ''){
						
			errores[16] = '&bull; Hay un error en el DC de la cuenta bancaria.<br>';
			cuentaerrores=cuentaerrores+1;
						
		}
	}

	if (paso==5) {
		radiocheck = checkradiobuton();
		if (radiocheck == false) {
			errores[64] = '<br>- Debe seleccionar un precio del Seguro para poder Contratarlo.<br><br>';
			cuentaerrores=cuentaerrores+1;
		}
	}
	
	longitud=val_txt.length; 
						
	for(z=0;longitud>z;z++){
		mostrar = val_txt.join(""); //uno el array para sacarlo por pantalla
		idsconerror = camposerror.join("::");
	}
	
	for(b=0;b<cuentaerrores;b++){
		mostrarerrores = errores.join(""); //uno el array de errores
	}
	
/*---------------------------------- fin validacion de campos requeridos--------------------------------------------*/
						
		
	if (cont2>0 || cuentaerrores>0 ){	// si tenemos algun campo vacio o si algun campo contiene algun error
		switch(paso){//para cada paso sacamos las alertas correspondientes
			case "2":
			case "2_operadores":
			case "3":
			case "4": 							
			case "5": 							
			case "7":
				if(mostrar && mostrarerrores){
					Sexy.error(mostrar+mostrarerrores);	
				} else {
					if(mostrar){
						Sexy.error(mostrar);
					}
					if(mostrarerrores){
						Sexy.error(mostrarerrores);
					}
				}																		
				break;
			default : 	
				break;
		}
		return false;
	} 

	form.submit();

		$(document).ready(function() { 
			$('#progreso').click(function() { 
				$.blockUI({ css: { 
					border: 'none', 
					padding: '15px', 
					backgroundColor: '#000', 
					'webkit-border-radius': '10px', 
					'moz-border-radius': '10px', 
					opacity: .5, 
					color: '#fff' 
				} }); 
			setTimeout($.unblockUI, 20000); 
			}); 
		}); 

}


function valida_fecha_efecto(ano, mes, dia) {

 mes=mes-1;	//no se por que pero ahy que restar un mes
 
 var f2=new Date();
 var  hora = f2.getHours();
 var  minutos = f2.getMinutes();
 var  segundos = f2.getSeconds();
 
 var f1=new Date(ano, mes, dia, hora, minutos, segundos);
 //Sexy.error(f1+"---"+f2);

 error=false;
 
 if (f1<f2) {//la fecha no puede ser anterior
    error=true;
 }
 
 f2.setTime(f2.getTime()+30*24*60*60*1000);//se le suman 30 dias 
 
 if (f1>f2) {//la fecha no puede ser superior a 30 dias
    error=true;
 } 
 
 var f3=new Date();//necesito una nueva fecha para compararlo a la nueva ya que la otra se le suma 15
 
 micadena1=String(f1);
 micadena2=String(f3);
 
 if(micadena1==micadena2){//si son iguales las fechas
   
   	error=false;
 }
 
	return error;

}


				
function MostrarOcultar(parr) {

	var np = 'p' + parr; /*numero de parrafo*/
	var ne = 'e' + parr; /*numero de enlace*/
	var npout = 'p' + parr + 'out';

	var elem = document.getElementById(np);
	var enlace = document.getElementById(ne);
	var elemout = document.getElementById(npout);


	switch (elem.style.display) {
		case 'none': 
			elem.style.display = 'block';
// 			enlace.title = 'Ocultar Datos';
			elemout.style.display = 'none';
			break;
		default: 
			elem.style.display = 'none';
// 			enlace.title = 'Mostrar Datos';
			elemout.style.display = 'block';
			break;
	}

	return;
}



// function switchid(id){	
// 	hideallids();
// 	showdiv(id);
// }
// 
// function hideallids(){
// 	var ids = new Array('p1','p2','p3','p4','p5','p6');
// 	for (var i=0;i<ids.length;i++){
// 		hidediv(ids[i]);
// 	}		  
// }
// 
// function hidediv(id) {
// 
// 	if (document.getElementById) { // DOM3 = IE5, NS6
// 		document.getElementById(id).style.display = 'none';
// 	}
// 	else {
// 		if (document.layers) { // Netscape 4
// 			document.id.display = 'none';
// 		}
// 		else { // IE 4
// 			document.all.id.style.display = 'none';
// 		}
// 	}
// 
// }
// 
// function showdiv(id) {
// 	//safe function to show an element with a specified id
// 	document.getElementById(id).style.display = 'block';
// 	document.getElementById("a").style.color = 'red';
// 
// }
// 


function cerofecha(campo,dato) {
	cadcero='';
	for(i=0;i<(2-dato.length);i++){
		cadcero+='0';
	}
	campo.value=cadcero+dato;
	if (campo.value == '00') {
		campo.value = '';
	}
}

				
// function frases_alea(){//funcion que te devuelve frases aleatorias en un array			
// 	
// 	frases = new Array();
// 	frases[0] = "Consultanos y beneficiate de nuestras nuevas tarifas";
// 	frases[1] = "En Eurolloyd aplicamos los descuentos de tu seguro actual en nuestros precios";
// 	frases[2] = "Si quieres seguridad para t&iacute; y los tuyos, consulta nuestro seguro de accidentes para motoristas.";
// 	frases[3] = "Si te interesa, puedes contratar tu seguro directamente desde nuestra pagina web: WWW.EUROLLOYD.ES ";
// 	frases[4] = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="160" height="300">      <param name="movie" value="definitivo01.swf">      <param name="quality" value="high">      <embed src="definitivo01.swf" width="160" height="300" quality="high"      pluginspage="http://www.macromedia.com/go/getflashplayer"      type="application/x-shockwave-flash"></embed>    </object>';
// 	aleatorio=Math.floor(Math.random()*5);
// 
// 	return frases[aleatorio];
// }
				
					
// function resultado_frases(){//funcion que te devuelve frases aleatorias cada 5 segundos
// 
// 	document.getElementById('algo').innerHTML=frases_alea();
// 	return setInterval(function(){document.getElementById('algo').innerHTML=frases_alea();},1000)
// 	
// }  					
 				

				
function abre_capa_caser (){
	
	document.getElementById('caserxml').style.display="block";

} 
				
function cierra_capa_caser (){
	
	document.getElementById('caserxml').style.display="none";

} 
				
function abre_capa_liberty (){
	
	document.getElementById('libertyxml').style.display="block";

} 
				
function cierra_capa_liberty (){
	
	document.getElementById('libertyxml').style.display="none";

} 
				
function abre_capa_vitalicio (){
	
	document.getElementById('vitalicioxml').style.display="block";
					
} 
				
function cierra_capa_vitalicio (){
	
	document.getElementById('vitalicioxml').style.display="none";

}
				
function abre_capa_pelayo (){
	
	document.getElementById('pelayoxml').style.display="block";
					
} 
				
function cierra_capa_pelayo (){
	
	document.getElementById('pelayoxml').style.display="none";

}
				
function abre_capa_estrella (){
	
	document.getElementById('estrellaxml').style.display="block";
					
} 
				
function cierra_capa_estrella (){
	
	document.getElementById('estrellaxml').style.display="none";

}

function abre_capa_harleyEstrella (){
	
	document.getElementById('HARLEYEstrella').style.display="block";
					
} 
				
function cierra_capa_harleyEstrella (){
	
	document.getElementById('HARLEYEstrella').style.display="none";

}

				
function enviar_mail(cia){

	document.getElementById('email_tarif').value=cia;

}
				
function abre_capa_post (){
	
	document.getElementById('radio_post').style.display="block";
					
} 
			
function cierra_capa_post (){
	
	document.getElementById('radio_post').style.display="none";

}


function abre_capa_debugging (){
	
	document.getElementById('debugging').style.display="block";
					
} 

function cierra_capa_debugging (){
	
	document.getElementById('debugging').style.display="none";

}


function abre_capa_tarifas (){
	
	document.getElementById('tarifas_debug').style.display="block";
					
} 

function cierra_capa_tarifas (){
	
	document.getElementById('tarifas_debug').style.display="none";

}

function abre_capa_BMWEstrella (){
	
	document.getElementById('BMWEstrella').style.display="block";
					
} 
				
function cierra_capa_BMWEstrella (){
	
	document.getElementById('BMWEstrella').style.display="none";

}

function abre_capa_datos (){
	
	document.getElementById('datos').style.display="block";
					
} 
				
function cierra_capa_datos (){
	
	document.getElementById('datos').style.display="none";

}

function abre_capa (capa){
		
	capa.style.display="block";
	
} 
				
function cierra_capa (capa){
	
	capa.style.display="none";

} 


function valida_fecha(Dia, Mes, Ano) {
		hoy=new Date();
		//guardo en variables las fechas de hoy
		var ano_hoy
		ano_hoy = hoy.getFullYear();
		Mes = (Mes.length < 2)?"0"+Mes:Mes; 
		Dia = (Dia.length < 2)?"0"+Dia:Dia; 
		hoy1 = Ano + Mes + Dia;
		var ano 
		ano = parseFloat(Ano); 
		var mes
		mes = parseFloat(Mes); 
		var dia 
		dia = parseFloat(Dia); 
		var Error
		Error = 0;
		var resuc
		resuc = true;
	
		// validamos que la fecha sea correcta
		if(isNaN(ano) || isNaN(mes) || isNaN(dia) || 
			(ano < 1900) || (ano > ano_hoy && desDe == 3) || 
			(mes < 1) || (mes > 12) || 
			(dia < 1) || (dia > 31)) {
			Error = 1;
		} else {
			if((ano%4 != 0) && (mes == 2) && (dia > 28)) {
				Error = 1;
			} else {
				if ((((mes == 4) || (mes == 6) || (mes == 9) || (mes==11)) && (dia>30)) || ((mes==2) && (dia>29))) {
					Error = 1;
				}
			}
		}
		
		if (Error != 0) {
			resuc = false;
		} 
		
		return resuc; 
		
}


function change_select_propietario(xxx) {
	if ( xxx == "cif" ) {
		document.getElementById("persona_fisica_propietario").style.display = "none";
		document.getElementById("persona_juridica_propietario").style.display = "block";
	} else {
		document.getElementById("persona_fisica_propietario").style.display = "block";
		document.getElementById("persona_juridica_propietario").style.display = "none";
    }
// 	pais(xxx, 'propietario');
	return
}

function change_select_tomador(xxx) {
	if ( xxx == "cif" ) {
		document.getElementById("persona_fisica_tomador").style.display = "none";
		document.getElementById("persona_juridica_tomador").style.display = "block";
	} else {
		document.getElementById("persona_fisica_tomador").style.display = "block";
		document.getElementById("persona_juridica_tomador").style.display = "none";
    }
// 	pais(xxx, 'tomador');
	return
}

function pais(id1, fig1) {
	var id = id1;
	var fig = fig1;
	if ( id == "nie" ) {
		document.getElementById("pais_"+fig).style.display = "block";
		document.getElementById("pais_"+fig+"_selector").style.display = "block";
		document.getElementById("fisica_juridica_"+fig).style.display = "block";
// 		document.getElementById("fisica_juridica_"+fig+"_codpost").style.display = "none";
		if(navigator.appName == "Microsoft Internet Explorer"){
			document.getElementById("pais origen "+fig).setAttribute("className", "obli");
		} else {
			document.getElementById("pais origen "+fig).setAttribute("class", "obli");
		}
	} else if ( id == "nif" ) {
		document.getElementById("pais_"+fig).style.display = "none";
		document.getElementById("pais_"+fig+"_selector").style.display = "none";
		document.getElementById("fisica_juridica_"+fig).style.display = "block";
// 		document.getElementById("fisica_juridica_"+fig+"_codpost").style.display = "none";
		if(navigator.appName == "Microsoft Internet Explorer"){
			document.getElementById("pais origen "+fig).setAttribute("className", "");
		} else {
			document.getElementById("pais origen "+fig).setAttribute("class", "");
		}
	} else if ( id == "cif" ) {
		document.getElementById("pais_"+fig).style.display = "none";
		document.getElementById("pais_"+fig+"_selector").style.display = "none";
		document.getElementById("fisica_juridica_"+fig).style.display = "none";
// 		document.getElementById("fisica_juridica_"+fig+"_codpost").style.display = "block";
		if(navigator.appName == "Microsoft Internet Explorer"){
			document.getElementById("pais origen "+fig).setAttribute("className", "");
		} else {
			document.getElementById("pais origen "+fig).setAttribute("class", "");
		}


	}
}

function novel(vl) {
	if ( vl == "5") {	// Tiene historial siniestral
		document.getElementById("historial1").style.display = "block";
// 		document.getElementById("historial1r").style.display = "block";
		document.getElementById("historial2").style.display = "block";
// 		document.getElementById("historial2r").style.display = "block";
			if(navigator.appName == "Microsoft Internet Explorer"){
				document.getElementById("siniestros sin culpa").setAttribute("className", "obli");
				document.getElementById("siniestros con culpa").setAttribute("className", "obli");
			} else {
				document.getElementById("siniestros sin culpa").setAttribute("class", "obli");
				document.getElementById("siniestros con culpa").setAttribute("class", "obli");
			}
	} else {
		document.getElementById("historial1").style.display = "none";
// 		document.getElementById("historial1r").style.display = "none";
		document.getElementById("historial2").style.display = "none";
// 		document.getElementById("historial2r").style.display = "none";
			if(navigator.appName == "Microsoft Internet Explorer"){
				document.getElementById("siniestros sin culpa").setAttribute("className", "");
				document.getElementById("siniestros con culpa").setAttribute("className", "");
			} else {
				document.getElementById("siniestros sin culpa").setAttribute("class", "");
				document.getElementById("siniestros con culpa").setAttribute("class", "");
			}
	}
}

function revisachar(key) {
	regexp = /W/g;
	if(box.value.search(regexp) >= 0){
		box.value = box.value.replace(regexp, '');
	}
}

function fechas(dia, mes, ano, DiaM1, MesM1, AnoM1) {
	Matric = new Date(AnoM, MesM, DiaM); 
	Efect = new Date(ano_efe, mes_efe, dia_efe); 

		if(Matric - Efect > 0){ 	// no es valido
			salidaout = false; 
		} else {  					// es valido
			salidaout = true; 
		}

		return salidaout; 
}


function asegurado(){		//funcion que en el paso 3 activa los campos
	if(navigator.appName == "Microsoft Internet Explorer"){
		var $ordenclass = "className";
	} else {
		var $ordenclass = "class";
	}
// 	alert(navigator.appName);
	document.getElementById("Aseguradora").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Aseguradora").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Aseguradora").removeAttribute("disabled");
	document.getElementById("campo Aseguradora").setAttribute($ordenclass, "obli");

	document.getElementById("Numero de Poliza").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Numero de Poliza").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Numero de Poliza").removeAttribute("disabled");
// 	document.getElementById("campo Numero de Poliza").setAttribute($ordenclass, "obli");

	document.getElementById("Tipo de Poliza").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Tipo de Poliza").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Tipo de Poliza").removeAttribute("disabled");
	document.getElementById("campo Tipo de Poliza").setAttribute($ordenclass, "obli");

	document.getElementById("Antiguedad").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Antiguedad").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo Antiguedad").removeAttribute("disabled");
	document.getElementById("campo Antiguedad").setAttribute($ordenclass, "obli");

	document.getElementById("Fecha Vencimiento").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo mes Fecha Vencimiento").setAttribute($ordenclass, "etiqueta");
	document.getElementById("campo mes Fecha Vencimiento").removeAttribute("disabled");
	document.getElementById("campo mes Fecha Vencimiento").setAttribute($ordenclass, "obli");

}

function noasegurado(){		//funcion que en el paso 3 desactiva los campos
	if(navigator.appName == "Microsoft Internet Explorer"){
		var $ordenclass = "className";
	} else {
		var $ordenclass = "class";
	}
	document.getElementById("Aseguradora").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Aseguradora").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Aseguradora").setAttribute("disabled", true);
	document.getElementById("campo Aseguradora").setAttribute($ordenclass, "");

	document.getElementById("Numero de Poliza").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Numero de Poliza").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Numero de Poliza").setAttribute("disabled", true);
// 	document.getElementById("campo Numero de Poliza").setAttribute($ordenclass, "");

	document.getElementById("Tipo de Poliza").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Tipo de Poliza").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Tipo de Poliza").setAttribute("disabled", true);
	document.getElementById("campo Tipo de Poliza").setAttribute($ordenclass, "");

	document.getElementById("Antiguedad").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Antiguedad").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo Antiguedad").setAttribute("disabled", true);
	document.getElementById("campo Antiguedad").setAttribute($ordenclass, "");
// 	document.getElementById("cia anterior").removeAttribute($ordenclass);

	document.getElementById("Fecha Vencimiento").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo mes Fecha Vencimiento").setAttribute($ordenclass, "etiqueta_disabled");
	document.getElementById("campo mes Fecha Vencimiento").setAttribute("disabled", true);
	document.getElementById("campo mes Fecha Vencimiento").setAttribute($ordenclass, "");

}

function canovencimiento(ms, mc, ano) {
	// ms = mes seleccionado
	// mc = mes en curso
	var mes1 = ms;
	var mes2 = mc;
	var anio = ano;
	if (mes1 > mes2) {
		anio = anio;
		document.getElementById('anovencimiento').value = anio;	
	} else if (mes1 < mes2) {
		anio = anio + 1;
		document.getElementById('anovencimiento').value = anio;	
	} else if (mes1 = mes2) {
		anio = anio;
		document.getElementById('anovencimiento').value = anio;	
	}
}
// ******************* FUNCIONES PARA LOS ACCESORIOS DE COCHES *******************
// ******************* FUNCIONES PARA LOS ACCESORIOS DE COCHES *******************

// Accesorios para CASER
function openaccesorios(codveh,marca,modelo,version,acc_g,acc_f,cia) {

	// servidor -> Variable global definida al comienzo del script para identificar el entorno actual (pruebas o www)
	
	if (cia == 'CASER') { var ancho = '590'; var alto = '360'; }
	if (cia == 'GENERALI') { var ancho = '540'; var alto = '265'; }
	alerta('http://'+servidor+'.eurolloyd.es/multitarificador/LIB/formView/tarificador/accesorios_autos_'+cia+'.php?cod_base='+codveh+'&marca='+marca+'&modelo='+modelo+'&versionlit='+version+'&acc_g='+acc_g+'&acc_f='+acc_f+'&cia='+cia, ancho, alto);
	document.getElementById('desea_accesorios').value="si";
	document.getElementById('siguiente').value="<< Confirmar Precio >>";
}
// ******************* FIN DE FUNCIONES PARA LOS ACCESORIOS DE COCHES
// ******************* FIN DE FUNCIONES PARA LOS ACCESORIOS DE COCHES
function cartaga(nif) {
	if (nif == 'A83634188') {
		document.getElementById('lit_usuario').style.display="";
		document.getElementById('usuario').style.display="";
	} else {
		document.getElementById('lit_usuario').style.display="none";
		document.getElementById('usuario').style.display="none";
	}
}

function appexternos(nif) {
	if (nif == 'B60808474') {
		document.getElementById('colabappexternos').style.display="";
	} else {
		document.getElementById('colabappexternos').style.display="none";
	}
}

function valida_vencimiento(mes, ano) {
	f2=new Date();
	f1=new Date(ano, mes);
	error=false;
 	if (f1 < f2) {		//la fecha no puede ser anterior
		error=true;
	}
	return error;
}

function m_mes() {
	document.getElementById("Mes de Matriculacion").removeAttribute("disabled");
	if (document.getElementById("Mes de Matriculacion").value > 0) {
		anosmoto(document.getElementById('Dia de Matriculacion').value, document.getElementById('Mes de Matriculacion').value, document.getElementById("Ano de Matriculacion").value);
	}
}

function m_ano() {
	document.getElementById("Ano de Matriculacion").removeAttribute("disabled");
	if (document.getElementById("Ano de Matriculacion").value > 0) {
		anosmoto(document.getElementById('Dia de Matriculacion').value, document.getElementById('Mes de Matriculacion').value, document.getElementById("Ano de Matriculacion").value);
	}
}

function anosmoto(dia, mes, ano) {
	error = false;
	mes=mes-1;	//no se por que pero ahy que restar un mes
 	var f2=new Date();
 	var f2b=new Date();
	var  hora = f2.getHours();
	var  minutos = f2.getMinutes();
	var  segundos = f2.getSeconds();
	
	var f1=new Date(ano, mes, dia, hora, minutos, segundos);

	f2b.setTime(f2.getTime()-7*24*60*60*1000);	//se le suma 1 dias 

		if (f1<f2b) {	//la fecha no puede ser anterior
			document.getElementById('anosmoto').style.display="block";
		} else {
			document.getElementById('anosmoto').style.display="none";
		}
	
	f2.setTime(f2.getTime()+1*60*60*1000);	//se le suma 1 dias 

	if (f1>f2) {			//la fecha no puede ser superior
		Sexy.error('La fecha de matriculaci&oacute;n no es correcta.<br>');
		document.getElementById('anosmoto').style.display="none";
		error = true;
	} 

	sel_anos = difer_anios(ano);	// Obtiene la diferencia de años

	return error;
}


// function verFechas(){
// 	ant=document.getElementById('nuevo_usado').value;
// 	if(ant !='nuevo'){
// 		document.getElementById('antiguedad').style.display = "block";
// 		document.getElementById('Dia_de_Matriculacion').style.display = "block";
// 		document.getElementById('Mes_de_Matriculacion').style.display = "block";
// 		document.getElementById('Ano_de_Matriculacion').style.display = "block";
// 		document.getElementById('Dia_de_Matriculacion').setAttribute("class", "obli");
//    		document.getElementById('Mes_de_Matriculacion').setAttribute("class", "obli");
//    		document.getElementById('Ano_de_Matriculacion').setAttribute("class", "obli");
// 	} else {
// 		document.getElementById('antiguedad').style.display = "none";
// 		document.getElementById('Dia_de_Matriculacion').style.display = "none";
// 		document.getElementById('Mes_de_Matriculacion').style.display = "none";
// 		document.getElementById('Ano_de_Matriculacion').style.display = "none";
// 		document.getElementById('Dia_de_Matriculacion').setAttribute("class", "");
//    		document.getElementById('Mes_de_Matriculacion').setAttribute("class", "");
//    		document.getElementById('Ano_de_Matriculacion').setAttribute("class", "");
// 	}
// }
// 
// RELOJ MIENTRAS BUSCA LOS PRECIOS
// function llamada() {
// 	document.getElementById('buscando').style.display = "block";
//    	document.getElementById('buscando').style.visibility = 'visible';
// 	document.getElementById('circulo').style.backgroundImage = 'url(http://www.eurolloyd.es/img/ajax-loader.gif)';
// 	setTimeout("mientras()", 200);
// 	document.getElementById('botones').style.display = "none";
// }
// function mientras() {
// 	document.getElementById('cargando').style.display = "block";
// 	document.getElementById('tabla_total').style.display = "none";
// 	setTimeout("cargado()", 1);
// }
// function cargado() {
// 	document.getElementById('cargando').style.display = "none";
// 	document.getElementById('tabla_total').style.display = "block";
// }

// function showGARANTIAS(num_producto, tipo_moto){
// /* Sexy.error(num_producto+' '+tipo_moto);*/
// 
//     jQuery('div#garantias').dialog({
// 		title: 'Garantias del producto' ,
// 		bgiframe: true,
// 		resizable: false,
// 		height:300,
// 		width:500,
// 		modal: true,
// 		close: function() {
// 			jQuery(this).dialog('destroy');
// 		},
// 
// 		overlay: {
// 			backgroundColor: '#000'
// 		},
// 		buttons: {
// 			'Cerrar': function() {
// 				jQuery(this).dialog('destroy');
// 			}
// 		}
// 	});  
// 
//     jQuery.post('garantias.php', {producto:num_producto, tipo_moto:tipo_moto},
//    
//     function(data){
//         jQuery('div#garantias').empty();      
//         var xml= data;
//         var item, valor, descripcion;
//         var cia = jQuery(xml).find('cia').text();
//  		jQuery('div#garantias').append('<h4>Garantias de '+cia+'</h4>');
//  		jQuery('div#garantias').append('<ul></ul>');
// 		jQuery(xml).find('item').each(function(){
// 			var valor = jQuery(this).find('id').text();
// 			var descripcion = jQuery(this).find('descripcion').text();
// 			jQuery('div#garantias ul').append('<li>'+descripcion+'</li>');
// 		});
//     }, "xml");
// 
// }

function verTODAS() {
	jQuery("#todas").slideDown("slow");
}

function noverTODAS() {
	jQuery("#todas").fadeOut("slow");
} 

function showTARIFAS() {
	jQuery("#tabla_precios").css('display','block');
}

function hideTARIFAS() {
	jQuery("#tabla_precios").css('display','none');
}


function imprimepresupuestomarcas(tdatos, idtarifa, marca) {
	// servidor -> Variable global definida al comienzo del script para identificar el entorno actual (pruebas o www)
	var params = 'id='+tdatos+'&t='+idtarifa;
	var url = 'http://'+servidor+'.eurolloyd.es/'+marca+'/presupuesto.php?'+params;
	alerta(url, '440', '500');
}

function imprimepresupuesto(tdatos, idtarifa, opcion, cat) {	// Presupuesto del Seguro - PASO 4 - Primas y Modalidades
	var params = 'id='+tdatos+'&t='+idtarifa+'&opt='+opcion;
	var categoria = cat;
	if (cat == 3) {
		var url = 'http://'+servidor+'.eurolloyd.es/multitarificador/presupuesto_motos.php?'+params;
	} else if (cat == 1) {
		var url = 'http://'+servidor+'.eurolloyd.es/multitarificador/presupuesto_autos.php?'+params;
	}
	if(opcion == 'imprime'){
		alerta(url, '500', '700');
	}else{
		alerta(url, '300', '130');	
	}
}

function imprimeoctavillas(tdatos, idtarifa) {		// Octavillas del Camión KmCero
	var params = 'id='+tdatos+'&t='+idtarifa;
	var url = 'http://'+servidor+'.eurolloyd.es/multitarificador/octavillas.php?'+params;
	alerta(url, '440', '500');
}

function imprimedocumentacion(tdatos, cia, opcion) {		// Documentación de Contratación mediante WebServices
	if (cia == 'GENERALI') {
		var params = 'g='+tdatos+'&opt='+opcion;
		var direccion = 'http://'+servidor+'.eurolloyd.es/multitarificador/LIB/cias/WSDL/VITALICIO/XML/AUTOS/espera_doc.php?'+params;
		alerta(direccion, '550', '360');
	} else {
		var params = 'g='+tdatos+'&opt='+opcion;
		var url = 'http://'+servidor+'.eurolloyd.es/documentacion/imprimir_documentacion.php?'+params;
		alerta(url, '450', '280');
	}
}

// function imprimeasistencia(tdatos, opcion) {		// Documentación de Contratación mediante WebServices
// 	var params = 'g='+tdatos+'&opt='+opcion;
// 	var url = 'http://'+servidor+'.eurolloyd.es/documentacion/imprimir_asistencia.php?'+params;
// 	alerta(url, '450', '280');
// }

// function traerdocumentacion(url, cia, npol, prop_asist, externo) {
// 	if (cia == 'LIBERTY') {
// 		var direccion = url;
// 		alerta(direccion, '550', '360');
// 	} else 
// 	if (cia == 'GENERALI') {
// 		var params = npol;
// 		var asiste = prop_asist;
// 		var appexterno = externo;
// 		var direccion = 'http://'+servidor+'.eurolloyd.es/multitarificador/LIB/cias/WSDL/VITALICIO/XML/AUTOS/espera_doc.php?poliza='+params+'&pasist='+asiste+'&externo='+appexterno;
// 		alerta(direccion, '550', '360');
// 		
// 	}
// }


function pasamarca(vm) {
	document.getElementById('marca').setAttribute("value", vm);
	if(document.formulario.onsubmit && !document.formulario.onsubmit()) {
		return;
	}
	document.formulario.submit();
		$(document).ready(function() { 
			$('#grantabla').click(function() { 
				$.blockUI({ css: { 
					border: 'none', 
					padding: '15px', 
					backgroundColor: '#000', 
					'webkit-border-radius': '10px', 
					'moz-border-radius': '10px', 
					opacity: .5, 
					color: '#fff' 
				} }); 
			setTimeout($.unblockUI, 60000); 
			}); 
		}); 

}	

function comprobarAcentos(inputtext) {
	inputtext.value = inputtext.value.replace('\u00E1', 'a', 'g');
	inputtext.value = inputtext.value.replace('\u00E9', 'e', 'g');
	inputtext.value = inputtext.value.replace('\u00ED', 'i', 'g');
	inputtext.value = inputtext.value.replace('\u00F3', 'o', 'g');
	inputtext.value = inputtext.value.replace('\u00FA', 'u', 'g');
	inputtext.value = inputtext.value.replace('\u00C1', 'A', 'g');
	inputtext.value = inputtext.value.replace('\u00C9', 'E', 'g');
	inputtext.value = inputtext.value.replace('\u00CD', 'I', 'g');
	inputtext.value = inputtext.value.replace('\u00D3', 'O', 'g');
	inputtext.value = inputtext.value.replace('\u00DA', 'U', 'g');
	return true;
}

function siguientepestania(act, sig) {
	var oculta = act;
	var muestra = sig;
	var $ordenclass = "class";

	document.getElementById(oculta).setAttribute($ordenclass, "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");
	document.getElementById(muestra).setAttribute($ordenclass, "ui-tabs-panel ui-widget-content ui-corner-bottom");

	document.getElementById("pest_"+muestra).setAttribute($ordenclass, "ui-state-default ui-corner-top ui-tabs-selected ui-state-active");
	document.getElementById("pest_"+oculta).setAttribute($ordenclass, "ui-state-default ui-corner-top");

	return true;
}

function copiardatosfiguras(fig, opt) {
	if (opt == "si") {
		document.getElementById('nif_nie_cif_'+fig).value = document.getElementById('DNI_conductor').value;
		document.getElementById('dia nacimiento '+fig).value = document.getElementById('Nacimiento_d_conductor').value;
		document.getElementById('mes nacimiento '+fig).value = document.getElementById('Nacimiento_m_conductor').value;
		document.getElementById('ano nacimiento '+fig).value = document.getElementById('Nacimiento_a_conductor').value;
		document.getElementById('dia carnet '+fig+' Fisico').value = document.getElementById('Carnet_d_conductor').value;
		document.getElementById('mes carnet '+fig+' Fisico').value = document.getElementById('Carnet_m_conductor').value;
		document.getElementById('ano carnet '+fig+' Fisico').value = document.getElementById('Carnet_a_conductor').value;
		document.getElementById('Nombre '+fig+' Fisico').value = document.getElementById('Nombre_conductor').value;
		document.getElementById('Apellido1 '+fig+' Fisico').value = document.getElementById('Apellido1_conductor').value;
		document.getElementById('Apellido2 '+fig+' Fisico').value = document.getElementById('Apellido2_conductor').value;
		document.getElementById('Sexo '+fig+' Fisico').value = document.getElementById('Sexo').value;
		document.getElementById('Tipo de Via '+fig+' Fisico').value = document.getElementById('Tipo de Via').value;
		document.getElementById('Domicilio '+fig+' Fisico').value = document.getElementById('Domicilio_conductor').value;
		document.getElementById('Numero '+fig+' Fisico').value = document.getElementById('Numero_conductor').value;
		document.getElementById('Piso '+fig+' Fisico').value = document.getElementById('Piso_conductor').value;
		document.getElementById('Localidad '+fig+' Fisico').value = document.getElementById('Localidad_conductor').value;
		document.getElementById('Provincia '+fig+' Fisico').value = document.getElementById('Provincia_conductor').value;
		document.getElementById('codigo postal '+fig+' Fisico').value = document.getElementById('Codpost_conductor').value;
		document.getElementById('Telefono1 '+fig+' Fisico').value = document.getElementById('Telefono1_conductor').value;
		document.getElementById('Email '+fig+' Fisico').value = document.getElementById('Email_conductor').value;
	} else if (opt == "no") {
		document.getElementById('nif_nie_cif_'+fig).value = "";
		document.getElementById('dia nacimiento '+fig).value = "";
		document.getElementById('mes nacimiento '+fig).value = "";
		document.getElementById('ano nacimiento '+fig).value = "";
		document.getElementById('dia carnet '+fig+' Fisico').value = "";
		document.getElementById('mes carnet '+fig+' Fisico').value = "";
		document.getElementById('ano carnet '+fig+' Fisico').value = "";
		document.getElementById('Nombre '+fig+' Fisico').value = "";
		document.getElementById('Apellido1 '+fig+' Fisico').value = "";
		document.getElementById('Apellido2 '+fig+' Fisico').value = "";
		document.getElementById('Sexo '+fig+' Fisico').value = "";
		document.getElementById('Tipo de Via '+fig+' Fisico').value = "";
		document.getElementById('Domicilio '+fig+' Fisico').value = "";
		document.getElementById('Numero '+fig+' Fisico').value = "";
		document.getElementById('Piso '+fig+' Fisico').value = "";
		document.getElementById('Localidad '+fig+' Fisico').value = "";
		document.getElementById('Provincia '+fig+' Fisico').value = "";
		document.getElementById('codigo postal '+fig+' Fisico').value = "";
		document.getElementById('Telefono1 '+fig+' Fisico').value = "";
		document.getElementById('Email '+fig+' Fisico').value = "";
	}
// 	Sexy.info('<br>- Datos del '+fig+' copiados correctamente.<br>');nac_conductor
}

function alerta(url, ancho, alto) {
	$(document).ready(function(){  
		Shadowbox.init();
			setTimeout(function() {  
				parent.Shadowbox.open({  
					content:    url,  
					player:     "iframe",  
					width:      ancho,  
					height:     alto  
				});  
		    }, 50);  
	});  
}

function confirmarprima() {
	document.getElementById('paso').value = "4";
}

function comprobaraccesorios() {
	if (document.getElementById('siguiente').value == "<< Confirmar Precio >>") {
		document.getElementById('paso').value = "4";
	}
}

function difer_anios(a){			// Funcion para crear los options de un select 
    hoy=new Date();
    var ano = a;
    act = hoy.getFullYear();
    var dif = (act - ano);
    for (i=1; i<=act; i++) {
// 		document.forms.formulario.anosenpropiedad.options[i]=null;
		document.forms.formulario.anosenpropiedad.length=0;
    }
    for (i=0; i<=dif; i++) {
		document.forms.formulario.anosenpropiedad.options[i]=new Option(i+ " a\u00f1os",i);
// 		if (i==dif){
// 			document.getElementById('anosenpropiedad').selectedIndex = document.forms.formulario.anosenpropiedad.options[i].value; 
// 		}
    }
	return;
} 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// A petición de Teresa, si el usuario no introduce un número de teléfono o es incoherente, muestra un mensaje (una capa oculta)
// Desarrollado por Óliver (21/06/2011)
function aviso_tlf(valor){
	if(valor == '' || 
	   valor == '000000000' ||
	   valor == '111111111' ||
	   valor == '222222222' ||
	   valor == '333333333' ||
	   valor == '444444444' ||
	   valor == '555555555' ||
	   valor == '666666666' ||
	   valor == '777777777' ||
	   valor == '888888888' ||
	   valor == '999999999'){
	   //Sexy.info('<b>No has indicado tu n&uacute;mero de tel&eacute;fono.</b><br>Si nos lo facilitas podemos hacer un estudio personalizado de tu seguro y ofrecerte mejor precio.<br>Gracias.');
	   $('#aviso_tlf').fadeIn('slow');
	}
}

function tcuota($b) {	// funcion para cuota de socio - es muy importante esta funcion
	if($b == 0) {				// NO tiene incrementada la cuota de socio en el producto
		document.getElementById('asistencia_xl').value = "10040103#68,47";
		document.getElementById('asistencia_moto').value = "10040102#50,97";
		document.getElementById('asis_xl').innerHTML = "68,47";
		document.getElementById('asis_moto').innerHTML = "50,97";
	}else if($b == 1) {			// SI tiene incrementada la cuota de socio en el producto
		document.getElementById('asistencia_xl').value = "10040103#52,50";
		document.getElementById('asistencia_moto').value = "10040102#35,00";
		document.getElementById('asis_xl').innerHTML = "52,50";
		document.getElementById('asis_moto').innerHTML = "35,00";
	}
}

function pasaprima(prima, modalidad) {		// Función que recoge el click desde 3ctabla_todos_precios para pasarlo a precio libre
	var p = prima;
	var m = modalidad;
	document.getElementById('preciolibre_anual').value = p;
}

function fracc_recuperacion(prima, oper) {		// Funcion para el fraccionamiento de pago Recuperación Clientes
	var p = prima;
	var operador = oper;
	if (p == "") {
		Sexy.error('- Debe indicar la prima anual');
		document.formulario.pago.checked = false;
		document.getElementById('preciolibrepago').value = 1;	// ANUAL
	} else {
		if (document.formulario.pago.checked == true) {
			if (p >= 250) {
				// Activa pago semestral
				var ps = (prima * 1.03);
				var resps = Math.round(ps*100)/100
				document.getElementById('preciolibre_semestral').value = resps;
				document.getElementById('preciolibrepago').value = 2;	// SEMESTRAL
			} else {
				Sexy.error('- ' + operador + ' por favor ... por favor ... el importe es inferior a 250 &euro;');
				document.formulario.pago.checked = false;
				document.getElementById('preciolibrepago').value = 1;	// ANUAL
			}
		} else {
			// Activa pago anual
			document.getElementById('preciolibre_semestral').value = "";
			document.getElementById('preciolibrepago').value = 1;	// ANUAL
		}
	}
}






