/*
Este es un acuerdo legal entre el licenciatario y Labrys Technologies (en adelante, Labrys).

LICENCIA. Labrys le concede el derecho no-exclusivo, no transferible de usar sus librerías 
de software propietarias en el ámbito del proyecto desarrollado. Labrys se reserva todos 
los derechos que no le hayan sido expresamente concedidos.

PLAZO. Se les concede a los usuarios finales el derecho de usar esta librería durante un 
plazo ilimitado y exclusivamente para el proyecto objeto de este acuerdo. 

Esta licencia no es válida si no va acompañada de la factura original de desarrollo del 
proyecto. 

Esta licencia finalizará automáticamente si usted incumple cualquiera de los términos o 
condiciones del contrato y deberá proceder a destruir cualquiera copias hubiera realizado.

USO DEL SOFTWARE. Usted puede usar este software pero esto no le convierte en el 
propietario de esta librería. La posesión y títulos de estas pertenecerán en todo momento 
a Labrys, desde los discos originales hasta las siguientes copias independientemente del 
medio usado o la forma en que estas se hayan realizado.

COPYRIGHT. Esta librería y cualquier material impreso que le acompañe, son propiedad de 
Labrys. Usted deberá incluir todos los avisos de copyright en las copias de seguridad de 
las librerías de software. Usted no puede vender, alquilar o arrendar esta librería. Usted 
no podrá realizar tareas de ingeniería inversa, modificación, recopilación, desensamblado, 
o creación de software derivado de dicha librería.

INTEGRIDAD. Esta licencia significa un total acuerdo entre usted y Labrys y solo podrá ser 
modificada mediante un escrito firmado por ambas partes.

NINGÚN VENDEDOR, DISTRIBUIDOR, DETALLISTA, COMERCIAL O CUALQUIER OTRA PERSONA, ESTÁ 
AUTORIZADA A MODIFICAR ESTA LICENCIA O ACORDAR CUALQUIER GARANTIA, PETICIÓN O PROMESA, 
QUE SEA DIFERENTE, O UN AÑADIDO A, LAS PETICIONES O PROMESAS DE ESTA LICENCIA. 

GARANTIA LIMITADA. Labrys no concede ninguna garantía concerniente a esta copia del software
y  de esta librería. Labrys no garantiza que dicho software este libre de errores. Labrys o 
sus distribuidores no tienen responsabilidad por los daños que esto pueda ocasionar. 

Labrys o sus distribuidores no serán responsables de daños ocasionales o indirectos, que 
puedan derivarse del funcionamiento o el uso de estas librerías de software, incluso aunque 
hayan sido avisados de la existencia de estos posibles daños.
*/
function Validacion(nombreform){this.objform=document.forms[nombreform];if(!this.objform){return;}this.addValidacion=add_validacion;this.validaFormulario=valida_formulario;}function valida_formulario(){for(var itr=0;itr<this.objform.elements.length;itr++){if(this.objform.elements[itr].validaciones &&!this.objform.elements[itr].validaciones.validar()){return false;}}return true;}function add_validacion(itemname,descriptor,errstr,iw5){if(!this.objform){alert("ERROR: el objeto formulario no ha sido definido adecuadamente");return;}var itemobj=this.objform[itemname];if(!itemobj){alert("ERROR: No se puede obtener el objeto input de nombre: "+itemname);return;}if(!itemobj.validaciones){itemobj.validaciones=new GrupoValidaciones(itemobj);}itemobj.validaciones.add(descriptor,errstr,iw5);}function ValidationDesc(inputitem,desc,error,iw5){this.desc=desc;this.error=error;this.objentrada=inputitem;this.validar=validar_objeto;this.iw5=iw5;}function validar_objeto(){if(!ValidaDatos(this.desc,this.objentrada,this.error)){if((this.iw5!=null)&&(this.iw5!=""))eval(this.iw5);this.objentrada.focus();return false;}return true;}function GrupoValidaciones(inputitem){this.vSet=new Array();this.add=add_descvalidacion;this.validar=grupo_validacion;this.objentrada=inputitem;}function add_descvalidacion(desc,error,iw5){this.vSet[this.vSet.length]=new ValidationDesc(this.objentrada,desc,error,iw5);}function grupo_validacion(){for(var itr=0;itr<this.vSet.length;itr++){if(!this.vSet[itr].validar()){return false;}}return true;}function validateEmailv2(email){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;}return true;}return false;}function validateFecha(J82,g9_$){if((g9_$==null)||(g9_$==""))p3v="/";else p3v=g9_$;OvSRh=J82;if(OvSRh){borrar=OvSRh;if(((OvSRh.substr(2,1)==p3v)&&(OvSRh.substr(5,1)==p3v))||((OvSRh.substr(2,1)=="/")&&(OvSRh.substr(5,1)=="/"))){for(i=0;i<10;i++){if(((OvSRh.substr(i,1)<"0")||(OvSRh.substr(i,1)>"9"))&&(i!=2)&&(i!=5)){borrar='';break;}}if(borrar){a=OvSRh.substr(6,4);m=OvSRh.substr(3,2);d=OvSRh.substr(0,2);if((a<1900)||(a>2050)||(m<1)||(m>12)||(d<1)||(d>31))borrar='';else{if((a%4!=0)&&(m==2)&&(d>28))borrar='';else{if((((m==4)||(m==6)||(m==9)||(m==11))&&(d>30))||((m==2)&&(d>29)))borrar='';}}}}else borrar='';if(borrar==''){return false;}}return true;}function ValidaDatos(strValidateStr,objValue,strError){var epos=strValidateStr.search("=");var command="";var cmdvalue="";if(epos>=0){command=strValidateStr.substring(0,epos);cmdvalue=strValidateStr.substr(epos+1);}else{command=strValidateStr;}switch(command){case "req":case "requerido":{if(eval(objValue.value.length)==0){if(!strError||strError.length==0){strError=objValue.name+" : Campo obligatorio";}alert(strError);return false;}break;}case "maxlongitud":case "maxlong":{if(eval(objValue.value.length)>eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : "+cmdvalue+" caracteres maximo ";}alert(strError+"\n[Longitud actual = "+objValue.value.length+" ]");return false;}break;}case "minlongitud":case "minlong":{if(eval(objValue.value.length)<eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : "+cmdvalue+" caracteres minimo  ";}alert(strError+"\n[Longitud actual = "+objValue.value.length+" ]");return false;}break;}case "alnum":case "alfanumerico":{var charpos=objValue.value.search("[^A-Za-z0-9]ñÑ ");if(objValue.value.length>0 && charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Solo se permiten numeros alfanumericos ";}alert(strError+"\n [Error en el caracter de la posicion "+eval(charpos+1)+"]");return false;}break;}case "num":case "numerico":{var charpos=objValue.value.search("[^0-9]");if(objValue.value.length>0 && charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Solo se permiten numeros ";}alert(strError+"\n [Error en el caracter de la posicion "+eval(charpos+1)+"]");return false;}break;}case "float":{var charpos=objValue.value.search("[^0-9.]");if(objValue.value.length>0 && charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Solo se permiten numeros ";}alert(strError+"\n [Error en el caracter de la posicion "+eval(charpos+1)+"]");return false;}break;}case "texto":case "txt":{var charpos=objValue.value.search("[^A-Za-zñÑ] ");if(objValue.value.length>0 && charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Solo se permiten caracteres de letras ";}alert(strError+"\n [Error en el caracter de la posicion "+eval(charpos+1)+"]");return false;}break;}case "alnumhyphen":{var charpos=objValue.value.search("[^A-Za-z0-9\-_]ñÑ ");if(objValue.value.length>0 && charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": los caracteres permitidos solo son A-Z,a-z,0-9,- y _";}alert(strError+"\n [Error en el caracter de la posicion "+eval(charpos+1)+"]");return false;}break;}case "email":{if(!validateEmailv2(objValue.value)){if(!strError||strError.length==0){strError=objValue.name+": Introduzca una direccion de email correcta ";}alert(strError);return false;}break;}case "fecha":{alert("Validando fecha.");if(!validateFecha(objValue.value,cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Introduzca una FECHA correcta dd/mm/aaaa";}alert(strError);return false;}break;}case "menor":case "menorque":{if(isNaN(objValue.value)){alert(objValue.name+": Debe ser un numero ");return false;}if(eval(objValue.value)>=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : el valor debe ser menor que "+cmdvalue;}alert(strError);return false;}break;}case "mayor":case "mayorque":{if(isNaN(objValue.value)){alert(objValue.name+": Debe ser  un numero ");return false;}if(eval(objValue.value)<=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : el valor debe ser mayor que "+cmdvalue;}alert(strError);return false;}break;}case "regexp":{if(objValue.value.length>0){if(!objValue.value.match(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Se han encontrado caracteres erroneos ";}alert(strError);return false;}}break;}case "seleccion":case "selec":{if(objValue.selectedIndex==null){alert("ERROR: se ha introducido una validacion de seleccion a un elementos no seleccionable");return false;}if(objValue.selectedIndex==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Por favor seleccione una opcion ";}alert(strError);return false;}break;}case "seleccionMayor":case "selecMayor":{if(objValue.selectedIndex==null){alert("ERROR: se ha introducido una validacion de seleccion a un elementos no seleccionable");return false;}if(objValue.selectedIndex<=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Por favor seleccione una opcion correcta ";}alert(strError);return false;}break;}case "seleccionMenor":case "selecMenor":{if(objValue.selectedIndex==null){alert("ERROR: se ha introducido una validacion de seleccion a un elementos no seleccionable");return false;}if(objValue.selectedIndex>=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Por favor seleccione una opcion correcta ";}alert(strError);return false;}break;}}return true;}