//<script language="JavaScript">
<!--
function isdate(dateStr)
{

																			// Comprueba los siguientes tipos de fecha:
																			// DD/MM/AA   DD/MM/AAAA   DD-MM-AA   DD-MM-AAAA

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

																			// Para obligar a la introduccion de 4 dígitos en el añ, usar esta otra cadena
																			// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

	var matchArray = dateStr.match(datePat);	 // is the format ok?
	
	if (matchArray == null) 
	{
		alert("Check the format of the date.");
		return false;
	}
	
	month	= matchArray[3];									// Separamos los días mese y años
	day		= matchArray[1];
	year		= matchArray[4];
	
	
	if (month < 1 || month > 12) 
	{																			// Comprobar que sea un mes válido
		alert("The month will be 1-12.");
		return false;
	}
	
	if (day < 1 || day > 31)										// Comprobar que sea un día válido
	{
		alert("The day will be 1-31.");
		return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		alert("The month "+month+" don't have 31 days!");
		return false;
	}
	
	if (month == 2) 
	{																			// Comprueba el 29 de Febrero
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		
		if (day>29 || (day==29 && !isleap)) 
		{
			alert("Febrary of " + year + " don't has  " + day + " days!");
			return false;
		}
	}
return true;  // date is valid
}

					function MM_validateForm() { //v1.3 (modificada por LGI)
					  var i,objStr,field,theCheck,atPos,theNum,colonPos,min,max,errors='',title;
					  
					  for (i=0; i<(MM_validateForm.arguments.length-2); i+=4) {
					    objStr = MM_validateForm.arguments[(navigator.appName == 'Netscape')?i:i+1];
					    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) || (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
					      objStr = 'document'+objStr.substring(objStr.substring(0,objStr.lastIndexOf('.')).  lastIndexOf('.'),objStr.length);  //fix layer ref if not supp
					    field = eval(objStr);
					    field.name = (field.name)?field.name:objStr;
					    theCheck = MM_validateForm.arguments[i+2];
					    title = MM_validateForm.arguments[i+3];
					    
					    if (field.value) { //IF NOT EMPTY FIELD
					      if (theCheck.indexOf('isEmail') != -1) 
							{ //CHECK EMAIL
							
								atPos = field.value.indexOf('@');
								if (atPos < 1 || atPos == (field.value.length - 1))
								      errors += '- The field '+title+' must have a valid e-mail.\n';
							} // FIN CHECHEO E-MAIL

							if (theCheck =='RD')
							{ //Inicio == RD
								if (!isdate(field.value))
								{ // Inicio IsDate
									errors += '- Introduce the date in a valid format Example: 12/31/1973 \n';
								} // Fin IsDate
							} // Fin == RD
							
																													
							if (theCheck != 'R' && theCheck != 'RD' && theCheck != 'RisEmail') 
							{ // COMPROBACION DE NUMEROS
								theNum = parseFloat(field.value);
								if (field.value != ''+theNum) errors += '- The field '+title+' needs a valid number.\n';
								if (theCheck.indexOf('inRange') != -1) 
								{ //COMPROBACION DE RANGO DE NUMEROS
								  colonPos = theCheck.indexOf(':');
								  min = theCheck.substring(8,colonPos);
								  max = theCheck.substring(colonPos+1,theCheck.length);
								  if (theNum < min || max < theNum) // RANGO INCORRECTO
								    errors += '- The field '+title+' needs a valid range into '+min+' and '+max+'.\n';
							    } 
							
								}	// FIN COMPROBACION NUMEROS
							}		// FIN COMPROBACION CAMPO VACIO
					    else 
							if (theCheck.charAt(0) == 'R') errors += '- The field '+title+' is required.\n';
					  } // For
					  if (errors) alert('Check the data.\n\nThe form can not be processed:\n\n'+
					                    errors+'\nPlease, change the data and try again.');
					  document.MM_returnValue = (errors == '')
					}
					//-->
//</script>