//function creaAjax(){ //------------------------------------------------------------------------------- //var objetoAjax=false; //try { /*Para navegadores distintos a internet explorer*/ //objetoAjax = new XMLHttpRequest();; //} catch (e) { //try { ///*Para explorer*/ //objetoAjax = new ActiveXObject("Microsoft.XMLHTTP"); //} //catch (E) { //objetoAjax = false; //} //} //if (!objetoAjax && typeof XMLHttpRequest!='undefined') { //objetoAjax = new XMLHttpRequest(); //} //return objetoAjax; //} //function FAjax (url,capa,valores,metodo){ //var ajax=creaAjax(); //var capaContenedora = document.getElementById(capa); /*Creamos y ejecutamos la instancia si el metodo elegido es POST*/ //if(metodo.toUpperCase()=='POST'){ // ajax.open ('POST', url, true); // ajax.onreadystatechange = function() { // if (ajax.readyState==1) { //Petición en carga //capaContenedora.innerHTML="Cargando......."; //} //else if (ajax.readyState==4){ //Petición completada //if(ajax.status==200) //{ //document.getElementById(capa).innerHTML=ajax.responseText; //} //else if(ajax.status==404) //{ //capaContenedora.innerHTML = "La direccion no existe"; //} //else //{ //capaContenedora.innerHTML = "Error: "+ajax.status; //} //} //} //ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); //ajax.send(valores); //return; //} /*Creamos y ejecutamos la instancia si el metodo elegido es GET*/ //if (metodo.toUpperCase()=='GET'){ //ajax.open ('GET', url, true); //ajax.onreadystatechange = function() { //if (ajax.readyState==1) { //capaContenedora.innerHTML="Cargando......."; //} //else if (ajax.readyState==4){ //if(ajax.status==200){ //var vxml = ajax.responseXML.documentElement; //Accedemos al xml recibido //for (i = 0; i < vxml.getElementsByTagName('mensaje').length; i++){ //var item = vxml.getElementsByTagName('mensaje')[1]; //var txt = item.getElementsByTagName('texto')[0].firstChild.data; //también se puede escribir así //capaContenedora.style.visibility="visible"; //capaContenedora.innerHTML=txt; //} //} //else if(ajax.status==404) //{ //capaContenedora.innerHTML = "La direccion no existe"; //} //else //{ //capaContenedora.innerHTML = "Error: ".ajax.status; //} //} //} //ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); //ajax.send(null); //return //} //} function ejecuta(x) { scr=x; } function CCuit(valor) { if (! esnumero(document.frmLogin.txtUsuario.value,document.frmLogin.txtUsuario.value.length)) { alert ("El CUIT ingresado no es un número"); document.frmLogin.txtUsuario.focus(); } else if (document.frmLogin.txtUsuario.value.length !=11) { alert ("El CUIT ingresado deber contener 11 dígitos"); document.frmLogin.txtUsuario.focus() } else if (! digitoverif(document.frmLogin.txtUsuario.value)) { alert ("El CUIT ingresado no cumple con la rutina del dígito verficador"); document.frmLogin.txtUsuario.focus() } else { document.frmLogin.action ="seguridad/do_login.asp" document.frmLogin.submit } } function esnumero(cuit,hasta) { var flag=true; var i=0; while (flag==true && i < hasta) { if (cuit.substring(i, i+1)<"0" | cuit.substring(i, i+1)>"9") flag=false; i= i + 1; } return flag; } function digitoverif(cuit) { var strbase = "54327654321"; var tot = 0; var z = 0; var dv; var i=0; var flag=false; while (i < 10) { tot=tot+strbase.substring(i, i+1)*cuit.substring(i, i+1); i= i + 1; } while (z < tot) { z = z + 11; } dv = z - tot; if (dv==cuit.substring(10,11)) flag=true; return flag; } // ********** AYUDA // ********** Parte 1: Inicializar valores MouseX=0; MouseY=0; // ********** Parte 2: Funciones // Función para capturar el evento "Mouse Move" (al moverse el mouse) function init() { if (window.Event) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = getXY; } // Función que actualiza la posición del ratón function getXY(e) { MouseX = (window.Event) ? e.pageX : (event.clientX + document.body.scrollLeft); MouseY = (window.Event) ? e.pageY : (event.clientY + document.body.scrollTop); } // Función que aparece y desaparece el cuadrito de la ayuda function hint( id, status ) { var htmObj = document.getElementById(id) if(!htmObj) return ; htmObj.style.visibility = status ? 'visible' : 'hidden'; htmObj.style.top = MouseY+20+'px'; htmObj.style.left = MouseX+10+'px'; } function nuevoAjax() { /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por lo que se puede copiar tal como esta aqui */ var xmlhttp=false; try { // Creacion del objeto AJAX para navegadores no IE xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { // Creacion del objet AJAX para IE xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { xmlhttp=false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } return xmlhttp; } function cargaContenido(selectACargar) { // Recibo el número correspondiente al combo que se debe llenar de datos var selectAnterior=selectACargar-1; // Obtengo el número del combo que activó el evento onChange // Extraigo el valor del combo que se ha cambiado var valor=document.getElementById("select_"+selectAnterior).options[document.getElementById("select_"+selectAnterior).selectedIndex].value; var elemento; if(valor!=0) { ajax=nuevoAjax(); // Envio al servidor el valor seleccionado y el combo al cual se le deben poner los datos ajax.open("GET", "select_dependientes_3_niveles_proceso.asp?seleccionado="+valor+"&select_a_cargar="+selectACargar, true); ajax.onreadystatechange=function() { if (ajax.readyState==1) { // Mientras carga elimino la opcion "Elige" y pongo una que dice "Cargando" if (selectACargar<5) { elemento=document.getElementById("select_"+selectACargar); elemento.length=0; var opcionCargando=document.createElement("option"); opcionCargando.value=0; opcionCargando.innerHTML="Cargando..."; elemento.appendChild(opcionCargando); elemento.disabled=true; } } if (ajax.readyState==4) { // Coloco en la fila contenedora los datos que recibo del servidor document.getElementById("fila_"+selectACargar).innerHTML=ajax.responseText; } } ajax.send(null); } /* Colocamos mediante los whiles los selects en "Selecciona opción..." cuando el select anterior ha quedado en estado "Elige" */ var x=1, y=null; while(x<=2) { valor=document.getElementById("select_"+x).options[document.getElementById("select_"+x).selectedIndex].value; if(valor==0) { while(x<=3) { y=x+1; elemento=document.getElementById("select_"+y); elemento.length=0; var opcionSelecciona=document.createElement("option"); opcionSelecciona.value=0; opcionSelecciona.innerHTML="Selecciona opción..."; elemento.appendChild(opcionSelecciona); elemento.disabled=true; x++; } } x++; } } function cargaContenidoSD(selectACargar) { // Recibo el número correspondiente al combo que se debe llenar de datos var selectAnterior=selectACargar-1; // Obtengo el número del combo que activó el evento onChange // Extraigo el valor del combo que se ha cambiado var valor=document.getElementById("SubDiario_"+selectAnterior).options[document.getElementById("SubDiario_"+selectAnterior).selectedIndex].value; // var valor=1 & valor var elemento; if(valor!=0) { ajax=nuevoAjax(); // Envio al servidor el valor seleccionado y el combo al cual se le deben poner los datos ajax.open("GET", "./listados/select_dependientes_2_niveles_SD.asp?seleccionado="+valor+"&select_a_cargar="+selectACargar, true); ajax.onreadystatechange=function() { if (ajax.readyState==1) { // Mientras carga elimino la opcion "Elige" y pongo una que dice "Cargando" elemento=document.getElementById("SubDiario_"+selectACargar); elemento.length=0; var opcionCargando=document.createElement("option"); opcionCargando.value=0; opcionCargando.innerHTML="Cargando..."; elemento.appendChild(opcionCargando); elemento.disabled=true; } if (ajax.readyState==4) { // Coloco en la fila contenedora los datos que recibo del servidor document.getElementById("fil_"+selectACargar).innerHTML=ajax.responseText; } } ajax.send(null); } /* Colocamos mediante los whiles los selects en "Selecciona opción..." cuando el select anterior ha quedado en estado "Elige" */ var x=1, y=null; while(x<=1) { valor=document.getElementById("SubDiario_"+x).options[document.getElementById("SubDiario_"+x).selectedIndex].value; if(valor==0) { while(x<=1) { y=x+1; elemento=document.getElementById("SubDiario_"+y); elemento.length=0; var opcionSelecciona=document.createElement("option"); opcionSelecciona.value=0; opcionSelecciona.innerHTML="Selecciona opción..."; elemento.appendChild(opcionSelecciona); elemento.disabled=true; x++; } } x++; } } function A(e,t){ var k=null; (e.keyCode) ? k=e.keyCode : k=e.which; if(k==13) (!t) ? B() : t.focus(); } function ACabecera(e,t){ var k=null; (e.keyCode) ? k=e.keyCode : k=e.which; if(k==13) (!t) ? Cabezal() : t.focus() ; } function ALinea(e,t,f){ var k=null; (e.keyCode) ? k=e.keyCode : k=e.which; if(k==13) (!f) ? Detalle() : t.focus() ; } function Detalle() { B2() } function B2(){ //document.AgregaLinea.Cod0.focus(); } function validarSiNumero(numero,campo,e,t){ if (!/^([0-9])*$/.test(numero)) {alert("El valor " + numero + " no es un número"); campo.value=""; campo.focus()} else {var k=null; (e.keyCode) ? k=e.keyCode : k=e.which; if(k==13) (!t) ? B() : t.focus() ;} } function focoini(){ //Hago esta negrada, porque cuando esta logueado el control no existe. try{ document.frmLogin.txtUsuario.focus() } catch(err){ //Manejo el error } } function BorraLinea(mov){ FAjax("5BorraLineas.asp","Detalle","IdMovimiento="+mov,"POST"); } function Debe() { var im im=document.AgregaLinea.Debe0.value if (im>0) document.AgregaLinea.Leyenda0.focus(); else document.AgregaLinea.Haber0.focus(); } function Haber() { var im im=document.AgregaLinea.Haber0.value if (im>0) document.AgregaLinea.Leyenda0.focus(); else document.AgregaLinea.Debe0.focus(); } function foco(campo) { if (campo.value>"") campo.style.backgroundColor="#DDDDDD"; else campo.focus(); } function CargaEjercicios() { // Obtengo el número del combo que activó el evento onChange var selectAnterior="cmbClientes"; // Extraigo el valor del combo que se ha cambiado var valor=document.getElementById(selectAnterior).options[document.getElementById(selectAnterior).selectedIndex].value; var elemento; if(valor!=0) { ajax=nuevoAjax(); // Envio al servidor el valor seleccionado y el combo al cual se le deben poner los datos ajax.open("GET", "script/do_CargaComboEjercicio.asp?IdCliente="+valor+"&select_a_cargar=cmbEjercicio", true); ajax.onreadystatechange=function() { if (ajax.readyState==1) { // Mientras carga elimino la opcion "Elige" y pongo una que dice "Cargando" //if (selectACargar<5) //{ elemento=document.getElementById("cmbEjercicio"); elemento.length=0; var opcionCargando=document.createElement("option"); opcionCargando.value=0; opcionCargando.innerHTML="Cargando..."; elemento.appendChild(opcionCargando); elemento.disabled=true; //} } if (ajax.readyState==4) { // Coloco en la fila contenedora los datos que recibo del servidor document.getElementById("fila_2").innerHTML=ajax.responseText; } } ajax.send(null); } } function DateCompare(dateStrOrigen,dateStrFin){ if (Mask(dateStrOrigen,'99/99/9999') != true) return false; if (Mask(dateStrFin,'99/99/9999') != true) return false; var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; //FECHA ORIGEN var matchArrayOrigen = dateStrOrigen.match(datePat) if (matchArrayOrigen == null) return false monthOrigen = matchArrayOrigen[3] dayOrigen = matchArrayOrigen[1] yearOrigen = matchArrayOrigen[4] //FECHA FIN var matchArrayFin = dateStrFin.match(datePat) if (matchArrayFin == null) return false monthFin = matchArrayFin[3] dayFin = matchArrayFin[1] yearFin = matchArrayFin[4] //CONCATENO Y ARMO STRINGS DE LA FORMA YYYYMMDD strDateOrigen = yearOrigen + monthOrigen + dayOrigen strDateFin = yearFin + monthFin + dayFin //---> CUIDADO !! Aca decia ">=" pero le saque el igual para que permita seleccionar la fecha desde y la fecha hasta en el mismo dia!!! //---> Pablo: 28/07/2009 //COMPARO LOS STRINGS if(strDateOrigen > strDateFin){ return true; } else{ return false; } } /************************************************************** IsDate2: Returns a Boolean (true) if the date is true, false is not Parameters: - DateStr: String date in format (DD/MM/YYYY) Returns: Boolean ***************************************************************/ function IsDate2(dateStr) { // Checks for the following valid date formats: // DD/MM/YYYY DD-MM-YYYY if (Mask(dateStr,'99/99/9999') != true) return false; var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; var matchArray = dateStr.match(datePat) if (matchArray == null) return false month = matchArray[3] day = matchArray[1] year = matchArray[4] if (month < 1 || month > 12) return false if (day < 1 || day > 31) return false if ((month==4 || month==6 || month==9 || month==11) && day==31) return false if (month == 2) { var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) if (day>29 || (day==29 && !isleap)) return false; } return true; } /************************************************************** IsAlphanumeric: Returns a Boolean value indicating whether an expression can be evaluated as a number or char. Parameters: Expression = Variant containing a numeric expression or string expression. Returns: Boolean ***************************************************************/ function IsAlphanumeric(Expression) { Expression = Expression.toLowerCase(); RefString = "abcdefghijklmnopqrstuvwxyz0123456789 "; if (Expression.length < 1) return (false); for (var i = 0; i < Expression.length; i++) { var ch = Expression.substr(i, 1) var a = RefString.indexOf(ch, 0) if (a == -1) return (false); } return(true); } /* ====================================================================== FUNCTION: IsInt INPUT: numstr (string/number) - the string that will be tested to ensure that each character is a digit allowNegatives (boolean) - (optional) when true, allows numstr to be negative (contain a '-'). When false, any negative number or a string starting with a '-' will be considered invalid. RETURN: true, if all characters in the string are a character from 0-9, regardless of value for allowNegatives true, if allowNegatives is true and the string starts with a '-', and all other characters are 0-9. false, otherwise. PLATFORMS: Netscape Navigator 3.01 and higher, Microsoft Internet Explorer 3.02 and higher, Netscape Enterprise Server 3.0, Microsoft IIS/ASP 3.0. ====================================================================== */ function IsInt( numstr, allowNegatives ) { // Return immediately if an invalid value was passed in if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "") return false; // Default allowNegatives to true when undefined or null if (allowNegatives+"" == "undefined" || allowNegatives+"" == "null") allowNegatives = true; var isValid = true; // convert to a string for performing string comparisons. numstr += ""; // Loop through string and test each character. If any // character is not a number, return a false result. // Include special case for negative numbers (first char == '-'). for (i = 0; i < numstr.length; i++) { if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == "-"))) { isValid = false; break; } else if ((numstr.charAt(i) == "-" && i != 0) || (numstr.charAt(i) == "-" && !allowNegatives)) { isValid = false; break; } } // END for return isValid; } // end IsInt /************************************************************** Mask: Returns a Boolean if the specified Expression match the specified Mask. Parameters: Expression = String to validate Mask = String that can contain the following options: 9 = only numbers (0..9) X = only letters (a..z or A..Z) * = Anything... Example: alert(Mask("(954) 572-4419", "(999) 999-9999")); => TRUE alert(Mask("33351-820", "99999-9999")); => FALSE alert(Mask("This is a test", "XXXXXX")); => FALSE alert(Mask("This 34 a test", "**************")); => TRUE Returns: Boolean ***************************************************************/ function Mask(Expression, Mask) { Mask = Mask.toUpperCase(); LenStr = Expression.length; LenMsk = Mask.length; if ((LenStr == 0) || (LenMsk == 0)) return (false); if (LenStr != LenMsk) return (false); TempString = ''; for (Count = 0; Count <= Expression.length; Count++) { StrChar = Expression.substring(Count, Count + 1); MskChar = Mask.substring(Count, Count + 1); if (MskChar == '9') { if(!IsNumber(StrChar)) return (false); } else if (MskChar == 'X') { if(!IsChar(StrChar)) return (false); } else if (MskChar == '*') { if(!IsAlphanumeric(StrChar)) return (false); } else { if (MskChar != StrChar) return (false); } } return (true); } /************************************************************** IsNumber: Returns a Boolean value indicating whether an expression can be evaluated as a number (this includes values like $15,656.00) Parameters: Expression = Variant containing a numeric expression or string expression. Returns: Boolean ***************************************************************/ function IsNumber(Expression) { Expression = Expression.toLowerCase(); RefString = "0123456789.-"; if (Expression.length < 1) return (false); for (var i = 0; i < Expression.length; i++) { var ch = Expression.substr(i, 1) var a = RefString.indexOf(ch, 0) if (a == -1) return (false); } return(true); } /************************************************************** LTrim: Returns a String containing a copy of a specified string without leading spaces Parameters: String = The required string argument is any valid string expression. If string contains null, false is returned Returns: String ***************************************************************/ function LTrim(String) { var i = 0; var j = String.length - 1; if (String == null) return (false); for (i = 0; i < String.length; i++) { if (String.substr(i, 1) != ' ' && String.substr(i, 1) != '\t') break; } if (i <= j) return (String.substr(i, (j+1)-i)); else return (''); } /* RTrim: Returns a String containing a copy of a specified string without trailing spaces Parameters: String = The required string argument is any valid string expression. If string contains null, false is returned Returns: String /***************************************************************/ function RTrim(String) { var i = 0; var j = String.length - 1; if (String == null) return (false); for(j = String.length - 1; j >= 0; j--) { if (String.substr(j, 1) != ' ' && String.substr(j, 1) != '\t') break; } if (i <= j) return (String.substr(i, (j+1)-i)); else return (''); } /************************************************************** RTrim: Returns a String containing a copy of a specified string without both leading and trailing spaces Parameters: String = The required string argument is any valid string expression. If string contains null, false is returned Returns: String ***************************************************************/ function Trim(String) { if (String == null) return (false); return RTrim(LTrim(String)); } /************************************************************** FormatNumber: Returns an expression formatted as a number. Parameters: Expression = Expression to be formatted. NumDigitsAfterDecimal = Numeric value indicating how many places to the right of the decimal are displayed. Returns: String ***************************************************************/ function FormatNumber(Expression, NumDigitsAfterDecimal) { var iNumDecimals = NumDigitsAfterDecimal; var dbInVal = Expression; var bNegative = false; var iInVal = 0; var strInVal var strWhole = "", strDec = ""; var strTemp = "", strOut = ""; var iLen = 0; if (dbInVal < 0) { bNegative = true; dbInVal *= -1; } dbInVal = dbInVal * Math.pow(10, iNumDecimals) iInVal = parseInt(dbInVal); if ((dbInVal - iInVal) >= .5) { iInVal++; } strInVal = iInVal + ""; strWhole = strInVal.substring(0, (strInVal.length - iNumDecimals)); strDec = strInVal.substring((strInVal.length - iNumDecimals), strInVal.length); while (strDec.length < iNumDecimals) { strDec = "0" + strDec; } iLen = strWhole.length; if (iLen >= 3) { while (iLen > 0) { strTemp = strWhole.substring(iLen - 3, iLen); if (strTemp.length == 3) { strOut = "," + strTemp + strOut; iLen -= 3; } else { strOut = strTemp + strOut; iLen = 0; } } if (strOut.substring(0, 1) == ",") { strWhole = strOut.substring(1, strOut.length); } else { strWhole = strOut; } } if (bNegative) { return "-" + strWhole + "." + strDec; } else { return strWhole + "." + strDec; } } /************************************************************** Right: Returns a String containing a specified number of characters from the right side of a string. Parameters: String = String expression from which the leftmost characters are returned. If string contains null, false is returned. Length = Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned. Returns: String ***************************************************************/ function Right(String, Length) { if (String == null) return (false); var dest = ''; for (var i = (String.length - 1); i >= 0; i--) dest = dest + String.charAt(i); String = dest; String = String.substr(0, Length); dest = ''; for (var i = (String.length - 1); i >= 0; i--) dest = dest + String.charAt(i); return dest; } /************************************************************** Mid: Returns a String containing a specified number of characters from a string Parameters: String = String expression from which characters are returned. If string contains null, false is returned. Start = Number. Character position in string at which the part to be taken begins. If Start is greater than the number of characters in string, Mid returns a zero-length string (""). Length = Number of characters to return. If omitted false is returned. Returns: String ***************************************************************/ function Mid(String, Start, Length) { if (String == null) return (false); if (Start > String.length) return ''; if (Length == null || Length.length == 0) return (false); return String.substr((Start - 1), Length); } /************************************************************** Left: Returns a String containing a specified number of characters from the left side of a string. Parameters: String = String expression from which the leftmost characters are returned. If string contains null, false is returned. Length = Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned. Returns: String ***************************************************************/ function Left(String, Length) { if (String == null) return (false); return String.substr(0, Length); } //-------------------------------------------------------------------- // Función que chequea que se ingresen solo letras y números. // Existe un mínimo de números a ingresar (NumMin) // No se pueden ingresar caracteres especiales. function passwordCheck(checkString,NumMin,mens) { var contNumber=0,message,message2; message="Ingrese solo letras y números",message2; message2="Existe una cantidad mínima de letras y números a ingresar."; newString = ""; count = 0; if (mens != null) message=mens; for (i = 0; i < checkString.length; i++) { ch = checkString.substring(i, i+1); if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z")) { newString += ch; contNumber++; } if (ch >= "0" && ch <= "9") { newString += ch; contNumber++; } } if (checkString != newString) return message; if (contNumber < NumMin) return message2; return null; } function CambiaColor (elemento) { elemento.style.backgroundColor="yellow"; }