function MM_findObj(n, d) { //v3.0
  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); return x;
}


function validarForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=validarForm.arguments;
  for (i=0; i<(args.length-2); i+=3) {
		test=args[i+2];
		val=MM_findObj(args[i]);		
		if (val) { 
			nm=val.name;
			if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) {
						// Es un email
						hay_error="no"
						p=val.indexOf('@');						
						if (p<1 || p==(val.length-1)) hay_error="si";
						if (val.length<6){
							hay_error="si";
						} else {
							aux=val.substring(val.length-6, val.length-1)
							p=aux.indexOf('.');
							if (p<1 || p==(val.length-1)){
								hay_error="si";
							}
						}
						if (hay_error=="si") errors+='- '+nm+' erróneo.\n';
					} else{ // no es mail
						if (test=='T') {
								 if (val == "Todos" ||val == "Todas" ||val == 0 ) {
									 errors+='- '+nm+' es obligatorio selecionar uno/a. \n';
								 }
						} else {  // no es T
							if (test!='R') {
								 num = parseFloat(val);
								 if (val!=''+num) errors+='- '+nm+' detallar.\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+='- '+nm+' debe estar entre '+min+' and '+max+'.\n';
								 }
							}// fin de test R
						} // fin de Test  T
					}// fin de es mail
			 } else {//Si se producen errores
				 if ((test.charAt(0) == 'R') && (nm!='telefono')) errors += '- '+nm+' necesario.\n'; 
			 }
		}// fin de comprobar si hay valor
  }// fin del For
  
  if (errors) alert('Se han producido los siguientes errores:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}
var nav4 = window.Event ? true : false;
function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;	
return (key <= 13 || (key >= 48 && key <= 57) || (key == 45) );
}





