// JavaScript Document
function lTrim(sStr){
	while (sStr.charAt(0) == " ")
		sStr = sStr.substr(1, sStr.length - 1);
	 return sStr;
	}
	
function rTrim(sStr){
	 while (sStr.charAt(sStr.length - 1) == " ")
	  sStr = sStr.substr(0, sStr.length - 1);
	 return sStr;
}
function allTrim(sStr){
	 return rTrim(lTrim(sStr));
}

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 val_cotiz(){
	if (allTrim(document.frm_cotiz.cot_nombre.value)==""){		
		alert("Por favor, ingrese su nombre");
		document.frm_cotiz.cot_nombre.value='';
		document.frm_cotiz.cot_nombre.focus();
	}else if(allTrim(document.frm_cotiz.cot_email.value)==""){
		alert("Por favor, ingrese su E-mail");
		document.frm_cotiz.cot_email.value='';
		document.frm_cotiz.cot_email.focus();
	}else if(val_email_online(document.frm_cotiz.cot_email.value)==false){
		alert("Por favor, ingrese un E-mail válido");
		document.frm_cotiz.cot_email.select();
	}else if(allTrim(document.frm_cotiz.cot_categoria.value)==""){
		alert("Por favor, ingrese la categoria.");
		document.frm_cotiz.cot_categoria.value="";
		document.frm_cotiz.cot_categoria.focus();
	}else if(allTrim(document.frm_cotiz.cot_servicio.value)==""){
		alert("Por favor, ingrese el servicio");
		document.frm_cotiz.cot_servicio.value="";
		document.frm_cotiz.cot_servicio.focus();
	}else if(allTrim(document.frm_cotiz.cot_informacion.value)==""){
		alert("Por favor, ingrese una información adicional");
		document.frm_cotiz.cot_informacion.value="";
		document.frm_cotiz.cot_informacion.focus();	
	}else{				
		document.frm_cotiz.submit();
	}
}

/***** CONTACTENTOS *****/
function val_contactenos_(){
	if (allTrim(document.frm_contactos.contacto_nombre.value)==""){		
		alert("Por favor, ingrese su nombre");
		document.frm_contactos.contacto_nombre.focus();
	}else if(allTrim(document.frm_contactos.contacto_email.value)==""){
		alert("Por favor, ingrese su email");
		document.frm_contactos.contacto_email.focus();
	}else if(val_email_online(document.frm_contactos.contacto_email.value)==false){
		alert("Por favor, ingrese un email válido");
		document.frm_contactos.contacto_email.select();
	}else if(allTrim(document.frm_contactos.contacto_informacion.value)==""){
		alert("Por favor, ingrese su consulta");
		document.frm_contactos.contacto_informacion.focus();
	}else{		
		document.frm_contactos.submit();
	}
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||allTrim(value)=="")
  {alert(alerttxt);return false;}
else {return true}
}
}

function validate_form(frm_contactos)
{
	with (frm_contactos)
	{
		if (validate_required(contacto_nombre,"Por favor, ingrese su nombre")==false)
			{contacto_nombre.value="";contacto_nombre.focus();return false;}		
		if (validate_required(contacto_email,"Por favor, ingrese su E-mail")==false)
			{contacto_email.focus();return false;}
		if(val_email_online(contacto_email.value)==false)
			{alert("Por favor, ingrese un email válido");contacto_email.select();return false;}
	}
}
/*********************/
function validarco(formulario) {
if (formulario.contacto_nombre.value.length <8) {
    alert("Ingrese sus Nombres y Apellidos");
				    formulario.contacto_nombre.focus();
    return (false);
  }
	if ((formulario.contacto_email.value.indexOf ('@', 0) == -1)||(formulario.contacto_email.value.length < 5)) { 
    alert("Escriba email");
		formulario.contacto_email.focus(); 
    return (false); 
  }
 	 	if (formulario.contacto_telefonos.value.length <7) {
    alert("Ingrese numero telefonico");
				    formulario.contacto_telefonos.focus();
    return (false);
  }
  if (formulario.contacto_informacion.value.length <8) {
    alert("Ingrese consulta");
				    formulario.contacto_informacion.focus();
    return (false);
  }
     return (true); 
}
function validarc(formulario) {
if (formulario.cot_nombre.value.length <8) {
    alert("Ingrese sus Nombres y Apellidos");
				    formulario.cot_nombre.focus();
    return (false);
  }
	if ((formulario.cot_email.value.indexOf ('@', 0) == -1)||(formulario.cot_email.value.length < 5)) { 
    alert("Escriba email");
		formulario.cot_email.focus(); 
    return (false); 
  }
 	 	if (formulario.cot_telefonos.value.length <7) {
    alert("Ingrese numero telefonico");
				    formulario.cot_telefonos.focus();
    return (false);
  }
 
     return (true); 
}


function validar(e){
tecla_codigo = (document.all) ? e.keyCode : e.which;
patron =/[0-9\-]/;
tecla_valor = String.fromCharCode(tecla_codigo);
return patron.test(tecla_valor);
}

function flashjuego() {
 
     var newWin = window.open("modulos_web/msj_flash.php", "", "width=650, height=460,top=40,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=0");
    if (navigator.appVersion.indexOf("(X11") != -1 ||
        navigator.appVersion.indexOf("(Mac") != -1)
      newWin = window.open("modulos_web/msj_flash.php", "", "width=650, height=460,top=40,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=0");
 
  }

function perfil() {
 
     var newWin = window.open("perfil.html", "", "width=680, height=660,top=40,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=0");
   
  }

function envioperfil() {
      var newWin = window.open("perfiles.php", "", "width=420, height=50,top=40,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=0");
  }
  
function recordar() {
      var newWin = window.open("recordar.php", "", "width=490, height=50,top=210,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=0");
  }  