/* $Id: functions.js,v 1.11 2002/01/03 12:09:30 loic1 Exp $ */

/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function
//
function Verificar_email(email) {
// var mayusculas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 var minusculas = "abcdefghijklmnopqrstuvwxyz";
 var numeros = "1234567890";
 var especiales = "@_.-";
 var valido = false;
 var arrobas = 0;
 var posicion_arroba = 0;
 var puntos = 0;
 var c = 0;

	for (n=0; n<email.length; n++) {
		if ((numeros.indexOf(email.charAt(n)) == -1)&&
			//(mayusculas.indexOf(email.charAt(n)) == -1)&&
			(minusculas.indexOf(email.charAt(n)) == -1)&&
			(especiales.indexOf(email.charAt(n)) == -1)) {
			return (valido);
		}
		if (email.charAt(n)=="@") {
			posicion_arroba = email.indexOf("@");
			arrobas++;
		}
		if (email.charAt(n)==".") {
			puntos++;
		}
	}
 
	if (arrobas != 1) {
		return (valido);
	}
	else if (puntos < 1) {
			return (valido);
	}
	else if ((email.charAt(c) == "@")||
		(email.charAt(c) == "_")||
		(email.charAt(c) == ".")) {
			return (valido);
	}
	else {
		valido = true
	}

 return (valido);
}
//
function do_Validar(formulario) {
//
	with (formulario) {
	if (!Verificar_email(formulario.Email.value)) {
		alert("<< La Dirección de EMAIL no es válida. >>\n\nAsegúrese de introducir sólo letras minúsculas \ny de que el dato no este vacío.");
		formulario.Email.focus();
	}
	else {
		submit()
	}
	}//end With
}