<!--
//Documento JavaScript por Moisés Busanya



//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//Funciones HOMEPAGE
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//

// Función de cambio de fondo dependiendo de la promo

function f_cambia_fondo(v_promo) {
		var v_capa = document.getElementById("fondo");
		var v_fondo = "edge_trailer/edge_trailer_fondo_"+v_promo+".jpg"+ "?id=" + new Date().getTime();
		v_capa.style.backgroundImage = "url(" + v_fondo + ")";
}

// Función de cambio de fondo de menú

function f_menu(v_imagen,v_capa_id) {
		var v_capa = document.getElementById(v_capa_id);
		v_capa.style.backgroundImage = "url(" + v_imagen + ")";
		 if (navigator.appName=="Netscape") {
			v_capa.style.cursor='pointer';
		} else {
			v_capa.style.cursor='hand';
		}
}

// Función de votación por estrellas

function f_estrellas(v_capa_id,v_estrella) {
		var v_capa_1 = document.getElementById(v_capa_id+"_1");
		var v_capa_2 = document.getElementById(v_capa_id+"_2");
		var v_capa_3 = document.getElementById(v_capa_id+"_3");
		var v_capa_4 = document.getElementById(v_capa_id+"_4");
		var v_capa_5 = document.getElementById(v_capa_id+"_5");
		
		v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_3.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_4.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_5.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		
		if (v_estrella==1)
		{
			
			v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
		
		}
		
		if (v_estrella==2)
		{
			
			v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
		
		}
		
		if (v_estrella==3)
		{
			
			v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_3.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
		
		}
		
		if (v_estrella==4)
		{
			
			v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_3.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_4.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
		
		}
		
		if (v_estrella==5)
		{
			
			v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_3.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_4.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
			v_capa_5.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_on.jpg)";
		
		}
}

// Función de votación por estrellas (APAGADO)

function f_estrellas_apaga(v_capa_id) {
		var v_capa_1 = document.getElementById(v_capa_id+"_1");
		var v_capa_2 = document.getElementById(v_capa_id+"_2");
		var v_capa_3 = document.getElementById(v_capa_id+"_3");
		var v_capa_4 = document.getElementById(v_capa_id+"_4");
		var v_capa_5 = document.getElementById(v_capa_id+"_5");
		
		v_capa_1.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_2.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_3.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_4.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
		v_capa_5.style.backgroundImage = "url(edge_public/img_edge/edge_star_user_off.jpg)";
}

// Mostrar ocultar combos registro

function mostrar_ocultar(valor) {
 	document.getElementById('v_provincia_s').style.display="none";
 	document.getElementById('v_provincia_f').style.display="none";
 	document.getElementById('v_provincia_i').style.display="none";
	if (valor.value == "Spain") {
		document.getElementById('v_provincia_s').style.display="block";
	} else {
		if (valor.value == "France") {
			document.getElementById('v_provincia_f').style.display="block";
		} else {
			document.getElementById('v_provincia_i').style.display="block";
		}
	}
}

function mostrar_ocultar_b(valor) {
 	document.getElementById('v_provincia_s_b').style.display="none";
 	document.getElementById('v_provincia_f_b').style.display="none";
 	document.getElementById('v_provincia_i_b').style.display="none";
	if (valor.value == "Spain") {
		document.getElementById('v_provincia_s_b').style.display="block";
	} else {
		if (valor.value == "France") {
			document.getElementById('v_provincia_f_b').style.display="block";
		} else {
			document.getElementById('v_provincia_i_b').style.display="block";
		}
	}
}

// Valida registro

function f_valida_registro() {
 
 	errores="";
	
	var v_reg_edad=document.frm_registro.v_reg_edad.value;
	var v_fecha_js = new Date();
	dia=v_reg_edad.split("/")[0];
	mes=v_reg_edad.split("/")[1];
	anyo=v_reg_edad.split("/")[2];
		
	if (v_reg_edad.length>0) {
		if( (isNaN(dia)==true) || (isNaN(mes)==true) || (isNaN(anyo)==true) )
		{
			errores="La fecha de nacimiento introducida no es correcta.";
			document.getElementById('v_reg_edad').focus();
		}
		if(anyoBisiesto(anyo))
			febrero=29;
		else
			febrero=28;
		
		if ((mes<1) || (mes>12))
		{
			errores= "El mes introducido en la fecha de nacimiento no es valido. Por favor, introduzca un mes correcto.";
			document.getElementById('v_reg_edad').focus();
		}
		
		if ((mes==2) && ((dia<1) || (dia>febrero)))
		{
			errores= "El día introducido en la fecha de nacimiento no es valido. Por favor, introduzca un día correcto.";
			document.getElementById('v_reg_edad').focus();
		}
		
		if (((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && ((dia<1) || (dia>31)))
		{
			errores= "El día introducido en la fecha de nacimiento no es valido. Por favor, introduzca un día correcto.";
			document.getElementById('v_reg_edad').focus();
		
		}
		
		if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && ((dia<1) || (dia>30)))
		{
		errores= "El día introducido en la fecha de nacimiento no es valido. Por favor, introduzca un día correcto.";
		document.getElementById('v_reg_edad').focus();
		
		}
		
		if ((anyo<1900) || (anyo>2020))
		{
		errores= "El año introducido en la fecha de nacimiento no es valido. Por favor, introduzca un año entre 1900 y 2020.";
		document.getElementById('v_reg_edad').focus();
		
		}
		
		if ((v_fecha_js.getFullYear()-anyo)<18)
		{
		errores= "Lo sentimos, pero según tu fecha de nacimiento no eres mayor de edad, y debes serlo para registrarte como Jugador.";
		document.getElementById('v_reg_edad').focus();
		
		}
	}
	   
	if (document.frm_registro.v_reg_clave.value != document.frm_registro.v_reg_clave_2.value){
	
		errores="No coinciden las claves que has escrito.";
		document.getElementById('v_reg_clave').focus();
	
	}
		
	if (document.frm_registro.v_reg_email.value != document.frm_registro.v_reg_email_2.value){
	
		errores="No coinciden las direcciones de correo electrónico que has escrito.";
		document.getElementById('v_reg_email').focus();
		
	}
		
	if (document.frm_registro.v_reg_nickname.value.length<3){
	
		errores="El nombre de jugador debe tener al menos 3 caracteres de longitud.";
		document.getElementById('v_reg_nickname').focus();
		
	}
		
	if (document.frm_registro.v_reg_clave.value.length<6){
	
		errores="La contraseña debe tener al menos 6 caracteres de longitud.";
		document.getElementById('v_reg_clave').focus();
		
	}
	
	if (document.frm_registro.v_provincia_s.value == "0" && document.frm_registro.v_reg_pais.value == "Spain"){
	
		errores="Es obligatorio indicar una provincia.";
		document.getElementById('v_provincia_s').focus();
		
	}
	
	if (document.frm_registro.v_provincia_f.value == "0" && document.frm_registro.v_reg_pais.value == "France"){
	
		errores="Es obligatorio indicar una provincia.";
		document.getElementById('v_provincia_f').focus();
		
	}
		
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (!(filter.test(document.frm_registro.v_reg_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_reg_email').focus();
	}
		
	if (document.frm_registro.v_reg_nickname.value == "" || document.frm_registro.v_reg_clave.value == "" || document.frm_registro.v_reg_clave_2.value == "" || document.frm_registro.v_reg_email.value == "" || document.frm_registro.v_reg_email_2.value == "" || document.frm_registro.v_reg_nombre.value == "" || document.frm_registro.v_reg_apellidos.value == "" || document.frm_registro.v_reg_pais.value == "0" || document.frm_registro.v_reg_seguridad.value == "" || document.frm_registro.v_reg_edad.value == "")
	   errores= "No puedes dejar un campo obligatorio en blanco.";
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

function f_valida_envia_wish() {
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var errores="";

	if (!(filter.test(document.frm_wish.v_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_email').focus();
	}
	
	if (errores=="")
	{
		document.frm_wish.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
}

//Año bisiesto
function anyoBisiesto(anyo)
{
	if (anyo < 100)
	var fin = anyo + 1900;
	else
	var fin = anyo ;
	
	
	if (fin % 4 != 0)
	return false;
	else
	{
	if (fin % 100 == 0)
	{
	
	if (fin % 400 == 0)
	{
	return true;
	}
	
	else
	{
	return false;
	}
	}
	
	else
	{
	return true;
	}
	}
}

// Valida Configuracion perfil

function f_valida_cfg() {
 
 	errores="";
		   
	if (document.frm_registro.v_reg_clave.value != document.frm_registro.v_reg_clave_2.value){
	
		errores="No coinciden las claves que has escrito";
		document.getElementById('v_reg_clave').focus();
	
	}
		
	if (document.frm_registro.v_reg_clave.value.length<6 && document.frm_registro.v_reg_clave_2.value!=""){
	
		errores="La contraseña debe tener al menos 6 caracteres de longitud.";
		document.getElementById('v_reg_clave').focus();
		
	}
		
	if (document.frm_registro.v_reg_clave_act.value == "")
	   errores= "Debes poner tu contraseña actual para realizar los cambios.";
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

// Valida perfil

function f_valida_edita_perfil() {
 
 	errores="";
	
	fckEditor1val = FCKeditorAPI.__Instances['v_firma'].GetHTML();		
	document.getElementById('v_firma').value = fckEditor1val;
		
	if (document.frm_registro.v_reg_pais.value==0 || (document.frm_registro.v_provincia_i.value=="" && document.frm_registro.v_provincia_s.value==0 && document.frm_registro.v_provincia_f.value==0)){
	
		errores="Debes indicar Pais y Provincia.";
		document.getElementById('v_reg_pais').focus();
		
	}
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

// Valida ludoteca

function f_valida_edita_ludoteca() {
 
	errores="";
	
	if (document.frm_registro.v_top_1.value==document.frm_registro.v_top_2.value || document.frm_registro.v_top_1.value==document.frm_registro.v_top_3.value || document.frm_registro.v_top_1.value==document.frm_registro.v_top_4.value || document.frm_registro.v_top_1.value==document.frm_registro.v_top_5.value){
	
		if (document.frm_registro.v_top_2.value>0 || document.frm_registro.v_top_3.value>0 || document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0){
		
		errores="No puedes poner dos Top iguales.";
		
		}
		
	}
	
	if (document.frm_registro.v_top_2.value==document.frm_registro.v_top_3.value || document.frm_registro.v_top_2.value==document.frm_registro.v_top_4.value || document.frm_registro.v_top_2.value==document.frm_registro.v_top_5.value){
	
		if (document.frm_registro.v_top_3.value>0 || document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0){
		
		errores="No puedes poner dos Top iguales.";
		
		}
		
	}
	
	if (document.frm_registro.v_top_3.value==document.frm_registro.v_top_4.value || document.frm_registro.v_top_3.value==document.frm_registro.v_top_5.value){
	
		if (document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0){
		
		errores="No puedes poner dos Top iguales.";
		
		}
		
	}
	
	if (document.frm_registro.v_top_4.value==document.frm_registro.v_top_5.value){
	
		if (document.frm_registro.v_top_5.value>0){
		
		errores="No puedes poner dos Top iguales.";
		
		}
		
	}
		
	if (document.frm_registro.v_top_1.value==0 && (document.frm_registro.v_top_2.value>0 || document.frm_registro.v_top_3.value>0 || document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0)){
	
		errores="No puedes poner un Top superior al Top 1 sin definir primero tu Top 1.";
		
	}
	
	if (document.frm_registro.v_top_2.value==0 && (document.frm_registro.v_top_3.value>0 || document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0)){
	
		errores="No puedes poner un Top superior al Top 2 sin definir primero tu Top 2.";
		
	}
	
	if (document.frm_registro.v_top_3.value==0 && (document.frm_registro.v_top_4.value>0 || document.frm_registro.v_top_5.value>0)){
	
		errores="No puedes poner un Top superior al Top 3 sin definir primero tu Top 3.";
		
	}
	
	if (document.frm_registro.v_top_4.value==0 && (document.frm_registro.v_top_5.value>0)){
	
		errores="No puedes poner un Top superior al Top 4 sin definir primero tu Top 4.";
		
	}
	
	if (document.frm_registro.v_top_1.value==0 && document.frm_registro.v_top_2.value==0 && document.frm_registro.v_top_3.value==0 && document.frm_registro.v_top_4.value==0 && document.frm_registro.v_top_5.value==0){
	
		errores="";
		
	}
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}

}

// Valida Buscador amigos

function f_busca_amigos() {
 
 	errores="";
		
	if (document.frm_registro.v_buscar_ami_j.value=="" && document.frm_registro.v_buscar_ami_c.value=="" && document.frm_registro.v_buscar_ami_p.value==""){
	
		errores="Debes concretar lo que quieres buscar.";
		
	}
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

// Valida Aceptar amigos

function f_valida_amigos() {
 
 	errores="";
		
	
	   
 	if (errores=="")
	{
		document.frm_registro.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

// Valida tema foro

function f_valida_tema() {
	
	var errores="";
	
	fckEditor1val = FCKeditorAPI.__Instances['v_texto'].GetHTML();		
	document.getElementById('v_texto').value = fckEditor1val;
	
	if ((document.frm_crear_tema.v_titulo_tema.value == "")||(document.frm_crear_tema.v_texto.value == "")) {
		errores="No puedes dejar en blanco el Tema y/o el Mensaje.";
	 }
	 
	 if (document.frm_crear_tema.v_texto.value.length < 25) {
		errores="Mensaje demasiado corto para ser publicado.";
	 }
	 
	 if (errores=="")
	{
				
		document.frm_crear_tema.submit();
	}
	else
	{
		
	 	document.getElementById('v_envio').value = 0;
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}

}

// Valida respuesta foro

function f_valida_respuesta() {
	
	var errores="";
	
	fckEditor1val = FCKeditorAPI.__Instances['v_texto'].GetHTML();		
	document.getElementById('v_texto').value = fckEditor1val;
	
	if (document.frm_crear_tema.v_texto.value == "") {
		errores="No puedes dejar en blanco el Mensaje.";
	 }
	 
	 if (document.frm_crear_tema.v_texto.value.length < 25) {
		errores="Mensaje demasiado corto para ser publicado.";
	 }
	 
	 if (errores=="")
	{
				
		document.frm_crear_tema.submit();
	}
	else
	{
		
	 	document.getElementById('v_envio').value = 0;
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}

}

// Valida reporte foro

function f_valida_reporte() {
	
	var errores="";
	
	fckEditor1val = FCKeditorAPI.__Instances['v_texto'].GetHTML();		
	document.getElementById('v_texto').value = fckEditor1val;
	
	if (document.frm_crear_tema.v_texto.value == "") {
		errores="No puedes dejar en blanco el Mensaje.";
	 }
	 
	 if (errores=="")
	{
				
		document.frm_crear_tema.submit();
	}
	else
	{
		
	 	document.getElementById('v_reportar').value = 0;
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}

}

// Valida mover tema foro

function f_valida_mover() {
	
	var errores="";
	 
	 if (document.frm_mover_tema.v_foro_final.value == 0) {
		errores="Selecciona el Foro Destino.";
	 }
	 
	 if (errores=="")
	{
				
		document.frm_mover_tema.submit();
	}
	else
	{
		
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}

}

//Contador de caracteres

function f_contador (campo, cuentacampo, limite) {
if (campo.value.length > limite) campo.value = campo.value.substring(0, limite);
else cuentacampo.value = limite - campo.value.length;
}

//Redimensiona pagina de perfil

function f_redimensiona(altura,capa){
	
	var valor = document.getElementById(capa).offsetHeight;
	
	if (valor<altura){
		
		document.getElementById(capa).style.height="730px";
	
	}
	
}

//Recalcula carrito

function f_recalcula(){
	
	var errores="";
	
	var elementos = document.frm_carrito.elements.length;
		
	for (v_i=0;v_i<=elementos-1;v_i++) {
		
		if (isNaN(document.frm_carrito.elements[v_i].value)) errores="Alguna de las cantidades no se trata de una cifra.";
		
	}
	
	 if (errores=="") {
				
		document.frm_carrito.action="edge_tienda_carrito.asp?etacc=3";
		document.frm_carrito.submit();
		
	}
	else
	{
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}
	
}

//Formaliza carrito

function f_formaliza(){
	
	var errores="";
	
	var elementos = document.frm_carrito.elements.length;
		
	for (v_i=0;v_i<=elementos-1;v_i++) {
		
		if (isNaN(document.frm_carrito.elements[v_i].value)) errores="Alguna de las cantidades no se trata de una cifra.";
		
	}
	
	 if (errores=="") {
				
		document.frm_carrito.action="edge_tienda_st_1.asp";
		document.frm_carrito.submit();
		
	}
	else
	{
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}
	
}

//Valida Pedidos Tienda
function f_valida_pedido() {
    var errores="";
	
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (!(filter.test(document.frm_carrito.v_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_email').focus();
	}
	
	if (document.frm_carrito.v_pago.value == 0) {
		
	   		errores= "Debes indicar una Forma de Pago.";
		
	 }
	
	if (document.frm_carrito.v_zona.value == 0) {
		
	   		errores= "No puedes dejar la Zona sin seleccionar.";
		
	 }
	 
	 //Si es de Spain deberá poner un CP correcto
	 
	 var er_cp=/^([0-9]{5,5})+$/;
	 	  
    if(!er_cp.test(document.frm_carrito.v_codigo.value)) {
     	if (document.frm_carrito.v_pais.value == "Spain"){
        errores="Es obligatorio indicar un Código Postal correcto.";  
    }
    }
	 
	 if (document.frm_carrito.v_provincia_s.value == "0" && document.frm_carrito.v_pais.value == "Spain"){
	
		errores="Es obligatorio indicar una provincia.";
		document.getElementById('v_provincia_s').focus();
		
	}
	
	if (document.frm_carrito.v_zona.value == "1" && (document.frm_carrito.v_pais.value != "Spain" && document.frm_carrito.v_pais_b.value != "Spain")){
	
		errores="La zona de envío es incorrecta.";
		document.getElementById('v_zona').focus();
		
	}
	
	if (document.frm_carrito.v_provincia_f.value == "0" && document.frm_carrito.v_pais.value == "France"){
	
		errores="Es obligatorio indicar una provincia.";
		document.getElementById('v_provincia_f').focus();
		
	}
	
	if (document.frm_carrito.v_nombre.value == "" || document.frm_carrito.v_apellidos.value == "" || document.frm_carrito.v_telefono.value == "" || document.frm_carrito.v_pais.value == 0 || (document.frm_carrito.v_provincia_s.value == 0 && document.frm_carrito.v_provincia_f.value == 0 && document.frm_carrito.v_provincia_i.value == "") || document.frm_carrito.v_localidad.value == "" || document.frm_carrito.v_direccion.value == "" || document.frm_carrito.v_codigo.value == "" || document.frm_carrito.v_email.value == "") {

		
	   		errores= "No puedes dejar un campo obligatorio en blanco.";
		
	 }
	 
	 //Comprobamos DNI si es de España
	 
	  if (document.frm_carrito.v_pais.value == "Spain" && ! checkNIF(document.frm_carrito.v_dni.value)) {
		  
		   var CIF= document.frm_carrito.v_dni.value;
		   
		   if (!CIF.testCIF()) {
		
	   			errores= "El DNI/NIE/CIF no es un DNI/NIE/CIF correcto.";
			
			}
		
	 }
	 
	 //Comprobamos que no deje el campo de país de envío en blanco si rellena al menos el nombre de dirección de envío
	 
	 if (document.frm_carrito.v_nombre_b.value != "" && document.frm_carrito.v_pais_b.value == 0) {
		
	   		errores= "Indica el país del destinatario o deja todo el apartado de destinatario en blanco.";
		
	 }
	 
	 //Contrareembolso solo en España
	 
	 if (document.frm_carrito.v_pago.value==3 && document.frm_carrito.v_zona.value!=1) {
		 
		 errores="Los pagos Contrareembolso solo se aceptan en España Peninsular y Baleares."
		 
	} 
	
	//Los regalos no son Contrareembolso
	 
	 if (document.frm_carrito.v_pago.value==3 && document.frm_carrito.v_regalo[0].checked==true) {
		 
		 errores="Los regalos no aceptan pagos a Contrareembolso, selecciona otra forma de pago."
		 
	}
	
	//Obligatorio rellenar el texto de regalo en el caso de tener marcada la casilla
	
	if (document.frm_carrito.v_dedicatoria.value=="" && document.frm_carrito.v_regalo[0].checked==true) {
		 
		 errores="Si quieres enviar un regalo debes incluir una nota para el beneficiario. ¡Si no no sabrá quién o por qué se lo estás enviado!"
		 
	} 
	
	//No puede enviarse un regalo a si mismo
	
	if (document.frm_carrito.v_nombre.value==document.frm_carrito.v_nombre_b.value && document.frm_carrito.v_apellidos.value==document.frm_carrito.v_apellidos_b.value && document.frm_carrito.v_regalo[0].checked==true) {
		 
		 errores="Has seleccionado envío de regalo. No te puedes enviar un regalo a ti mismo.\nEsta forma de envío es para enviar un regalo a otra persona y que no se incluya la factura de la compra.\nSi el destino de tu compra es un regalo y quieres recibir tú el pedido para entregar el regalo en mano debes desmarcar esta opción."
		 
	}
	
	//No puede enviarse un regalo a si mismo
	
	if (document.frm_carrito.v_direccion.value==document.frm_carrito.v_direccion_b.value && document.frm_carrito.v_regalo[0].checked==true) {
		 
		 errores="Has seleccionado envío de regalo. No te puedes enviar un regalo a ti mismo.\nEsta forma de envío es para enviar un regalo a otra persona y que no se incluya la factura de la compra.\nSi el destino de tu compra es un regalo y quieres recibir tú el pedido para entregar el regalo en mano, debes desmarcar esta opción."
		 
	}
	
	 if (errores=="")
	{
				
		document.frm_carrito.action="edge_tienda_st_2.asp";
		document.frm_carrito.submit();
		
	}
	else
	{
		
	 	errores="\nError en formulario:\n\n"+errores;
		
		alert(errores);
	}
}

//Atencion Jugador

function f_atencion(){
	
	var errores="";
	
	if (document.frm_registro.v_nombre.value=="" || document.frm_registro.v_email.value=="" || document.frm_registro.v_mensaje.value=="" || document.frm_registro.v_asunto.value==0) {
		
			errores="No puedes dejar un campo obligatorio en blanco."
		
	}
	
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (!(filter.test(document.frm_registro.v_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_email').focus();
	}
	
	 if (errores=="") {
				
		document.frm_registro.action="edge_atencion.asp";
		document.frm_registro.submit();
		
	}
	else
	{
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}
	
}

//Atencion Profesional

function f_profesional(){
	
	var errores="";
	
	if (document.frm_registro.v_nombre.value=="" || document.frm_registro.v_email.value=="" || document.frm_registro.v_mensaje.value=="" || document.frm_registro.v_asunto.value==0) {
		
			errores="No puedes dejar un campo obligatorio en blanco."
		
	}
	
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (!(filter.test(document.frm_registro.v_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_email').focus();
	}
	
	 if (errores=="") {
				
		document.frm_registro.action="edge_profesional.asp";
		document.frm_registro.submit();
		
	}
	else
	{
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}
	
}

function f_solicitud(){
	
	var errores="";
	
	if (document.frm_registro.v_nombre.value=="" || document.frm_registro.v_email.value=="" || document.frm_registro.v_evento.value=="" || document.frm_registro.v_formato.value=="" || document.frm_registro.v_localidad.value=="" || document.frm_registro.v_provincia.value=="" || document.frm_registro.v_direccion.value=="" || document.frm_registro.v_fecha.value=="" || document.frm_registro.v_hora.value=="" || document.frm_registro.v_inscripcion.value=="" || document.frm_registro.v_premios.value=="") {
		
			errores="No puedes dejar un campo obligatorio en blanco."
		
	}
	
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (!(filter.test(document.frm_registro.v_email.value))){
		errores="La dirección de correo electrónico no es correcta.";
		document.getElementById('v_email').focus();
	}
	
	 if (errores=="") {
				
		document.frm_registro.action="edge_lcg.asp";
		document.frm_registro.submit();
		
	}
	else
	{
		errores="\nError en formulario:\n\n"+errores;
		alert(errores);
	}
	
}

// Valida mensajeria privada

function f_valida_envia_mail() {
 
 	errores="";
		
	if (document.frm_mensajes.v_mensaje.value=="" || document.frm_mensajes.v_mensaje.value.length < 25){
	
		errores="No puedes enviar un mensaje tan corto.";
		document.getElementById('v_mensaje').focus();
		
	}
	   
 	if (errores=="")
	{
		document.frm_mensajes.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

// Valida invitación

function f_valida_envia_invitacion() {
 
 	errores="";
		
	if (document.frm_mensajes.v_mensaje.value=="" || document.frm_mensajes.v_mensaje.value.length < 25){
	
		errores="No puedes enviar un mensaje tan corto.";
		document.getElementById('v_mensaje').focus();
		
	}
	   
 	if (errores=="")
	{
		document.frm_mensajes.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

//Valida Quest

function f_valida_ql() {
 
 	errores="";
		
	fckEditor1val = FCKeditorAPI.__Instances['v_texto'].GetHTML();		
	document.getElementById('v_texto').value = fckEditor1val;
	
	if (document.frm_log.v_hero_1.value==document.frm_log.v_hero_2.value || document.frm_log.v_hero_1.value==document.frm_log.v_hero_3.value || document.frm_log.v_hero_3.value==document.frm_log.v_hero_2.value &&(document.frm_log.v_hero_1.value!=0 && document.frm_log.v_hero_2.value!=0 && document.frm_log.v_hero_3.value!=0)){
	
		errores="Has seleccionado dos o más héroes iguales.";
		
	}
		
	if (document.frm_log.inputDate.value=="" || document.frm_log.v_quest.value==0 || document.frm_log.v_hero_1.value==0 || (document.frm_log.v_success.value==0 && document.frm_log.v_score.value=="")){
	
		errores="Debes completar todos los campos.";
		
	}
	
	if (document.frm_log.v_hero_1.value==0){
	
		errores="Debes seleccionar como mínimo un héroe.";
		
	}
	
	var v_sc=document.frm_log.v_score.value;
	
	v_sc=v_sc.replace(" ","");
		
	if (isNaN(v_sc) || v_sc=="" || v_sc==" " || v_sc=="  " || v_sc=="   " || v_sc=="    "){
	
		errores="Debes introducir una puntuación final.";
		
	}
	
	   
 	if (errores=="")
	{
		document.frm_log.submit();
	}
	else
	{
	 	errores="\nEdge Entertainment te avisa:\n\n"+errores;
		alert(errores);
	}
					

}

function f_borra_ql(v_id_ql) {
 
 	var answer = confirm ("¿Seguro que quieres borrar este resultado?")
	if (answer) window.location="edge_lotr_gr_quest_log_alta.asp?elotract=d&elotrid="+v_id_ql;
		
}

function nif(dni) {
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1);
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let) {
    return false;
  }else{
    return true;
  }
}


function nif(dni) {
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1);
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let) {
    return false;
  }else{
    return true;
  }
}

String.prototype.testCIF = function(){
    var pares = 0;
    var impares = 0;
    var suma;
    var ultima;
    var unumero;
    var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
    var xxx;
   
    texto = this.toUpperCase();
   
    var regular = new RegExp(/^[ABCDEFGHKLMNPQS]\d{7}[0-9,A-J]$/g);
    if (!regular.exec(texto)) return false;
         
    ultima = texto.substr(8,1);

    for (var cont = 1 ; cont < 7 ; cont ++){
        xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
        impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
        pares += parseInt(texto.substr(cont,1));
    }
    xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
    impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
     
    suma = (pares + impares).toString();
    unumero = parseInt(suma.substr(suma.length - 1, 1));
    unumero = (10 - unumero).toString();
    if(unumero == 10) unumero = 0;
     
    if ((ultima == unumero) || (ultima == uletra[unumero]))
        return true;
    else
        return false;
}

function checkNIF(nif) {
	if (!nif) return false;
	var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
	if (nif.length != 9) return false;
	else {
		letra = nif.substr(8, 1); letra = letra.toUpperCase();
		dni = nif.substr(0, 8);
		dni = dni.toUpperCase(); dni = dni.replace('X','0'); dni = dni.replace('Y','1'); dni = dni.replace('Z','2');
		dni -= parseInt(dni/23) * 23;
		//alert (letras.charAt(dni) + '-' + letra);
		if (letras.charAt(dni) != letra) return false; 
		else return true;
		}
	}

function checkNSS(nss) {
	if (!nss) return false;
	if (nss.length != 11 && nss.length != 12) return false;
	if (nss.substr(2, 1) == 0) nss = '' + nss.substr(0, 2) + nss.substr(3, nss.length-1);
	if (mod(nss.substr(0, nss.length-2), 97) == nss.substr(nss.length-2, 2)) return true;
	else return false;
	}

//+++++++++++++++++++++++++++++++++++++++++++//
//Estas funciones son de AJAX
//+++++++++++++++++++++++++++++++++++++++++++//

function llamada (url, id_contenedor)
{
    var pagina_requerida = false;
	//alert(url);
    if (window.XMLHttpRequest)
    {
        //Si es Mozilla, Safari etc
        pagina_requerida = new XMLHttpRequest ();
    } else if (window.ActiveXObject)
    {
        //pero si es IE
        try 
        {
            pagina_requerida = new ActiveXObject ("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            //en caso que sea una versión antigua
            try
            {
                pagina_requerida = new ActiveXObject ("Microsoft.XMLHTTP");
            }
            catch (e)
            {
            }
        }
    } 
    else
    return false;
    pagina_requerida.onreadystatechange = function ()
    {
        //función de respuesta
        cargarpagina (pagina_requerida, id_contenedor);
    }
    pagina_requerida.open ('GET', url, true); //asignamos los métodos open y send
    pagina_requerida.send (null);
}
//Todo es correcto y ha llegado el momento de poner la información requerida
//en su sitio en la pagina xhtml
function cargarpagina (pagina_requerida, id_contenedor)
{
    if (pagina_requerida.readyState == 4 && (pagina_requerida.status == 200 || window.location.href.indexOf ("http") == - 1))
    document.getElementById (id_contenedor).innerHTML = pagina_requerida.responseText;
}

