// JavaScript Document


    function  ModificaContent(cajaTexto,evento)
    {  
        contentCaja = cajaTexto.value.toLowerCase();
        if (cajaTexto.id=="cUsername")
        {
            if (contentCaja=="usuario" && evento == "1")
               cajaTexto.value="";
            
            if (contentCaja=="" && evento == "0")
               cajaTexto.value="USUARIO";
        }
		else
		{
			if (cajaTexto.id=="cPassword")
			{
				if (contentCaja=="***" && evento == "1")
				{
				   cajaTexto.value="";
				}
				
				if (contentCaja=="" && evento == "0")
				{
				   cajaTexto.value="***";
				}
			}
		}
	}
	
 
 function SimularEnterForm(miCampo)
 {
	if (window.event && window.event.keyCode == 13)
	{
		if (ValidaLogin())
		{
			miCampo.form.submit();
			return false;
		}
		else
			return true;
	}
	else
		return true;
 } 

	function ValidaLogin()
	{
		var cUsername=document.getElementById("cUsername");
		var cPassword=document.getElementById("cPassword");
		var strAlerta="";
		
		if (cUsername.value=="" || cUsername.value=="USUARIO") strAlerta = strAlerta + "El nombre de usuario es obligatorio \n";
		if (cPassword.value=="***" || cPassword.value=="") strAlerta = strAlerta + "El password es obligatorio \n";
		
		if (strAlerta!="")
		{
			alert(strAlerta);
			return false;
		}
		else
		{
			return true;	
		}
	}


 function checkEmail (correo)
    {
	    var filter  = /^([a-zA-Z0-9_\.\-%%])+\@(([a-zA-Z0-9\-%%])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    if (filter.test(correo))
	    {
		    return true;
		}
	    else 
	    {
		    return false;
		}
    }



function validar(formularioAct)
{
	var strAlerta = "";
	var nidusuarioregistrado=formularioAct.nidusuarioregistrado.value;
	if (nidusuarioregistrado=="")
	{
		var cNombre=formularioAct.cNombre.value;
		var cApellido1=formularioAct.cApellido1.value;
		var cDia=formularioAct.dFechaNacimientoDia.value;
		var cMes=formularioAct.dFechaNacimientoMes.value;
		var cAnio=formularioAct.dFechaNacimientoAno.value;
		var cEmail=formularioAct.cEmail.value;
		var cCPostal=formularioAct.cCPostal.value;

		var bTieneToyota=formularioAct.pc_1696[0].checked;
		if (!bTieneToyota)
			bTieneToyota=formularioAct.pc_1697[0].checked; //viene desde email
		
		if (!bTieneToyota) //si no tiene toyota chequea los campos necesarios
		{
			var cNombreMarca=formularioAct.pa_1692.value;
			var cNombreModelo=formularioAct.pa_1693.value;
			if (cNombreMarca=="-1") strAlerta = strAlerta + "La marca del coche es obligatoria \n";
			if (cNombreModelo=="") strAlerta = strAlerta + "El modelo del coche es obligatorio \n";
		}

		var bUsuarioMTW=formularioAct.pc_1698[0].checked;
		if (bTieneToyota && !bUsuarioMTW)
		{ //no es usuario de MTW
			var cNombreToyota=formularioAct.pa_1694.value;
			var cMatricula=formularioAct.pa_1695.value;
			if (cNombreToyota=="-1") strAlerta = strAlerta + "El modelo de Toyota es obligatorio \n";
			if (cMatricula=="") strAlerta = strAlerta + "La matrícula es obligatoria \n";
		}
		
		if (cNombre=="") strAlerta = strAlerta + "El nombre es obligatorio \n";
		if (cApellido1=="") strAlerta = strAlerta + "El apellido 1 es obligatorio \n";

		if (cDia=="-1" || cMes=="-1" || cAnio=="-1") strAlerta = strAlerta + "La fecha de nacimiento es obligatoria \n";

		if (cEmail=="")
		{
			strAlerta = strAlerta + "El e-mail es obligatorio \n";
		}
		else
		{
			if (!checkEmail(cEmail))
			{
				strAlerta = strAlerta + "El e-mail tiene un formato incorrecto \n";
			}
		}
		if (cCPostal=="")
		{
			strAlerta = strAlerta + "El código postal es obligatorio \n";
		}
		else
		{
			if ((cCPostal.length!=5) || (isNaN(cCPostal)))
			{
				strAlerta = strAlerta + "El código postal tiene un formato incorrecto \n";
			}
		}
	}

	//campos comunes para todos
	var cUso=ObtieneValorRadio(formularioAct.pc_1699);
	var cKmLabo=formularioAct.pc_1700.value;
	var cKmTrab=formularioAct.pc_1701.value;
	var cDistancia=formularioAct.pc_1705.value;
	var cEnchCasa=ObtieneValorRadio(formularioAct.pc_1702);
	var cEncTrabajo=ObtieneValorRadio(formularioAct.pc_1703);
	var cColaborar=ObtieneValorRadio(formularioAct.pc_1704);

	if (cUso=="") strAlerta = strAlerta + "Uso diario del coche es obligatorio \n";
	if (cKmLabo=="-1") strAlerta = strAlerta + "Kilómetros días laborables obligatorio \n";
	if (cKmTrab=="-1") strAlerta = strAlerta + "Kilómetros hasta el trabajo es obligatorio \n";
	if (cDistancia=="-1") strAlerta = strAlerta + "Distancia recorrida es obligatorio \n";
	if (cEnchCasa=="") strAlerta = strAlerta + "Enchufe en tu casa obligatorio \n";
	if (cEncTrabajo=="") strAlerta = strAlerta + "Enchufe en el trabajo es obligatorio \n";
	if (cColaborar=="") strAlerta = strAlerta + "Colaboración con Toyota es obligatorio \n";

	var o_chkCondiciones=document.getElementById("chkCondiciones");
	if (o_chkCondiciones.checked==false) strAlerta = strAlerta + "Falta aceptar las condiciones";
	
	if (strAlerta!="")
	{
		alert(strAlerta);
		return false;
	}
	return true;	
	
}


	function validarEmailPassword()
	{
	var o_TxtMail=document.getElementById("emailPss");
	var strAlerta = "";
	if (o_TxtMail.value=="")
	{
		strAlerta = strAlerta + "El e-mail es obligatorio \n";
	}
	else
	{
		if (!checkEmail(o_TxtMail.value))
		{
			strAlerta = strAlerta + "El e-mail tiene un formato incorrecto \n";
		}
	}

	
	if (strAlerta!="")
	{
		alert(strAlerta);
		return false;
	}
	return true;	
	}


	function AlmacenaSeguimiento (seccion)
	{
	WBO_AMOUNT="0.0"; /* <== set here the command amount */
	WBO_CLIENT="";     /* <== set here your client id */
	WBO_INVOICE="";     /* <== set here your bill id */
	WBO_NUM_ITEMS=1; /* <== set here the number of item */
	WBO_POST_VALIDATION=0; /* <== set to 1 if need backoffice validation */
	
	if (webo_performance) {
	transfo = new performanceTransfo(SITE=429920, WBO_ID_TRANSFO=seccion);
	transfo.setAmount(WBO_AMOUNT);
	transfo.setClient(WBO_CLIENT);
	transfo.setId(WBO_INVOICE);
	transfo.setQuantity(WBO_NUM_ITEMS);
	transfo.setPostValidation(WBO_POST_VALIDATION);
	transfo.setHost("toyotaes2.solution.weborama.fr");
	
	/* == Optional parameters == */
	//~optional parameters~
	/* == Type parameters == */
	/* == Free parameters == */
	transfo.execute();
	
	}
	return true;
	}

