/** 
 * JS_Comprovacions
 * todo: maf 2008-01-10 cal migrar tots els accesos a dades al format estandar getElementById
 * todo: maf 2008-01-10 cal migrar tots els accesos a estandar prototype  
 */
var nav;

function quinnavegador(){
	if (navigator.appName == "Netscape"){
		if (navigator.appVersion[0]=="5")
			nav="Netscape5";
		else
			nav="Netscape";
	}
	else{
		if (navigator.appName == "Microsoft Internet Explorer")
			  nav="Explorer";
	}
}
function NovaFinestra(NomURL,w,h){
    mywindow=window.open(NomURL,"","resizable=yes, menubar=no,toolbar=no,width="+w+",height="+h+",scrollbars=yes");
    mywindow.moveTo(5,5);
    mywindow.focus(mywindow);
}

function mostrardata(){
    DiesSetmana = new Array("Diumenge","Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte");
    MesosAny = new Array("Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Setembre","Octubre","Novembre","Desembre");
    Data = new Date();
    var dia=DiesSetmana[Data.getDay()];
    var ndia=Data.getDate();
    var mes=MesosAny[Data.getMonth()];
    var any=Data.getFullYear();
    document.write (dia+', '+ndia+' '+mes+' '+any);
}
function actualitzartextarea(nom_h,nom){
	var l;
	var i;
	
	mystring = new String(nom_h);
	l=mystring.length;
	for (i=0;i<l;i++){
		if (mystring.slice(i,i+2) == '$$'){
			document.all[nom].value=document.all[nom].value + '\n';
			i++;
		}else{
			document.all[nom].value=document.all[nom].value + mystring.slice(i,i+1);
		}
	}
}


function calcular_edad(camp_data,camp_edat)
{ 

    //calculo la fecha de hoy 
    hoy=new Date() 

    //calculo la fecha que recibo 
    //La descompongo en un array 
    var array_fecha = document.all[camp_data].value.split("/") 
    //si el array no tiene tres partes, la fecha es incorrecta 
    if (array_fecha.length!=3) 
       return false 

    //compruebo que los ano, mes, dia son correctos 
    var ano 
    ano = parseInt(array_fecha[2]); 
    if (isNaN(ano)) 
	{
       document.all[camp_edat].value="" ;	
       return false 
	}

    var mes 
    mes = parseInt(array_fecha[1]); 
    if (isNaN(mes)) 
	{
       document.all[camp_edat].value="" ;
       return false 
	}

    var dia 
    dia = parseInt(array_fecha[0]); 
    if (isNaN(dia)) 
	{
       document.all[camp_edat].value="" ;
       return false 
	}


    //si el año de la fecha que recibo solo tiene 2 cifras hay que cambiarlo a 4 
    if (ano<=99) 
       ano +=1900 

    //resto los años de las dos fechas 
    edad=hoy.getYear()- ano - 1; //-1 porque no se si ha cumplido años ya este año 

    //si resto los meses y me da menor que 0 entonces no ha cumplido años. Si da mayor si ha cumplido 
    if (hoy.getMonth() + 1 - mes < 0) //+ 1 porque los meses empiezan en 0 
	{
       edad=edad ;
	}
	else
	{
		if (hoy.getMonth() + 1 - mes > 0) 
		{
		   edat=edad+1;
		}
		else
		{
			//entonces es que eran iguales. miro los dias 
			//si resto los dias y me da menor que 0 entonces no ha cumplido años. Si da mayor o igual si ha cumplido 
			if (hoy.getUTCDate() - dia >= 0) 
			{
			   edad=edad+1 ;
			}
		}
	}
	
    document.all[camp_edat].value=edad ;
} 

// Esta función permitirá validar la fecha
// En el objeto text hacemos lo Siguiente
function fechas(caja)
{
   if (caja)  
   {  
      borrar = caja;
      if ((caja.substr(2,1) == "/") && (caja.substr(5,1) == "/") && (caja.length<11))
      {      
         for (i=0; i<10; i++)
	     {	
            if (((caja.substr(i,1)<"0") || (caja.substr(i,1)>"9")) && (i != 2) && (i != 5))
			{
               borrar = '';
               break;  
			}  
         }
	     if (borrar)
	     { 
	        a = caja.substr(6,4);
		    m = caja.substr(3,2);
		    d = caja.substr(0,2);
		    if((a < 1900) || (a > 2050) || (m < 1) || (m > 12) || (d < 1) || (d > 31))
		       borrar = '';
		    else
		    {
		       if((a%4 != 0) && (m == 2) && (d > 28))	   
		          borrar = ''; // Año no viciesto y es febrero y el dia es mayor a 28
			   else	
			   {
		          if ((((m == 4) || (m == 6) || (m == 9) || (m==11)) && (d>30)) || ((m==2) && (d>29)))
			         borrar = '';	      				  	 
			   }  
		    } 
         } 
      } 			    			
	  else
	     borrar = '';
		 
	  if (borrar == '')
	  {
	     return (false)
	  }
	  else
	  {
	  	 return (true)
	  }
   }   
} 

/* maf 2007-08-09
   funcions mogudes de l'html a aquest fitxer
*/

function elimFormacio(){
	if (document.forms["form_formacio"].formacio.selectedIndex!=-1){
		NovaFinestra('form_curs.php?accio=Baixa&codi=' + document.forms["form_formacio"].formacio.options[document.forms["form_formacio"].formacio.selectedIndex].value ,600,300);
	}else{
		alert('Cal seleccionar algun curs de la llista');
	}
}
function modifFormacio(){
	if (document.forms["form_formacio"].formacio.selectedIndex!=-1){
		NovaFinestra('form_curs.php?accio=Modificacio&codi=' + document.forms["form_formacio"].formacio.options[document.forms["form_formacio"].formacio.selectedIndex].value ,600,300);
	}else{
		alert('Cal seleccionar algun curs de la llista');
	}
}
function elimExperiencia(){
	if (document.forms["form_laboral"].experiencia.selectedIndex!=-1){
		NovaFinestra('form_exp.php?accio=Baixa&codi=' + document.forms["form_laboral"].experiencia.options[document.forms["form_laboral"].experiencia.selectedIndex].value ,600,300);
	}else{
		alert('Cal seleccionar algun curs de la llista');
	}
}
function modifExperiencia(){
	if (document.forms["form_laboral"].experiencia.selectedIndex!=-1){
		NovaFinestra('form_exp.php?accio=Modificacio&codi=' + document.forms["form_laboral"].experiencia.options[document.forms["form_laboral"].experiencia.selectedIndex].value ,600,300);
	}else{
		alert('Cal seleccionar algun curs de la llista');
	}
}
/* maf 2007-05-14 
   canvia el valor dun select
  */
function canviaValor(control,valor){
	document.all[control].value = valor;
	return true;
}

function posa_majuscules(control){
    //2008-01-17 maf pasem a getbyid
	//mystring = new String(document.all[control].value);
	mystring = new String(document.getElementById(control).value);
	//document.all[control].value = mystring.toUpperCase(); 
	document.getElementById(control).value = mystring.toUpperCase();
}

function posa_majuscules_primera(frmObj){
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	//tmpStr = frmObj.value.toLowerCase();
	//tmpStr = new String(document.all[frmObj].value);
	//2008-01-17 maf pasem a getbyid
    tmpStr  = new String(document.getElementById(frmObj).value);
	tmpStr = tmpStr.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)
	{
		for (index = 0; index < strLen; index++)
		{
			if (index == 0)
			{
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else
			{
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))
				{
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	//frmObj.value = tmpStr;
	
	//2008-01-17 maf pasem a getbyid
	//document.all[frmObj].value = tmpStr;
	document.getElementById(frmObj).value = tmpStr;
}

function checkemail(correu){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(correu)){
		return true
	}
	else{
		alert("Comprova que el correu electrònic estigui correctament escrit");
		alert("Si no en tens deixa aquesta casella en blanc!");
		return false
	}
}

function checkNumber(valor,mida)
{
	var mystring = new String(valor);	
	var myint = parseInt(valor);   
	if ((mystring.length != mida) || myint!=mystring){	
	      //alert (myint);
		  //alert (valor);
		  return false 
	}
	else{
			return true
	}
}

function checkNumberInt(valor){
	var mystring = new String(valor);	
	var myint = parseInt(valor);   
	if (myint!=mystring){	
		  return false 
	}
	else{
			return true
	}
}

//comprovem format del nif persones fisiques
function check_cpostal(cadena){
	var patron = /^[0-9][0-9][0-9][0-9][0-9]$/;
	if (!cadena.match(patron)){
		return false;
	}else{
		return true;
	}
} 

//comprovem format del nif persones fisiques
function check_pfisic(cadena){
	var patron = /^[0-9XYZ][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-Z]$/;
	if (!cadena.match(patron)){
		return false;
	}else{
		return true;
	}
} 
//comprovem format del cif persones juridiques
function check_pjuridic(cadena){
	//afegim la J en la comprovacio de la lletra inicial ja que correspon a SCCP.
	//aquest problema sorgeix el dia 28/10/2009
	//var patronN = /^[ABCDEFGHKLMNPQS][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/;
	var patronN = /^[ABCDEFGHJKLMNPQS][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/;
	//var patronL = /^[ABCDEFGHKLMNPQS][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-J]$/;
	var patronL = /^[ABCDEFGHJKLMNPQS][0-9][0-9][0-9][0-9][0-9][0-9][0-9][A-J]$/;
	if (!cadena.match(patronN) && !cadena.match(patronL)){
		return false;
	}else{
		return true;
	}
} 
//comprovem NIF
//no estem validant els digits de control !! però tenim preparats els scripts per fer-ho
function check_NIF(documentId){	
	var ok;	
	ok=false;
	dnicifstring = new String(documentId);
	dnicifstring = dnicifstring.toUpperCase();
	if (check_pfisic(dnicifstring)){
		ok=true;
	}
	if (check_pjuridic(dnicifstring)){
		ok=true;
	}
	return ok;
}

function checksubmitCondicions(){
   if (!document.all['check_condicions'].checked)
   {
      alert("Cal marcar la casella d'acceptació de les condicions d'ús per poder continuar la inscripció a la borsa de treball");
      return false
   }

}

function checksubmitDemRegistre(){
       if (!check_NIF(document.getElementById('DEM_DNI').value)){
            alert("Error, el NIF es incorrecte, el NIF es de la Forma 12345678H");
            return false;
       }
    
       if (document.getElementById('DEM_PASSWORD').value == ""){
          alert("Si us plau, entra un password per poder accedir a l'espai de gestió currículums");
          document.getElementById('DEM_PASSWORD').focus();
          return false
       }
    
       if (document.getElementById('DEM_PASSWORD_2').value == ""){
          alert("Si us plau, entra un password per poder accedir a l'espai de gestió currículums");
          document.getElementById('DEM_PASSWORD_2').focus();
          return false
       }
          
       if (document.getElementById('DEM_PASSWORD').value != document.all('DEM_PASSWORD_2').value){
          alert("Els passwords introduïts no coincideixen");
          document.getElementById('DEM_PASSWORD').focus();
          return false
       }
       return true;
}
function checksubmitDemCanviClau(){
     //caldria comprovar la clau antiga sigui correcta ¿?     
     
     if (document.getElementById('DEM_PASSWORD').value == ""){
        alert("Si us plau, entra eln password actual");
        document.getElementById('DEM_PASSWORD').focus();
        return false
     }
     
     if (document.getElementById('DEM_NOU_PASSWORD').value == ""){
        alert("Si us plau, entra el nou password");
        document.getElementById('DEM_NOU_PASSWORD').focus();
        return false
     }
  
     if (document.getElementById('DEM_NOU_PASSWORD_2').value == ""){
        alert("Si us plau, repeteix el nou password en la casella de confirmció");
        document.getElementById('DEM_NOU_PASSWORD_2').focus();
        return false
     }
        
     if (document.getElementById('DEM_NOU_PASSWORD').value != document.getElementById('DEM_NOU_PASSWORD_2').value){
        alert("Els nous passwords introduïts no coincideixen");
        document.getElementById('DEM_NOU_PASSWORD').focus();
        return false
     }
     return true;
}
/**
 * funcio que comprova les dades del demandant en el moment d'inscripcio i també en el moment de modificar les dades.<b>
 * mitajnçant el parametre mode permetem discriminar entre un i altre cas (o els que fessin falta per un futur) 
 */
function checksubmitDemPers(mode){
   if(mode=='registre'){
        if(!checksubmitDemRegistre()){
            return false;
        }
   }
   if (document.getElementById('DEM_NOM').value == ""){
      alert("Si us plau, introdueix el teu nom");
      document.getElementById('DEM_NOM').focus();
      return false
   }

   if (document.getElementById('DEM_COGNOMS').value == ""){
      alert("Si us plau, introdueix els teus cognoms");
      document.getElementById('DEM_COGNOMS').focus();
      return false
   }	 
   if ((document.getElementById('DEM_DATA_NAIX').value == "") || (!fechas(document.all('DEM_DATA_NAIX').value))){
      alert("Si us plau, la data de naixement no té un format correcte o està en blanc");
      document.getElementById('DEM_DATA_NAIX').focus();
      return false
   }

   if (document.getElementById('DEM_LLOC_NAIX').value == ""){
      alert("Si us plau, introdueix el teu lloc de naixement");
      document.getElementById('DEM_LLOC_NAIX').focus();
      return false
   }

   if (document.getElementById('DEM_EDAT').value == ""){
      alert("Si us plau, introdueix la teva edat");
      document.getElementById('DEM_EDAT').focus();
      return false
   }

   if (document.getElementById('DEM_CODI_NAC').value == ""){
      alert("Si us plau, introdueix la teva nacionalitat");
      document.getElementById('DEM_CODI_NAC').focus();
      return false
   }
   
   if (document.getElementById('DEM_DOMICILI').value == ""){
      alert("Si us plau, introdueix el teu domicili actual");
      document.getElementById('DEM_DOMICILI').focus();
      return false
   }

   if (!check_cpostal(document.getElementById('DEM_CP').value)){
   		alert("Si us plau, introdueix el codi postal correctament");
   		alert("Recorda que has d'introduir un CP vàlid del tipus 12345");
   		return false
   }

   if (document.getElementById('DEM_LOCALITAT').value == ""){
      alert("Si us plau, introdueix la localitat de residència actual.");
      document.getElementById('DEM_LOCALITAT').focus();
      return false
   }

   if (!checkNumber((document.getElementById('DEM_TELF1').value),9)){
      alert("Si us plau, introdueix el telèfon correctament");
      alert("Recorda que has d'introduir un telefon vàlid del tipus 977112233, només números!!");
      document.getElementById('DEM_TELF1').focus();
      return false
   }
 
   if (document.getElementById('DEM_EMAIL').value != ""){
		if (!checkemail(document.getElementById('DEM_EMAIL').value)){
			document.getElementById('DEM_EMAIL').focus();
			return false
		}
   }   
 
   return true
}

function checksubmitDemForm()
{
   if (document.all['DEM_NIVELL_ESTUDIS'].value == "") //no ha seleccionat algun nivell d'estudis
   {
      alert("Si us plau, introdueix un nivell d'estudis");
      document.all['DEM_NIVELL_ESTUDIS'].focus();
      return false
   }
   /* #1 maf 2007-08-08 
   	* afegit check per nivell i especialitat si es selecciona un nivell amb especilitats
   	* dependents 
   	*/
   else{	//ha seleccionat algun nivell d'estudis
   		if (taulaNivells[document.all['DEM_NIVELL_ESTUDIS'].value]==true){	//te especialitats?
			if (document.all['DEM_ESPECIALITAT'].value==""){	//no ha marcat cap especialitat
				alert("Si us plau, introdueix la especialitat per al primer nivell d'estudis indicat.");
				document.all['DEM_ESPECIALITAT'].focus();
				return false
			}
	    }
   }
   /* #2 maf 2007-08-08 
    * afegir check per nivel de coneix 2
   	* afegit check per nivell i especialitat si es selecciona un nivell amb especilitats
   	* dependents 
   	*/
   if (document.all['DEM_NIVELL_ESTUDIS_2'].value != "") //ha seleccionat algun nivell d'estudis
   {
   		if (taulaNivells[document.all['DEM_NIVELL_ESTUDIS_2'].value]==true){	//te especialitats?
			if (document.all['DEM_ESPECIALITAT_2'].value==""){	//no ha marcat cap especialitat
				alert("Si us plau, introdueix la especialitat per al segon nivell d'estudis indicat.");
				document.all['DEM_ESPECIALITAT_2'].focus();
				return false
			}
	    }
   }


   if (document.all['DEM_CAT_CON'].value == '')
   {
      alert("Si us plau, introdueix un nivell de català");
      document.all['DEM_CAT_CON'].focus();
      return false
   }

   if (document.all['DEM_CAS_CON'].value == '')
   {
      alert("Si us plau, introdueix un nivell de castellà");
      document.all['DEM_CAS_CON'].focus();
      return false
   }

/*  maf 2007-05-25 if que comprovava dos cops el ['DEM_IDI3_CODI'].value ?¿ eliminat un dels dos.
	eliminats uns alerts que es van deixar per comprovacionsi no es van eliminar.
 */
   if ((document.all['DEM_IDI3_CODI'].value != '')  && (document.all['DEM_IDI3_CON'].value == ''))
   {

      alert("Si us plau, cal introduir un nivell per l'idioma seleccionat");
      document.all['DEM_IDI3_CON'].focus();
      return false
   }
   if ((document.all['DEM_IDI4_CODI'].value != '')  && (document.all['DEM_IDI4_CON'].value == ''))
   {
      alert("Si us plau, cal introduir un nivell per l'idioma seleccionat");
      document.all['DEM_IDI4_CON'].focus();
      return false
   }

   return true	
}

function checksubmitDemLab()
{
   if (document.all['DEM_SIT_LAB'].value == "")
   {
      alert("Si us plau, introdueix la teva situació laboral actual");
      document.all['DEM_SIT_LAB'].focus();
      return false
   }
   if (document.all['DEM_OCU1'].value == "")
   {
      alert("Si us plau, introdueix al menys una ocupació preferida");
      document.all['DEM_OCU1'].focus();
      return false
   }
   return true	
}

function checksubmitOfeFeina()
{


   if (document.all['OFE_ESP_OCUPACIO'].value == "")
   {
      alert("Si us plau, introdueix l'especialitat de l'oferta de treball");
      document.all['OFE_ESP_OCUPACIO'].focus();
      return false
   }

   if (document.all['OFE_TASQUES'].value == "")
   {
      alert("Si us plau, indica les principals tasques a desenvolupar");
      document.all['OFE_TASQUES'].focus();
      return false
   }

   return true	

}

function checksubmitOfeCondicions()
{

   if (document.all['OFE_DATA_INC'].value == "")
   {
      alert("Si us plau, indica la data aproximada d'inici del contracte");
      document.all['OFE_DATA_INC'].focus();
      return false
   }

   if (document.all['OFE_HORARI_TREB'].value == "")
   {
      alert("Si us plau, indica l'horari de treball");
      document.all['OFE_HORARI_TREB'].focus();
      return false
   }

   if (document.all['OFE_TIPUS_CONT'].value == "")
   {
      alert("Si us plau, indica el tipus de contracte que es vol realitzar");
      document.all['OFE_TIPUS_CONT'].focus();
      return false
   }

   if (document.all['OFE_DURADA_CONT'].value == "")
   {
      alert("Si us plau, indica la durada aproximada del contracte inicial");
      document.all['OFE_DURADA_CONT'].focus();
      return false
   }

   if (document.all['OFE_LOCALITAT_TREB'].value == "")
   {
      alert("Si us plau, indica el municipi on es treballarà.");
      document.all['OFE_LOCALITAT_TREB'].focus();
      return false
   }

   return true	

}
/*
todo: cal comprovar si es un cop posat un nivell d'estudis amb opcions ha selecttionat alguna de les opcions
		ara no s'esta comprovant, unicament es mira si ha seleccionat un nivell d'estudis.
*/
function checksubmitOfePerfil()
{
   if (document.all['OFE_EXPERIENCIA'].value == "")
   {
      alert("Si us plau, indica si és necessària experiència i en cas afirmatiu el temps mínim d'experiència");
      document.all['OFE_EXPERIENCIA'].focus();
      return false
   }
   /** #1 maf 2007-08-08 
   	* afegit check per nivell i especialitat si es selecciona un nivell amb especilitats
   	* dependents 
   	* #2 maf 2007-11-12
   	* pi : 2007000436. es demana que el nivell d'estudis sigui sempre requisit. 
   	*/
   if (document.all['OFE_NIV_ESTUDIS'].value != ""){	//ha seleccionat algun nivell d'estudis
   		if (taulaNivells[document.all['OFE_NIV_ESTUDIS'].value]==true){	//te especialitats?
			if (document.all['OFE_ESPECIALITAT'].value==""){	//no ha marcat cap especialitat
				alert("Si us plau, introdueix la especialitat per al nivell d'estudis indicat.");
				document.all['OFE_ESPECIALITAT'].focus();
				return false
			}
	    }
   }else{
		alert("Si us plau, introdueix el nivell d'estudis mínim.");
		document.all['OFE_NIV_ESTUDIS'].focus();
		return false   
   }
   if (document.all['OFE_CONEIXEMENTS'].value == "")
   {
      alert("Si us plau, indica els coneixements i/o habilitats que es requereixen per al candidat.");
      document.all['OFE_CONEIXEMENTS'].focus();
      return false
   }   
   return true	
}

function checksubmitOfeSel()
{
   if (document.all['OFE_NOM_RESP'].value == "")
   {
      alert("Si us plau, introdueix el nom del responsable de la selecció");
      document.all['OFE_NOM_RESP'].focus();
      return false
   }
   if (document.all['OFE_COGNOMS_RESP'].value == "")
   {
      alert("Si us plau, introdueix el cognom del responsable de la selecció");
      document.all['OFE_COGNOMS_RESP'].focus();
      return false
   }
   
   if (!checkNumberInt(document.all['OFE_PLACES'].value)){
		alert("Si us plau, introdueix un número de places a cobrir");
		document.all['OFE_PLACES'].focus();
		return false;
   }
   return true	
}

function checksubmitEmpresaRegistre(){
       if (document.getElementById('EMP_PASSWORD').value == ""){
           alert("Si us plau, introdueix un password");
           document.getElementById('EMP_PASSWORD').focus();
           return false;
       }
       if (document.getElementById('EMP_PASSWORD_2').value == ""){
           alert("Si us plau, introdueix un password");
           document.getElementById('EMP_PASSWORD_2').focus();
           return false;
        }   
       if (document.getElementById('EMP_PASSWORD').value != document.getElementById('EMP_PASSWORD_2').value){
           alert("Si us plau, les claus d'accés introduïdes han de ser iguals");
           document.getElementById('EMP_PASSWORD').focus();
           return false; 
        }
        return true;
}

/* maf 208-01-17 s'han canviat tots els accessos a document.getElementById() enlloc de document.all[] */
function checksubmitEmpresa(mode){
    if(mode=='registre'){
        if (!checksubmitEmpresaRegistre()){
            return false;
        }
	}

   if (!check_NIF(document.getElementById('EMP_NIF').value)){
        alert("Error, el NIF es incorrecte. El NIF es de la forma 12345678K, A1234567J O A12345670");
        return false;
   }
   if (document.getElementById('EMP_NOM').value == ""){
      alert("Si us plau, introdueix el nom de l'empresa");
      document.getElementById('EMP_NOM').focus();
      return false;
   }
   if (document.getElementById('EMP_DOMICILI').value == ""){
      alert("Si us plau, introdueix el domicili de l'empresa");
      document.getElementById('EMP_DOMICILI').focus();
      return false;
   }
   if (!check_cpostal(document.getElementById('EMP_CP').value)){
        alert("Si us plau, introdueix el codi postal de l'empresa correctament");
        alert("Recorda que has d'introduir un CP vàlid del tipus 12345");
        return false;
   }
   if (document.getElementById('EMP_MUNICIPI').value == ""){
      alert("Si us plau, introdueix el municipi de l'empresa");
      document.getElementById('EMP_MUNICIPI').focus();
      return false;
   }
   if (!checkNumber((document.getElementById('EMP_TELF').value),9)){
      alert("Si us plau, introdueix el telèfon de l'empresa correctament");
      alert("Recorda que has d'introduir un telefon vàlid del tipus 977112233, només números!!");
      document.getElementById('EMP_TELF').focus();
      return false;
   }
   if (document.getElementById('EMP_TELF_2').value != ""){
       if (!checkNumber((document.getElementById('EMP_TELF_2').value),9)){
          alert("Si us plau, introdueix el telèfon 2 de l'empresa correctament");
          alert("Recorda que has d'introduir un telefon vàlid del tipus 977112233, només números!!");
          document.getElementById('EMP_TELF_2').focus();
          return false;
       }
   }
   if (document.getElementById('EMP_MAIL').value != ""){
        if (!checkemail(document.getElementById('EMP_MAIL').value)){
            document.getElementById('EMP_MAIL').focus();
            return false;
        }
   }   
   if (document.getElementById('EMP_CODI_SECTOR').value == ""){
      alert("Si us plau, introdueix el sector d'activitat de l'empresa");
      document.getElementById('EMP_CODI_SECTOR').focus();
      return false;
        
   }
   
   //maf 2008-01-17 com que no es guarda ja aquesta dada es treu el check()
   //maf 2009-08-18 com que no queda clar si es guarda o no i en algnues pagines
   //               apareixen referencies encara a aquest camp el reactivo.
   if (document.getElementById('EMP_ACTIVITAT').value == ""){
      alert("Si us plau, introdueix la explicació d'activitat de l'empresa");
      document.getElementById('EMP_ACTIVITAT').focus();
      return false;
        
   }
    
   return true;
}