
function Campo_blanco2 (vcampo, ncampo, vacioSI, aMSG)
{	
	var tamano;
	var x;
	var campoOK;
	var nMail;
	
	if (!vcampo)
		vcampo = "";
	tamano = vcampo.length;

	//Test for mail file.
	myFile = ncampo.toLowerCase();
	if (myFile.indexOf("mail")!=-1)
	{
		if (emailOK(vcampo)) 
		{
			return true;		
		}
		else 
		{
			switch (idioma)
			{
				case 1: //Espaņol
					{
						nMail = "Correo no v\341lido.\nIntroduzca un correo con formato usuario@servidor.dominio";
						break;
					}
				case 23: //Euskera
					{
						nMail = "Postaelektronikoa  ez da zuzena.\nJarraitu hurrengo adibidea: erabiltzaile@zerbitzari.domeinua";
						break;
					}
				case 2: //Ingles
					{
						nMail = "Incorrect e-mail format. The correct format is: user@server.domain";
						break;
					}
				default : //Por defecto.
					{
						nMail = "Incorrect e-mail format. The correct format is: user@server.domain";
					}
			}
			alert (nMail);
			return false;
		}
	} 
	// Comprobar si el valor del campo esta rellenado con blancos, o no ha sido rellenado.

	if (tamano>0 && vacioSI=="1")
	{
		campoOK = false;
		for (x=0;x<=tamano-1;x++) 
		{			
			if (vcampo.charAt(x)==" ")
			{
			} else
			{
				campoOK=true;
			}			
		}
		return campoOK;
	}
	else
	{ 
		if (vacioSI=="1")
		{
			campoOK=false;
		} else 
		{
			campoOK=true;
		}
	
	}
		
	// Mostrar mensaje de error.
	if (campoOK==false) 
	{
		alert (aMSG);
		return false;
	} else { return true; }	
		
}

function emailOK(email)
{
	var regMailvalido = /^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(asia|aero|arpa|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/; // Valida
	
	return regMailvalido.test(email.toLowerCase());
}

function controlSuscripcion(boton,valorEnviar){
	if ((idioma == 1)&&
	   ((ref == "ww-SUSCRIP")||(ref == "WW-SUSCRIP")))
	{
		if((document.getElementById("Lst_1") != null && document.getElementById("Lst_1").checked == true)||
		(document.getElementById("Lst_2") != null && document.getElementById("Lst_2").checked == true)||
		(document.getElementById("Lst_3") != null && document.getElementById("Lst_3").checked == true)||
		(document.getElementById("Lst_4") != null && document.getElementById("Lst_4").checked == true)||
		(document.getElementById("Lst_5") != null && document.getElementById("Lst_5").checked == true)||
		(document.getElementById("Lst_6") != null && document.getElementById("Lst_6").checked == true)||
		(document.getElementById("Lst_7") != null && document.getElementById("Lst_7").checked == true)||
		(document.getElementById("Lst_8") != null && document.getElementById("Lst_8").checked == true)||
		(document.getElementById("Lst_9") != null && document.getElementById("Lst_9").checked == true)||
		(document.getElementById("Lst_10") != null && document.getElementById("Lst_10").checked == true))
		{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
		else
		{
			alert("Por favor, seleccione las newsletters a las que desea suscribirse.");
			if(document.getElementById("Lst_1") != null)
				document.getElementById("Lst_1").focus();
			else if (document.getElementById("Lst_2") != null)
				document.getElementById("Lst_2").focus();
			else if (document.getElementById("Lst_3") != null)
				document.getElementById("Lst_3").focus();
			else if (document.getElementById("Lst_4") != null)
				document.getElementById("Lst_4").focus();
			else if (document.getElementById("Lst_5") != null)
				document.getElementById("Lst_5").focus();
			else if (document.getElementById("Lst_6") != null)
				document.getElementById("Lst_6").focus();
			else if (document.getElementById("Lst_7") != null)
				document.getElementById("Lst_7").focus();
			else if (document.getElementById("Lst_8") != null)
				document.getElementById("Lst_8").focus();
			else if (document.getElementById("Lst_9") != null)
				document.getElementById("Lst_9").focus();
			else if (document.getElementById("Lst_10") != null)
				document.getElementById("Lst_10").focus();
				boton.onclick=valorEnviar;
		}
	}
	else if ((idioma == 2)&&
		((ref == "ww-SUSCRIP")||(ref == "WW-SUSCRIP")))
	{
		if((document.getElementById("Lst_11") != null && document.getElementById("Lst_11").checked == true)||
		(document.getElementById("Lst_12") != null && document.getElementById("Lst_12").checked == true)||
		(document.getElementById("Lst_13") != null && document.getElementById("Lst_13").checked == true)||
		(document.getElementById("Lst_14") != null && document.getElementById("Lst_14").checked == true)||
		(document.getElementById("Lst_15") != null && document.getElementById("Lst_15").checked == true)||
		(document.getElementById("Lst_16") != null && document.getElementById("Lst_16").checked == true)||
		(document.getElementById("Lst_17") != null && document.getElementById("Lst_17").checked == true)||
		(document.getElementById("Lst_18") != null && document.getElementById("Lst_18").checked == true)||
		(document.getElementById("Lst_19") != null && document.getElementById("Lst_19").checked == true)||
		(document.getElementById("Lst_20") != null && document.getElementById("Lst_20").checked == true))
		{
			//$dialog.dialog('open');
			boton.onclick='';
			document.f1.submit();
		}
		else
		{
			alert("Please, select the newsletters you want to subscribe to.");
			if(document.getElementById("Lst_11") != null)
				document.getElementById("Lst_11").focus();
			else if (document.getElementById("Lst_12") != null)
				document.getElementById("Lst_12").focus();
			else if (document.getElementById("Lst_13") != null)
				document.getElementById("Lst_13").focus();
			else if (document.getElementById("Lst_14") != null)
				document.getElementById("Lst_14").focus();
			else if (document.getElementById("Lst_15") != null)
				document.getElementById("Lst_15").focus();
			else if (document.getElementById("Lst_16") != null)
				document.getElementById("Lst_16").focus();
			else if (document.getElementById("Lst_17") != null)
				document.getElementById("Lst_17").focus();
			else if (document.getElementById("Lst_18") != null)
				document.getElementById("Lst_18").focus();
			else if (document.getElementById("Lst_19") != null)
				document.getElementById("Lst_19").focus();
			else if (document.getElementById("Lst_20") != null)
				document.getElementById("Lst_20").focus();
				boton.onclick=valorEnviar;
		}
	}
	else if ((idioma == 1)&&(ref == "WW-EN-DES-VPN")){	<!-- VPN Secure -->
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value) {
			alert("No coinciden los email. Por favor confirme el email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else if ((idioma == 1)&&(ref == "WW-EN-DES-PASB")){	<!-- AdminSecure -->
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value) {
			alert("No coinciden los email. Por favor confirme el email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else if ((idioma == 1)&&(ref == "WW-EN-DES-TPCB")){	<!-- TruPrevent Corporate -->
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value) {
			alert("No coinciden los email. Por favor confirme el email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else if ((idioma == 2)&&(ref == "WW-EN-DES-VPN")){
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value){
			alert("Emails are different. Please, insert the same email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else if ((idioma == 2)&&(ref == "WW-EN-DES-PASB")){
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value){
			alert("Emails are different. Please, insert the same email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else if ((idioma == 2)&&(ref == "WW-EN-DES-TPCB")){
		if (document.f1.EMail.value != document.f1.ConfirmarEmail.value){
			alert("Emails are different. Please, insert the same email.");
			document.f1.ConfirmarEmail.focus();
			boton.onclick=valorEnviar;
		}
		else{
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit();
		}
	}
	else {
		//OMG 30/11/2006 Modificacion para validar la confirmacion de email
		var enviar = false;
		if (document.getElementById("ConfirmarEmail") != null){
			if (document.f1.EMail.value != document.f1.ConfirmarEmail.value){
				if (idioma == 1){
					alert("No coinciden los email. Por favor confirme el email.");
				}else{
					alert("Emails are different. Please, insert the same email.");
				}
				document.f1.ConfirmarEmail.focus();
			}else{
				enviar = true;	 
			}	
		}else{	
			enviar = true;	
		}
		//OMG 19/01/2007 Envio de email para formularios largos, con Nš PCs
		if (window.document.f1.Number_Of_PC){
			if (window.document.f1.Number_Of_PC.disabled = false){
				window.document.f1.Number_Of_PC.disabled = true;
				window.document.f1.Number_Of_PC.value = 1;
				boton.onclick=valorEnviar;
			}	
		}		
		if (enviar)
		{ 
			//$dialog.dialog('open');
			boton.onclick="";
			document.f1.submit(); 
		} 
		
	}
}




