﻿// LNU 2009-04-06 
function chekLNU(Option)
{
	if (Option==0)
	{
		if (window.document.f1.Radio_1)
		{
		
			document.f1.Radio_1[0].checked = true;
			document.f1.Radio_1[1].checked = false;
			document.f1.receiveinformation.value=1;
		}
	}
	else if (Option==1)
	{
		if (window.document.f1.Radio_1)
		{
			if (document.f1.Radio_1[1].checked){
				document.f1.receiveinformation.value=0;
				if (document.getElementById('capaLNU'))
				{
					document.getElementById('capaLNU').style.display='inline';
				}
			}

			if (document.f1.Radio_1[0].checked){
				document.f1.receiveinformation.value=1;
				if (document.getElementById('capaLNU'))
				{
					document.getElementById('capaLNU').style.display='none';
				}
			}
			if ((window.document.f1.Checkbox_LNU_1) && (window.document.f1.Checkbox_LNU_2))
			{
				if (document.f1.Radio_1[1].checked)
				{
					document.f1.receiveinformation.value=2;
					document.f1.Checkbox_LNU_1.checked= true;
					document.f1.Checkbox_LNU_2.checked= false;
				}
			}
		}
	}
	else if (Option==2)
	{
		if ((window.document.f1.Checkbox_LNU_1) && (window.document.f1.Checkbox_LNU_2))
		{
			if (document.f1.Checkbox_LNU_1.checked)
			{
				document.f1.receiveinformation.value=2;
			}
			
			if (document.f1.Checkbox_LNU_2.checked)
			{
				document.f1.Checkbox_LNU_1.checked= true;
				document.f1.receiveinformation.value=0;
			}
			
			if ((document.f1.Checkbox_LNU_1.checked==false) && (document.f1.Checkbox_LNU_2.checked==false))
			{				
				document.f1.Radio_1[0].checked = true;
				document.f1.Radio_1[1].checked = false;
				document.f1.receiveinformation.value=1;
				if (document.getElementById('capaLNU'))
				{
					document.getElementById('capaLNU').style.display='none';
				}
			}
		}
	}
	else if (Option==3)
	{
		if (window.document.f1.Radio_1)
		{
			
			document.f1.Radio_1[0].checked = false;
			document.f1.Radio_1[1].checked = true;
			document.f1.receiveinformation.value=0;
			document.f1.Checkbox_LNU_2.checked= true;
		}
	}
}
// LNU FIN 
//2008-11-24 ST - OnClickDownload

var allProvinces;


function filtrarProvincias()
{
    var comboCountry = window.document.f1.Country;
    var comboProvince = window.document.f1.ProvinceSpain;
    if (!allProvinces)
    {
        allProvinces = new Array()
                
        for(i=0; i < comboProvince.options.length; i++)
        {
            allProvinces[i] = comboProvince.options[i];
        }        
    }
    
    comboProvince.options.length=0;
    
    //Si se ha seleccionado algun pais
    var strCountryA2 = comboCountry.options[comboCountry.selectedIndex].value.substring(0,2);
    if (strCountryA2!="")
    {
        var optBlanco = document.createElement('option');
		comboProvince.options.add(optBlanco);
        for(i=0; i < allProvinces.length; i++)
        {
			var item = allProvinces[i];
            var strProvinceA2 = item.value.substring(0,2);
            if (strProvinceA2==strCountryA2)
            {
                comboProvince.options.add(item);                
            }
        }
    }
}

function fnGetUrlParam( name )
{  
if (name.value === undefined)
{
	name.value = 1;
}
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
var regexS = "[\\?&]"+name+"=([^&#]*)";  
var regex = new RegExp( regexS );  
var results = regex.exec( window.location.href );  
if( results == null )    
return 1;  
else   
return results[1];

}

function fnOnChangeUserType1() 	
{

	var Url = location.href; 
	Url = Url.replace(/.*\?(.*?)/,"$1"); 
	Variables = Url.split ("&"); 
	for (i = 0; i < Variables.length; i++) 
	{        
	Separ = Variables[i].split("=");        
	eval ('var '+Separ[0]+'="'+Separ[1]+'"'); 
	} // para la url de ejemplo // wwww.midominio.com/page.php?id=13&ref=12// tendriamos dos variables id y ref con sus valores // //Para comprobarlo: 
	//alert(Selected);

	var comboUser = window.document.f1.UserType;
	//var selected = fnGetUrlParam("selected");

	comboUser.selectedIndex = Selected;

	var Opcion = comboUser.options[comboUser.selectedIndex].value;
	var LineaContact = document.getElementById('TR_TITULO_Contact');
	var LineaCompany = document.getElementById('TR_TITULO_Company');
	var LineaNumberPC = document.getElementById('TR_TITULO_Number_Of_PC');
	var LineaCustomer = document.getElementById('TR_TITULO_CustomerPanda');
	
	if (Selected == '1')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='none';
		LineaNumberPC.style.display='none';
		LineaCustomer.style.display='none';
		
	}
	else if (Selected == '2')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='block';
		LineaNumberPC.style.display='block';
		LineaCustomer.style.display='none';
	}
	else if(Selected == '3')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='block';
		LineaNumberPC.style.display='block';
		LineaCustomer.style.display='block';
	}
	else
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='none';
		LineaNumberPC.style.display='none';
		LineaCustomer.style.display='none';
	}	
}
function fnOnChangeUserType() 
{	
	var comboUser = window.document.f1.UserType;
	var Opcion = comboUser.options[comboUser.selectedIndex].value;
	var LineaContact = document.getElementById('TR_TITULO_Contact');
	var LineaCompany = document.getElementById('TR_TITULO_Company');
	var LineaNumberPC = document.getElementById('TR_TITULO_Number_Of_PC');
	var LineaCustomer = document.getElementById('TR_TITULO_CustomerPanda');
	
	if (Opcion == '1')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='none';
		LineaNumberPC.style.display='none';
		LineaCustomer.style.display='none';
		
	}
	else if (Opcion == '2')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='block';
		LineaNumberPC.style.display='block';
		LineaCustomer.style.display='none';
	}
	else if(Opcion == '3')
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='block';
		LineaNumberPC.style.display='block';
		LineaCustomer.style.display='block';
	}
	else
	{
		LineaContact.style.display='block';
		LineaCompany.style.display='none';
		LineaNumberPC.style.display='none';
		LineaCustomer.style.display='none';
	}	
}
function fnOnChangeEnterprise_Or_Home_User()
{
    var comboUser = window.document.f1.Enterprise_Or_Home_User;
    var txtPhone = window.document.f1.Phone;
    var txtCompany = window.document.f1.Company;
    
    if ((comboUser.options[comboUser.selectedIndex].value=="2") || (comboUser.options[comboUser.selectedIndex].value=="Empresa"))
    {
        txtPhone.disabled = false;
        txtCompany.disabled = false;
        txtPhone.value = "";
        txtCompany.value = "";
        txtPhone.style.backgroundColor = '#fff'
        txtCompany.style.backgroundColor = '#fff'
    }
    else
    {
        txtPhone.disabled = true;
        txtCompany.disabled = true;
		//bt=document.getElementById('txtPhone')
		//bt.Style.visibility = 'hidden';
        txtPhone.value = "-";		
        txtCompany.value = "-";
        txtPhone.style.backgroundColor = '#dcdcdc'
        txtCompany.style.backgroundColor = '#dcdcdc'
    }
}

function fnSelectCountryRetail() 
{		
	var literal;

    var comboCountry = window.document.f1.Country;
    var comboProvince = window.document.f1.ProvinceSpain;

	//Si existe el campo provincias
	if (window.document.f1.ProvinceSpain)
	{
		//relleno el combo
		filtrarProvincias();
	}

	if (window.document.f1.ProvinceSpain)
	{

		//elimino el asterisco
		literal = window.document.getElementById("TITULO_ProvinceSpain").innerHTML;
		literal = literal.replace(" *", "");
		//Si el campo provincias tiene elementos
		if (comboProvince.options.length > 1)
		{
			comboProvince.options[0].selected = true;
			comboProvince.disabled=false;
			comboProvince.setAttribute("obligar","1");
			literal = literal.concat(" *");
		}

		//Si el campo provincias no tiene elementos
		else
		{
			comboProvince.disabled=true;
			comboProvince.setAttribute("obligar","0");
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
		}

		//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
		window.document.getElementById("TITULO_ProvinceSpain").innerHTML = literal;
	}
	else{
		return;
	}	
}


function fnSelectCountryCorporate() 
{		
	var literal;
    var comboCountry = window.document.f1.Country;
    var comboProvince = window.document.f1.ProvinceSpain;

	//Si existe el campo provincias
	if (window.document.f1.ProvinceSpain)
	{
		//relleno el combo
		filtrarProvincias();
	}

	if (window.document.f1.ProvinceSpain)
	{
		var strCountryA2 = comboCountry.options[comboCountry.selectedIndex].value.substring(0,2);

		//elimino el asterisco
		literal = window.document.getElementById("TITULO_ProvinceSpain").innerHTML
		literal = literal.replace(" *", "");

		//Si el país seleccinado es España
		if (strCountryA2=="ES")
		{
			//SÍ es obligatorio
			comboProvince.options[0].selected = true;
			comboProvince.disabled=false;		
			comboProvince.setAttribute("obligar","1");
			literal = literal.concat(" *");
		}
		//País distinto de España 
		else
		{
			//CON Provincias
			if (comboProvince.options.length > 1)
			{
				//NO es obligatorio
				comboProvince.options[0].selected = true;
				comboProvince.disabled=false;
			}
			//SIN Provincias
			else
			{
				//Desactivado
				comboProvince.disabled=true;
			}

			comboProvince.setAttribute("obligar","0");
		}
		//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
		window.document.getElementById("TITULO_ProvinceSpain").innerHTML = literal;
	}
	else{
		return;
	}	
}


// Fin 2008-11-24 ST - OnClickDownload

function SuscripcionesVis()
{
	var nombreCapa;
	var muestra = 0;
	var objeto;
	var i;
	var j;
	var tmp;
	var maxTipoUsuario = 10;
	
	for(i=0; i <= maxTipoUsuario; i++)
	{
		nombreCapa = 'capa' + i;
		
		if (document.getElementById(nombreCapa))
		{
			if (i == document.f1.tipoUsuario.value)
			{
				document.getElementById(nombreCapa).style.display='inline';
				muestra = 1;
			}
			else
			{
				objeto = document.getElementById(nombreCapa);
				if (objeto)
				{
					var inputs = document.getElementsByTagName('input');
					var checkboxes = [];
					for (var j = 0; j < inputs.length; j++)
					{
					  if (inputs[j].type != null && inputs[j].type == 'checkbox')
					  {
					    inputs[j].checked = false;
					  }
					}
				}
			}
		}
	}
	
	if (muestra==0)
	{	
		//Mostrar la capa por defecto
		if (document.getElementById('capaDefault'))
		{
			if (document.getElementById('capaDefault').style)
			{
				document.getElementById('capaDefault').style.display='block';
			}
		}
	}

}

function fnHabilitaCamposSuscripcion()
{
	var cliente = window.document.f1.Tipo_Cliente.value;
	if (cliente!='Empresa' && cliente!='Enterprise' && cliente!='Company')
	{
		window.document.f1.Number_Of_PC.disabled=true;
		window.document.f1.Phone.disabled=true;
		window.document.f1.Post.disabled=true;
	}
	else
	{
		window.document.f1.Number_Of_PC.disabled=false;
		window.document.f1.Phone.disabled=false;
		window.document.f1.Post.disabled=false;	
	}
}

//OMG 06/02/2007 Habilitar NºPCs con valor por defecto
function fnHabilitaCamposSuscripcionEmpresa()
{
	var cliente = window.document.f1.Tipo_Cliente.value;
	if (cliente!='Empresa' && cliente!='Enterprise')
	{
		window.document.f1.Company.disabled=true;
		window.document.f1.Phone.disabled=true;
		window.document.f1.Post.disabled=true;
	}
	else if (cliente!='Particular' && cliente!='Home Users')
	{
		window.document.f1.Company.disabled=false;
		window.document.f1.Phone.disabled=false;
		window.document.f1.Post.disabled=false;	
	}
	else
	{
		window.document.f1.Company.disabled=false;
		window.document.f1.Phone.disabled=false;
		window.document.f1.Post.disabled=false;	
		window.document.f1.Number_Of_PC.value = "";	
	}
}

function fnSelectEnterprise_Or_Home_User()
{
	if (window.document.form1!=null)
	{
	window.document.f1.Number_Of_PC.disabled=false;
	window.document.f1.Number_Of_PC.obligar = "True";
	window.document.f1.Number_Of_PC.onfocus="javascript:this.obligar='True';"
	}
}

function seleccionPCs(){

	if (window.document.form1!=null)
	{
	
	// EM-EN-ENTIDC-602, EM-ES-ENTIDC-602, EM-ca-ENTIDC-602, EM-US-ENTIDC-602, EM-GB-ENTIDC-602, EM-ES-ENTIDCC-602
	if ( (window.location.href.indexOf("EM-EN-ENTIDC-602") != -1) || (window.location.href.indexOf("EM-ES-ENTIDC-602") != -1) || (window.location.href.indexOf("EM-ca-ENTIDC-602") != -1) || (window.location.href.indexOf("EM-US-ENTIDC-602") != -1) || (window.location.href.indexOf("EM-GB-ENTIDC-602") != -1) || (window.location.href.indexOf("EM-ES-ENTIDCC-602") != -1)) {
		window.document.f1.Antivirus_Using.obligar = "False";	
	}
	
	}
}


function fnSelectCountry() 
{		
	//Modificacion OneClick Download. 
	//Lógica de provincias según el tipo de formulario y el código de producto

	if(((window.document.f1.tipoUsuario.value == 17)) 
	  && ((window.document.f1.codigoProducto.value == 1 ) || (window.document.f1.codigoProducto.value == 23) || (window.document.f1.codigoProducto.value == 26)|| (window.document.f1.codigoProducto.value == 27) || (window.document.f1.codigoProducto.value == 59)|| (window.document.f1.codigoProducto.value == 100))){
	fnSelectCountryCorporate();	
	}
	else{
		fnSelectCountryRetail();

	}
	//Moficiación del pie dependiendo del país
	fnCambioPie();
}
function fnCambioPie()
{

	//Función para el cambio de Pie dependiendo del país
	var pais = window.document.getElementById("s_Country").value;
	pais = pais.split("|")[0];
	document.f1.Radio_1[0].checked = true;
	if(pais == "US")
	{
		document.getElementById("pie_pagina").style.display = 'none';
		document.getElementById("idPolitica").href = "http://www.pandasecurity.com/usa/homeusers/media/legal-notice/#e10";
		document.getElementById("idPolitica").onClick = "window.open(this.href, this.target, 'width=300,height=700');";
		document.f1.receiveinformation.value=1;
		if(document.getElementById('Lst_21')){
			document.getElementById('Lst_21').checked = 'checked'
		}else if (document.getElementById('Lst_22')){
			document.getElementById('Lst_22').checked = 'checked'
		}
		
	}
	else if (pais == "ES" || pais== "GB" || pais == "DE" || pais == "PL")
	{
		document.getElementById("pie_pagina").style.display = 'block';
		document.getElementById("idPolitica").href = '../media/legal-notice/#e10';
		document.getElementById("Radio2").onclick = function() {chekLNU(1);};
		document.getElementById('capaLNU').style.display='none';
		if(document.getElementById('Lst_21')){
			document.getElementById('Lst_21').checked = 'checked'
		}else if (document.getElementById('Lst_22')){
			document.getElementById('Lst_22').checked = 'checked'
		}
	}	
	else 
	{
		document.getElementById("pie_pagina").style.display = 'block';
		document.getElementById("idPolitica").href = '../media/legal-notice/#e10';
		document.getElementById("Radio2").onclick = function() {chekLNU(3);}
		document.getElementById('capaLNU').style.display='none';
		if(document.getElementById('Lst_21')){
			document.getElementById('Lst_21').checked = 'checked'
		}else if (document.getElementById('Lst_22')){
			document.getElementById('Lst_22').checked = 'checked'
		}
	}
}
function fnFocusProvinceSpain()
{   
      /*if (window.document.f1.Country.options[window.document.f1.Country.selectedIndex].value.substring(0,2)!="ES"){
	  window.document.f1.State_Or_Province.value="";
   	   window.document.f1.State_Or_Province.focus();
      }*/
}

function fnFocusProvinceUS(){   
      /*
      if ((window.document.f1.Country.options[window.document.f1.Country.selectedIndex].value.substring(0,2)!="US")
      && (idioma == 2)) {
       window.document.f1.State_Or_Province.value="";
   	   window.document.f1.State_Or_Province.focus();
      }
      */
}

function selectCountry()
{
	seleccionPCs();

	if (window.document.f1.Country)
	{
	selCountry = country.toLowerCase();
	var countries  = window.document.f1.Country.length;
	for (var x = 0; x<countries -1; x++)
	{
		opCountry = window.document.f1.Country.options[x].value.substring(0,2).toLowerCase();
		if (opCountry == selCountry)
		{			
			window.document.f1.Country.options[x].selected = true;
			break;
		}		
	}
	}
}


function fnSelectFuncion() {			
	var idx;
if (window.document.f1.Department && window.document.f1.Activity)
{
if (idioma == 1)
	{
		idx = window.document.f1.Post.options[window.document.f1.Post.selectedIndex].index;
		window.document.f1.Department.options[0].selected = true;
		window.document.f1.Activity.options[0].selected = true;
		if (idx == 8 || idx == 7)
		{
			if (navigator.userAgent.indexOf("Netscape6")!= -1)
			{
				document.f1.Department.obligar = '0';
				document.f1.Department.onfocus="javascript:this.obligar='0';"
				document.f1.Department.disabled=true;
				document.f1.Activity.obligar = '0';
				document.f1.Activity.onfocus="javascript:this.obligar='0';"
				document.f1.Activity.disabled=true;
			}
			else 
			{ 
				document.f1.Department.obligar= '0';
				document.f1.Department.onfocus="javascript:this.obligar='0';"
				document.f1.Department.disabled=true;
				document.f1.Activity.obligar = '0';
				document.f1.Activity.onfocus="javascript:this.obligar='0';"
				document.f1.Activity.disabled=true;
			}
		}
		else 
		{
			if (navigator.userAgent.indexOf("Netscape6")!= -1)
			{
				document.f1.Department.obligar = '1';
				document.f1.Department.onfocus="javascript:this.obligar='1';"
				document.f1.Department.disabled=false;
				document.f1.Activity.obligar = '1';
				document.f1.Activity.onfocus="javascript:this.obligar='1';"
				document.f1.Activity.disabled=false;			
			}
			else 
			{ 
				document.f1.Department.obligar = '1';
				document.f1.Department.onfocus="javascript:this.obligar='1';"
				document.f1.Department.disabled=false;
				document.f1.Activity.obligar = '1';
				document.f1.Activity.onfocus="javascript:this.obligar='1';"
				document.f1.Activity.disabled=false;
			}
		}			
	} else {
		idx = window.document.f1.Post_NO.options[window.document.f1.Post_NO.selectedIndex].index;
		window.document.f1.Department_NO.options[0].selected = true;
		window.document.f1.Activity_NO.options[0].selected = true;
		if (idx == 8 || idx == 7)
		{
			if (navigator.userAgent.indexOf("Netscape6")!= -1)
			{
				document.f1.Department_NO.obligar = '0';
				document.f1.Department_NO.onfocus="javascript:this.obligar='0';"
				document.f1.Department_NO.disabled=true;
				document.f1.Activity_NO.obligar = '0';
				document.f1.Activity_NO.onfocus="javascript:this.obligar='0';"
				document.f1.Activity_NO.disabled=true;
			}
			else 
			{ 
				document.f1.Department_NO.obligar= '0';
				document.f1.Department_NO.onfocus="javascript:this.obligar='0';"
				document.f1.Department_NO.disabled=true;
				document.f1.Activity_NO.obligar = '0';
				document.f1.Activity_NO.onfocus="javascript:this.obligar='0';"
				document.f1.Activity_NO.disabled=true;
			}
		}
		else 
		{
			if (navigator.userAgent.indexOf("Netscape6")!= -1)
			{
				document.f1.Department_NO.obligar = '1';
				document.f1.Department_NO.onfocus="javascript:this.obligar='1';"
				document.f1.Department_NO.disabled=false;
				document.f1.Activity_NO.obligar = '1';
				document.f1.Activity_NO.onfocus="javascript:this.obligar='1';"
				document.f1.Activity_NO.disabled=false;			
			}
			else 
			{ 
				document.f1.Department_NO.obligar = '1';
				document.f1.Department_NO.onfocus="javascript:this.obligar='1';"
				document.f1.Department_NO.disabled=false;
				document.f1.Activity_NO.obligar = '1';
				document.f1.Activity_NO.onfocus="javascript:this.obligar='1';"
				document.f1.Activity_NO.disabled=false;
			}
		}
	}
}
}



//Funcion que activa o desactiva el campo ¿cual? dependiendo de la opcion elegida en el radiobutton correspon
function fnVerCual(nombre)
{


	var activo;
	if (eval("window.document.f1." + nombre) &&  eval("document.f1." + nombre + "_cual")){
		activo=eval("window.document.f1." + nombre + "[0].checked");
		eval("window.document.f1." + nombre + "_cual.disabled=" + !activo); 
	}
	
}
var onLoadExecuted = 0;
function PonmeAsterisco()
{
	if(onLoadExecuted==1)
	{
				return;
	}
	else
	{

	// Mostrar u ocultar el *
		var ObligatorioTelf = window.document.getElementById('Phone');
		/*
		var ObligatorioBudget = window.document.getElementById('s_Budget');
		var ObligatorioAuthority = window.document.getElementById('s_Authority');
		var ObligatorioNeed = window.document.getElementById('s_Need');
		var ObligatorioTimeFrame = window.document.getElementById('s_TimeFrame');
		var ObligatorioTime = window.document.getElementById('s_Time');	
		*/
		if (window.location.href.match("TipoUsuario=98") != null)
		{
			var ObligatorioBudget = window.document.f1.Budget[0];
			var ObligatorioAuthority = window.document.f1.Authority[0];
			var ObligatorioNeed = window.document.f1.Need[0];
			var ObligatorioTimeFrame =window.document.f1.TimeFrame[0];
			var ObligatorioTime = window.document.getElementById('s_Time');	
		}
		if (ObligatorioTelf != null)
		{
			var literal = window.document.getElementById("TITULO_Phone").innerHTML;
			if (ObligatorioTelf.getAttribute('obligar') == 1)
			{
				literal = literal + " *";
			}
			else
			{
				//elimino el *
				literal = literal.replace(" *", "");
			}
			//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
			window.document.getElementById("TITULO_Phone").innerHTML = literal;
		}
		if (ObligatorioBudget != null)
		{
			var literal2 = window.document.getElementById("TITULO_Budget").innerHTML;
			if (ObligatorioBudget.getAttribute('obligar') == 1)
			{
				literal2 = literal2 + " *";
			}
			else
			{
			
				//elimino el *
				literal2 = literal2.replace(" *", "");
			}
		//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
		window.document.getElementById("TITULO_Budget").innerHTML = literal2;
		}
		if (ObligatorioAuthority != null)
		{
			var literal3 = window.document.getElementById("TITULO_Authority").innerHTML;
			if (ObligatorioAuthority.getAttribute('obligar') == 1)
			{
				literal3 = literal3 + " *";
			}
			else
			{
				//elimino el *
				literal3 = literal3.replace(" *", "");
			}
		//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio	
		window.document.getElementById("TITULO_Authority").innerHTML = literal3;
		}
		if (ObligatorioNeed != null)
		{
			var literal4 = window.document.getElementById("TITULO_Need").innerHTML;
			if (ObligatorioNeed.getAttribute('obligar') == 1)
			{
				literal4 = literal4 + " *";
			}
			else
			{
				//elimino el *
				literal4 = literal4.replace(" *", "");
			}
			//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
			window.document.getElementById("TITULO_Need").innerHTML = literal4;
		}
		if (ObligatorioTimeFrame != null)
		{
			var literal5 = window.document.getElementById("TITULO_TimeFrame").innerHTML;
			if (ObligatorioTimeFrame.getAttribute('obligar') == 1 )
			{
				literal5 = literal5 + " *";
			}
			else
			{
				//elimino el *
				literal5 = literal5.replace(" *", "");
			}
			//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
			window.document.getElementById("TITULO_TimeFrame").innerHTML = literal5;
		}
		if (ObligatorioTime != null)
		{
			var literal6 = window.document.getElementById("TITULO_Time").innerHTML;
			if (ObligatorioTime.getAttribute('obligar') == 1 )
			{
				literal6 = literal6 + " *";
			}
			else
			{
				//elimino el *
				literal6 = literal6.replace(" *", "");
			}
			//Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
			window.document.getElementById("TITULO_Time").innerHTML = literal6;
		}
		onLoadExecuted = 1;
	}
}

function fnTimeFrame()
{

	if(window.document.f1.tipoUsuario.value == 97) 
	{
		var Muestrame = window.document.f1.RADIO_PROD;
		var LineaStreet = window.document.getElementById('TR_TITULO_Street');
		var LineaTown = window.document.getElementById('TR_TITULO_Town');
		var LineaPostCode = window.document.getElementById('TR_TITULO_PostCode');
		
		if (Muestrame[0].checked == true)
		{
			LineaStreet.style.display = 'none';
			LineaTown.style.display = 'none';
			LineaPostCode.style.display = 'none';
		}
		else
		{
			LineaStreet.style.display = 'block';
			LineaTown.style.display = 'block';
			LineaPostCode.style.display = 'block';
			
		}
		
	}
	else
	{
		//var Muestrame = window.document.getElementById('s_TimeFrame');
		var Muestrame = window.document.f1.TimeFrame;
		var LineaTime = window.document.getElementById('TR_TITULO_Time');
		var ObligatorioTime = window.document.getElementById('s_Time');
		//var ObligatorioTime = window.document.getElementById('s_Time').getAttribute('obligar')
		
		var literal = window.document.getElementById("TITULO_Time").innerHTML;
		if (Muestrame[0].checked == true)
		{
			LineaTime.style.display = 'block';
			//if (ObligatorioTime.getAttribute('obligar') == 1)
			//{
				//pongo el *
			//	literal = literal + " *";
			//}
		}
		else
		{	
			//elimino el *
			//literal = literal.replace(" *", "");
			LineaTime.style.display = 'none';
		}
		////Actualizo el literal incluyendo o no el asterisco según si el campo es o no obligatorio
		//window.document.getElementById("TITULO_Time").innerHTML = literal;
	}
}


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 validacion_leadBant()
{
	var idioma = window.document.f1.idioma.value;
	var boton = window.document.getElementById('enviar');
	var errorLeadBant = '';
	var Contacto = window.document.f1.Contact.value;
	var email1 = window.document.f1.Email.value;
	var telf = window.document.f1.Phone.value;
	var Empresa = window.document.f1.Company.value;
	var cboNpcs = window.document.f1.Number_Of_PC;
	var cboPais = window.document.f1.Country;
	var cboProvincia = window.document.f1.ProvinceSpain;
	var cboBudget = window.document.f1.Budget;
	var cboAuthority = window.document.f1.Authority;
	var cboNeed = window.document.f1.Need;
	var cboTimeFrame = window.document.f1.TimeFrame;	
	var cboTime = window.document.f1.Time;	
	var ObligatorioTelf = window.document.getElementById('Phone').getAttribute('obligar');
	/*
	var ObligatorioPresupuesto = window.document.getElementById('s_Budget').getAttribute('obligar');
	var ObligatorioCargo = window.document.getElementById('s_Authority').getAttribute('obligar')
	var ObligatorioNecesidad = window.document.getElementById('s_Need').getAttribute('obligar')
	var ObligatorioTimeFrame = window.document.getElementById('s_TimeFrame').getAttribute('obligar')
	var ObligatorioTime = window.document.getElementById('s_Time').getAttribute('obligar')
	*/
	var ObligatorioPresupuesto = window.document.f1.Budget[0].getAttribute('obligar');
	var ObligatorioCargo = window.document.f1.Authority[0].getAttribute('obligar')
	var ObligatorioNecesidad = window.document.f1.Need[0].getAttribute('obligar')
	var ObligatorioTimeFrame = window.document.f1.TimeFrame[0].getAttribute('obligar')
	var ObligatorioTime = window.document.getElementById('s_Time').getAttribute('obligar')
	var valorEnviar = boton.onclick;
	boton.onclick = "";
	//Comprobamos el nombre del contacto
	if ((window.document.getElementById('TR_TITULO_Contact').style.display =='block') && (Contacto == ""))
	{
		errorLeadBant = 'true';
		window.document.getElementById('TITULO_Contact').style.color = "red" ;
	}
	else
	{window.document.getElementById('TITULO_Contact').style.color = "#494949" ;}
	//Comprobamos que los 2 correos sean validos
	
	if ((email1 == "") || (!emailOK(email1)))
	{
		errorLeadBant += ' ErrorA';
		window.document.getElementById('TITULO_Email').style.color = "red" ;		
	}
	else
	{
		window.document.getElementById('TITULO_Email').style.color = "#494949" ;
	}
	//Comprobamos el telefono
	if (ObligatorioTelf == 1)
	{
		if((telf == "") || (isNaN(telf)))
		{
			errorLeadBant += ' ErrorB';
			window.document.getElementById('TITULO_Phone').style.color = "red" ;
		}
		else{window.document.getElementById('TITULO_Phone').style.color = "#494949" ;}
	}
	else
	{window.document.getElementById('TITULO_Phone').style.color = "#494949" ;}
	//Comprobamos el nombre de la empresa
	if ((window.document.getElementById('TR_TITULO_Company').style.display =='block') && (Empresa == ""))
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Company').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Company').style.color = "#494949" ;}	
	//Comprobamos el numero de PCs insertados
	if ((window.document.getElementById('TR_TITULO_Number_Of_PC').style.display =='block') && (cboNpcs.selectedIndex == 0))
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Number_Of_PC').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Number_Of_PC').style.color = "#494949" ;}
	//comprobamos que el pais esta rellenado
	if ((window.document.getElementById('TR_TITULO_Country').style.display =='block') && (cboPais.selectedIndex == 0))
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Country').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Country').style.color = "#494949" ;}
	//Comprobamos si existen provincias en el pais elegido
	if (cboProvincia.options.length > 1)
	{
		//Comprobamos si ha seleccionado una provincia
		if (cboProvincia.selectedIndex == 0)
		{
			errorLeadBant += 'true';
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "red" ;
		}
		else
		{
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
		}
	}
	else
	{window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;}
	
	//Comprobamos si ha seleccionado presupuesto
	if ((window.document.getElementById('TR_TITULO_Budget').style.display =='block') && 
	((cboBudget[0].checked == false) && (cboBudget[1].checked == false)) && ObligatorioPresupuesto == 1)
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Budget').style.color = "red" ;
	}
	else
	{window.document.getElementById('TITULO_Budget').style.color = "#494949" ;}
	//Comprobamos si ha seleccionado un cargo
	if ((window.document.getElementById('TR_TITULO_Authority').style.display =='block') && ((cboAuthority[0].checked == false) && (cboAuthority[1].checked == false)) && ObligatorioCargo == 1)
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Authority').style.color = "red" ;
	}
	else
	{window.document.getElementById('TITULO_Authority').style.color = "#494949" ;}
	//Comprobamos si ha seleccionado need
	if ((window.document.getElementById('TR_TITULO_Need').style.display =='block') && ((cboNeed[0].checked == false) && (cboNeed[1].checked == false)) && ObligatorioNecesidad == 1)
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Need').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Need').style.color = "#494949" ;}
	//Comprobamos si ha seleccionado TimeFrame
	if ((window.document.getElementById('TR_TITULO_TimeFrame').style.display =='block') && ((cboTimeFrame[0].checked == false) && (cboTimeFrame[1].checked == false)) && ObligatorioTimeFrame == 1)
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_TimeFrame').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_TimeFrame').style.color = "#494949" ;}
	//Comprobamos si ha seleccionado Time
	if ((window.document.getElementById('TR_TITULO_Time').style.display =='block') && (cboTime.selectedIndex == 0) && ObligatorioTime == 1)
	{
		errorLeadBant += 'true';
		window.document.getElementById('TITULO_Time').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Time').style.color = "#494949" ;}
	if (errorLeadBant != '')
	{
		var mensajeconcatenado = '';
		if((errorLeadBant.indexOf('ErrorA') !=-1) && idioma == 1)
		{ 		
			mensajeconcatenado = ' \n\nIntroduzca un correo con formato 	usuario@servidor.dominio';
		}
		else if ((errorLeadBant.indexOf('ErrorA') !=-1) && idioma == 2)
		{
			mensajeconcatenado = '\n\nIncorrect e-mail format. The correct format is: user@server.domain';
		}
		else if ((errorLeadBant.indexOf('ErrorA') !=-1) && idioma == 6)
		{
			mensajeconcatenado = '\n\nLe format de l´adresse email est incorrect. Il doit être sous la forme utilisateur@serveur.domaine.';
		}
		if((errorLeadBant.indexOf('ErrorB') !=-1) && idioma == 1)
		{
			mensajeconcatenado += '\nEl campo teléfono debe ser numérico.';
		}
		else if ((errorLeadBant.indexOf('ErrorB') !=-1) && idioma == 2)
		{
			mensajeconcatenado += '\nThe phone must be numeric';
		}
		else if ((errorLeadBant.indexOf('ErrorB') !=-1) && idioma == 6)
		{
			mensajeconcatenado += '\nLe numéro de téléphone doit être composé de chiffres.';
		}		
		if(idioma==1) alert("Por favor, rellene todos los campos obligatorios" + mensajeconcatenado);
		else if (idioma==2) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==3) alert("Bitte füllen Sie alle erforderlichen Felder aus" + mensajeconcatenado);
		else if (idioma==5) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==6) alert("Veuillez remplir tous les champs obligatoires" + mensajeconcatenado);
		else if (idioma==9) alert("Japones");
		else if (idioma==10) alert("Por favor, preencha todos os campos obrigatórios" + mensajeconcatenado);
		else if (idioma==11) alert("Si prega di compilare tutti i campi obbligatori" + mensajeconcatenado);
		else if (idioma==13) alert("S'il vous plaît remplir tous les champs obligatoires" + mensajeconcatenado);
		else alert("Please fill all mandatory fields" + mensajeconcatenado);	
		boton.onclick=valorEnviar;
	}
	else
	{
		//alert('todo OK');
		//$dialog.dialog('open');
		document.f1.submit();
	}
}

function validacion_Groupon()
{
	//
	var idioma = window.document.f1.idioma.value;
	var boton = window.document.getElementById('enviar');	
	var cboTipoUsuario = window.document.f1.UserType;	
	var errorParticular = '';
	var errorEmpresa = '';
	var errorDistribuidor = '';
	var valorEnviar = boton.onclick;
	boton.onclick = "";

		switch(cboTipoUsuario.selectedIndex)
		{
		case 0:
			errorParticular = validacion_ParticularGroupon();
			break;
		case 1:
			errorParticular = validacion_ParticularGroupon();
			errorEmpresa = validacion_Empresa();
			break;
		case 2:
			errorParticular = validacion_ParticularGroupon();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		default:		
			errorParticular = validacion_ParticularGroupon();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		}
		//var idioma = 1;
	if	((errorParticular !='' || errorEmpresa !='' || errorDistribuidor !=''))
	{
		var mensajeconcatenado = '';
		if((errorParticular.indexOf('ErrorA') !=-1) && idioma == 1)
		{ 		
			mensajeconcatenado = ' \n\nIntroduzca un correo con formato 	usuario@servidor.dominio';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 2)
		{
			mensajeconcatenado = '\n\nIncorrect e-mail format. The correct format is: user@server.domain';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 6)
		{
			mensajeconcatenado = '\n\nLe format de l´adresse email est incorrect. Il doit être sous la forme utilisateur@serveur.domaine.';
		}
		if((errorParticular.indexOf('ErrorB') !=-1) && idioma == 1)
		{
			mensajeconcatenado += '\nEl campo teléfono debe ser numérico.';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 2)
		{
			mensajeconcatenado += '\nThe phone must be numeric';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 6)
		{
			mensajeconcatenado += '\nLe numéro de téléphone doit être composé de chiffres.';
		}
		
		if(idioma==1) 
		alert("Por favor, rellene todos los campos obligatorios" + mensajeconcatenado);
		else if (idioma==2) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==3) alert("Bitte füllen Sie alle erforderlichen Felder aus" + mensajeconcatenado);
		else if (idioma==5) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==6) alert("Veuillez remplir tous les champs obligatoires" + mensajeconcatenado);
		else if (idioma==9) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==10) alert("Por favor, preencha todos os campos obrigatórios" + mensajeconcatenado);
		else if (idioma==11) alert("Si prega di compilare tutti i campi obbligatori" + mensajeconcatenado);
		else if (idioma==13) alert("S'il vous plaît remplir tous les champs obligatoires" + mensajeconcatenado);
		else alert("Please fill all mandatory fields" + mensajeconcatenado);	
		boton.onclick=valorEnviar;
		
	}
	else
	{
		//alert('Todo OK');
		//$dialog.dialog('open');
		document.f1.submit();
	}
}
function validacion_Groupon1()
{
	//
	var idioma = window.document.f1.idioma.value;
	var boton = window.document.getElementById('enviar');	
	var cboTipoUsuario = window.document.f1.UserType;	
	var errorParticular = '';
	var errorEmpresa = '';
	var errorDistribuidor = '';
	var valorEnviar = boton.onclick;
	boton.onclick = "";

		switch(cboTipoUsuario.selectedIndex)
		{
		case 0:
			errorParticular = validacion_ParticularGroupon1();
			break;
		case 1:
			errorParticular = validacion_ParticularGroupon1();
			errorEmpresa = validacion_Empresa();
			break;
		case 2:
			errorParticular = validacion_ParticularGroupon1();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		default:		
			errorParticular = validacion_ParticularGroupon1();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		}
		//var idioma = 1;
	if	((errorParticular !='' || errorEmpresa !='' || errorDistribuidor !=''))
	{
		var mensajeconcatenado = '';
		if((errorParticular.indexOf('ErrorA') !=-1) && idioma == 1)
		{ 		
			mensajeconcatenado = ' \n\nIntroduzca un correo con formato 	usuario@servidor.dominio';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 2)
		{
			mensajeconcatenado = '\n\nIncorrect e-mail format. The correct format is: user@server.domain';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 6)
		{
			mensajeconcatenado = '\n\nLe format de l´adresse email est incorrect. Il doit être sous la forme utilisateur@serveur.domaine.';
		}
		if((errorParticular.indexOf('ErrorB') !=-1) && idioma == 1)
		{
			mensajeconcatenado += '\nEl campo teléfono debe ser numérico.';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 2)
		{
			mensajeconcatenado += '\nThe phone must be numeric';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 6)
		{
			mensajeconcatenado += '\nLe numéro de téléphone doit être composé de chiffres.';
		}
		
		if(idioma==1) 
		alert("Por favor, rellene todos los campos obligatorios" + mensajeconcatenado);
		else if (idioma==2) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==3) alert("Bitte füllen Sie alle erforderlichen Felder aus" + mensajeconcatenado);
		else if (idioma==5) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==6) alert("Veuillez remplir tous les champs obligatoires" + mensajeconcatenado);
		else if (idioma==9) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==10) alert("Por favor, preencha todos os campos obrigatórios" + mensajeconcatenado);
		else if (idioma==11) alert("Si prega di compilare tutti i campi obbligatori" + mensajeconcatenado);
		else if (idioma==13) alert("S'il vous plaît remplir tous les champs obligatoires" + mensajeconcatenado);
		else alert("Please fill all mandatory fields" + mensajeconcatenado);	
		boton.onclick=valorEnviar;
		
	}
	else
	{
		//alert('Todo OK');
		//$dialog.dialog('open');
		document.f1.submit();
	}
}
function validacion_leads()	
{
	var idioma = window.document.f1.idioma.value;
	var boton = window.document.getElementById('enviar');	
	var cboTipoUsuario = window.document.f1.UserType;	
	var errorParticular = '';
	var errorEmpresa = '';
	var errorDistribuidor = '';
	var valorEnviar = boton.onclick;
	boton.onclick = "";

		switch(cboTipoUsuario.selectedIndex)
		{
		case 0:
			errorParticular = validacion_Particular();
			break;
		case 1:
			errorParticular = validacion_Particular();
			errorEmpresa = validacion_Empresa();
			break;
		case 2:
			errorParticular = validacion_Particular();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		default:		
			errorParticular = validacion_Particular();
			errorEmpresa = validacion_Empresa();
			errorDistribuidor = validacion_Distribuidor();
			break;
		}
	if	((errorParticular !='' || errorEmpresa !='' || errorDistribuidor !=''))
	{
		var mensajeconcatenado = '';
		if((errorParticular.indexOf('ErrorA') !=-1) && idioma == 1)
		{ 		
			mensajeconcatenado = ' \n\nIntroduzca un correo con formato 	usuario@servidor.dominio';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 2)
		{
			mensajeconcatenado = '\n\nIncorrect e-mail format. The correct format is: user@server.domain';
		}
		else if ((errorParticular.indexOf('ErrorA') !=-1) && idioma == 6)
		{
			mensajeconcatenado = '\n\nLe format de l´adresse email est incorrect. Il doit être sous la forme utilisateur@serveur.domaine.';
		}
		if((errorParticular.indexOf('ErrorB') !=-1) && idioma == 1)
		{
			mensajeconcatenado += '\nEl campo teléfono debe ser numérico.';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 2)
		{
			mensajeconcatenado += '\nThe phone must be numeric';
		}
		else if ((errorParticular.indexOf('ErrorB') !=-1) && idioma == 6)
		{
			mensajeconcatenado += '\nLe numéro de téléphone doit être composé de chiffres.';
		}
		
		if(idioma==1) 
		alert("Por favor, rellene todos los campos obligatorios" + mensajeconcatenado);
		else if (idioma==2) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==3) alert("Bitte füllen Sie alle erforderlichen Felder aus" + mensajeconcatenado);
		else if (idioma==5) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==6) alert("Veuillez remplir tous les champs obligatoires" + mensajeconcatenado);
		else if (idioma==9) alert("Please fill all mandatory fields" + mensajeconcatenado);
		else if (idioma==10) alert("Por favor, preencha todos os campos obrigatórios" + mensajeconcatenado);
		else if (idioma==11) alert("Si prega di compilare tutti i campi obbligatori" + mensajeconcatenado);
		else if (idioma==13) alert("S'il vous plaît remplir tous les champs obligatoires" + mensajeconcatenado);
		else alert("Please fill all mandatory fields" + mensajeconcatenado);	
		boton.onclick=valorEnviar;
		
	}
	else
	{
		//alert('Todo OK');
		//$dialog.dialog('open');
		document.f1.submit();
	}
}

function validacion_ParticularGroupon()
{	
	var Contacto = window.document.f1.Contact.value;
	var email1 = window.document.f1.Email.value;
	var telf = window.document.f1.Phone.value;
	var cboTipoUsuario = window.document.f1.UserType;
	var cboPais = window.document.f1.Country;
	var cboProvincia = window.document.f1.ProvinceSpain;
	var Street = window.document.f1.Street.value;
	var Town = window.document.f1.Town.value;
	var PostCode = window.document.f1.PostCode.value;
	var GrouponCode = window.document.f1.Groupon.value;
//	var errormail = false;
	var errorParticular = '';
	var mensajeConcatenado;

	if ((window.document.getElementById('TR_TITULO_Contact').style.display =='block') && (Contacto == ""))
	{
		errorParticular = 'ErrorContacto';
		window.document.getElementById('TITULO_Contact').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Contact').style.color = "#494949" ;
	}
	//comprobamos que los emails tienen un formato correcto
	if ((email1 == "") || (!emailOK(email1)))
	{
		errorParticular += ' ErrorA';
		window.document.getElementById('TITULO_Email').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_Email').style.color = "#494949" ;
		mensajeConcatenado = '';
	}
	//Comprobamos si el teléfono es un valor numérico
	if ((telf == "") || (isNaN(telf)))
	//if((/^[0-9]{8,}$/).exec(telf)==null)
	//if((/^[0-9]$/).exec(telf)==null)
	{
		errorParticular += ' ErrorB';;
		window.document.getElementById('TITULO_Phone').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Phone').style.color = "#494949" ;
	} 
	//comprobamos que hay seleccionado un cliente y un pais
	if (cboTipoUsuario.value == "" && cboPais.value == "") 
	{
		errorParticular += ' ErrorPaisUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else if (cboTipoUsuario.value == "" && cboPais.value != "")
	{
		errorParticular += ' ErrorUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	else if (cboTipoUsuario.value != "" && cboPais.value == "")
	{
		errorParticular += ' ErrorPais';
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	if (cboProvincia.options.length > 1)
	{
		if (cboProvincia.selectedIndex == 0)
		{
			errorParticular += ' ErrorProvincia';
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "red" ;
		}
		else
		{
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
		}
	}
	else
	{
		window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
	}
	if ((window.document.getElementById('TR_TITULO_Street').style.display =='block') && (Street == ""))
	{
		errorParticular = 'ErrorStreet';
		window.document.getElementById('TITULO_Street').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Street').style.color = "#494949" ;
	}
	if ((window.document.getElementById('TR_TITULO_Town').style.display =='block') && (Town == ""))
	{
		errorParticular = 'ErrorTown';
		window.document.getElementById('TITULO_Town').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Town').style.color = "#494949" ;
	}
	if ((window.document.getElementById('TR_TITULO_PostCode').style.display =='block') && ((PostCode == "") || (isNaN(PostCode))))
	{
		errorParticular = 'ErrorPostCode';
		window.document.getElementById('TITULO_PostCode').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_PostCode').style.color = "#494949" ;
	}
	if ((window.document.getElementById('TR_TITULO_Groupon').style.display =='block') && (GrouponCode == ""))
	{
		errorParticular = 'ErrorGroupon';
		window.document.getElementById('TITULO_Groupon').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Groupon').style.color = "#494949" ;
	}
	return errorParticular;

}

function validacion_ParticularGroupon1()
{	
	var Contacto = window.document.f1.Contact.value;
	var email1 = window.document.f1.Email.value;
	var telf = window.document.f1.Phone.value;
	var cboTipoUsuario = window.document.f1.UserType;
	var cboPais = window.document.f1.Country;
	var cboProvincia = window.document.f1.ProvinceSpain;
//	var Street = window.document.f1.Street.value;
//	var Town = window.document.f1.Town.value;
//	var PostCode = window.document.f1.PostCode.value;
	var GrouponCode = window.document.f1.Groupon.value;
//	var errormail = false;
	var errorParticular = '';
	var mensajeConcatenado;

	if ((window.document.getElementById('TR_TITULO_Contact').style.display =='block') && (Contacto == ""))
	{
		errorParticular = 'ErrorContacto';
		window.document.getElementById('TITULO_Contact').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Contact').style.color = "#494949" ;
	}
	//comprobamos que los emails tienen un formato correcto
	if ((email1 == "") || (!emailOK(email1)))
	{
		errorParticular += ' ErrorA';
		window.document.getElementById('TITULO_Email').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_Email').style.color = "#494949" ;
		mensajeConcatenado = '';
	}
	//Comprobamos si el teléfono es un valor numérico
	if ((telf == "") || (isNaN(telf)))
	//if((/^[0-9]{8,}$/).exec(telf)==null)
	//if((/^[0-9]$/).exec(telf)==null)
	{
		errorParticular += ' ErrorB';;
		window.document.getElementById('TITULO_Phone').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Phone').style.color = "#494949" ;
	} 
	//comprobamos que hay seleccionado un cliente y un pais
	if (cboTipoUsuario.value == "" && cboPais.value == "") 
	{
		errorParticular += ' ErrorPaisUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else if (cboTipoUsuario.value == "" && cboPais.value != "")
	{
		errorParticular += ' ErrorUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	else if (cboTipoUsuario.value != "" && cboPais.value == "")
	{
		errorParticular += ' ErrorPais';
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	if (cboProvincia.options.length > 1)
	{
		if (cboProvincia.selectedIndex == 0)
		{
			errorParticular += ' ErrorProvincia';
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "red" ;
		}
		else
		{
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
		}
	}
	else
	{
		window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
	}
	if ((window.document.getElementById('TR_TITULO_Groupon').style.display =='block') && (GrouponCode == ""))
	{
		errorParticular = 'ErrorGroupon';
		window.document.getElementById('TITULO_Groupon').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Groupon').style.color = "#494949" ;
	}
	return errorParticular;

}


function validacion_Particular()
{	
	var Contacto = window.document.f1.Contact.value;
	var email1 = window.document.f1.Email.value;
	var telf = window.document.f1.Phone.value;
	var cboTipoUsuario = window.document.f1.UserType;
	var cboPais = window.document.f1.Country;
	var cboProvincia = window.document.f1.ProvinceSpain;
//	var errormail = false;
	var errorParticular = '';
	var mensajeConcatenado;

	if ((window.document.getElementById('TR_TITULO_Contact').style.display =='block') && (Contacto == ""))
	{
		errorParticular = 'ErrorContacto';
		window.document.getElementById('TITULO_Contact').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Contact').style.color = "#494949" ;}
	//comprobamos que los emails tienen un formato correcto
	if ((email1 == "") || (!emailOK(email1)))
	{
		errorParticular += ' ErrorA';
		window.document.getElementById('TITULO_Email').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_Email').style.color = "#494949" ;
		mensajeConcatenado = '';
	}
	//Comprobamos si el teléfono es un valor numérico
	if ((telf == "") || (isNaN(telf)))
	//if((/^[0-9]{8,}$/).exec(telf)==null)
	//if((/^[0-9]$/).exec(telf)==null)
	{
		errorParticular += ' ErrorB';;
		window.document.getElementById('TITULO_Phone').style.color = "red" ;
	}
	else
	{
		window.document.getElementById('TITULO_Phone').style.color = "#494949" ;
	} 
	//comprobamos que hay seleccionado un cliente y un pais
	if (cboTipoUsuario.value == "" && cboPais.value == "") 
	{
		errorParticular += ' ErrorPaisUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else if (cboTipoUsuario.value == "" && cboPais.value != "")
	{
		errorParticular += ' ErrorUsuario';
		window.document.getElementById('TITULO_UserType').style.color = "red" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	else if (cboTipoUsuario.value != "" && cboPais.value == "")
	{
		errorParticular += ' ErrorPais';
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "red" ;	
	}
	else
	{
		window.document.getElementById('TITULO_UserType').style.color = "#494949" ;
		window.document.getElementById('TITULO_Country').style.color = "#494949" ;	
	}
	if (cboProvincia.options.length > 1)
	{
		if (cboProvincia.selectedIndex == 0)
		{
			errorParticular += ' ErrorProvincia';
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "red" ;
		}
		else
		{
			window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
		}
	}
	else
	{
		window.document.getElementById('TITULO_ProvinceSpain').style.color = "#494949" ;
	}
	return errorParticular;

}
function validacion_Empresa()
{
	var Empresa = window.document.f1.Company.value;
	var cboNpcs = window.document.f1.Number_Of_PC;
	var errorEmpresa = '';
	if ((window.document.getElementById('TR_TITULO_Company').style.display =='block') && (Empresa == ""))
	{
		errorEmpresa = 'true';
		window.document.getElementById('TITULO_Company').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Company').style.color = "#494949" ;}
	
	if ((window.document.getElementById('TR_TITULO_Number_Of_PC').style.display =='block') && (cboNpcs.selectedIndex == 0))
	{
		errorEmpresa += 'true';
		window.document.getElementById('TITULO_Number_Of_PC').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_Number_Of_PC').style.color = "#494949" ;}
	return errorEmpresa;
}
function validacion_Distribuidor()
{
	var cboDistribuidor = window.document.f1.CustomerPanda;
	var errorDistribuidor = '';
	if ((window.document.getElementById('TR_TITULO_CustomerPanda').style.display =='block') && (cboDistribuidor.selectedIndex == 0))
	{
		errorDistribuidor = 'true';
		window.document.getElementById('TITULO_CustomerPanda').style.color = "red" ;
	}
	else
	{
	window.document.getElementById('TITULO_CustomerPanda').style.color = "#494949" ;}
	return errorDistribuidor;
}

function validar_leads()	
{
	if (window.location.href.match("TipoUsuario=96") != null)
	{
		validacion_Groupon1();
	}
	else if (window.location.href.match("TipoUsuario=97") != null)
	{
		validacion_Groupon();
	}
	else if (window.location.href.match("TipoUsuario=98") != null)
	{
		validacion_leadBant();
	}
	else if (window.location.href.match("TipoUsuario=99") != null)
	{
		validacion_leads();
	}
	else
	{
		var boton = window.document.getElementById('enviar');
		var x;
		var obli;
		var myType;
		var SiLegales=false;   // El option de legales no figura como obligatorio, y debe ser obligatorio, por lo que se incorpora esta variable
		var valorEnviar = boton.onclick;
		boton.onclick = "";
		if(window.document.f1.Country)
		{		
			if(window.document.f1.Country.options[window.document.f1.Country.selectedIndex].value == "|")
			{
				//alert('Entro segundo If');
				if(idioma==1) alert("Por favor, rellene todos los campos obligatorios");
				else alert("Please fill all mandatory fields");	
				boton.onclick=valorEnviar;
				return false;
			}
		}	 
		
		//Bucle que comprueba si están rellenos los campos obligatorios
		for (x=0;x!=document.f1.length;x++)
		{	
			if (document.f1.elements[x])
			{
				if (!(document.f1.elements[x].disabled)){ //compruebo que el campo no este desactivado
					if ((document.f1.elements[x].type!="hidden") && (document.f1.elements[x].type!= null))
					{		
						// El option de legales no figura como obligatorio, y debe ser obligatorio, por lo que se incorpora
						// una excepción a este caso
						if (document.f1.elements[x].name == "Radio_1"){
						   if (document.f1.elements[x].checked == false){ 
								if (SiLegales == true){
									if(idioma==1) 
										alert("Por favor, especifique si desea recibir información promocional de Panda, marcando la opción deseada.");
									else 
										alert("Please specify whether you would like to receive marketing information from Panda Software by selecting the corresponding option.");	
									document.f1.elements[x].focus();
									boton.onclick=valorEnviar;
									return false;
								 }
								SiLegales = true;
							} 
							else 
								SiLegales = false;						 
						}

						
						if (navigator.userAgent.indexOf("Netscape6")!= -1 || navigator.userAgent.indexOf("Firefox")){
							obli=document.f1.elements[x].getAttribute("obligar");
							msg=document.f1.elements[x].getAttribute("msg");
						}
						else{
							obli=document.f1.elements[x].obligar;
							msg=document.f1.elements[x].msg;
						}

						myType = document.f1.elements[x].type;
						myType = myType.toLowerCase();
						if (myType=="text" || myType=="textarea")
						{
							if (!Campo_blanco2(document.f1.elements[x].value, document.f1.elements[x].name, obli, msg) )
							{ 
								document.f1.elements[x].focus();
								boton.onclick=valorEnviar;
								return false;
							}
						}
						else{
							if ((myType=="select-one" || myType=="select") && !(document.f1.elements[x].disabled))
							{
								if (!Campo_blanco2(window.document.f1.elements[x].options[window.document.f1.elements[x].selectedIndex].value,
									document.f1.elements[x].name, obli, msg))
								{
									document.f1.elements[x].focus();
									boton.onclick=valorEnviar;
									return false;
								}
							}
						} //fin del else
					}// fin del if
				}
			} // Fin del if disabled
		}// fin del for
		
		if (window.document.f1.Enterprise_Or_Home_User)
		{
			if ((window.document.f1.Enterprise_Or_Home_User.options[window.document.f1.Enterprise_Or_Home_User.selectedIndex].value.toLowerCase() == "home user") || (window.document.f1.Enterprise_Or_Home_User.options[window.document.f1.Enterprise_Or_Home_User.selectedIndex].value.toLowerCase() == "particular"))
			{
				if (window.document.f1.Number_Of_PC!=null)
				window.document.f1.Number_Of_PC.disabled=false;
			}
		}
		// Control sobre el formulario de suscripción y ENVIO				
		//ref = "<%=Request.QueryString["Ref"]%>";	
		ref=queryString("Ref");
		
		controlSuscripcion(boton,valorEnviar);
	}						
} // fin de la funcion


function PageQuery(q) {
	
	if(q.length > 1)
		this.q = q.substring(1, q.length);
	else
		this.q = null;

	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}

	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

