
function funcionLeasing(variable){
	borrado()
	document.getElementById(variable).className="activo";
}

function borrado(){
	document.getElementById('financiera').className="";
	document.getElementById('fiscales').className="";
	document.getElementById('tecnicas').className="";
}

function validar(){
	/*alert('entra');*/
	/* Asi consigo que los anteriormente cambiados de color, se pongan con color blanco*/
	document.getElementById('nombre').style.backgroundColor="#ffffff";
	document.getElementById('provincia').style.backgroundColor="#ffffff";
	document.getElementById('cp').style.backgroundColor="#ffffff";
	document.getElementById('telefono').style.backgroundColor="#ffffff";
	document.getElementById('mail').style.backgroundColor="#ffffff";
	document.getElementById('marca').style.backgroundColor="#ffffff";
	document.getElementById('modelo').style.backgroundColor="#ffffff";
	document.getElementById('precioTotal').style.backgroundColor="#ffffff";
	document.getElementById('entrada').style.backgroundColor="#ffffff";
	document.getElementById('plazoPeq').style.backgroundColor="#ffffff";
	document.getElementById('procedencia').style.backgroundColor="#ffffff";
	document.getElementById('antiguedad').style.backgroundColor="#ffffff";
	/* pregunto si hay algún campo sin rellenar*/	
	if ((document.getElementById('nombre').value == '') ||
		(document.getElementById('provincia').value == '0') ||
		(document.getElementById('procedencia').value == '') ||
		(document.getElementById('antiguedad').value == '') ||
		(document.getElementById('cp').value == '') ||
		(document.getElementById('telefono').value == '') ||
		(document.getElementById('mail').value == '') ||
		(document.getElementById('marca').value == '')	||
		(document.getElementById('modelo').value == '') ||
		(document.getElementById('precioTotal').value == '') ||
		(document.getElementById('entrada').value == '') ||
		(document.getElementById('plazoPeq').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			/* pregunto individualmente por cada campo, para si esta vacio cambiarlo de color*/
			if (document.getElementById('mail').value == ''){
				document.getElementById('mail').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('precioTotal').value == ''){
				document.getElementById('precioTotal').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('entrada').value == ''){
				document.getElementById('entrada').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('marca').value == ''){
				document.getElementById('marca').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('modelo').value == ''){
				document.getElementById('modelo').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('plazoPeq').value == ''){
				document.getElementById('plazoPeq').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('nombre').value == ''){
				document.getElementById('nombre').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('provincia').value == '0'){
				document.getElementById('provincia').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('procedencia').value == ''){
				document.getElementById('procedencia').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('antiguedad').value == ''){
				document.getElementById('antiguedad').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('telefono').value == ''){
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
			}
			
			if (document.getElementById('cp').value == ''){
				document.getElementById('cp').style.backgroundColor="#fffdbc";
			}
			
			/* pregunto si el telefono es correcto, si el email es correcto o si lo es el cp.En caso de que no sean correctos cambian de color*/ 
			
			}else if(isNaN(document.getElementById('telefono').value)){
				alert ('El Teléfono que ha introducido no es correcto');
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
				return false;
			}else if(isNaN(document.getElementById('precioTotal').value)){
				alert ('El Precio total del vehiculo que ha introducido no es correcto');
				document.getElementById('precioTotal').style.backgroundColor="#fffdbc";
				return false;
			}else if(isNaN(document.getElementById('entrada').value)){
				alert ('El Importe solicitado que ha introducido no es correcto');
				document.getElementById('entrada').style.backgroundColor="#fffdbc";
				return false;
		 	}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
				document.getElementById('cp').style.backgroundColor="#fffdbc";
				return false;				
			}else if(isEmail(document.getElementById('mail').value) == false){
				alert ('El E-mail que ha introducido no es correcto');
				document.getElementById('mail').style.backgroundColor="#fffdbc";
				return false;
			}else if((document.getElementById('entrada').value) > (document.getElementById('precioTotal').value)){
				alert ('El Precio del vehiculo es superior a la cantidad solicitada');
				document.getElementById('entrada').style.backgroundColor="#fffdbc";
				document.getElementById('precioTotal').style.backgroundColor="#fffdbc";
				return false;		
			}else if(document.getElementById('leido').checked == false){
				alert('Lea y acepte la política de privacidad');
				return false;
			}else{
				return true;
			}
return false;
}

function validar2(){
	/* Asi consigo que los anteriormente cambiados de color, se pongan con color blanco*/
	document.getElementById('nombre').style.backgroundColor="#ffffff";
	document.getElementById('provincia').style.backgroundColor="#ffffff";
	document.getElementById('cp').style.backgroundColor="#ffffff";
	document.getElementById('telefono').style.backgroundColor="#ffffff";
	document.getElementById('mail').style.backgroundColor="#ffffff";
	/* pregunto individualmente por cada campo, para si esta vacio cambiarlo de color*/
	if ((document.getElementById('nombre').value == '') ||
		(document.getElementById('provincia').value == '0') ||
		(document.getElementById('cp').value == '') ||
		(document.getElementById('telefono').value == '') ||
		(document.getElementById('mail').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			if (document.getElementById('mail').value == ''){
				document.getElementById('mail').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('nombre').value == ''){
				document.getElementById('nombre').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('provincia').value == '0'){
				document.getElementById('provincia').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('telefono').value == ''){
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
			}
			
			if (document.getElementById('cp').value == ''){
				document.getElementById('cp').style.backgroundColor="#fffdbc";
			}
			
			/* pregunto si el telefono es correcto, si el email es correcto o si lo es el cp.En caso de que no sean correctos cambian de color*/ 
			}else if(isNaN(document.getElementById('telefono').value)){
				alert ('El Teléfono que ha introducido no es correcto');
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
				return false;
			}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
				document.getElementById('cp').style.backgroundColor="#fffdbc";
				return false;				
			}else if(isEmail(document.getElementById('mail').value) == false){
				alert ('El E-mail que ha introducido no es correcto');
				document.getElementById('mail').style.backgroundColor="#fffdbc";
				return false;				
			}else if(document.getElementById('leido').checked == false){
				alert('Lea y acepte la política de privacidad');
				return false;
			}else{
				return true;
			}
	return false;
}

function contacto(){
	/* Asi consigo que los anteriormente cambiados de color, se pongan con color blanco*/
	document.getElementById('nombre').style.backgroundColor="#ffffff";
	document.getElementById('telefono').style.backgroundColor="#ffffff";
	document.getElementById('mail').style.backgroundColor="#ffffff";
	/* pregunto individualmente por cada campo, para si esta vacio cambiarlo de color*/
	if ((document.getElementById('nombre').value == '') ||
		(document.getElementById('telefono').value == '') ||
		(document.getElementById('mail').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			if (document.getElementById('mail').value == ''){
				document.getElementById('mail').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('nombre').value == ''){
				document.getElementById('nombre').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('telefono').value == ''){
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
			}
			/* pregunto si el telefono es correcto, si el email es correcto .En caso de que no sean correctos cambian de color*/
			}else if(isNaN(document.getElementById('telefono').value)){
				alert ('El Teléfono que ha introducido no es correcto');
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
				return false;
			}else if(isEmail(document.getElementById('mail').value) == false){
				alert ('El E-mail que ha introducido no es correcto');
				document.getElementById('mail').style.backgroundColor="#fffdbc";
				return false;				
			}else if(document.getElementById('leido').checked == false){
				alert('Lea y acepte la política de privacidad');
				return false;
			}else{
				return true;
			}
	return false;
}

function isEmail(str) {
	var result = false
	var theStr = new String(str)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
	}
	return result;
}
function recogerParametros(){
	var importe = document.getElementById('elImporte').value;
	var plazo = document.getElementById('elPlazo').value;
	var cuota = document.getElementById('cuotaTotal').innerHTML;
	//alert(cuota);
	var enlace = '?importe=' + importe + '&plazo=' + plazo + '&cuota=' + cuota;
	var enlace2;
	//alert(enlace);
	enlace2 = document.getElementById('par').href+=enlace;//+=enlace;
	//alert(enlace2);
	
}

function validarLeasing(){
	/* Asi consigo que los anteriormente cambiados de color, se pongan con color blanco*/
	document.getElementById('nombre').style.backgroundColor="#ffffff";
	document.getElementById('provincia').style.backgroundColor="#ffffff";
	document.getElementById('cp').style.backgroundColor="#ffffff";
	document.getElementById('telefono').style.backgroundColor="#ffffff";
	document.getElementById('mail').style.backgroundColor="#ffffff";
	document.getElementById('marca').style.backgroundColor="#ffffff";
	document.getElementById('modelo').style.backgroundColor="#ffffff";
	document.getElementById('extras').style.backgroundColor="#ffffff";   	
	/* preginto si hay algun campos sin rellenar*/	
	
	if ((document.getElementById('nombre').value == '') ||
		(document.getElementById('provincia').value == '') ||
		(document.getElementById('cp').value == '') ||
		(document.getElementById('telefono').value == '') ||
		(document.getElementById('mail').value == '') ||
		(document.getElementById('marca').value == '')	||
		(document.getElementById('modelo').value == '') ||
		(document.getElementById('extras').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');		
			/* pregunto individualmente por cada campo, para si esta vacio cambiarlo de color*/
			if (document.getElementById('mail').value == ''){
				document.getElementById('mail').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('extras').value == ''){
				document.getElementById('extras').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('marca').value == ''){
				document.getElementById('marca').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('modelo').value == ''){
				document.getElementById('modelo').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('nombre').value == ''){
				document.getElementById('nombre').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('provincia').value == '0'){
				document.getElementById('provincia').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('telefono').value == ''){
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
			}
			
			if (document.getElementById('cp').value == ''){
				document.getElementById('cp').style.backgroundColor="#fffdbc";
			}																					
	
			/* pregunto si el telefono es correcto, si el email es correcto o si lo es el cp.En caso de que no sean correctos cambian de color*/ 
			
			}else if(isNaN(document.getElementById('telefono').value)){
				alert ('El Teléfono que ha introducido no es correcto');
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
				return false;
			}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
				document.getElementById('cp').style.backgroundColor="#fffdbc";
				return false;				
			}else if(isEmail(document.getElementById('mail').value) == false){
				alert ('El E-mail que ha introducido no es correcto');
				document.getElementById('mail').style.backgroundColor="#fffdbc";
				return false;
			}else if(document.getElementById('leido').checked == false){
				alert('Lea y acepte la política de privacidad');
				return false;
			}else{
				return true;
			}
return false;																				
}


function validarRenting(){
	/* Asi consigo que los anteriormente cambiados de color, se pongan con color blanco*/
	document.getElementById('nombre').style.backgroundColor="#ffffff";
	document.getElementById('provincia').style.backgroundColor="#ffffff";
	document.getElementById('cp').style.backgroundColor="#ffffff";
	document.getElementById('telefono').style.backgroundColor="#ffffff";
	document.getElementById('mail').style.backgroundColor="#ffffff";
	document.getElementById('marca').style.backgroundColor="#ffffff";
	document.getElementById('modelo').style.backgroundColor="#ffffff";
	document.getElementById('extras').style.backgroundColor="#ffffff";
	document.getElementById('km').style.backgroundColor="#ffffff";
	document.getElementById('plazo').style.backgroundColor="#ffffff";
	/* preginto si hay algun campos sin rellenar*/	
	if ((document.getElementById('nombre').value == '') ||
		(document.getElementById('provincia').value == '0') ||
		(document.getElementById('cp').value == '') ||
		(document.getElementById('telefono').value == '') ||
		(document.getElementById('mail').value == '') ||
		(document.getElementById('marca').value == '') ||
		(document.getElementById('modelo').value == '') ||
		(document.getElementById('marca').value == '')	||
		(document.getElementById('extras').value == '')){
			alert('Debe rellenar todos los campos para poder continuar');
			/* pregunto individualmente por cada campo, para si esta vacio cambiarlo de color*/
			if (document.getElementById('mail').value == ''){
				document.getElementById('mail').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('extras').value == ''){
				document.getElementById('extras').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('marca').value == ''){
				document.getElementById('marca').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('modelo').value == ''){
				document.getElementById('modelo').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('nombre').value == ''){
				document.getElementById('nombre').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('provincia').value == '0'){
				document.getElementById('provincia').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('km').value == ''){
				document.getElementById('km').style.backgroundColor="#fffdbc";
			}
			if (document.getElementById('telefono').value == ''){
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
			}			
			if (document.getElementById('cp').value == ''){
				document.getElementById('cp').style.backgroundColor="#fffdbc";
			}			
			
			/* pregunto si el telefono es correcto, si el email es correcto o si lo es el cp.En caso de que no sean correctos cambian de color*/ 
			
			}else if(isNaN(document.getElementById('telefono').value)){
				alert ('El Teléfono que ha introducido no es correcto');
				document.getElementById('telefono').style.backgroundColor="#fffdbc";
				return false;
			}else if(isNaN(document.getElementById('cp').value)){
				alert ('El C.P. que ha introducido no es correcto');
				document.getElementById('cp').style.backgroundColor="#fffdbc";
				return false;				
			}else if(isEmail(document.getElementById('mail').value) == false){
				alert ('El E-mail que ha introducido no es correcto');
				document.getElementById('mail').style.backgroundColor="#fffdbc";
				return false;
			}else if(document.getElementById('leido').checked == false){
				alert('Lea y acepte la política de privacidad');
				return false;
			}else{
				return true;
			}
return false;
}