// JavaScript Document

function subMenuIn(cual)
{
	if(cual != undefined) {
		//$('#'+cual).animate({top:-24},'normal');
		t = $('#subMenuTop'+i).css('top');
		
		$('#'+cual).css("top",t-24+"px");
	}
	for (i=1; i<7; i++){
		t = $('#subMenuTop'+i).css('top');
		//if(t == "-24px") $('#subMenuTop'+i).animate({top:22},'normal');
		if(t == "-24px") $('#subMenuTop'+i).css("top","22px");
		
	}
	return true;
}

function urlToBlank(url){
	if (cual != undefined){
		alert("vale");
	}
}

function comprovaFormComent()
{
	var missatge = new String("");
	error = false;
	
	//Nom
	var elNom = new String(document.forms[1].nom.value);
	if(elNom.trim().length == 0)
	{
		missatge += "Nombre inválido\n";
		error = true;
	}

	//Telèfon
	var elTlf = new String(document.forms[1].telefon.value);
	if(isNaN(elTlf) || elTlf.trim().length != 9)
	{
		missatge += "Teléfono inválido\n";
		error = true;
	}
	
	//E-mail
	var comprovacio=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
	var elMail = new String(document.forms[1].email.value);
	if(comprovacio.test(elMail) == false)
	{
		missatge += "E-mail inválido\n";
		error = true;
	}
	
	//Comprovar check
	var check = document.forms[1].accepto;
	if(!check.checked)
	{
		missatge += "No se permite el envío de ninguna notificación sin aceptar los términos de privadidad.";
		error = true;
	}
	
	if(error)
	{
		alert(missatge);
	}else{
		document.getElementById("elForm").submit();
	}
}