function f_validate() {
	var cont;
	// Se recorren los campos que requieren validación.
	for(cont=0; cont<aFieldsValidate.length; cont++) {
		// Segun el tipo de validación requerida se re-envía el contenido del campo a la función correcta, indicando si es obligatorio.
		if(aFieldsValidate[cont][1]=="String") bool = f_valString(document.forms[0].elements[aFieldsValidate[cont][0]].value, aFieldsValidate[cont][2], aFieldsValidate[cont][4]);
		if(aFieldsValidate[cont][1]=="Date") bool = f_valDate(document.forms[0].elements[aFieldsValidate[cont][0]].value, aFieldsValidate[cont][2]);
		if(aFieldsValidate[cont][1]=="Int") bool = f_valInt(document.forms[0].elements[aFieldsValidate[cont][0]].value, aFieldsValidate[cont][2]);
		if(aFieldsValidate[cont][1]=="Option") bool = f_valOption(document.forms[0].elements[aFieldsValidate[cont][0]].selectedIndex, aFieldsValidate[cont][2]);
		if(aFieldsValidate[cont][1]=="Email") bool = f_valMail(document.forms[0].elements[aFieldsValidate[cont][0]].value, aFieldsValidate[cont][2]);
		if(!bool) { alert(aFieldsValidate[cont][3]); return false; }
	}
	return true;
}
function f_valOption(i) {
	return i!=0;
}
function f_valInt(i, b) {
	if(b && i=="") return false;
	return String(i)==String(parseInt(i));
}
function f_valString(s, b, max) {
	if(s=="" && b) return false;
	if(max!=null) if(s.length>max) return false;
	return true;
}
function f_valDate(d, b) {
	aMonth = Array(31,28,31,30,31,30,31,31,30,31,30,31);
	fecha = new String(d);
	if(fecha.length==0 && !b) return true;
	fecha = fecha.split("/");
	if(fecha.length!=3)  return false;
	if(fecha[0].length<1 || fecha[0].length>2 || fecha[1].length<1 || fecha[1].length>2 || fecha[2].length<1 || fecha[2].length>4 ) return false;
	fecha[0] = paseInt(String(fecha[0]));
	fecha[1] = paseInt(String(fecha[1]));
	fecha[2] = paseInt(String(fecha[2]));
	if(fecha[2]%4==0) aMonth[1]=29;
	if(fecha[1]<1 || fecha[1]>12) return false;
	if(fecha[0]<1 || fecha[0]>aMonth[fecha[1]-1]) return false;
	return true;
}
function paseInt(str) {
	var cont, i = 0;
	for(cont=0; cont<str.length; cont++) { status=cont; i = (i*10) + parseInt(str.substr(cont,1)); }
	return i;
}
function f_valMail(email, b) {
	var isEmail = email.match(/^\w+(-\w+)*(\.\w+(-\w+)*)*@\w+(-\w+)*(\.\w+(-\w+)*)*\.([a-z]{3}|[a-z]{2})$/);
	if (isEmail || (!b && email=="")) return true;
	return false;
}