function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  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 validRequired(formField,fieldLabel)
{
	var result = true;

	if (formField.value == "")
	{
		alert('Debe ingresar sus datos en el campo "' + fieldLabel +'".');
		formField.focus();
		result = false;
	}
	
	return result;
}

function validRequiredUsuario(formField,fieldLabel)
{
var campo_valor=formField.value

if (campo_valor == "")
	{
		alert('Debe ingresar sus datos en el campo "' + fieldLabel +'".');
		formField.focus();
		return false
	}
else
	{
	  var ubicacion
	  var enter = "\r\n"
	  var caracteres = "abcdefghijklmnopqrstuvwxyzñ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZÑ_" + String.fromCharCode(13) + enter
	
	if (campo_valor.length<6)
		{
		alert("ERROR: El campo " + fieldLabel + " debe contener al menos 6 carácteres.")
		formField.focus();
		return false;
		}

	  var contador = 0
	  for (var i=0; i < campo_valor.length; i++)
	  	{
		    ubicacion = campo_valor.charAt(i)
		    if (caracteres.indexOf(ubicacion) != -1)
		    	contador++
		    else
		    	{
		      	alert("ERROR: Has utilizado carácteres no permitidos   (' " + ubicacion + " ')   para el campo "+fieldLabel+"\nRecuerda que sólo se permiten letras, números y el guión bajo de separación  _   sin espacios, ni acentos.")
		      	formField.focus();
		      	return false
		    	}
	  	}
	}
		
return true;
}

function validRequiredNick(formField,fieldLabel)
{
var campo_valor=formField.value
if (campo_valor == "")
	{
		alert('Debe ingresar sus datos en el campo "' + fieldLabel +'".');
		formField.focus();
		return false
	}
else if (campo_valor.length<6)
		{
		alert("ERROR: El campo " + fieldLabel + " debe contener al menos 6 carácteres.")
		formField.focus();
		return false;
		}
	
return true;
}


function allDigits(str)
{
	return inValidCharSet(str,"0123456789-");
}

function inValidCharSet(str,charset)
{
	var result = true;

	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("La dirección de email no es correcta. Debe de ser del tipo: usuario@dominio.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('El campo "' + fieldLabel +'" debe ser una fecha del tipo dd-mm-aaaa.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value,10);
 		if (isNaN(num))
 		{
			alert('El campo "' + fieldLabel +'" debe ser un número.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function registrar_submit(theForm)
{
var theForm=document.getElementById("creator");
	if (!validRequiredUsuario(theForm.user,"Usuario",true))
		return false;

	if (!validRequiredNick(theForm.nick,"Nick",true))
		return false;

	if (!validEmail(theForm.email,"E-mail",true))
		return false;

	if (!validRequired(theForm.passwrd1,"Contraseña",true))
		return false;

	if (!validRequired(theForm.passwrd2,"Confirmar contraseña",true))
		return false;

	if (theForm.passwrd1.value=="" || theForm.passwrd2.value=="" || theForm.passwrd1.value!=theForm.passwrd2.value)
		{
		alert("La contraseña y la confirmacion de contraseña no coinciden.");
		theForm.passwrd1.value="";
		theForm.passwrd2.value="";
		theForm.passwrd1.focus();
		return false;
		}

//	if (!validRequired(theForm.nombre,"Nombre",true))
//		return false;

	if (!validRequired(theForm.gender,"Sexo",true))
		return false;

	if (theForm.bday1.selectedIndex==0)
		{
		alert("Selecciona tu dia de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday1.focus();
		return false;
		}

	if (theForm.bday2.selectedIndex==0)
		{
		alert("Selecciona tu mes de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday2.focus();
		return false;
		}		

	if (!validNum(theForm.bday3,"Año de Nacimiento",true))
		return false;

	if (theForm.cod_pais.selectedIndex==0)
		{
		alert("Selecciona tu país.");
		theForm.cod_pais.focus();
		return false;
		}
		
	if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
		{
		alert("Introduce tu provincia.");
		theForm.cod_ciudad.focus();
		return false;
		}
	
	if ( theForm.cod_pais.selectedIndex!=1 && theForm.ciudad.value=="" )
		{
		alert("Introduce tu ciudad o población. ");
		theForm.ciudad.focus();
		return false;
		}

//	if (!validRequired(theForm.location,"Ciudad",true))
//		return false;

//	if (!validRequired(theForm.cod_pais,"Pais",true))
//		return false;

//	if (!validRequired(theForm.aficiones,"Aficiones",true))
//		return false;
//
//	if (!validRequired(theForm.ocupacion,"Ocupacion",true))
//		return false;

//	if (!validRequired(theForm.horario,"Horario de conexión.",true))
//		return false;

//	if (!validRequired(theForm.notas,"Notas personales.",true))
//		return false;
//
//	if (!validRequired(theForm.usertext,"Texto personal.",true))
//		return false;

//	if (!validRequired(theForm.signature,"Firma.",true))
//		return false;

theForm.submit();
}

function registrar_submit1(theForm)
{
if (!validRequiredUsuario(theForm.user,"Usuario",true))
	return false;

if (!validRequiredNick(theForm.nick,"Nick",true))
	return false;

if (!validEmail(theForm.email,"E-mail",true))
	return false;

if (!validRequired(theForm.passwrd1,"Contraseña",true))
	return false;

if (!validRequired(theForm.passwrd2,"Confirmar contraseña",true))
	return false;

if (theForm.passwrd1.value=="" || theForm.passwrd2.value=="" || theForm.passwrd1.value!=theForm.passwrd2.value)
	{
	alert("La contraseña y la confirmacion de contraseña no coinciden.");
	theForm.passwrd1.value="";
	theForm.passwrd2.value="";
	theForm.passwrd1.focus();
	return false;
	}

if (theForm.gender.selectedIndex==0)
	{
	alert("Elige tu sexo: ¿Chico o Chica?");
	theForm.gender.focus();
	return false;
	}

if (theForm.bday1.selectedIndex==0)
	{
	alert("Selecciona tu dia de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
	theForm.bday1.focus();
	return false;
	}

if (theForm.bday2.selectedIndex==0)
	{
	alert("Selecciona tu mes de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
	theForm.bday2.focus();
	return false;
	}		

if (!validNum(theForm.bday3,"Año de Nacimiento",true))
	return false;

if (theForm.cod_pais.selectedIndex==0)
	{
	alert("Selecciona tu país.");
	theForm.cod_pais.focus();
	return false;
	}
	
if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
	{
	alert("Introduce tu provincia.");
	theForm.cod_ciudad.focus();
	return false;
	}

if ( theForm.cod_pais.selectedIndex!=1 && theForm.ciudad.value=="" )
	{
	alert("Introduce tu ciudad o población. ");
	theForm.ciudad.focus();
	return false;
	}
	
return true;
}

function registrar_submit2(theForm)
{
var theForm=document.getElementById("creator");

	if (!validRequired(theForm.nombre,"Nombre",true))
		return false;

	if (!validRequired(theForm.gender,"Sexo",true))
		return false;

	if (theForm.bday1.selectedIndex==0)
		{
		alert("Selecciona tu dia de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday1.focus();
		return false;
		}

	if (theForm.bday2.selectedIndex==0)
		{
		alert("Selecciona tu mes de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday2.focus();
		return false;
		}		

	if (!validNum(theForm.bday3,"Año de Nacimiento",true))
		return false;

	if (theForm.cod_pais.selectedIndex==0)
		{
		alert("Selecciona tu país.");
		theForm.cod_pais.focus();
		return false;
		}
		
	if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
		{
		alert("Introduce tu provincia.");
		theForm.cod_ciudad.focus();
		return false;
		}
	
	if ( theForm.cod_pais.selectedIndex!=1 && theForm.ciudad.value=="" )
		{
		alert("Introduce tu ciudad o población. ");
		theForm.ciudad.focus();
		return false;
		}

//	if (!validRequired(theForm.location,"Ciudad",true))
//		return false;

//	if (!validRequired(theForm.cod_pais,"Pais",true))
//		return false;

	if (!validRequired(theForm.aficiones,"Aficiones",true))
		return false;

	if (!validRequired(theForm.horario,"Horario de conexión.",true))
		return false;

	if (!validRequired(theForm.notas,"Notas personales.",true))
		return false;

//	if (!validRequired(theForm.usertext,"Texto personal.",true))
//		return false;

//	if (!validRequired(theForm.signature,"Firma.",true))
//		return false;

// Esto para correo direct
//return true;
theForm.submit();
}

function registrar_submit2_correo_direct(theForm)
{
var theForm=document.getElementById("creator");
return registrar_submit1(theForm);

	if (!validRequired(theForm.nombre,"Nombre",true))
		return false;

	if (!validRequired(theForm.gender,"Sexo",true))
		return false;

	if (theForm.bday1.selectedIndex==0)
		{
		alert("Selecciona tu dia de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday1.focus();
		return false;
		}

	if (theForm.bday2.selectedIndex==0)
		{
		alert("Selecciona tu mes de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday2.focus();
		return false;
		}		

	if (!validNum(theForm.bday3,"Año de Nacimiento",true))
		return false;

	if (theForm.cod_pais.selectedIndex==0)
		{
		alert("Selecciona tu país.");
		theForm.cod_pais.focus();
		return false;
		}
		
	if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
		{
		alert("Introduce tu provincia.");
		theForm.cod_ciudad.focus();
		return false;
		}
	
	if ( theForm.cod_pais.selectedIndex!=1 && theForm.ciudad.value=="" )
		{
		alert("Introduce tu ciudad o población. ");
		theForm.ciudad.focus();
		return false;
		}

//	if (!validRequired(theForm.location,"Ciudad",true))
//		return false;

//	if (!validRequired(theForm.cod_pais,"Pais",true))
//		return false;

//	if (!validRequired(theForm.aficiones,"Aficiones",true))
//		return false;

//	if (!validRequired(theForm.ocupacion,"Ocupacion",true))
//		return false;

//	if (!validRequired(theForm.horario,"Horario de conexión.",true))
//		return false;

//	if (!validRequired(theForm.notas,"Notas personales.",true))
//		return false;

//	if (!validRequired(theForm.usertext,"Texto personal.",true))
//		return false;

//	if (!validRequired(theForm.signature,"Firma.",true))
//		return false;

// Esto para correo direct
return true;
theForm.submit();
}

function validar1(theForm)
{
	if (!validRequired(theForm.oldpasswrd,"Contraseña",true))
		return false;

	if (!validRequired(theForm.nick,"Nick o Alias",true))
		return false;

	if (!validEmail(theForm.email,"E-mail",true))
		return false;

	if (!validRequired(theForm.nombre,"Nombre",true))
		return false;

//	if (!validRequired(theForm.apellidos,"Apellidos",true))
//		return false;

	if (!validRequired(theForm.gender,"Sexo",true))
		return false;

	if (theForm.bday1.selectedIndex==0)
		{
		alert("Selecciona tu dia de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday1.focus();
		return false;
		}

	if (theForm.bday2.selectedIndex==0)
		{
		alert("Selecciona tu mes de nacimiento, para que los usuarios puedan saber tu edad y tu cumpleaños :)");
		theForm.bday2.focus();
		return false;
		}

	if (!validNum(theForm.bday3,"Año de Nacimiento",true))
		return false;

	if (theForm.cod_pais.selectedIndex==0)
		{
		alert("Selecciona tu país.");
		theForm.cod_pais.focus();
		return false;
		}
		
	if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
		{
		alert("Introduce tu provincia.");
		theForm.cod_ciudad.focus();
		return false;
		}
	
	if ( theForm.cod_pais.selectedIndex!=1 && theForm.ciudad.value=="" )
		{
		alert("Introduce tu ciudad o población.");
		theForm.ciudad.focus();
		return false;
		}

//	if (!validRequired(theForm.location,"Ciudad",true))
//		return false;

//	if (!validRequired(theForm.cod_pais,"Pais",true))
//		return false;

	if (!validRequired(theForm.aficiones,"Aficiones",true))
		return false;

	if (!validRequired(theForm.ocupacion,"Ocupacion",true))
		return false;

	if (!validRequired(theForm.horario,"Horario de conexión.",true))
		return false;

	if (!validRequired(theForm.notas,"Notas personales.",true))
		return false;

	if (!validRequired(theForm.usertext,"Texto personal.",true))
		return false;

	if (!validRequired(theForm.signature,"Firma.",true))
		return false;

	return true;
}

function submit_comprar(theForm)
{

if (!theForm.frm_forma_pago.value=="g" && [1].checked)
	{
	if (!valida_tpv(theForm))
		return false;
	}

if (!validRequired(theForm.frm_nombre,"Nombre",true))
	return false;
	
if (!validRequired(theForm.frm_apellidos,"Apellidos",true))
	return false;

//if (!validRequired(theForm.frm_nick,"Nick para camiseta",true))
//	return false;

if (!validRequired(theForm.frm_edad,"Edad",true))
	return false;

if (theForm.frm_talla_camiseta.selectedIndex==0)
	{
	alert("Selecciona tu talla de camiseta.");
	theForm.frm_talla_camiseta.focus();
	return false;
	}

if (!validRequired(theForm.frm_telefono,"Teléfono fijo",true))
	return false;

if (!validRequired(theForm.frm_telefono_movil,"Teléfono móvil",true))
	return false;
		
if (!validEmail(theForm.frm_email,"E-mail",true))
	return false;

if (!validRequired(theForm.frm_direccion,"Direccíon",true))
	return false;

if (!validRequired(theForm.frm_codigo_postal,"Código postal",true))
	return false;

if (theForm.cod_pais.selectedIndex==0)
	{
	alert("Selecciona tu país.");
	theForm.cod_pais.focus();
	return false;
	}
		
if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex==0)
	{
	alert("Introduce tu provincia.");
	theForm.cod_ciudad.focus();
	return false;
	}

if (theForm.cod_pais.selectedIndex==1 && theForm.cod_ciudad.selectedIndex!=0 && theForm.frm_ciudad.value=="")
	{
	alert("Introduce tu ciudad.");
	theForm.frm_ciudad.focus();
	return false;
	}
	
if ( theForm.cod_pais.selectedIndex!=1 && theForm.frm_ciudad.value=="" )
	{
	alert("Introduce tu ciudad o población.");
	theForm.frm_ciudad.focus();
	return false;
	}

theForm.submit();
}

function submit_tpv_vip(theForm)
{
var bsubmit=document.getElementById("boton_submit");
bsubmit.disabled=true;

if (!validRequired(theForm.frm_email,"Email",true))
	{
	bsubmit.disabled=false;
	return false;
	}

if (!valida_tpv(theForm))
	{
	bsubmit.disabled=false;
	return false;
	}

theForm.submit();
}

function valida_tpv(theForm)
{

	if (!validRequired(theForm.frm_titulart,"Titular de la tarjeta",true))
		return false;
	
	if (!validRequired(theForm.frm_numt,"Número de la tarjeta",true))
		return false;

	if (!validRequired(theForm.frm_cvvt,"Número CVV",true))
		return false;

	if (theForm.frm_mest.selectedIndex==0 || theForm.frm_anyot.selectedIndex==0)
		{
		alert("Selecciona la fecha de caducidad de la tarjeta.");
		if (theForm.frm_mest.selectedIndex==0)
			theForm.frm_mest.focus();
		else
			theForm.frm_anyot.focus();
		return false;
		}

return true;
}

function sms_board_submit(theForm)
{
if (!validRequired(theForm.texto,"Texto del mensaje",true))
	return false;

if (!theForm.clave_sms.value)
	{
	alert("Para poder insertar tu mensaje en el SMS BOARD\ndebes enviar un mensaje con tu telefono móvil/celular\npara conseguir tu CLAVE SMS.\n\nEnvía la palabra GENTEYA SB al número 7372 y recibirás tu clave en pocos segundos.");
	theForm.clave_sms.focus();
	return false;
	}

theForm.submit();
}

function validateForm_historias(theForm)
{
	if (!validRequired(theForm.elnick,"Nick"))
		return false;

	if (!validRequired(theForm.titulo,"Titulo",true))
		return false;

	if (!validRequired(theForm.historia,"Historia"))
		return false;

	return true;
}

function valida_upload(form_tmp)
{
if (form_tmp.file.value=="" )
	return error("Debes seleccionar la foto que quieres poner.",form_tmp.file);

if (!advertir_foto())
	return error("Gracias por colaborar :D",form_tmp.file);

//form_tmp.boton_submit.disabled=true;
if (form_tmp.name=="upload_foro")
	document.getElementById("foto_foro").src=load_img.src;
else
	document.getElementById("foto_genteya").src=load_img.src;

//form_tmp.txt_esperar.innerHTML='<font size=2 face=arial color=blue><b>Subiendo foto, por favor, espera unos segundos...<br>Nota: el tiempo variara de unos segundos a unos minutos, dependiendo del tamaño de la fotografía.</b></font><br>&nbsp;';
// document.getElementById('frm_subir_foto').submit();
return true;
if (d.frm_subir_foto)
	d.frm_subir_foto.submit();
else
	d.submit();
}

function valida_upload_index()
{
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
	var d=document.all;
else 
	var d=document.forms.namedItem("frm_subir_foto");

if (d.file.value=="" )
	return error("Debes seleccionar la foto que quieres poner.",d.file);

if (!advertir_foto())
	return error("Gracias por colaborar :D",d.file);
	
document.getElementById('boton_submit').disabled=true;
document.getElementById('txt_esperar').innerHTML='<font size=2 face=arial color=blue><b>Subiendo foto, por favor, espera unos segundos...<br>Nota: el tiempo variara de unos segundos a unos minutos, dependiendo del tamaño de la fotografía.</b></font><br>&nbsp;';
// document.getElementById('frm_subir_foto').submit();
if (d.frm_subir_foto)
	d.frm_subir_foto.submit();
else
	d.submit();
}

function valida_upload_grupos(form_tmp,id_img)
{
if (form_tmp.file.value=="" )
	return error("Debes seleccionar la foto que quieres poner.",form_tmp.file);

if (form_tmp.modo_upload.value=="foto_grupo_top")
	document.getElementById(id_img).src=load_img.src;
else
	document.getElementById(id_img).src=load_img1.src;

return true;
}

function valida_upload_camiseta()
{
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
	var d=document.all;
else 
	var d=document.forms.namedItem("frm_subir_foto_camisetas");

if (d.file.value=="" )
	return error("Debes seleccionar la foto que quieres poner.",d.file);

if (!advertir_foto())
	return error("Gracias por colaborar :D",d.file);
	
document.getElementById('boton_submit').disabled=true;
document.getElementById('txt_esperar').innerHTML='<font size=2 face=arial color=blue><b>Subiendo foto, por favor, espera unos segundos...<br>Nota: el tiempo variara de unos segundos a unos minutos, dependiendo del tamaño de la fotografía.</b></font><br>&nbsp;';
// document.getElementById('frm_subir_foto').submit();
if (d.frm_subir_foto_camisetas)
	d.frm_subir_foto_camisetas.submit();
else
	d.submit();
}

function valida_enviar_msg()
{
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
	var d=document.all;
else 
	var d=document.forms.namedItem("frm_msg");

if (d.termcond)
	{
	if (!d.termcond.checked)
		return error("Debes aceptar los terminos y condiciones.",d.termcond);
	if (d.fromname.value=="")
		return error("Debes poner tu nick o alias para enviar el mensaje.",d.fromname);
	if (!validEmail(d.email,"E-mail",true))
		return false;
	}

if (d.asunto.value=="")
	return error("Debes identificar tu mensaje con un asunto.",d.asunto);

if (d.cuerpo.value=="")
	return error("Debes escribir algo en el mensaje.",d.cuerpo);

if (d.frm_msg)
	d.frm_msg.submit();
else
	d.submit();
}

function valida_enviar_msg_reply()
{
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
	var d=document.all;
else 
	var d=document.forms.namedItem("frm_msg");

if (d.asunto.value=="")
	return error("Debes identificar tu mensaje con un asunto.",d.asunto);

if (d.cuerpo.value=="")
	return error("Debes escribir algo en el mensaje.",d.cuerpo);

if (d.frm_msg)
	d.frm_msg.submit();
else
	d.submit();
}

function valida_invitacion()
{
var navegador = navigator.appName 
if (navegador == "Microsoft Internet Explorer") 
	var d=document.all;
else 
	var d=document.forms.namedItem("frm_invitar");

if (d.email.value=="")
	return error("Debes introducir una direccion de email.",d.email);

if (!isEmailAddr(d.email.value))
	return error("Debes introducir una direccion de email válida.",d.email);	

if (d.nombre.value=="")
	return error("Introduce el nombre de tu amig@",d.nombre);

if (d.invitacion_txt.value=="")
	return error("Introduce el texto de invitacion para convencer a tu amigo de que se una a nosotros :D",d.invitacion_txt);

if (d.frm_invitar)
	d.frm_invitar.submit();
else
	d.submit();
}

function valida_invitacion_msn(form)
{
var d=document.getElementById("frm_invitar_msn");

if (d.msn.value=="")
	return error("Debes introducir tu dirección de MSN Messenger.",d.msn);

if (d.password_msn.value=="")
	return error("Debes introducir tu dirección contraseña de MSN Messenger.\n\nRecuerda que tu contraseña no será guardada en ningun momento,\n y será utilizada únicamente una vez en el proceso de invitación :)",d.password_msn);

if (!isEmailAddr(d.msn.value))
	return error("Tu dirección de MSN Messenger NO es válida, inténtalo de nuevo.",d.msn);	

if (d.frm_invitar)
	{
	open_invitacion_msn();
	return true;
	//d.frm_invitar_msn.submit();
	}
else
	return true;
	//d.submit();
}

function validar_recordatorio(frecordatorio)
{
if (frecordatorio.pass1.value=="")
	return error("Debes introducir la nueva contraseña elegida por ti.",frecordatorio.pass1);
	
if (frecordatorio.pass1.value!=frecordatorio.pass2.value)
	return error("Las contraseñas introducidas no coinciden.",frecordatorio.pass1);

if (!validRequired(frecordatorio.pass1,"Contraseña",true))
	return false;
		
if (frecordatorio.pass1.value.toLowerCase()!=frecordatorio.pass1.value)
	return error("La contraseña no debe contener letras mayúsculas.\n\nQuizás tengas la tecla Bloq.Mayús. o Bloq.Mays pulsada y todas tus letras se escriban en mayúsculas\n de forma automática. Púlsala de nuevo para desactivarla si este es el caso.",frecordatorio.pass1);

}

function error($msg,obj)
{
alert($msg);
obj.focus();
return false;
}

function advertir_foto()
{
if (confirm('MUY IMPORTANTE!: Informamos de que el uso de este portal web para insultar, difamar o injuriar, utilizando fotografias ajenas, está fuertemente penado por la ley. Si se informa sobre estos hechos o son detectado por nuestros administradores, se dará parte a las autoridades.\n\nPulse en Aceptar si la fotografía que va a subir es de su persona y cumple las normas. De lo contrario, pulse en CANCELAR.\n\nTrabajamos para crear el mejor ambiente posible en GenteYA\nGracias por colaborar :D '))
	return true;
else
	return false;
}

function reload_foto_tn(id, foto)
{
if (opener)
	ventana=opener
else
	ventana=window

ventana.document.getElementById("fotoimg150_"+id).src=foto;

}

function reload_foto_grupos_tn(id_grupo, modo, foto)
{
if (opener)
	ventana=opener
else
	ventana=window

if (modo=="foto_grupo")
	ventana.document.getElementById("grupo_"+id_grupo).src=foto;
else if (modo=="foto_grupo_top")
	ventana.document.getElementById("id_cabecera_grupo").src=foto;
else
	alert("Ha ocurrido un error de parametros. Informe al webmaster en webmaster@genteya.com");
}



function validar_form_encuesta(frm)
{
var pulsado=false;
for (var x = 0; x < frm.frm_fecha_enc.length; x++) if (frm.frm_fecha_enc[x].checked ) pulsado=true;
if (!pulsado)
	{
	alert("Indica qué te parece la fecha.");
	return false;
	}

var pulsado=false;
for (var x = 0; x < frm.frm_lugar_enc.length; x++) if (frm.frm_lugar_enc[x].checked ) pulsado=true;
if (!pulsado)
	{
	alert("Indica qué te parece el lugar.");
	return false;
	}

var pulsado=false;
for (var x = 0; x < frm.frm_precio_enc.length; x++) if (frm.frm_precio_enc[x].checked ) pulsado=true;
if (!pulsado)
	{
	alert("Indica qué te parece el precio.");
	return false;
	}

return true;
}

function validar_reserva_fiesta(obj)
{
if (!validRequired(obj.frm_nombre,"Nombre",true))
	return false;

if (!validRequired(obj.frm_apellidos,"Apellidos",true))
	return false;

if (!validRequired(obj.frm_dni,"Dni",true))
	return false;

obj.frm_dni.value=str_replace(" ", "", obj.frm_dni.value)
obj.frm_dni.value=str_replace("-", "", obj.frm_dni.value)
if (!check_nif(obj.frm_dni.value))
	{
	alert("Su DNI "+obj.frm_dni.value+" no es correcto, no olvide inclur la letra final, sin espacions ni guiones");
	return false;
	}


if (!validRequired(obj.frm_telefono_movil,"Teléfono Móvil",true))
	return false;

if (obj.frm_num_invitados_chicos.selectedIndex==0)
	{
	alert("Selecciona el numero de chicos invitados que llevaras contigo a la fiesta.");
	obj.frm_num_invitados_chicos.focus();
	return false;
	}

if (obj.frm_num_invitados_chicas.selectedIndex==0)
	{
	alert("Selecciona el numero de chicas invitados que llevaras contigo a la fiesta.");
	obj.frm_num_invitados_chicas.focus();
	return false;
	}

if (!obj.frm_terminos.checked)
	{
	alert("Debes aceptar los términos y condiciones de la fiesta.");
	obj.frm_terminos.focus();
	return false;
	}

return true;
}

function validar_conf_reserva_fiesta(obj)
{
if (obj.frm_num_invitados_chicos.selectedIndex==0)
	{
	alert("Selecciona el numero de chicos invitados que llevaras contigo a la fiesta.");
	obj.frm_num_invitados_chicos.focus();
	return false;
	}

if (obj.frm_num_invitados_chicas.selectedIndex==0)
	{
	alert("Selecciona el numero de chicas invitados que llevaras contigo a la fiesta.");
	obj.frm_num_invitados_chicas.focus();
	return false;
	}

if (!obj.frm_terminos.checked)
	{
	alert("Debes aceptar los términos y condiciones de la fiesta.");
	obj.frm_terminos.focus();
	return false;
	}

return true;
}

function check_nif(nif)
{
var dni=nif.substr(0,nif.length-1);
var nif=nif.charAt(nif.length-1);
nif=nif.toUpperCase();
var cadena = 'TRWAGMYFPDXBNJZSQVHLCKET';
var posicion = dni % 23;
if (cadena.charAt(posicion)!=nif)
	return false;
else
	return true;
}

function valida_movil(obj)
{
if (!validRequired(obj.frm_movil,"Teléfono Móvil",true))
	return false;

if (!validRequired(obj.frm_movil_validar,"Repite tu móvil",true))
	return false;

if (obj.frm_movil.value.length!=9)
	{
	alert("El teléfono móvil indicado no es válido. Por favor, revíselo.");
	return false;
	}

if (obj.frm_movil_validar.value!=obj.frm_movil.value)
	{
	alert("Tu numero de teléfono móvil y la validación de tu número no coindicen.");
	return false;
	}

if (!obj.frm_terminos.checked)
	{
	alert("Debes aceptar los términos y condiciones del servicio.");
	obj.frm_terminos.focus();
	return false;
	}

if (obj.frm_prefijo[obj.frm_prefijo.selectedIndex].value=="0")
	{
	alert("Selecciona el prefijo de tu país.");
	obj.frm_prefijo.focus();
	return false;
	}

return true;
}

function validar_reclamar_sms(obj)
{
if (!validRequired(obj.frm_movil,"Teléfono Móvil",true))
	return false;

if (obj.frm_movil.value.length!=9)
	{
	alert("El teléfono móvil indicado no es válido. No incluya guiones ni espacios, solo numeros de 9 dígitos. Por favor, revíselo.");
	return false;
	}

if (!is_numeric(obj.frm_movil.value))
	{
	alert("No use espacios ni guiones en su número de telefono. Introduzca solo números.");
	return false;
	}

if (obj.frm_dia.selectedIndex==0)
	{
	alert("Selecciona el día aproximado de envío del SMS.");
	obj.frm_dia.focus();
	return false;
	}

if (obj.frm_mes.selectedIndex==0)
	{
	alert("Selecciona el mes aproximado de envío del SMS.");
	obj.frm_mes.focus();
	return false;
	}

if (obj.frm_anyo.selectedIndex==0)
	{
	alert("Selecciona el año aproximado de envío del SMS.");
	obj.frm_anyo.focus();
	return false;
	}

if (obj.frm_hora.selectedIndex==0)
	{
	alert("Selecciona la hora aproximada de envío del SMS.");
	obj.frm_hora.focus();
	return false;
	}

if (obj.frm_minuto.selectedIndex==0)
	{
	alert("Selecciona el minuto aproximado de envío del SMS.");
	obj.frm_minuto.focus();
	return false;
	}

if (obj.frm_dia.selectedIndex==0)
	{
	alert("Selecciona el día aproximado de envío del SMS.");
	obj.frm_dia.focus();
	return false;
	}

if (obj.frm_observaciones.value=="")
	{
	alert("Indique las observaciones oportunas sobre el envio de su SMS.");
	return false;
	}


return true;
}

function validar_crear_grupo(theForm)
{

if (!validRequiredUsuario(theForm.nombre_grupo,"Nombre del grupo",true))
	return false;

if (!validRequired(theForm.descripcion,"Descripción",true))
	return false;

if ( theForm.descripcion.value.length<25)
	{
	alert("ERROR: La descripción debe tener al menos 25 carácteres.");
	return false;
	}
return true;
}

function valida_bajas(obj)
{
if (!validRequired(obj.frm_email,"Email",true))
	return false;

var motivo=document.getElementById("feedback").value;

if (motivo=="")
	{
	alert("Ayúdanos a mejorar, por favor indícanos el motivo por el que solicitas la bajas ;)");
	return false;
	}

obj.motivo_baja.value=motivo;
//document.getElementById("form_bajas_gris").motivo_baja.value=motivo;
//document.getElementById("form_bajas").motivo_baja.value=motivo;

return true;
}

function valida_bajas_movil(obj)
{
if (!validRequired(obj.frm_movil,"Teléfono Móvil",true))
	return false;

return true;
}

function is_numeric(num)
{
var exp = new RegExp("^[0-9-.]*$","g");
return exp.test(num);
}

function show_tarjeta_box()
{
document.getElementById('frm_tarjeta_box').style.height="380px";
document.getElementById('frm_tarjeta_box').style.width="450px";
//document.getElementById('frm_tarjeta_box').style.display='inline';
document.getElementById('frm_tarjeta_box').style.display="";
return;

}

function hide_tarjeta_box()
{
document.getElementById('frm_tarjeta_box').style.height="0px";
document.getElementById('frm_tarjeta_box').style.width="0px";
document.getElementById('frm_tarjeta_box').style.display="none";
//document.getElementById(frm_tarjeta_box).style.visibility="hidden";
//document.getElementById(frm_tarjeta_box).innerHTML="";
}

function validar_form_sorteo_loteria(frm)
{
if (!chk_frm_loteria(frm,"primer",frm.a))
	return false;

if (!chk_frm_loteria(frm,"segundo",frm.b))
	return false;

if (!chk_frm_loteria(frm,"tercero",frm.c))
	return false;

if (!chk_frm_loteria(frm,"cuarto",frm.d))
	return false;

if (!chk_frm_loteria(frm,"quinto",frm.e))
	return false;

return true;
}

function chk_frm_loteria(frm,num,frm_num)
{
if (frm_num.value=="")
	alert("Error: Introduce los 5 números con los que deseas jugar.");
else if (!is_numeric(frm_num.value))
	alert("Error: El valor introducido no es un número.");
else if (frm_num.value>15)
	alert("Error: Los números a introducir han de estar comprendidos entre el 1 y el 15.\nEl "+num+" número es mayor que 15.");
else if (frm_num.value<1)
	alert("Error: Los números a introducir han de estar comprendidos entre el 1 y el 15.\nEl "+num+" número es menor que 1.");
else if (repetido_numero_loteria(frm,frm_num.value))
	alert("Error: No puedes introducir dos números iguales.");
else
	return true;

frm_num.value="";
frm_num.focus();
return false;
}

function repetido_numero_loteria(frm,numero)
{
var repetidos=0;
for (n=0;n<frm.length;n++)
	{
	if (frm[n].value==numero)
		repetidos++;
	if (repetidos==2)
		return true;
	}

return false;
}
