// JavaScript Document

function emptyvalidation(entered, alertbox)
{

	with (entered)
	{
		if (value==null || value=="")
		{
			if (alertbox!="") 
			{
				alert(alertbox);
			}
			
			return false;
		}
		else 
		{
			return true;
		}
	}
}


function validate_mail(field,alerttxt){
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function formvalidation(thisform){   
    with (thisform)
    {   if (emptyvalidation(nombre,"Nombre vacio")==false) {nombre.focus(); return false;}
		if (emptyvalidation(tel,"Teléfono vacio")==false) {tel.focus(); return false;}
        if (emptyvalidation(correo,"Correo vacio")==false) {correo.focus(); return false;}
        if (emptyvalidation(mensaje,"mensaje vacio")==false) {mensaje.focus(); return false;}
        if (validate_mail(correo,"Su correo no es valido")==false) {correo.focus();return false;}
    }
}


