// JavaScript Document
// ******************************************* GENERAL *************************************
function buscarBlur(src) {
	if (src.value==""){
		src.value="Buscar";
	}
}
function buscarFocus(src) {
	if (src.value=="Buscar"){
		src.value="";
	}
}

function mostrardiv() {
	div = document.getElementById('llistats');
	div.style.visibility = 'visible';
	document.getElementById('ampliar_info').innerHTML = "<a href='javascript:ocultardiv()'>- cerrar listado por fecha de calendario</a>";
}

function ocultardiv() {
	div = document.getElementById('llistats');
	div.style.visibility = 'hidden';
	document.getElementById('ampliar_info').innerHTML = "<a href='javascript:mostrardiv()'>+ listado por fecha de calendario</a>";
}

/*****************************************************/

function validar(form,idioma){
	
	switch (idioma) {
    case "cat":
       texto_nom="És obligatori omplir el camp NOM";
	   texto_email="Direcció d'e-mail no vàl·lida!!";
	   texto_password="És obligatori omplir el camp PASSWORD";
	   texto_data_n="És obligatori omplir el camp DATA DE NAIXAMENT";
	   texto_pais="És obligatori omplir el camp PAIS";
	   texto_ciutat="És obligatori omplir el camp CIUTAT";
	   texto_ocupacio="És obligatori omplir el camp OCUPACIO";
	   texto_legal="És obligatori aceptar les condicions legals";


       break;
    case "esp":
		texto_nom="Es obligatorio rellenar el campo NOMBRE";
	   texto_email="¡¡Dirección de e-mail no válida!!";
	   texto_password="Es obligatorio rellenar el campo PASSWORD";
	   texto_data_n="Es obligatorio rellenar el campo FECHA DE NACIMIENTO";
	   texto_pais="Es obligatorio rellenar el campo PAÍS";
	   texto_ciutat="Es obligatorio rellenar el campo CIUDAD";
	   texto_ocupacio="Es obligatorio rellenar el campo OCUPACIÓN";
	   texto_legal="Es obligatorio aceptar las condiciones legales";
	
	   
       break;
    case "eng":
    	texto_nom="NAME field is obligatory";
	   texto_email="e-mail no valid!!";
	   texto_password="PASSWORD field is obligatory";
	   texto_data_n="BIRTH DATE field is obligatory";
	   texto_pais="COUNTRY field is obligatory";
	   texto_ciutat="CITY field is obligatory";
	   texto_ocupacio="OCUPATION field is obligatory";
	   texto_legal="Is obligatory accept the legal conditions";
	   
       break;
	} 
	
    //empresa
	if (form.nom.value.length==0){
       alert(texto_nom);
      	form.nom.focus();
       return false;
    }

	if (!form.email.value.length==0){

       var s = form.email.value;

       var filter=/^[A-Za-z_-]+(\.?)[A-Za-z0-9_]*@[A-Za-z0-9_-]+\.[A-Za-z0-9_.]+[A-za-z]$/;

       if (filter.test(s)){

           // com que està OK, no fem res

       }else{

           alert(texto_email);
           form.email.focus();
           return false;

       }

   	}else{
           alert(texto_email);
           form.email.focus();
           return false;
	}
	
	if (form.password.value.length==0){
       alert(texto_password);
       form.password.focus();
       return false;
    }
	if (form.data_n.value.length==0){
       alert(texto_data_n);
       form.data_n.focus();
       return false;
    }
	if (form.pais.value.length==0){
       alert(texto_pais);
       form.pais.focus();
       return false;
    }
	if (form.ciutat.value.length==0){
       alert(texto_ciutat);
       form.ciutat.focus();
       return false;
    }
	if (form.ocupacio.value.length==0){
       alert(texto_ocupacio);
       form.ocupacio.focus();
       return false;
    }
	if (!form.legalCheck.checked){//Elemento type=checkbox
		alert(texto_legal);
		return false;
	}
	
}


