// JavaScript Document

function val_email_online(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function clean_box(){
	document.frm_contactos.txt_nombre.value="";	
	document.frm_contactos.txt_email.value="";	
	document.frm_contactos.txt_telf.value="";	
	document.frm_contactos.txt_cons.value="";	
	document.frm_contactos.txt_nombre.focus();	
}

function env_email_val(){
	if (document.frm_contactos.txt_nombre.value==""){		
		document.getElementById('div_msj').innerHTML="Por favor, ingrese su nombre";
		document.frm_contactos.txt_nombre.focus();
	}else if(document.frm_contactos.txt_email.value==""){
		document.getElementById('div_msj').innerHTML="Por favor, ingrese su email";
		document.frm_contactos.txt_email.focus();
	}else if(val_email_online(document.frm_contactos.txt_email.value)==false){
		document.getElementById('div_msj').innerHTML="Por favor, ingrese un email válido";
		document.frm_contactos.txt_email.select();
	}else if(document.frm_contactos.txt_cons.value==""){
		document.getElementById('div_msj').innerHTML="Por favor, ingrese su consulta";
		document.frm_contactos.txt_cons.focus();
	}else{
		document.frm_contactos.submit();
	}
}
