
function enviar()
{
	 if(validar())
	 {
	 	document.getElementById("forma").submit();
	 }
}
function validar()
{

	
	var nombre = document.getElementById("nombre");
	var correo = document.getElementById("correo");
	var comentarios = document.getElementById("comentarios");

	if(!is_empty(nombre.value)){ aviso("nombre"); return false;}
	if(!is_email(correo.value)){ aviso("correo"); return false;}
	if(!is_empty(comentarios.value)){ aviso("comentarios"); return false;}	
	
	return true;	
}

function aviso(campo)
{

	var field = "w"+campo;
	document.getElementById(field).style.display = "inline";
	setTimeout("quitar(\""+field+"\")",2000);
}
function quitar(campo)
{
	document.getElementById(campo).style.display = "none";
}
function is_email(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return (reg.test(email) == false)? false : true;
}

function vacio(q)
{  
	for(i=0;i<q.length;i++)
	{  
		if(q.charAt(i)!="")
		{  
			return true;
		}  
	}  
	return false;
}  
   
function is_empty(campo)
{  
	if(vacio(campo)==false)
	{  
		return false;  
	}else{  
		return true;
	}  
}
  