// JavaScript Document
function envia_contacto(){
	  var bien=true;
	  var text="Han ocurrido los siguientes errores: ";
	  if (!validarCampo(document.form_contacto.nombre.value))
	  	{
				text+="\n  Atención: El campo Nombre longitud minima 1.";
		        bien=false;
		}
		
		 	
	
	if (document.form_contacto.email.value=="" || document.form_contacto.email.value.length==0){
	   bien=false;
	   text+="\n  Atención: Escribir E-mail.";
	 }else{
		 if (!validarEmail(document.form_contacto.email.value)){
				bien=false;
				text+="\n  Atención: Formato del e-mail es incorrecto.";
			 }
	 }
	 
	 if (!validarCampo(document.form_contacto.comentarios.value)){
			text+="\n  Atención: El campo Comentario longitud minima 1.";
			bien=false;
	 }
	

	
	if (bien==true){
    document.form_contacto.submit();	
    }else{
     alert(text);
    }
  
}

function validarEmail(valor)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
		{
			return (true)
		} 
		else 
		{
	    	return (false);
	  	}
	 }

function validarCampo(valor)
	{
		if (/\w+([\.-]?\w)/.test(valor))
		{
			return (true)
		} 
		else 
		{
	    	return (false);
	  	}
	 }
	 
	 
/*
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.id; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- El campo '+nm+' debe ser un correo electrónico válido.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- El campo '+nm+' debe ser un número.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- El campo '+nm+' debe ser un número entre '+min+' y '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- El campo '+nm+' es obligatorio.\n'; }
    } if (errors) alert('Atención:\n'+errors);
    
	if (errors == '')
	{
		document.form_contacto.submit();	
	}
	//document.MM_returnValue = (errors == '');
} }*/
