function desplega(capa){
	
	valor=document.getElementById(capa);
	
			if(valor.style.visibility=="visible")
			{
				valor.style.visibility="hidden";
				valor.style.display="none";
			}
			else
			{
				valor.style.visibility="visible";
				valor.style.display="inline";
			}
			
	
			
}

function MM_validateForm() { //v4.0

  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; 
	  
	  	if (nm=="Adressa") nmtext="Adreça";
		//else if (nm=="V2") nmtext="Tipus d’entitat";

	
				
		
		
		else nmtext=nm.replace(/_/gi, " ");
		
		disa=val.disabled;
		len = document.getElementsByName(nm).length;
		chck=val.checked; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nmtext+' ha de contenir una adreça de correu electrònic vàlida.\n';
        } 
		else if (test.indexOf('checked') != -1){
		
	}else if (test.indexOf('radio') != -1){

		var radio_choice = false;
		var radios = document.getElementsByName(nm);
		

		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < document.getElementsByName(nm).length; counter++)
		{
			
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (radios[counter].checked)
		radio_choice = true; 
		}

		
		if (!radio_choice){ if (disa == false){ errors += '- '+nmtext+' és obligatori.\n'; }}


		//if (valButton(nm)){ if (disa == false){ errors += '- '+nm+' es obligatorio.\n'; }} 
		
	}else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nmtext+' ha de contenir un número.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nmtext+' must contain a number between '+min+' and '+max+'.\n';
      }else if (test.indexOf('morethan0') != -1){
		  	if (num>0){}
			else errors+='- Seleccioni almenys un valor pel camp '+nmtext+'.\n';
	  }
	  
	  } } else if (test.charAt(0) == 'R') if (disa == false){ errors += '- '+nmtext+' és obligatori.\n'; }}
    } 

	if (errors) alert('S´han trobat els següents errors:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
