<!--
//////////////////////////////////////////////////////////////////////////////////////////////
/*								ARCHIVO VALIDAR.JS  Ver. 2.0 2006	 						*/
/*					 		VALIDA CAMPOS DEL FORMULARIO DE CONTACTO CON JAVASCRIPT			*/
/*									MEDIANTE VALIDACIONES EN CLLIENTE						*/
/*									COPYRIGHT 2006 WEB - INFORMÁTICA						*/
/*									JORGE CORDERO  alexmansv@yahoo.com						*/	
//////////////////////////////////////////////////////////////////////////////////////////////
function Validar(form)
{
  	if(form.txtNombre.value == "")
	{ 
		alert("Por favor ingrese su nombre");
		window.document.forms[0].txtNombre.focus();
		return false;
	}

  	if(form.txtCorreo.value == "")
	{
	 	alert("Por favor ingrese su correo"); 
		window.document.forms[0].txtCorreo.focus();
		return false;
	}
	
  	if(revisarCorreo(form.txtCorreo.value)==false)
	{
	 	alert("Por favor ingrese una direcion de correo válida"); 
		form.txtCorreo.focus();
		return false;
	}
	
  	if(form.txtAsunto.value == "")
	{
	 	alert("Por favor ingrese un asunto para el mensaje"); 
		form.txtAsunto.focus();
		return false;
	}

  	if(form.txtMensaje.value == "")
	{
	 	alert("Por favor ingrese un mensaje"); 
		form.txtMensaje.focus();
		return false;
	}

}     

function revisarCorreo(texto){

    var mailres = true;            
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    
    var arroba = texto.indexOf("@",0);
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
    
    var punto = texto.lastIndexOf(".");
                
     for (var contador = 0 ; contador < texto.length ; contador++){
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
            mailres = false;
            break;
     }
    }

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
     mailres = true;
    else
     mailres = false;
                
    return mailres;
	} 

//-->
