/**
 * Copyriht (C) 2005 JKLM Ltda. Bogotá, Colombia.
 * All rigths Reserved.
 * JKLM
 */

 function validarForma(theForm){
 	if(theForm.elements["nombre"].value==null || theForm.elements["nombre"].value=="" || theForm.elements["nombre"].value==" "){
		alert("El nombre no puede estar vacio");	
		theForm.elements["nombre"].focus();
		return false;
	}

	if(theForm.elements["correo"].value==null || theForm.elements["correo"].value=="" || theForm.elements["correo"].value==" "){
		alert("El correo no puede estar vacio");	
		theForm.elements["correo"].focus();
		return false;
	}

	if(!esCorreoValido(theForm.elements["correo"])){
		return false;
	}

 	if(theForm.elements["comentarios"].value==null || theForm.elements["comentarios"].value=="" || theForm.elements["comentarios"].value==" "){
		alert("Los comentarios no puede estar vacios");	
		theForm.elements["comentarios"].focus();
		return false;
	}

	if(!validarLimite(theForm))
		return false;

	return true;
 }

 function esCorreoValido(correo_){
 	var s = correo_.value;
	var filter=/^[A-Za-z][A-Za-z0-9_.-]*@[A-Za-z0-9_-]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) {
		alert("El correo electronico debe ser de la forma: direccion@servidor.dominio");
		correo_.select();
		correo_.focus();
		return false;
	}						
	if (filter.test(s)){
		return true;
	} else {
		alert("El correo electronico debe ser de la forma: direccion@servidor.dominio");
		correo_.select();
		correo_.focus();
		return false;						
	}
 }
 
  function validarLimite(theForm){
	pVal = theForm.elements["comentarios"].value;
 	if(pVal.length >= 600){
		theForm.elements["comentarios"].value = null;
		theForm.elements["comentarios"].value = theForm.elements["valorAnt"].value;
		alert("Ha excedido el limite de 600 caracteres");
		return false;
	}else{
		return true;
	}
 }