
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function comprovaform(idioma){
	MM_validateForm('nom','','R','pcognom','','R','dni','','R','telefon','','R');
	var estaok=document.MM_returnValue;
	//alert('estaok:'+estaok);
	if (!estaok) {
		txt='';
		if (idioma==1) txt='Hi ha camps obligatoris erronis o incomplets.\n Si us plau, comproveu els camps obligatoris';
		if (idioma==2) txt='Hay campos obligatorios erróneos o incompletos.\n Por favor compruebe los campos obligatorios.';
		if (idioma==3) txt='Some necessary fields are wrong or incomplete.\n Please check the  necessary fields.';
		alert(txt);
	 }else{
		document.Treballar.submit();
	 }
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,errors,test,num,min,max,args=MM_validateForm.arguments;
  errors='';
  for (i=0; i<(args.length-2); i+=3) { 
	test=args[i+2]; 
	val=MM_findObj(args[i]);
    if (val) { 
		//nm=val.name; 
		val=val.value;
		if (((val)=="")||((val)=="undefined")) {
			errors='H';
			//if (test!='R') { 
				//num = parseFloat(val);
				//if (isNaN(val)) errors='H';
     
			//} 
		} 
	//else if (test.charAt(0) == 'R') errors='H'; 
	}
  } 
  //alert('Test:'+errors + 'Res:'+(errors == ''));
  document.MM_returnValue = (errors == '');
}

