//<wls_task.parche> (i)
function ferSubmitRecordarActivacion()
{
	codUsuario = trim(document.forms["IdentifClienteClubServiCaixa"].elements["codUsuario"].value);

	if (codUsuario.length<1)
	{
		alert(mensaje_usuario_obligatorio);
		return (false);	
	}

	document.forms["IdentifClienteClubServiCaixa"].submit();	
}
//<wls_task.parche> (f)

function ferSubmitIdentif(esVendaTelefonica)
{ 
	if (validarDatosIdentif(esVendaTelefonica))
	{
	     document.forms["IdentifClienteClubServiCaixa"].elements["codOperacion"].value = "Identificacion";
	     document.forms["IdentifClienteClubServiCaixa"].submit();
	}
	/* EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 -->*/
	if(navigator.userAgent.indexOf("Firefox/3") != -1)
		location.reload(true);
	/* <-- EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 */
}

function ferSubmitActivacion(esVendaTelefonica)
{
	if (validarDatosActivacion(esVendaTelefonica))
	{
	     document.forms["IdentifClienteClubServiCaixa"].elements["codOperacion"].value = "Activacion";
	     document.forms["IdentifClienteClubServiCaixa"].submit();
	}
}

function desconectar(pConfirmar)
{
	/*JT (29/1/2009) 2008-00758 Adaptacions Firefox 3*/
	if(pConfirmar != 'undefined' && pConfirmar)
	{
	/*FI JT (29/1/2009) 2008-00758 Adaptacions Firefox 3*/
		if(!confirm(mensaje_confirmar_salida_club))
		{			
			/*EGG:20090508:Bug Firefox*/
				/* EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 -->*/
				/*if(navigator.userAgent.indexOf("Firefox/3") != -1)*/
					/*location.reload(true);*/
				/*  <-- EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 */
			/*FEGG:20090508:Bug Firefox*/
			return false;
		}
	}
	
	document.forms["IdentifClienteClubServiCaixa"].elements["codOperacion"].value = "Desconexion";
	document.forms["IdentifClienteClubServiCaixa"].submit();
	   
	   		/*EGG:20090508:Bug Firefox*/   
		  	/* EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 -->*/
			/*  if(navigator.userAgent.indexOf("Firefox/3") != -1)*/
			 /*location.reload(true);*/
		  	/* <-- EDR - 16/10/2008 - Forçar refresc de la pàgina. Per versions anteriors a Firefox 3.0.3 */
	  		/*FEGG:20090508:Bug Firefox*/
	}
		

function validarDatosIdentif(esVendaTelefonica)
{	
	codUsuario = trim(document.forms["IdentifClienteClubServiCaixa"].elements["codUsuario"].value);
	if(esVendaTelefonica == "SI")
	{
			nif = trim(document.forms["IdentifClienteClubServiCaixa"].elements["nif"].value);			
	}
	else
	{
		 password = trim(document.forms["IdentifClienteClubServiCaixa"].elements["password"].value);
	}
	
	/******* VALIDACIONES DE CAMPOS INFORMADOS *******/	
	
	if (codUsuario.length<1)
	{
		alert(mensaje_usuario_obligatorio);
		return (false);	
	}

	/******* VALIDACIONES DE FORMATO DE CAMPOS *******/	
	if (!isEmail(codUsuario))
	{
		alert(mensaje_usuario_correo_electronico_incorrecto);
		return (false);	
	}

	if(esVendaTelefonica == "SI")
	{
				if (nif.length > 0)
				{
					if(esFormatoNIF(nif))
					{
						//formato de NIF, validamos letra
						if(!validarLetraFinal(nif))
						{
						 	alert(mensaje_nif_incorrecto);
							return (false);
						}
					}
					else if(esFormatoTarjetaResidente(nif))
					{
						//formato de Tarjeta Residente (NIE), validamos letra
						if(!validarLetraFinal(nif))
						{
						 	alert(mensaje_nif_incorrecto);
							return (false);
						}
					}
					else
					{
						//cualquier otro formato (pasaporte): lo consideramos correcto
					}	
					//ANM, 21-06-2005: se envía el texto en mayúsculas
					document.forms["IdentifClienteClubServiCaixa"].elements["nif"].value = nif.toUpperCase();
					//alert(document.forms["IdentifClienteClubServiCaixa"].elements["nif"].value);
				}
				else
				{
					 alert(mensaje_nif_obligatorio);
					 return (false);
				}				
	}
	else
	{
			if (password.length<1)
			{
				alert(mensaje_password_obligatorio);
				return (false);		
			}
			
			if (password.length<6 || password.length>8)
			{
				alert(mensaje_password_long_incorrecta);
				return (false);		
			}
			
			//ANM, 04-07-2005: validación codigo de seguridad, en caso de estar activado
			if(bln_codigo_activado)
			{
				codigo = document.forms["IdentifClienteClubServiCaixa"].elements["codiSeguretat"].value;
				
				if(trim(codigo) == "")
				{
					alert(mensaje_codigo_seguridad_obligatorio);
					return (false);
				}
			}
			//FIN ANM 04-07-2005
	}
	
	return true;
}

function validarDatosActivacion(esVendaTelefonica)
{	

	codUsuario = trim(document.forms["IdentifClienteClubServiCaixa"].elements["codUsuario"].value);

	if(esVendaTelefonica == "SI")
	{
			//nif = trim(document.forms["IdentifClienteClubServiCaixa"].elements["nif"].value);			
	}
	else
	{
		 //password = trim(document.forms["IdentifClienteClubServiCaixa"].elements["password"].value);
		 clave = trim(document.forms["IdentifClienteClubServiCaixa"].elements["claveActivacion"].value);
	}

	/******* VALIDACIONES DE CAMPOS INFORMADOS *******/	
	
	if (codUsuario.length<1)
	{
		alert(mensaje_usuario_obligatorio);
		return (false);	
	}

	/******* VALIDACIONES DE FORMATO DE CAMPOS *******/	
	if (!isEmail(codUsuario))
	{
		alert(mensaje_usuario_correo_electronico_incorrecto);
		return (false);	
	}

	if(esVendaTelefonica == "SI")
	{
//				if (nif.length > 0)
//				{
//					if(esFormatoNIF(nif))
//					{
//						//formato de NIF, validamos letra
//						if(!validarLetraFinal(nif))
//						{
//						 	alert(mensaje_nif_incorrecto);
//							return (false);
//						}
//					}
//					else if(esFormatoTarjetaResidente(nif))
//					{
//						//formato de Tarjeta Residente (NIE), validamos letra
//						if(!validarLetraFinal(nif))
//						{
//						 	alert(mensaje_nif_incorrecto);
//							return (false);
//						}
//					}
//					else
//					{
//						//cualquier otro formato (pasaporte): lo consideramos correcto
//					}	
//				}
//				else
//				{
//					 alert(mensaje_nif_obligatorio);
//					 return (false);
//				}				
	}
	else
	{
//			if (password.length<1)
//			{
//				alert(mensaje_password_obligatorio);
//				return (false);		
//			}
//			
//			if (password.length<6 || password.length>8)
//			{
//				alert(mensaje_password_long_incorrecta);
//				return (false);		
//			}
			
			if (clave.length<1)
			{
				alert(mensaje_clave_activacion_obligatorio);
				return (false);		
			}
			
			if (clave.length<20 || clave.length>20)
			{
				alert(mensaje_clave_activacion_long_incorrecta);
				return (false);		
			}
	}
	
	return true;
}


function invocarURL(locationURL)
{
// javi rincon 25-11-2005 --> error: la funcion "trim()" no existe en javascript
//	codUsuario = trim(document.IdentifClienteClubServiCaixa.codUsuario.value);
	codUsuario = document.IdentifClienteClubServiCaixa.codUsuario.value.replace(/^\s*|\s*$/g,"");
// <- javi rincon: fin cambios
	if (!codUsuario.length < 1)
	{
		locationURL = locationURL + "&codUsuario=" + codUsuario;	
	}

	document.location = locationURL;

}

function invocarURLNormal(locationURL)
{
	document.location = locationURL;
}
