// JavaScript Document
function validateForm(formDesc) {
	var formObj = 'document.'+formDesc.name;	
	arrayLen = formElement.length;
	//validation subroutine
	for (a = 0; a < arrayLen; a++) {
		if (eval(formObj+'.'+formElement[a]) && !document.getElementById(formElement[a]).disabled) {
			if (eval(formObj+'.'+formElement[a]).name.indexOf("mail") > -1){
				 if (validateEmail(eval(formObj+'.'+formElement[a]).value) == false) {
				 	return false;
				 	}
				}
			if (!eval(formObj+'.'+formElement[a]).value){
				alert(alertMsg[a]);
				eval(formObj+'.'+formElement[a]).focus();
				return false;				
				}
			}
		}
	//submitting data
	eval(formObj).submit();
	}


function validateEmail(email){
	var error;
	error = false;
	posicion = email.indexOf("@");
	switch (posicion) {
		case -1:
			error = true;
		case 0:
			error = true;
		case email.length-1:
			error = true;
		default:
			email = email.substr(posicion+1);
			posicion = email.indexOf("@");
			if (posicion>-1) {
				error = true;
				}
		posicion=email.indexOf(".");
		if (posicion==-1)
		{
//			window.alert("La parte del servidor debe contener un carácter ''.''");
			error = true;
		}
		if (posicion==0)
		{
//			window.alert("El carácter ''.'' no puede estar al principio de la parte del servidor");
			error = true;
		}
		while (posicion>-1)
		{				
			if (posicion==email.length-1)
			{
//				window.alert("El carácter ''.'' no puede estar al final de la parte del servidor");
				error = true;
			}
			email=email.substr(posicion+1);
			posicion=email.indexOf(".");
		}
	}
	if (error == true){ 
		alert("Debe de proveer una dirección de correo electrónico válida.")
		return false;
		}
		else return true;
		}