$(document).ready(function() {
	// Efecto menú superior
	$('#menu_lista a')
		.css({backgroundPosition: "-390px 0px"})
		.mouseover(function(){
			$(this).animate({backgroundPosition: "(0px 0px)"}, 350, "linear")
		})
		.mouseout(function(){
			$(this).animate({backgroundPosition: "(-390px 0px)"}, 350, "linear")
		});
	// Eventos botones
	$("#registro_boton").click(function(){
		window.location="?modulo=registro_usuarios";
	});
	$("#notaLegal").click(function(){
		popupBarra("http://masde55.com/notalegal.asp", 570, 580);
	});
	$("#footer_notaLegal").click(function(){
		popupBarra("http://masde55.com/notalegal.asp", 570, 580);
	});
	document.getElementById("footer_favoritos").onclick = function() {
		window.external.AddFavorite('http://www.masde55.com', document.title);
	}
	document.getElementById("footer_inicio").onclick = function() {
		this.style.behavior='url(#default#homepage)';
		this.setHomePage(' http://www.masde55.com ');
	}
	$("#contactar_borrar").click(function(){
		document.getElementById("contactar_form").reset();
	});
	$("#registro_borrar").click(function(){
		document.getElementById("registro_form").reset();
	});
	$("#enviar_amigo_borrar").click(function(){
		document.getElementById("enviar_amigo_form").reset();
	});
	$("#registro_baja_bt").click(function(){
		window.location="?modulo=registro_baja";
	});
	$("#submit_buscador").click(function(){
		window.location="?modulo=buscador_resultados&buscar="+$("#buscar").val();
	});
	// Eventos inputs
	$("#buscar").focus(function(){
		if ($(this).val()==str_buscar)
			$(this).val("");
	});
	$("#buscar").blur(function(){
		if ($(this).val()=="")
			$(this).val(str_buscar);
	});
});

// Funciones
function popupBarra(pagina, width, height) {
	window.open(pagina, 'ventana1', 'toolbar=0,scrollbars=1,location=0,statusbar=0, menubar=0,resizable=0,width='+width+',height='+height);
}
function validar_registro(objform) {
	if (!objform.acepto.checked) {
		alert(str_debeAceptar);
		return false;
	}
	error_str="";
	if (objform.nombre.value.length<3) error_str=error_str+str_nombre+"\n";
	if (objform.telefono.value.length!=9) error_str=error_str+str_telefono+"\n";
	if (objform.cp.value.length!=5) error_str=error_str+str_cp+"\n";
	if (objform.email.value.length<5 || objform.email.value.indexOf("@")<2) error_str=error_str+str_email+"\n";
	if (objform.password.value.length==0) error_str=error_str+str_password+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	if (objform.password.value!=objform.password2.value) {
		alert(str_passwordCoincide);
		return false;
	}
	alert(str_registroOK);
	return true;
}
function validar_contactar(objform) {
	if (!objform.acepto.checked) {
		alert(str_debeAceptar);
		return false;
	}
	error_str="";
	if (objform.nombre.value.length<2) error_str=error_str+str_nombre+"\n";
	if (objform.apellidos.value.length<2) error_str=error_str+str_apellidos+"\n";
	if (objform.telefono.value.length!=9) error_str=error_str+str_telefono+"\n";
	if (objform.email.value.length<5 || objform.email.value.indexOf("@")<2) error_str=error_str+str_email+"\n";
	if (objform.comentarios.value.length<2) error_str=error_str+str_comentarios+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	return true;
}
function validar_sorteo(objform) {
	if (!objform.acepto.checked) {
		alert(str_debeAceptar);
		return false;
	}
	error_str="";
	if (objform.nombre.value.length<3) error_str=error_str+str_nombre+"\n";
	if (objform.telefono.value.length!=9) error_str=error_str+str_telefono+"\n";
	if (objform.numero.value.length<1) error_str=error_str+str_numero+"\n";
	if (objform.email.value.length<5 || objform.email.value.indexOf("@")<2) error_str=error_str+str_email+"\n";
	if (objform.password.value.length==0) error_str=error_str+str_password+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	if (objform.password.value!=objform.password2.value) {
		alert(str_passwordCoincide);
		return false;
	}
	return true;
}
function validar_registro_baja(objform) {
	error_str="";
	if (objform.email.value.length<5 || objform.email.value.indexOf("@")<2) error_str=error_str+str_email+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	return true;
}
function validar_participa(objform) {
	error_str="";
	if (objform.nombre.value.length<2) error_str=error_str+str_nombre+"\n";
	if (objform.telefono.value.length!=9) error_str=error_str+str_telefono+"\n";
	if (objform.email.value.length<5 || objform.email.value.indexOf("@")<2) error_str=error_str+str_email+"\n";
	if (objform.comentarios.value.length<2) error_str=error_str+str_comentarios+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	return true;
}
function validar_enviar_amigo(objform) {
	error_str="";
	if (objform.nom1.value.length<2) error_str=error_str+str_nombre_remitente+"\n";
	if (objform.nom2.value.length<2) error_str=error_str+str_nombre_receptor+"\n";
	if (objform.email1.value.length<5 || objform.email1.value.indexOf("@")<2) error_str=error_str+str_email_remitente+"\n";
	if (objform.email2.value.length<5 || objform.email2.value.indexOf("@")<2) error_str=error_str+str_email_receptor+"\n";
	if (error_str!="") {
		alert(str_debeRellenar+":\n"+error_str);
		return false;
	}
	return true;
}