PageRenderTime 68ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/web/js/utils.js

#
JavaScript | 2677 lines | 2180 code | 70 blank | 427 comment | 333 complexity | 0f8d11c391d4779d68fbd732f2a005b3 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0
  1. /*
  2. *************************************************************************
  3. * The contents of this file are subject to the Openbravo Public License
  4. * Version 1.0 (the "License"), being the Mozilla Public License
  5. * Version 1.1 with a permitted attribution clause; you may not use this
  6. * file except in compliance with the License. You may obtain a copy of
  7. * the License at http://www.openbravo.com/legal/license.html
  8. * Software distributed under the License is distributed on an "AS IS"
  9. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  10. * License for the specific language governing rights and limitations
  11. * under the License.
  12. * The Original Code is Openbravo ERP.
  13. * The Initial Developer of the Original Code is Openbravo SL
  14. * All portions are Copyright (C) 2001-2006 Openbravo SL
  15. * All Rights Reserved.
  16. * Contributor(s): ______________________________________.
  17. ************************************************************************
  18. */
  19. <!--
  20. var baseFrameServlet = "http://localhost:8880/openbravo/security/Login_FS.html";
  21. var gColorSelected = "#c0c0c0";
  22. var gWhiteColor = "#F2EEEE";
  23. var arrGeneralChange=new Array();
  24. var dateFormat;
  25. var defaultDateFormat = "%d-%m-%Y";
  26. //Array de los números de días de cada mes
  27. daysOfMonth = new Array(
  28. new Array(0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), //No bisiestos
  29. new Array (0,31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //Bisiestos
  30. );
  31. /**
  32. * Esta librería JavaScript contiene las funciones y procedimientos básicos que se utilizan en
  33. * todas las páginas html. Son elementos básicos como el posicionamiento del foco en un control
  34. * de la página, control de campos numéricos...
  35. */
  36. var gBotonPorDefecto;
  37. var gEnviado=false;
  38. var arrTeclas=null;
  39. var gAUXILIAR=0;
  40. var gWaitingCallOut=false;
  41. /**
  42. * @name focoPrimerControl
  43. * @format function focoPrimerControl(Formulario, Campo)
  44. * @comment Posiciona el cursor en el primer campo visible de un formulario
  45. *
  46. * @param <b>Formulario</b> - Es un parámetro que puede no existir, pero que indica cúal es el formulario
  47. * donde se encuentra el campo sobre el que queremos posicionar el cursor. En
  48. * caso de no existir este parámetro, se toma el primer formulario de la página. <BR>
  49. * <b>Campo</b> - Nombre del control en el que se quiere posicionar el foco
  50. * @example focoPrimerControl();
  51. */
  52. function focoPrimerControl(Formulario, Campo)
  53. {
  54. var encontrado = false;
  55. if (Formulario==null) Formulario=document.forms[0];
  56. var total = Formulario.length;
  57. for(var i=0;i<total; i++)
  58. {
  59. if ((Formulario.elements[i].type != "hidden") && (Formulario.elements[i].type != "button") && (Formulario.elements[i].type != "submit") && (Formulario.elements[i].type != "image") && (Formulario.elements[i].type != "reset"))
  60. {
  61. if(Campo!=null) {
  62. if (Campo == Formulario.elements[i].name && !Formulario.elements[i].readonly && !Formulario.elements[i].disabled) {
  63. Formulario.elements[i].focus();
  64. encontrado=true;
  65. break;
  66. }
  67. } else if (!Formulario.elements[i].readonly && !Formulario.elements[i].disabled) {
  68. try {
  69. Formulario.elements[i].focus();
  70. encontrado=true;
  71. break;
  72. } catch (ignore) {}
  73. }
  74. }
  75. }
  76. if (encontrado && Formulario.elements[i].type && Formulario.elements[i].type.indexOf("select")==-1)
  77. Formulario.elements[i].select();
  78. }
  79. /**
  80. * @name limpiar
  81. * @format function limpiar(Formulario)
  82. * @comment Borra el contenido de los campos de texto de un formulario
  83. *
  84. * @param <b>Formulario</b> - Toma el valor del formulario donde están los campos que queremos limpiar
  85. * y si no existe, toma el primer formulario de la página
  86. * @example limpiar();
  87. */
  88. function limpiar(Formulario)
  89. {
  90. if (Formulario == null)
  91. Formulario = document.forms[0];
  92. var total = Formulario.length;
  93. for (var i=0;i<total;i++){
  94. if (Formulario.elements[i].type == "text" || Formulario.elements[i].type == "password")
  95. Formulario.elements[i].value = "";
  96. }
  97. }
  98. /**
  99. * @name confirmar
  100. * @format function confirmar(Accion)
  101. * @comment Es la encargada de presentar un mensaje o no, dependiendo de la <b>Accion<b> que se le
  102. * pase. Esta función es utilizada por las funciones que realizan envíos de formularios.
  103. * @param <b>Accion</b> - es un texto que indentifica el <b>Command</b> que se ejecuta.
  104. * @return <b>true</b> - en caso de no tener mensaje asociado a dicho <b>Command</b>, o si el usuario
  105. * ha confirmado el mensaje presentado.<BR>
  106. * <b>false</b> - si el usuario no confirma el mensaje presentado.
  107. */
  108. function confirmar(accion)
  109. {
  110. switch (accion)
  111. {
  112. case 'DELETE': return mensaje(2);
  113. case 'DELETE_RELATION': return mensaje(2);
  114. case 'GUARDAR': return mensaje(3);
  115. default: return true;
  116. }
  117. }
  118. function submitFormGetParams(Command, action) {
  119. var frm = document.forms[0];
  120. frm.action=action + "?Command=" + Command;
  121. var params="";
  122. for (var i=2;arguments[i]!=null;i++) {
  123. params += "&" + arguments[i] + ((arguments[i+1]!=null)?("=" + arguments[i+1]):"");
  124. i++;
  125. }
  126. if (params!="") frm.action += params;
  127. frm.target="_self";
  128. frm.submit();
  129. return true;
  130. }
  131. /**
  132. * @name getParamsScript
  133. * @format function getParamsScript(Formulario)
  134. * @comment Esta función recibe un Formulario en el que existen campos que se quieren enviar y, ella se encarga
  135. * de capturar todos los campos del formulario con sus valores y transformarlos en una cadena de
  136. * parámetros de un método GET para poderlos enviar.
  137. *
  138. * @param <b>Formulario</b> - Es el objeto formulario que se quiere enviar. Este parámetro es obligatorio.
  139. * @example getParamScript(document.forms[0]);
  140. */
  141. function getParamsScript(Formulario) {
  142. if (Formulario==null) return "";
  143. var script="";
  144. var total = Formulario.length;
  145. for (var i=0;i<total;i++) {
  146. if (Formulario.elements[i].type && (Formulario.elements[i].type != "button") && (Formulario.elements[i].type != "submit") && (Formulario.elements[i].type != "image") && (Formulario.elements[i].type != "reset") && (Formulario.elements[i].readonly!="true") && (Formulario.elements[i].name != "Command") && (Formulario.elements[i].name!="") && !Formulario.elements[i].disabled) {
  147. if (Formulario.elements[i].type.toUpperCase().indexOf("SELECT")!=-1 && Formulario.elements[i].selectedIndex!=-1) {
  148. script += ((script=="")?"":"&") + Formulario.elements[i].name + "=" + escape(Formulario.elements[i].options[Formulario.elements[i].selectedIndex].value);
  149. } else if (Formulario.elements[i].type.toUpperCase().indexOf("CHECKBOX")!=-1 || Formulario.elements[i].type.toUpperCase().indexOf("RADIO")!=-1) {
  150. if (radioValue(Formulario.elements[i]) != null) script += ((script=="")?"":"&") + Formulario.elements[i].name + "=" + escape(radioValue(Formulario.elements[i]));
  151. } else if (Formulario.elements[i].value!=null && Formulario.elements[i].value!="") {
  152. script += ((script=="")?"":"&") + Formulario.elements[i].name + "=" + escape(Formulario.elements[i].value);
  153. }
  154. }
  155. }
  156. return script;
  157. }
  158. /**
  159. * @name submitForm
  160. * @format function submitForm(Campo, Valor, Formulario, Comprobar)
  161. * @comment Esta función envía un formulario poniendo un valor que se le pasa en un campo que se
  162. * le indica antes de enviarlo y pudiendo comprobar si ya se había llamado a esta función
  163. * sin haber podido obtener un resultado todavía, es decir, comprobando que si se está
  164. * enviando todavía no permita volver a enviar hasta que no se realice el primer envío.
  165. *
  166. * @param <b>Campo</b> - Un objeto que referencia al campo en el que queremos depositar un valor que
  167. * le pasamos a continuación. <BR>
  168. * <b>Valor</b> - Un string que indica el valor que queremos dejar en el campo que le hemos
  169. * indicado antes. <BR>
  170. * <b>Formulario</b> - Un objeto que referencia al formulario que queremos enviar. Si este
  171. * parámetro se deja a null se entiende que es el formulario primero de la página. <BR>
  172. * <b>Comprobar</b> - Booleano que indica si queremos que controle si ya se está enviando
  173. * este formulario, no realizando varios envíos a la vez. El valor de este parámetro,
  174. * por defecto, es false
  175. *
  176. * @return <b>true</b> - si todo va bien y los datos son enviados correctamente.<BR>
  177. * <b>false</b> - si hay algún problema y los datos no se pueden enviar.
  178. * @example submitForm(document.forms[0].inpCampo, "FIND", null, true);
  179. */
  180. function submitForm(campo, valor, Formulario, bolComprobar, isCallOut) {
  181. if (Formulario == null) Formulario = document.forms[0];
  182. if (isCallOut==null) isCallOut = false;
  183. if (bolComprobar!=null && bolComprobar) {
  184. if (gEnviado==1) {
  185. mensaje(16);
  186. return false;
  187. } else {
  188. gEnviado=1;
  189. if (isCallOut) gWaitingCallOut=true;
  190. campo.value = valor;
  191. Formulario.submit();
  192. }
  193. } else {
  194. if (isCallOut) gWaitingCallOut=true;
  195. campo.value = valor;
  196. Formulario.submit();
  197. }
  198. return true;
  199. }
  200. /**
  201. * @name reloadFunction
  202. * @format function reloadFunction(text)
  203. * @comment Esta función se encarga de retrasar la ejecución del comando que se le pasa por parámetro,
  204. * el cual será llamado al pasar un tiempo determinado. Se utiliza para simular un timer en
  205. * javascript.
  206. *
  207. * @param <b>text</b> - Es una cadena de texto que contiene un comando javascript.
  208. *
  209. * @return <b>ID</b> - Devuelve el identificador del timer para poder cancelarlo en cualquier momento.
  210. * @example reloadFunction("alert('prueba');");
  211. */
  212. function reloadFunction(text) {
  213. return setTimeout(text, 1000);
  214. }
  215. /**
  216. * @name setChangedField
  217. * @format function setChangedField(campo, Formulario)
  218. * @comment Se encarga de marcar cuál ha sido el último campo cambiado para depurar si en una pantalla,
  219. * se han producido cambios. Requiere la existencia de un campo llamado inpLastFieldChanged.
  220. *
  221. * @param <b>campo</b> - Es un objeto que contiene el campo que ha sido modificado. Normalmente colocaremos
  222. * esta función en el onChange del propio campo modificado, por lo que en este parámetro
  223. * pasaremos el objeto this.<BR>
  224. * <b>Formulario</b> - Es el formulario en el que se encuentra el campo inpLastFieldChanged. Si se
  225. * encuentra en el formulario principal de la ventana, no es necesario indicarlo.
  226. *
  227. * @return <b>true</b> - Si todo va bien.<BR>
  228. * <b>false</b> - Si no encuentra el campo inpLastFieldChanged.
  229. * @example onChange="setChangedField(this);return true;"
  230. */
  231. function setChangedField(campo, Formulario) {
  232. if (Formulario==null || !Formulario) Formulario = document.forms[0];
  233. if (Formulario.inpLastFieldChanged==null) return false;
  234. Formulario.inpLastFieldChanged.value = campo.name;
  235. return true;
  236. }
  237. /**
  238. * @name checkForChanges
  239. * @format function checkForChanges(Formulario)
  240. * @comment Esta función comprueba si se han producido cambios en el formulario que se le indique.
  241. * Es necesario que exista un campo llamado inpLastFieldChanged, ya que es sobre este campo
  242. * sobre el que comprueba si existen modificaciones. Esta función es complemento de la función
  243. * setChangedField.
  244. *
  245. * @param <b>Formulario</b> - Es el formulario en el que se encuentra el campo inpLastFieldChanged. Si se
  246. * encuentra en el formulario principal de la ventana, no es necesario indicarlo.
  247. *
  248. * @return <b>true</b> - Si el campo inpLastFieldChanged contiene algún dato y se pulsa OK en el mensaje emergente.<BR>
  249. * <b>false</b> - Si no contiene ningún dato o se pulsa CANCEL en el mensaje emergente.
  250. * @example checkForChanges();
  251. */
  252. function checkForChanges(Formulario) {
  253. if (Formulario==null) Formulario = document.forms[0];
  254. if (inputValue(Formulario.inpLastFieldChanged)!="") {
  255. if (!mensaje(10)) return false;
  256. }
  257. return true;
  258. }
  259. function sendDirectLink(Formulario, columnName, parentKey, url, keyId, tableId, newTarget, bolComprobarCambios) {
  260. if (Formulario == null) Formulario = document.forms[0];
  261. var frmDepuracion = document.forms[0];
  262. var accion = "DEFAULT";
  263. if (bolComprobarCambios==null) bolComprobarCambios = false;
  264. if (arrGeneralChange!=null && arrGeneralChange.length>0 && bolComprobarCambios) {
  265. var strFunction = "sendDirectLink('" + Formulario.name + "', '" + columnName + "', '" + parentKey + "', '" + url + "', '" + keyId + "', '" + tableId + "', " + ((newTarget==null)?"null":"'" + newTarget + "'") + ", " + bolComprobarCambios + ")";
  266. reloadFunction(strFunction);
  267. return false;
  268. }
  269. if (bolComprobarCambios && !checkForChanges(frmDepuracion)) return false;
  270. if (confirmar(accion)) {
  271. Formulario.action = url;
  272. if (newTarget != null) Formulario.target = newTarget;
  273. Formulario.inpKeyReferenceColumnName.value = columnName;
  274. Formulario.inpSecondKey.value = parentKey;
  275. Formulario.inpKeyReferenceId.value = keyId;
  276. Formulario.inpTableReferenceId.value = tableId;
  277. submitForm(Formulario.Command, accion, Formulario, false, false);
  278. }
  279. return true;
  280. }
  281. function dispatchEventChange(target) {
  282. if (!target) return true;
  283. if (!target.type) return true;
  284. if (target.onchange && target.defaultValue && target.defaultValue != inputValue(target)) target.onchange();
  285. else if (target.onblur) target.onblur();
  286. return true;
  287. }
  288. /**
  289. * @name submitCommandForm
  290. * @format function submitCommandForm(Command, Depurar, Formulario, newAction, newTarget, Comprobar, ComprobarCambios, isCallOut)
  291. * @comment Esta es la función que principalmente se utilizará para implementar las operaciones
  292. * a realizar por los botones que pongamos en la página. Su misión es la de enviar un
  293. * formulario poniendo el Command (se trata de un texto que utilizamos para indicar al
  294. * servlet el tipo de operación que queremos que realice o el botón que le ha llamado)
  295. * que indiquemos. Permite hacer una depuración previa, pudiendo cancelar el envío si la
  296. * depuración no es satisfactoria.<BR><BR>
  297. *
  298. * La ejecución de esta función requiere que en el formulario a enviar exista un campo
  299. * oculto que se llame <b>Command</b>, el cual lo utilizará esta función para enviar el
  300. * Command que le indiquemos.
  301. *
  302. * @param <b>Command</b> - Texto que permite al servlet identificar que tipo de operación debe
  303. * realizar o qué botón le ha llamado. <BR>
  304. * <b>Depurar</b> - Booleano que indica si se quiere realizar una depuración antes de enviar
  305. * el formulario. El valor de este campo, por defecto, es false. Si esta opción se pone a
  306. * true, se deberá implementar una función en la propia página que se llame <b>depurar</b>
  307. * y en la que realizaremos las depuraciones pertinentes, devolviendo true o false
  308. * obligatoriamente. Si devolvemos false no se enviará el formulario. Esta función recibe
  309. * como parámetro el <b>Command</b>. <BR>
  310. * <b>Formulario</b> - Un objeto que referencia al formulario que queremos enviar. Si este
  311. * dato se pone null, se entiende que se trata del primer formulario de la página. <BR>
  312. * <b>newAction</b> - Un string que indica la URL de la página a la que queremos enviar el
  313. * formulario. Si se deja a null no se cambia la URL que tenga establecido el formulario
  314. * en su propiedad <b>action</b> <BR>
  315. * <b>newTarget</b> - Un string que indica un nombre de una ventana o frame al que queremos
  316. * enviar el formulario. Se refiere a la propiedad <b>target</b> del formulario. Si esta
  317. * opción no se indica o se deja a null, se mantiene la que ponga en el formulario. <BR>
  318. * <b>Comprobar</b> - Booleano que indica si queremos que controle si ya se ha pulsado este
  319. * botón anteriormente y todavía no ha podido contestar el servidor, evitando que un usuario
  320. * pueda dar varias veces al mismo botón, creyendo que no le ha dado, porque tarda en responder.
  321. * El valor por defecto de este parámetro es false.<BR>
  322. * <b>ComprobarCambios</b> - Booleano que indica si queremos que la función compruebe, previamente,
  323. * si se han producido cambios de datos en la ventana, presentando en tal caso el mensaje emergente
  324. * correspondiente.<BR>
  325. * <b>isCallOut</b> - Booleano que indica si estamos haciendo una llamada a un callout.
  326. *
  327. * @return <b>true</b> - si todo va correctamente y se envían los datos.<BR>
  328. * <b>false</b> - si hay algún problema y los datos no se pueden enviar o se cancela el envío al pulsar
  329. * CANCEL en el mensaje emergente de aviso de cambios en la ventana.
  330. * @example submitCommandForm("FIND", false, null, null, null, true, null, false);
  331. */
  332. function submitCommandForm(accion, bolDepurar, Formulario, newAction, newTarget, bolComprobar, bolComprobarCambios, isCallOut, controlEvt, evt)
  333. {
  334. if (Formulario == null) Formulario = document.forms[0];
  335. if (bolDepurar!=null && bolDepurar==true) if (!depurar(accion, Formulario, "")) return false;
  336. if (bolComprobarCambios==null) bolComprobarCambios = false;
  337. if (isCallOut==null) isCallOut = false;
  338. if (controlEvt==null) controlEvt = false;
  339. if (controlEvt) {
  340. if (!evt) evt = window.event;
  341. var target = (document.layers) ? evt.target : evt.srcElement;
  342. dispatchEventChange(target);
  343. }
  344. if (gWaitingCallOut || (arrGeneralChange!=null && arrGeneralChange.length>0 && bolComprobarCambios)) {
  345. var strFunction = "submitCommandForm('" + accion + "', " + bolDepurar + ", " + Formulario.name + ", " + ((newAction!=null)?("'" + newAction + "'"):"null") + ", " + ((newTarget!=null)?("'" + newTarget + "'"):"null") + ", " + bolComprobar + ", " + bolComprobarCambios + ")";
  346. reloadFunction(strFunction);
  347. return false;
  348. }
  349. if (bolComprobarCambios && !checkForChanges(Formulario)) return false;
  350. if (confirmar(accion)) {
  351. if (newAction != null) Formulario.action = newAction;
  352. if (newTarget != null) Formulario.target = newTarget;
  353. submitForm(Formulario.Command, accion, Formulario, bolComprobar, isCallOut);
  354. }
  355. return true;
  356. }
  357. /**
  358. * @name submitCommandFormParameter
  359. * @format function submitCommandFormParameter(Command, Campo, Valor, Depurar, Formulario,
  360. * newAction, newTarget, Comprobar, ComprobarCambios, isCallOut)
  361. * @comment Esta es la función que principalmente se utilizará para implementar las operaciones
  362. * a realizar por los botones que pongamos en la página, en los casos en los que queramos
  363. * que, además, envíe un parámetro adicional en función del Link que pinche, de forma que
  364. * su aplicación práctica sería para ir al detalle de una línea concreta que de una relación,
  365. * de forma que deberemos indicar la clave de la línea de la que queremos ver su detalle,
  366. * valor que será diferente dependiendo de la línea que elijamos. Su misión es la de enviar
  367. * un formulario poniendo el Command (se trata de un texto que utilizamos para indicar al
  368. * servlet el tipo de operación que queremos que realice o el botón que le ha llamado) que
  369. * indiquemos y el valor del que antes hablábamos en un campo del formulario, campo que debe
  370. * existir y que, por lo general será un campo oculto. Permite hacer una depuración previa,
  371. * pudiendo cancelar el envío si la depuración no es satisfactoria.<BR><BR>
  372. *
  373. * La ejecución de esta función requiere que en el formulario a enviar exista un campo oculto
  374. * que se llame <b>Command</b>, el cual lo utilizará esta función para enviar el Command que
  375. * le indiquemos. También deberá existir el campo en el que queremos guardar el valor clave
  376. * que identifica la línea.
  377. *
  378. * @param <b>Command</b> - Texto que permite al servlet identificar que tipo de operación debe realizar
  379. * o qué botón le ha llamado. <BR>
  380. * <b>Campo</b> - Un objeto que referencia a un campo del formulario en el que queremos que se
  381. * deposite el valor clave que identifica a la línea. <BR>
  382. * <b>Valor</b> - El valor de tipo string que es el valor clave que queremos depositar en el
  383. * campo anterior. <BR>
  384. * <b>Depurar</b> - Booleano que indica si se quiere realizar una depuración antes de enviar
  385. * el formulario. El valor de este campo, por defecto, es false. Si esta opción se pone a true,
  386. * se deberá implementar una función en la propia página que se llame <b>depurar</b> y en la
  387. * que realizaremos las depuraciones pertinentes, devolviendo true o false obligatoriamente.
  388. * Si devolvemos false no se enviará el formulario. Esta función recibe como parámetro el
  389. * <b>Command</b>. <BR>
  390. * <b>Formulario</b> - Un objeto que referencia al formulario que queremos enviar. Si este dato
  391. * se pone null, se entiende que se trata del primer formulario de la página. <BR>
  392. * <b>newAction</b> - Un string que indica la URL de la página a la que queremos enviar el
  393. * formulario. Si se deja a null no se cambia la URL que tenga establecido el formulario en
  394. * su propiedad <b>action</b>. <BR>
  395. * <b>newTarget</b> - Un string que indica un nombre de una ventana o frame al que queremos
  396. * enviar el formulario. Se refiere a la propiedad <b>target</b> del formulario. Si esta opción
  397. * no se indica o se deja a null, se mantiene la que ponga en el formulario. <BR>
  398. * <b>Comprobar</b> - Booleano que indica si queremos que controle si ya se ha pulsado este
  399. * botón anteriormente y todavía no ha podido contestar el servidor, evitando que un usuario
  400. * pueda dar varias veces al mismo botón, creyendo que no le ha dado, porque tarda en responder.
  401. * El valor por defecto de este parámetro es false.<BR>
  402. * <b>ComprobarCambios</b> - Booleano que indica si queremos que la función compruebe, previamente,
  403. * si se han producido cambios de datos en la ventana, presentando en tal caso el mensaje emergente
  404. * correspondiente.<BR>
  405. * <b>isCallOut</b> - Booleano que indica si estamos haciendo una llamada a un callout.
  406. *
  407. * @return <b>true</b> - si todo va correctamente y se envían los datos.<BR>
  408. * <b>false</b> - si hay algún problema y los datos no se pueden enviar o pulsa el boton CANCEL de la
  409. * ventana emergente de comprobación de cambios.
  410. * @example submitCommandFormParameter("FIND", document.forms[0].inpClave, "12", false, null, null, null, true, false);
  411. */
  412. function submitCommandFormParameter(accion, campo, valor, bolDepurar, Formulario, formAction, newTarget, bolComprobar, bolComprobarCambios, isCallOut, controlEvt, evt) {
  413. if (Formulario == null) Formulario = document.forms[0];
  414. if (bolDepurar!=null && bolDepurar==true) if (!depurar(accion, Formulario, valor)) return false;
  415. if (bolComprobarCambios==null) bolComprobarCambios = false;
  416. if (isCallOut==null) isCallOut = false;
  417. if (controlEvt==null) controlEvt = false;
  418. if (controlEvt) {
  419. if (!evt) evt = window.event;
  420. var target = (document.layers) ? evt.target : evt.srcElement;
  421. dispatchEventChange(target);
  422. }
  423. if (gWaitingCallOut || (arrGeneralChange!=null && arrGeneralChange.length>0 && bolComprobarCambios)) {
  424. var strFunction = "submitCommandFormParameter('" + accion + "', " + campo.form.name + "." + campo.name + ", '" + valor + "', " + bolDepurar + ", " + Formulario.name + ", " + ((formAction!=null)?("'" + formAction + "'"):"null") + ", " + ((newTarget!=null)?("'" + newTarget + "'"):"null") + ", " + bolComprobar + ", " + bolComprobarCambios + ", " + isCallOut + ")";
  425. reloadFunction(strFunction);
  426. return false;
  427. }
  428. if (bolComprobarCambios && !checkForChanges(Formulario)) return false;
  429. if (confirmar(accion)) {
  430. campo.value = valor;
  431. if (formAction != null) Formulario.action = formAction;
  432. if (newTarget != null) Formulario.target = newTarget;
  433. submitForm(Formulario.Command, accion, Formulario, bolComprobar, isCallOut);
  434. }
  435. return true;
  436. }
  437. /**
  438. * @name campoNumerico
  439. * @format function campoNumerico(CampoNumerico, Decimales, Negativo)
  440. * @comment Es la función encargada de controlar que los datos introducidos en un campo sean
  441. * numéricos, de tal forma que si no lo son, será la propia función la que lance un mensaje
  442. * de error y posicione el foco en el control. Se nos va a permiter controlar que el número
  443. * que se haya introducido sea un número entero o no, e incluso que sólo sea positivo o no.
  444. *
  445. * @param <b>CampoNumerico</b> - Objeto que referencia el control de la página que queremos depurar.<BR>
  446. * <b>Decimales</b> - Booleano que indica si se admiten números decimales o no. <BR>
  447. * <b>Negativos</b> - Booleano que indica si se admiten números negativos o no.
  448. * @return <b>true</b> - si el contenido del campo es numérico.<BR>
  449. * <b>false</b> - si no es numérico o no cumple alguno de los requisitos especificados.
  450. * @example campoNumerico(document.forms[0].inpImporte, true, false);
  451. * @see @link esNumerico , @link esNumero
  452. */
  453. function campoNumerico(CampoNumerico, bolDecimales, bolNegativo)
  454. {
  455. if (!esNumero(CampoNumerico.value, bolDecimales, bolNegativo))
  456. {
  457. mensaje(4);
  458. CampoNumerico.focus();
  459. CampoNumerico.select();
  460. return false;
  461. }
  462. return true;
  463. }
  464. /**
  465. * @name esNumero
  466. * @format function esNumero(ValorNumerico, Decimales, Negativo)
  467. * @comment Recorre el texto pasado, controlando si todos sus elementos son numéricos o no
  468. *
  469. * @param <b>ValorNumerico</b> - String que contiene el número a depurar.<BR>
  470. * <b>Decimales</b> - Booleano que indica si se admiten números decimales o no. <BR>
  471. * <b>Negativos</b> - Booleano que indica si se admiten números negativos o no.
  472. * @return <b>true</b> - si el contenido del campo es numérico.<BR>
  473. * <b>false</b> - si no es numérico o no cumple alguno de los requisitos especificados.
  474. */
  475. function esNumero(strValorNumerico, bolDecimales, bolNegativo) {
  476. var bolComa = false;
  477. var esNegativo = false;
  478. var i=0;
  479. if (strValorNumerico == null || strValorNumerico=="") return true;
  480. if (strValorNumerico.substring(i, i+1)=="-") {
  481. if (bolNegativo !=null && bolNegativo) {
  482. esNegativo = true;
  483. i++;
  484. } else {
  485. return false;
  486. }
  487. } else if (strValorNumerico.substring(i, i+1)=="+")
  488. i++;
  489. var total = strValorNumerico.length;
  490. for (i=i;i<total;i++) {
  491. if (isNaN(strValorNumerico.substring(i,i+1))) {
  492. if (bolDecimales && strValorNumerico.substring(i,i+1)=="." && !bolComa)
  493. bolComa = true;
  494. else
  495. return false;
  496. }
  497. }
  498. return true;
  499. }
  500. function getArrayValue(data, name, defaultValue) {
  501. if (data==null || data.length<=0) return ((defaultValue!=null)?defaultValue:"");
  502. var total = data.length;
  503. for (var i=0;i<total;i++) {
  504. if (data[i][0]==name) return data[i][1];
  505. }
  506. return ((defaultValue!=null)?defaultValue:"");
  507. }
  508. function addArrayValue(data, name, value, isUrlParameter) {
  509. if (isUrlParameter==null) isUrlParameter=false;
  510. if (data==null || data.length<=0) {
  511. data = new Array();
  512. data[0] = new Array(name, value, (isUrlParameter?"true":"false"));
  513. return data;
  514. }
  515. var total = data.length;
  516. for (var i=0;i<total;i++) {
  517. if (data[i][0]==name) {
  518. data[i][1] = value;
  519. return data;
  520. }
  521. }
  522. data[total] = new Array(name, value, (isUrlParameter?"true":"false"));
  523. return data;
  524. }
  525. function addUrlParameters(data) {
  526. if (data==null || data.length<=0) return "";
  527. var total = data.length;
  528. var text = "";
  529. for (var i=0;i<total;i++) {
  530. if (data[i][2]=="true") text += ((text!=null && text!="")?"&":"") + data[i][0] + "=" + escape(data[i][1]);
  531. }
  532. if (text!=null && text!="") text = "?" + text;
  533. return text;
  534. }
  535. function openNewLink(url, _name, height, width, top, left, checkChanges, target, doSubmit, closeControl, parameters) {
  536. parameters = addArrayValue(parameters, "location", "1");
  537. parameters = addArrayValue(parameters, "scrollbars", "1");
  538. parameters = addArrayValue(parameters, "status", "1");
  539. parameters = addArrayValue(parameters, "menubar", "1");
  540. parameters = addArrayValue(parameters, "toolbar", "1");
  541. parameters = addArrayValue(parameters, "resizable", "1");
  542. return openPopUp(url, _name, height, width, top, left, checkChanges, target, doSubmit, closeControl, parameters);
  543. }
  544. function openPopUp(url, _name, height, width, top, left, checkChanges, target, doSubmit, closeControl, parameters) {
  545. var adds = "";
  546. if (height==null) height = screen.height - 50;
  547. if (width==null) width = screen.width;
  548. if (top==null) top = (screen.height - height) / 2;
  549. if (left==null) left = (screen.width - width) / 2;
  550. if (checkChanges==null) checkChanges = false;
  551. if (closeControl==null) closeControl = false;
  552. if (doSubmit==null) doSubmit = false;
  553. if (checkChanges && !checkForChanges()) return false;
  554. if (url!=null && url!="") url += addUrlParameters(parameters);
  555. if (target!=null && target!="" && target.indexOf("_")!=0) {
  556. var objFrame = eval("parent." + target);
  557. objFrame.location.href=url;
  558. return true;
  559. }
  560. adds = "height=" + height + ", width=" + width + ", left=" + left + ", top=" + top;
  561. if (navigator.appName.indexOf("Netscape")) {
  562. adds += ", alwaysRaised=" + getArrayValue(parameters, "alwaysRaised", "1");
  563. adds += ", dependent=" + getArrayValue(parameters, "dependent", "1");
  564. adds += ", directories=" + getArrayValue(parameters, "directories", "0");
  565. adds += ", hotkeys=" + getArrayValue(parameters, "hotkeys", "0");
  566. }
  567. adds += ", location=" + getArrayValue(parameters, "location", "0");
  568. adds += ", scrollbars=" + getArrayValue(parameters, "scrollbars", "0");
  569. adds += ", status=" + getArrayValue(parameters, "status", "1");
  570. adds += ", menubar=" + getArrayValue(parameters, "menubar", "0");
  571. adds += ", toolbar=" + getArrayValue(parameters, "toolbar", "0");
  572. adds += ", resizable=" + getArrayValue(parameters, "resizable", "1");
  573. if (doSubmit && (getArrayValue(parameters, "debug", false)==true)) {
  574. if (!depurar(getArrayValue(parameters, "Command", "DEFAULT"), null, "")) return false;
  575. }
  576. var winPopUp = window.open((doSubmit?"":url), _name, adds);
  577. if (closeControl) window.onunload = function(){winPopUp.close();}
  578. if (doSubmit) {
  579. submitCommandForm(getArrayValue(parameters, "Command", "DEFAULT"), (getArrayValue(parameters, "debug", false)==true), null, url, _name, target, checkChanges);
  580. }
  581. winPopUp.focus();
  582. return winPopUp;
  583. }
  584. function abrirNuevoBrowser(url, _name, height, width, top, left) {
  585. return openNewLink(url, _name, height, width, top, left, null, null, null, true, null);
  586. }
  587. function abrirExcel(url, _name, checkChanges) {
  588. return openPopUp(url, _name, null, null, null, null, checkChanges, null, null, false, null);
  589. }
  590. function abrirPDF(url, _name, checkChanges) {
  591. return openPopUp(url, _name, null, null, null, null, checkChanges, null, null, false, null);
  592. }
  593. function abrirPDFFiltered(url, _name, checkChanges) {
  594. return openPopUp(url, _name, null, null, null, null, checkChanges, null, true, false, null);
  595. }
  596. function abrirPopUp(url, _name, height, width, closeControl, showstatus) {
  597. if (height==null) height = 250;
  598. if (width==null) width = 230;
  599. return openPopUp(url, _name, height, width, null, null, null, null, null, closeControl, null);
  600. }
  601. function abrirPDFSession(strPagina, strDirectPrinting, strHiddenKey, strHiddenValue, bolComprobarCambios) {
  602. var direct = (strDirectPrinting!="")?"Y":"N";
  603. return submitCommandForm("DEFAULT", false, null, "../businessUtility/PrinterReports.html?inppdfpath=" + escape(strPagina) + "&inpdirectprint=" + escape(direct) + "&inphiddenkey=" + escape(strHiddenKey) + ((strHiddenValue!=null)?"&inphiddenvalue=" + escape(strHiddenValue):""), "frameOculto", null, bolComprobarCambios);
  604. }
  605. function abrirBusqueda(url, _name, tabId, windowName, windowId, checkChanges) {
  606. var parameters = new Array();
  607. parameters = addArrayValue(parameters, "inpTabId", tabId, true);
  608. parameters = addArrayValue(parameters, "inpWindow", windowName, true);
  609. parameters = addArrayValue(parameters, "inpWindowId", windowId, true);
  610. return openPopUp(url, _name, 450, 600, null, null, checkChanges, null, null, true, parameters);
  611. }
  612. function openHelp(windowId, url, _name, checkChanges, height, width, windowType, windowName) {
  613. if (height==null) height = 450;
  614. if (width==null) width = 700;
  615. var parameters = new Array();
  616. parameters = addArrayValue(parameters, "inpwindowId", windowId, true);
  617. parameters = addArrayValue(parameters, "inpwindowType", windowType, true);
  618. parameters = addArrayValue(parameters, "inpwindowName", windowName, true);
  619. return openPopUp(url, _name, height, width, null, null, checkChanges, null, null, true, parameters);
  620. }
  621. function openServletNewWindow(Command, depurar, url, _name, processId, checkChanges, height, width, resizable, hasStatus) {
  622. if (height==null) height = 350;
  623. if (width==null) width = 500;
  624. var parameters = new Array();
  625. parameters = addArrayValue(parameters, "scrollbars", "1");
  626. parameters = addArrayValue(parameters, "debug", depurar, false);
  627. if (processId!=null && processId!="") parameters = addArrayValue(parameters, "inpProcessId", processId, true);
  628. if (Command!=null && Command!="") parameters = addArrayValue(parameters, "Command", Command, false);
  629. return openPopUp(url, _name, height, width, null, null, checkChanges, null, true, true, parameters);
  630. }
  631. function openLink(url, _name, height, width) {
  632. return openNewLink(url, ((_name.indexOf("_")==0)?"":_name), height, width, null, null, null, ((_name.indexOf("_")==0)?_name:""), false, false, null);
  633. }
  634. function editHelp(url, tipo, id, value, height, width) {
  635. if (height==null) height = 500;
  636. if (width==null) width = 600;
  637. var parameters = new Array();
  638. parameters = addArrayValue(parameters, "Command", tipo, true);
  639. parameters = addArrayValue(parameters, "inpClave", value, true);
  640. return openPopUp(url, "HELP_EDIT", height, width, null, null, null, null, false, true, parameters);
  641. }
  642. /**
  643. * @name pulsarTecla
  644. * @format function pulsarTecla(CodigoTecla)
  645. * @comment Esta función es interna y es ejecutada por otras funciones que activan el control de
  646. * eventos en una ventana HTML. Asocian esta función al evento <b>KeyDown</b> de la página,
  647. * controlando así las pulsaciones de teclas en la página. Esta función se encarga de controlar
  648. * la pulsación de la tecla <em>ENTER<em>, para ejecutar una acción por defecto.
  649. *
  650. * @param <b>CodigoTecla</b> - Es el código ASCII de la tecla que se ha pulsado. Este código lo pasa
  651. * el propio controlador de eventos, por lo que no tenemos que preocuparnos de él.
  652. * @return <b>true</b> - en caso de no haber pulsado ninguna de las teclas a controlar.<BR>
  653. * <b>false</b> - si se ha pulsado alguna de las teclas a controlar.
  654. */
  655. function pulsarTecla(CodigoTecla)
  656. {
  657. if (gBotonPorDefecto!=null)
  658. {
  659. var tecla = (!CodigoTecla) ? window.event.keyCode : CodigoTecla.which;
  660. if (tecla == 13)
  661. {
  662. eval(gBotonPorDefecto);
  663. return false;
  664. }
  665. }
  666. return true;
  667. }
  668. /**
  669. * @name porDefecto
  670. * @format function porDefecto(Accion)
  671. * @comment Esta función se encarga de establecer una <b>Accion</b> por defecto en la página, es decir,
  672. * la que se ejecutará al pulsar la tecla <em>ENTER</em>.<BR>
  673. * La <b>Accion</b> se le pasa en formato de texto, pero ha de ser un comando perfectamente
  674. * ejecutable. No es bueno abusar de esta función, porque se pueden mezclar funciones. <BR>
  675. * Es importante saber que en las páginas de tipo frame, esta función es común a los frames,
  676. * por lo que sólo podremos establecer en un frame esta función pero teniendo cuidado de que
  677. * el usuario no pueda ponerse en otro frame pulsando <em>ENTER</em> porque, en tal caso,
  678. * se ejecutará este comando igualmente, pudiéndo producirse algún error no deseado.
  679. *
  680. * @param <b>Accion</b> - es el comando que se debe ejecutar en caso de pulsar <em>ENTER</em>.
  681. * @example porDefecto("alert('Hola')");
  682. */
  683. function porDefecto(accion)
  684. {
  685. gBotonPorDefecto = accion;
  686. if (!document.all)
  687. {
  688. document.captureEvents(Event.KEYDOWN);
  689. }
  690. document.onkeydown=pulsarTecla;
  691. return true;
  692. }
  693. /**
  694. * @name Teclas
  695. * @format function Teclas(tecla, evento, campo, teclaAuxiliar)
  696. * @comment Esta función sirve para ir formando el array de teclas para cada pantalla.<BR>
  697. * Cada tecla que queremos utilizar debe contener esta estrtuctura.
  698. *
  699. * @param <b>tecla</b> - es la tecla que se debe pulsar en formato texto. No diferencia entre
  700. * mayúsculas y minúsculas.<BR>
  701. * <b>evento</b> - Se trata de la acción que queremos que se ejecute cuando se pulse
  702. * dicha tecla. Se le debe pasar el código a ejecutar como si fuese un
  703. * strring.<BR>
  704. * <b>campo</b> - Se indica aquí el nombre de un campo de la ventana. Sirve para decir
  705. * que el evento se deverá ejecutar sólo si nos encontramos en ese campo.
  706. * Si este parámetro se deja null, estamos indicando que se trata de un evento
  707. * global, es decir, para toda la ventana.
  708. * <b>teclaAuxiliar</b> - Sus valores serán, <em>CTRL</em>, <em>ALT</em> ó <em>null</em>,
  709. * donde <em>CTRL</em> indica que se debe pulsar CONTROL a la que
  710. * la tecla que se ha especificado, <em>ALT</em> indica que se debe
  711. * pulsar ALTERNATIVA a la vez que la tecla indicada y <em>null</em>
  712. * indica que no se debe pulsar ninguna tecla a la vez.
  713. * @example Teclas("A", "alert('Hola')", "inpcBpartnerId_D", null);
  714. */
  715. function Teclas(tecla, evento, campo, teclaAuxiliar) {
  716. this.tecla = tecla;
  717. this.evento = evento;
  718. this.campo = campo;
  719. this.teclaAuxiliar = teclaAuxiliar;
  720. }
  721. /**
  722. * @name obtenerCodigoTecla
  723. * @format function obtenerCodigoTecla(codigo)
  724. * @comment Se trata de una función interna que devuelve el código de la tecla que corresponde
  725. * a la letra pasada.
  726. *
  727. * @param <b>codigo</b> - Es el texto que corresponde a la letra de la que queremos obtener su
  728. * codigo de tecla.
  729. * @return el código de la tecla de la letra pasada.
  730. * @example obtenerCodigoTecla("A");
  731. */
  732. function obtenerCodigoTecla(codigo) {
  733. if (codigo==null) return 0;
  734. else if (codigo.length==1) return codigo.toUpperCase().charCodeAt(0);
  735. switch (codigo.toUpperCase()) {
  736. case "BACKSPACE": return 8;
  737. case "TAB": return 9;
  738. case "ENTER": return 13;
  739. case "SPACE": return 32;
  740. case "DELETE": return 46;
  741. case "INSERT": return 45;
  742. case "END": return 35;
  743. case "HOME": return 36;
  744. case "REPAGE": return 33;
  745. case "AVPAGE": return 34;
  746. case "LEFTARROW": return 37;
  747. case "RIGHTARROW": return 39;
  748. case "UPARROW": return 38;
  749. case "DOWNARROW": return 40;
  750. case "NEGATIVE": return 189;
  751. case "NUMBERNEGATIVE": return 109;
  752. case "DECIMAL": return 190;
  753. case "NUMBERDECIMAL": return 110;
  754. case "ESCAPE": return 27;
  755. case "F1": return 112;
  756. case "F2": return 113;
  757. case "F3": return 114;
  758. case "F4": return 115;
  759. case "F5": return 116;
  760. case "F6": return 117;
  761. case "F7": return 118;
  762. case "F8": return 119;
  763. case "F9": return 120;
  764. case "F10": return 121;
  765. case "F11": return 122;
  766. case "F12": return 123;
  767. case "P": return 80;
  768. /* case "shiftKey": return 16;
  769. case "ctrlKey": return 17;
  770. case "altKey": return 18;*/
  771. default: return 0;
  772. }
  773. }
  774. /**
  775. * @name controlTecla
  776. * @format function controlTecla(CodigoTecla)
  777. * @comment Se encarga de controlar la pulsación de teclas en una página, comprobando que
  778. * no se pulse ninguna de las teclas especificadas en el array global arrTeclas, en
  779. * cuyo caso procede a ejecutar la acción asociada a dicha tecla en dicho array.
  780. *
  781. * @param <b>CodigoTecla</b> - Es el código de la tecla pulsada por el usuario.
  782. * @return <b>true</b> - en caso de no pulsarse ninguna de las teclas del array.<BR>
  783. * <b>false</b> - en caso de pulsarse una tecla del array arrTeclas.
  784. */
  785. function controlTecla(CodigoTecla) {
  786. if (arrTeclas==null || arrTeclas.length==0) return true;
  787. if (!CodigoTecla) CodigoTecla = window.event;
  788. var tecla = window.event ? CodigoTecla.keyCode : CodigoTecla.which;
  789. var target = (CodigoTecla.target?CodigoTecla.target: CodigoTecla.srcElement);
  790. //var target = (document.layers) ? CodigoTecla.target : CodigoTecla.srcElement;
  791. var total = arrTeclas.length;
  792. for (var i=0;i<total;i++) {
  793. if (arrTeclas[i]!=null && arrTeclas[i]) {
  794. if (tecla == obtenerCodigoTecla(arrTeclas[i].tecla)) {
  795. if (arrTeclas[i].teclaAuxiliar==null || arrTeclas[i].teclaAuxiliar=="" || arrTeclas[i].teclaAuxiliar=="null") {
  796. if (arrTeclas[i].campo==null || (target!=null && target.name!=null && isIdenticalField(arrTeclas[i].campo, target.name))) {
  797. var eventoTrl = replaceEventString(arrTeclas[i].evento, target.name, arrTeclas[i].campo);
  798. eval(eventoTrl);
  799. return false;
  800. }
  801. } else if (arrTeclas[i].campo==null || (target!=null && target.name!=null && isIdenticalField(arrTeclas[i].campo, target.name))) {
  802. if (arrTeclas[i].teclaAuxiliar=="ctrlKey" && CodigoTecla.ctrlKey && !CodigoTecla.altKey && !CodigoTecla.shiftKey) {
  803. var eventoTrl = replaceEventString(arrTeclas[i].evento, target.name, arrTeclas[i].campo);
  804. eval(eventoTrl);
  805. return false;
  806. } else if (arrTeclas[i].teclaAuxiliar=="altKey" && !CodigoTecla.ctrlKey && CodigoTecla.altKey && !CodigoTecla.shiftKey) {
  807. var eventoTrl = replaceEventString(arrTeclas[i].evento, target.name, arrTeclas[i].campo);
  808. eval(eventoTrl);
  809. return false;
  810. } else if (arrTeclas[i].teclaAuxiliar=="shiftKey" && !CodigoTecla.ctrlKey && !CodigoTecla.altKey && CodigoTecla.shiftKey) {
  811. var eventoTrl = replaceEventString(arrTeclas[i].evento, target.name, arrTeclas[i].campo);
  812. eval(eventoTrl);
  813. return false;
  814. }
  815. }
  816. }
  817. }
  818. }
  819. return true;
  820. }
  821. function isIdenticalField(nombreArray, nombreActual) {
  822. if (nombreArray.substring(nombreArray.length-1)=="%") return (nombreActual.indexOf(nombreArray.substring(0, nombreArray.length-1))==0);
  823. else return (nombreArray == nombreActual);
  824. }
  825. function replaceEventString(eventoJS, inputname, arrayName) {
  826. eventoJS = ReplaceText(eventoJS, "@inputname@", inputname);
  827. if (arrayName!=null && arrayName!="" && arrayName.substring(arrayName.length-1)=="%") {
  828. var endname = inputname.substring(arrayName.length-1);
  829. eventoJS = ReplaceText(eventoJS, "@endinputname@", endname);
  830. }
  831. return eventoJS;
  832. }
  833. /**
  834. * @name activarControlTeclas
  835. * @format function activarControlTeclas()
  836. * @comment Es la encargada de activar el controlador de pulsación de teclas para la página.<BR>
  837. * Esta función se deberá activar tras haber definido el array de teclas global en dicha
  838. * página, es decir, <em>arrTeclas</em>.
  839. *
  840. * @example onLoad="activarControlTeclas();"
  841. */
  842. function activarControlTeclas() {
  843. if (arrTeclas==null || arrTeclas.length==0) return true;
  844. var agt=navigator.userAgent.toLowerCase();
  845. /* if (agt.indexOf('gecko') != -1) {
  846. document.releaseEvents(Event.KEYDOWN);
  847. }
  848. if (agt.indexOf('gecko') != -1)
  849. document.captureEvents(Event.KEYDOWN);*/
  850. document.onkeydown=controlTecla;
  851. return true;
  852. }
  853. /**
  854. * @name rellenarComboHijo
  855. * @format function rellenarComboHijo(combo, arrayDatos, padre, Selected, sinBlanco)
  856. * @comment Esta función se encarga de rellenar un combo de datos, a partir de un array que se le pasa,
  857. * buscando los elementos que contengan la clave padre indicada.
  858. *
  859. * @param <b>combo</b> - Es un objeto que identifica el combo a rellenar.<BR>
  860. * <b>arrayDatos</b> - Es un array con los datos que compondrán el combo. Este array debe estar
  861. * compuesto por los siguientes campos en orden:<BR>
  862. * <ol>
  863. * <li>Campo clave que representa el padre o elemento de agrupación de datos</li>
  864. * <li>Clave de cada elemento</li>
  865. * <li>Texto a presentar en el combo para cada elemento</li>
  866. * <li>Booleano que indica si se debe seleccionar o no</li>
  867. * </ol>.<BR>
  868. * <b>padre</b> - Es la clave del padre para buscar los elementos comunes a presentar.<BR>
  869. * <b>Selected</b> - Booleano que indica si se debe contemplar el último campo del array para seleccionar
  870. * elementos dentro del nuevo array. Si este campo es null o false, no es necesario
  871. * implementar el último elemento del array de datos.<BR>
  872. * <b>sinBlanco</b> - Booleano que indica si se debe añadir o no un elemento en blanco. Para los combos
  873. * en los que se puede no elegir ningún elemento. Por defecto es false.
  874. *
  875. * @return Devuelve <b>true</b> si todo va bien y, si no, devuelve <b>false</b>.
  876. * @example rellenarComboHijo(document.frmMain.inpCombo, arrDatos, '12', true, true);
  877. */
  878. function rellenarComboHijo(combo, arrayDatos, padre, bolSelected, sinBlanco) {
  879. var i, value="";
  880. for (i = combo.options.length;i>=0;i--)
  881. combo.options[i] = null;
  882. i=0;
  883. if (sinBlanco==null || !sinBlanco)
  884. combo.options[i++] = new Option("", "");
  885. if (arrayDatos==null) return false;
  886. var total = arrayDatos.length;
  887. for (var j=0;j<total;j++) {
  888. if (arrayDatos[j][0]==padre) {
  889. combo.options[i] = new Option(arrayDatos[j][2], arrayDatos[j][1]);
  890. if (bolSelected!=null && bolSelected && arrayDatos[j][3]=="true") {
  891. value = arrayDatos[j][1];
  892. combo.options[i].selected = true;
  893. }
  894. else combo.options[i].selected = false;
  895. i++;
  896. }
  897. }
  898. return value;
  899. }
  900. /**
  901. * @name layer
  902. * @format function layer(Span, Texto, esId)
  903. * @comment Esta función permite introducir un texto en objeto span, div o layer. Su finalidad es la
  904. * de poder cambiar texto en una página HTML de forma dinámica sin que el texto deba estar en
  905. * un campo de formulario.
  906. *
  907. * @param <b>Span</b> - Objeto que referencia a un span, div o layer de la página o el id de uno de
  908. * esos objetos que exista en la página. <BR>
  909. * <b>Texto</b> - Texto que queremos que ponga en el span, div o layer. Si ponemos "", entonces,
  910. * lo deja vacío. <BR>
  911. * <b>esID</b> - Booleano que indica a la función si el primer parámetro que se le ha pasado es
  912. * el id (true) o el objeto (false).
  913. * @example layer("idSpan", "HOLA", true);
  914. */
  915. function layer(nodo, strTexto, esId, isAppend)
  916. {
  917. if (strTexto==null)
  918. strTexto = "";
  919. if (isAppend==null) isAppend=false;
  920. if (document.layers)
  921. {
  922. if (esId!=null && esId)
  923. nodo = document.layers[nodo];
  924. if (nodo==null) return;
  925. nodo.document.write(strTexto);
  926. nodo.document.close();
  927. }
  928. else if (document.all)
  929. {
  930. if (esId!=null && esId)
  931. nodo = document.all[nodo];
  932. if (nodo==null) return;
  933. //nodo.innerHTML = '';
  934. try {
  935. if (isAppend) {
  936. strTexto = ((nodo.innerHTML==null)?"":nodo.innerHTML) + strTexto;
  937. isAppend = false;
  938. }
  939. nodo.innerHTML = strTexto;
  940. } catch (e) {
  941. if (isAppend) {
  942. strTexto = ((nodo.outterHTML==null)?"":nodo.outterHTML) + strTexto;
  943. isAppend = false;
  944. }
  945. nodo.outterHTML = strTexto;
  946. }
  947. nodo=null;
  948. }
  949. else if (document.getElementById)
  950. {
  951. if (esId!=null && esId)
  952. nodo = document.getElementById(nodo);
  953. if (nodo==null) return;
  954. var range = document.createRange();
  955. range.setStartBefore(nodo);
  956. var domfrag = range.createContextualFragment(strTexto);
  957. while (nodo.hasChildNodes())
  958. {
  959. nodo.removeChild(nodo.lastChild);
  960. }
  961. nodo.appendChild(domfrag);
  962. nodo=null;
  963. }
  964. }
  965. function readLayer(nodo, esId) {
  966. if (document.layers) {
  967. if (esId!=null && esId) nodo = document.layers[nodo];
  968. if (nodo==null) return "";
  969. return getChildText(nodo);
  970. } else if (document.all) {
  971. if (esId!=null && esId) nodo = document.all[nodo];
  972. if (nodo==null) return "";
  973. try {
  974. return nodo.innerHTML;
  975. } catch (e) {
  976. return nodo.outterHTML;
  977. }
  978. } else if (document.getElementById) {
  979. if (esId!=null && esId) nodo = document.getElementById(nodo);
  980. if (nodo==null) return "";
  981. return getChildText(nodo);
  982. }
  983. return "";
  984. }
  985. function getChildText(nodo) {
  986. if (nodo==null) return "";
  987. if (nodo.data) return nodo.data;
  988. else return getChildText(nodo.firstChild);
  989. }
  990. /**
  991. * @name rellenarCombo
  992. * @format function rellenarCombo(Combo, ArrayDatos, Selected, sinBlanco)
  993. * @comment Rellena un <b>Combo</b> con los valores del <b>ArrayDatos</b>. Admite que se ponga un
  994. * valor seleccionado en el <b>Combo</b>, que será el que se indique como tal en el
  995. * <b>ArrayDatos</b>.
  996. *
  997. * @param <b>Combo</b> - referencia a un objeto del tipo combo, que es el que queremos rellenar con
  998. * los valores del <b>ArrayDatos</b>. <BR>
  999. * <b>ArrayDatos</b> - es un Array que contiene los valores que queremos que aparezcan en el
  1000. * <b>Combo</b>. Su formato es (value, texto, selected), donde <em>valor</em> es el value que
  1001. * tendrá en <b>Combo</b>, <em>texto</em> es el texto que se verá en la lista desplegable y
  1002. * <em>selected</em> es un campo que tendrá el valor <strong>true</strong> o
  1003. * <strong>false</strong>, dependiendo de si queremos que ese registro aparezca seleccionado
  1004. * en el <b>Combo</b>. Este último campo (<em>selected</em>) sólo será necesario si queremos
  1005. * que esta función establezca valos seleccionados en el <b>Combo</b>. <BR>
  1006. * <b>Selected</b> - es un Booleano que indica si queremos que al rellenar el <b>Combo</b> se
  1007. * ponga algún valor como seleccionado.<BR>
  1008. * <b>sinBlanco</b> - para hacer que se elimine le primer elemento en blanco del combo. Recibe
  1009. * valores booleanos.
  1010. */
  1011. function rellenarCombo(combo, arrayDatos, bolSelected, sinBlanco) {
  1012. var i, value="";
  1013. for (i = combo.options.length;i>=0;i--)
  1014. combo.options[i] = null;
  1015. i=0;
  1016. if (sinBlanco==null || !sinBlanco)
  1017. combo.options[i++] = new Option("", "");
  1018. if (arrayDatos==null) return "";
  1019. var total = arrayDatos.length;
  1020. for (var j=0;j<total;j++) {
  1021. combo.options[i] = new Option(arrayDatos[j][1], arrayDatos[j][0]);
  1022. if (bolSelected!=null && bolSelected && arrayDatos[j][2]=="true") {
  1023. value = arrayDatos[j][0];
  1024. combo.options[i].selected = true;
  1025. }
  1026. else combo.options[i].selected = false;
  1027. i++;
  1028. }
  1029. return value;
  1030. }
  1031. /**
  1032. * @name selectDefaultValueFromArray
  1033. * @format function selectDefaultValueFromArray(arrayDatos, Selected)
  1034. * @comment Esta función se encarga de buscar el elemento seleccionado dentro de un array de datos. En
  1035. * caso de no encontrar ningún elemento seleccionado elige el primero.
  1036. *
  1037. * @param <b>arrayDatos</b> - Es un array que contiene los datos. Su formato es de 3 campos en el siguiente
  1038. * orden: primero la clave, luego el texto del elemento y, por último, un booleano que indica si el
  1039. * elemento está seleccionado o no.<BR>
  1040. * <b>Selected</b> - Booleano que indica si debe buscar un elemento seleccionado dentro del array. Si
  1041. * este parámetro se deja a null o es false, se presentará el primer elemento del array.
  1042. *
  1043. * @return Devuelve un valor en blanco si no encuentra ningún dato o el array está vacío. Devolverá la clave
  1044. * del elemento correspondiente en caso de realizar correctamente la búsqueda.
  1045. * @example selectDefaultValueFromArray(arrDatos, true);
  1046. */
  1047. function selectDefaultValueFromArray (arrayDatos, bolSelected) {
  1048. var value="";
  1049. if (arrayDatos==null) return "";
  1050. value = arrayDatos[0][0];
  1051. var total = arrayDatos.length;
  1052. for (var j=0;j<total;j++) {
  1053. if (bolSelected!=null && bolSelected && arrayDatos[j][2]=="true") {
  1054. value = arrayDatos[j][0];
  1055. }
  1056. }
  1057. return value;
  1058. }
  1059. /**
  1060. * @name changeOrderBy
  1061. * @format function changeOrderBy(list)
  1062. */
  1063. function changeOrderBy(sourceList) {
  1064. if (sourceList == null) return false;
  1065. for (var j=sourceList.length-1;j>=0;j--) {
  1066. if (sourceList.options[j].selected==true) {
  1067. var text = sourceList.options[j].text;
  1068. var value = sourceList.options[j].value;
  1069. if (value.indexOf("-")!=-1) {
  1070. value = value.substring(1);
  1071. text = text.substring(2);
  1072. text = "/\\" + text;
  1073. } else {
  1074. value = "-" + value;
  1075. text = text.substring(2);
  1076. text = "\\/" + text;
  1077. }
  1078. sourceList.options[j].value = value;
  1079. sourceList.options[j].text = text;
  1080. }
  1081. }
  1082. return true;
  1083. }
  1084. /**
  1085. * @name addListOrderBy
  1086. * @format function addListOrderBy(list, listDestino, prefix, all)
  1087. */
  1088. function addListOrderBy(sourceList, destinationList, withPrefix, selectAll) {
  1089. if (sourceList==null || destinationList==null) return false;
  1090. if (selectAll==null) selectAll=false;
  1091. if (withPrefix==null) withPrefix=false;
  1092. for (var j=sourceList.length-1;j>=0;j--) {
  1093. if (selectAll || sourceList.options[j].selected==true) {
  1094. var text = sourceList.options[j].text;
  1095. var value = sourceList.options[j].value;
  1096. if (withPrefix) {
  1097. if (value.indexOf("-")!=-1) value = value.substring(1);
  1098. if (text.indexOf("/\\")!=-1 || text.indexOf("\\/")!=-1) text = text.substring(2);
  1099. } else {
  1100. text = "/\\" + text;
  1101. }
  1102. destinationList.options[destinationList.length] = new Option(text, value);
  1103. sourceList.options[j]=null;
  1104. }
  1105. }
  1106. return true;
  1107. }
  1108. /**
  1109. * @name addList
  1110. * @format function addList(list, listDestino, all)
  1111. * @comment Se encarga de trasladar los elementos de un list a otro. Puede trasladar los elementos
  1112. * seleccionados o todos.
  1113. *
  1114. * @param <b>list</b> - Es un objeto que referencia al list de origen de los datos a copiar.<BR>
  1115. * <b>listDestino</b> - Es un objeto que referencia al list donde se van a copiar los elementos.<BR>
  1116. * <b>all</b> - Es un booleano que indica se copiamos solo los seleccionados o todos.
  1117. *
  1118. * @return Devuelve <b>true</b> si se ha podido procesar o <b>false</b> en caso contrario.
  1119. * @example addList(document.frmMain.inpList1, document.frmMain.inpList2, false);
  1120. */
  1121. function addList(sourceList, destinationList, selectAll) {
  1122. if (sourceList==null || destinationList==null) return false;
  1123. if (selectAll==null) selectAll=false;
  1124. for (var j=sourceList.length-1;j>=0;j--) {
  1125. if (selectAll || sourceList.options[j].selected==true) {
  1126. destinationList.options[destinationList.length] = new Option(sourceList.options[j].text, sourceList.options[j].value);
  1127. sourceList.options[j]=null;
  1128. }
  1129. }
  1130. return true;
  1131. }
  1132. /**
  1133. * @name moveElementInList
  1134. * @format function moveElementInList(list, incremento)
  1135. * @comment Mueve el elemento o elementos seleccionados dentro de un list, incrementando su posición en el
  1136. * valor del incremento.<BR>
  1137. * Si el incremento es negativo mueve los elementos hacia arriba y si no, hacia abajo.
  1138. *
  1139. * @param <b>list</b> - Es un objeto que referencia al list en el que queremos mover los elementos.<BR>
  1140. * <b>incremento</b> - Es un entero que indica el número de posiciones a mover los elementos y
  1141. * el signo del desplazamiento. Si no se indica es 1.
  1142. *
  1143. * @return Devuelve <b>true</b> si se puede realizar la operación o <b>false</b> en caso contrario.
  1144. * @example moveElementInList(document.frmMain.inpList, -1);
  1145. */
  1146. function moveElementInList(list, incr) {
  1147. if (list==null) return false;
  1148. else if (list.length<2) return false;
  1149. if (incr==null) incr=1;
  1150. if (incr>0) {
  1151. for (var i=list.length-2;i>=0;i--) {
  1152. if (list.options[i].selected==true && ((i+incr)>=0 || (i+incr)<list.length)) {
  1153. list.options[i].selected=false;
  1154. var text = list.options[i+incr].text;
  1155. var value = list.options[i+incr].value;
  1156. list.options[i+incr].value = list.options[i].value;
  1157. list.options[i+incr].text = list.options[i].text;
  1158. list.options[i+incr].selected=true;
  1159. list.options[i].value = value;
  1160. list.options[i].text = text;
  1161. }
  1162. }
  1163. } else {
  1164. var total = list.length;
  1165. for (var i=1;i<total;i++) {
  1166. if (list.options[i].selected==true && ((i+incr)>=0 || (i+incr)<list.length)) {
  1167. list.options[i].selected=false;
  1168. var text = list.options[i+incr].text;
  1169. var value = list.options[i+incr].value;
  1170. list.options[i+incr].value = list.options[i].value;
  1171. list.options[i+incr].text = list.options[i].text;
  1172. list.options[i+incr].selected=true;
  1173. list.options[i].value = value;
  1174. list.options[i].text = text;
  1175. }
  1176. }
  1177. }
  1178. return true;
  1179. }
  1180. /**
  1181. * @name valorArray
  1182. * @format function valorArray(ArrayDatos, Clave, Posicion)
  1183. * @comment Devuelve el valor del campo que está en la <b>Posicion</b> indicada, del registro cuyo
  1184. * primer campo tenga el valor <b>Clave</b>.
  1185. *
  1186. * @param <b>ArrayDatos</b> - Array que contiene los registros entre los que buscar. <BR>
  1187. * <b>Clave</b> - Valor que hay que buscar en el primer campo del <b>ArrayDatos</b>. <BR>
  1188. * <b>Posicion</b> - Posición del campo que contiene la descripción que queremos obtener. De
  1189. * este modo, podemos devolver cualquier campo del array
  1190. * @return Devuelve el valor del campo indicado o blanco si no se encuentra ningún registro con esa
  1191. * <b>Clave</b>.
  1192. */
  1193. function valorArray(arrDatos, strClave, intDevolverPosicion)
  1194. {
  1195. if (arrDatos == null) return "";
  1196. else if (strClave==null) return "";
  1197. if (intDevolverPosicion==null) intDevolverPosicion = 1;
  1198. var total = arrDatos.length;
  1199. for (var i=0;i<total;i++) {
  1200. if (arrDatos[i][0] == strClave) {
  1201. return arrDatos[i][intDevolverPosicion];
  1202. }
  1203. }
  1204. return "";
  1205. }
  1206. /**
  1207. * @name radioValue
  1208. * @format function radioValue(Radio)
  1209. * @comment Se encarga de obtener el valor seleccionado de un radio button que exista en la página. La
  1210. * complejida de esta función viene en que sirve tanto para obtener el valor seleccionado
  1211. * cuando sólo hay un campo asociado al radio button que se le pase y, también, cuando sean
  1212. * más de uno, como en el caso de una lista de valores de entre los que sólo podemos elegir
  1213. * uno y que están representados por radio buttons.
  1214. *
  1215. * @param <b>Radio</b> - es un objeto que referencia al radio button del que queremos sacar el valor
  1216. * seleccionado.
  1217. * @return Devuelve el valor seleccionado o null en caso de encontrarlo.
  1218. * @example radioValue(document.forms[0].inpRadioButton);
  1219. */
  1220. function radioValue(radio)
  1221. {
  1222. if (!radio) return null;
  1223. else if (!radio.length)
  1224. return ((radio.checked)?radio.value:null);
  1225. var total = radio.length;
  1226. for (var i=0;i<total;i++)
  1227. {
  1228. if (radio[i].checked)
  1229. return radio[i].value;
  1230. }
  1231. return null;
  1232. }
  1233. /**
  1234. * @name marcarTodos
  1235. * @format function marcarTodos(Check, Marcar)
  1236. * @comment Es muy útil, porque se encarga de marcar o desmarcar todos los checkBox, asociados al
  1237. * checkBox que se le pase. Se ha utilizado para los links de marcar y desmarcar todos de
  1238. * las páginas que tienen un checkbox por cada línea que presentan y se permite seleccionar
  1239. * mediante los checks una o más de una para realizar operaciones con las mismas. Lo bueno
  1240. * de esta función es que es independiente el hecho de que exista sólo un checkBox asociado
  1241. * o más.
  1242. *
  1243. * @param <b>Check</b> - es un objeto que referencia al check de la página que queremos marcar o
  1244. * desmarcar. <BR>
  1245. * <b>Marcar</b> - es un booleano que indica si la operación a realizar es la de marcar o
  1246. * la de desmarcar.
  1247. * @return <b>false</b> - en caso de no encontrar el check indicado. <BR>
  1248. * <b>true</b> - en los demás casos.
  1249. * @example marcarTodos(document.TITULOS.inpCheck, true);
  1250. */
  1251. function marcarTodos(chk, bolMarcar)
  1252. {
  1253. if (bolMarcar==null) bolMarcar = false;
  1254. if (!chk) return false;
  1255. else if (!chk.length) chk.checked = bolMarcar;
  1256. else {
  1257. var total = chk.length;
  1258. for (var i=0;i<total;i++) chk[i].checked = bolMarcar;
  1259. }
  1260. return true;
  1261. }
  1262. /**
  1263. * @name cambiarListaCombo
  1264. * @format function cambiarListaCombo(combo, arrayDatos, clave, blanco)
  1265. * @comment Para los arrays que se recargan desde la propia página al cambiar el valor seleccionado
  1266. * en algún otro combo
  1267. *
  1268. * @param <b>combo</b> - es un objeto que referencia al combo que queremos rellenar con los nuevos
  1269. * valores.<BR>
  1270. * <b>arrayDatos</b> - Es el array que contiene los datos que van a formar los valores del
  1271. * combo.<BR>
  1272. * <b>clave</b> - Es el valor de la clave que identifica los valores que hay que poner en el
  1273. * combo. Es el valor del primer campo del array.<BR>
  1274. * <b>blanco</b> - Es un booleano que indica si hay que poner un elemento en blanco (true) en
  1275. * el combo o no (false).
  1276. * @example cambiarListaCombo(document.frmEdicion.inpCombo, arrayProvincias, "1", false);
  1277. */
  1278. function cambiarListaCombo(combo, arrayDatos, clave, blanco) {
  1279. var i;
  1280. var n=0;
  1281. if (combo.options.length!=null) {
  1282. for (i = combo.options.length;i>=0;i--)
  1283. combo.options[i] = null;
  1284. }
  1285. if (blanco)
  1286. combo.options[n++] = new Option("", "");
  1287. if (arrayDatos==null) return false;
  1288. var total = arrayDatos.length;
  1289. for (i=0;i<total;i++) {
  1290. if (arrayDatos[i][0]==clave)
  1291. combo.options[n++] = new Option(arrayDatos[i][2], arrayDatos[i][1]);
  1292. }
  1293. }
  1294. /**
  1295. * @name limpiarList
  1296. * @format function limpiarList(campo)
  1297. * @comment Borra todos los elementos de un list.
  1298. *
  1299. * @param <b>campo</b> - Objeto que referencia el combo que queremos vaciar.
  1300. *
  1301. * @return Devuelve <b>true</b> si puede procesar la operación o <b>false</b> en caso contrario.
  1302. * @example limpiarList(document.frmMain.inpList);
  1303. */
  1304. function limpiarLista(campo) {
  1305. if (campo==null) return false;
  1306. for (var i = campo.options.length - 1;i>=0;i--) campo.options[i] = null;
  1307. return true;
  1308. }
  1309. /**
  1310. * @name eliminarElementosList
  1311. * @format function eliminarElementosList(campo)
  1312. * @comment Esta función se utiliza en los selectores múltiples para el paso de elementos entre lists,
  1313. * encargándose de la eliminación de los elementos seleccionados.
  1314. *
  1315. * @param <b>campo</b> - Es un objeto que referencia al list del que queremos eliminar elmentos.
  1316. *
  1317. * @return Devuelve <b>true</b> si se puede procesar o <b>false</b> en caso contrario.
  1318. * @example eliminarElementosList(document.frmMain.inpList);
  1319. */
  1320. function eliminarElementosList(campo) {
  1321. if (campo==null) return false;
  1322. for (var i = campo.options.length - 1;i>=0;i--) {
  1323. if (campo.options[i].selected) campo.options[i] = null;
  1324. }
  1325. return true;
  1326. }
  1327. /**
  1328. * @name generarArrayChecks
  1329. * @format function generarArrayChecks(Formulario, checkbox, textbox, resultado)
  1330. * @comment Genera un array a partir de los datos de los checkbox seleccionados y con el texto de los textbox
  1331. * indicados.
  1332. *
  1333. * @param <b>Formulario</b> - Es un objeto que referencia al formulario donde se encuentran los check y textbox.<BR>
  1334. * <b>checkbox</b> - Es un objeto que referencia a los checkbox que contienen los valores seleccionados.<BR>
  1335. * <b>textbox</b> - Es un string que contiene el nombre del textbox que contiene el texto a presentar del array.<BR>
  1336. * <b>resultado</b> - Es el array en el que se devolverán los datos del combo. Se trata de un
  1337. * parámetro de salida.
  1338. *
  1339. * @example generarArrayChecks(document.frmMain.inpCombo, arrDatos);
  1340. */
  1341. function generarArrayChecks(frm, check, text, resultado) {
  1342. var n=0;
  1343. if (check==null) {
  1344. resultado=null;
  1345. return;
  1346. }
  1347. if (!check.length || check.length<=1) {
  1348. if (check.checked) {
  1349. var texto = eval(frm.name + "." + text + check.value);
  1350. var valor = "";
  1351. if (texto!=null) {
  1352. if (!texto.length || texto.length<=1) valor = texto.value;
  1353. else valor = texto[0].value;
  1354. }
  1355. resultado[0] = new Array(check.value, valor);
  1356. }
  1357. } else {
  1358. for (var i = check.length-1;i>=0;i--) {
  1359. if (check[i].checked) {
  1360. var valor = "";
  1361. var texto = eval(frm.name + "." + text + check[i].value);
  1362. if (texto!=null) {
  1363. if (!texto.length || texto.length<=1) valor = texto.value;
  1364. else valor = texto[0].value;
  1365. }
  1366. resultado[n++] = new Array(check[i].value, valor);
  1367. }
  1368. }
  1369. }
  1370. }
  1371. /**
  1372. * @name estaEnCombo
  1373. * @format function estaEnCombo(combo, clave)
  1374. * @comment Se encarga de buscar una clave en un combo y devolver un booleano que indica si la ha encontrado o no.
  1375. *
  1376. * @param <b>combo</b> - Es un objeto que referencia al combo en el que buscamos la clave.<BR>
  1377. * <b>clave</b> - Es la clave que buscamos en el combo.
  1378. *
  1379. * @return Devuelve <b>true</b> si se encuentra la clave en el combo o <b>false</b> en caso contrario.
  1380. * @example estaEnCombo(document.frmMain.inpCombo, '12');
  1381. */
  1382. function estaEnCombo(combo, clave) {
  1383. if (combo==null || clave==null) return false;
  1384. var total = combo.options.length;
  1385. for (var i=0;i<total;i++) {
  1386. if (combo.options[i].value == clave) return true;
  1387. }
  1388. return false;
  1389. }
  1390. /**
  1391. * @name insertarElementosList
  1392. * @format function insertarElementosList(campo, arrayDatos)
  1393. * @comment Sirve para introducir valores nuevos en un list.
  1394. *
  1395. * @param <b>campo</b> - Es un objeto que referencia al campo sobre el que queremos añadir valores.<BR>
  1396. * <b>arrayDatos</b> - Es el array con los nuevos datos a añadir.
  1397. *
  1398. * @return Devuelve <b>true</b> si se puede procesar o <b>false</b> si hay algún problema.
  1399. * @example insertarElementosList(document.frmMain.inpList, arrDatos);
  1400. */
  1401. function insertarElementosList(campoDestino, arrayValores) {
  1402. if (campoDestino == null || arrayValores == null) return false;
  1403. var i = campoDestino.options.length;
  1404. var total = arrayValores.length;
  1405. for (var j=0; j<total;j++) {
  1406. if (!estaEnCombo(campoDestino, arrayValores[j][0]))
  1407. campoDestino.options[i++] = new Option(arrayValores[j][1], arrayValores[j][0]);
  1408. }
  1409. return true;
  1410. }
  1411. /**
  1412. * @name seleccionarListCompleto
  1413. * @format function seleccionarListCompleto(campo)
  1414. * @comment Se encarga de seleccionar todos los elementos de un list o combo. Se utiliza para los selectores
  1415. * múltiples, donde se deben marcar todos los valores elegidos antes de hacer el submit de la ventana.
  1416. *
  1417. * @param <b>campo</b> - Es un objeto que referencia al campo que queremos seleccionar.
  1418. *
  1419. * @return Devuelve <b>true</b> si se procesa correctamente o <b>false</b> si no existe el campo.
  1420. * @example seleccionarListCompleto(document.frmMain.inpList);
  1421. */
  1422. function seleccionarListCompleto(campo) {
  1423. if (campo==null || campo==null) return false;
  1424. var total = campo.options.length;
  1425. for (var i=0;i<total;i++) {
  1426. campo.options[i].selected = true;
  1427. }
  1428. return true;
  1429. }
  1430. /**
  1431. * @name tamanoMaximo
  1432. * @format function tamanoMaximo(campo, tamano)
  1433. * @comment Es un manejador de eventos que controla las pulsaciones de teclas en los textarea,
  1434. * donde no se puede controlar el tamaño del texto que se introduce. Con esta función
  1435. * podemos controlar que el usuario no introduce un texto mayor del que podemos almacenar,
  1436. * presentando un mensaje en caso de superar el límite.
  1437. *
  1438. * @param <b>campo</b> - Es un objeto que referencia al campo sobre el que ponemos el control. normalmente
  1439. * usuaremos el objeto this.<BR>
  1440. * <b>tamano</b> - Es el tamaño máximo de texto que permitiremos introducir.
  1441. *
  1442. * @return Devuelve <b>true</b> si se permite seguir introduciendo texto o <b>false</b> en caso contrario.
  1443. * @example onKeyDown="return tamanoMaximo(this, 50);"
  1444. */
  1445. function tamanoMaximo(campo, tamano, evt) {
  1446. if (campo==null || !campo) return false;
  1447. if (campo.value.length>=tamano) {
  1448. if (document.layers) CodigoTecla.which=0;
  1449. else {
  1450. if (evt==null) evt = window.event;
  1451. evt.keyCode=0;
  1452. evt.returnValue = false;
  1453. evt.cancelBubble = true
  1454. }
  1455. mensaje(11);
  1456. return false;
  1457. }
  1458. return true;
  1459. }
  1460. /**
  1461. * @name selectCombo
  1462. * @format function selectCombo(combo, clave)
  1463. * @comment Selecciona un elemento dentro de un combo.
  1464. *
  1465. * @param <b>combo</b> - Es una referencia al combo en el que queremos seleccionar un elemento.<BR>
  1466. * <b>clave</b> - Es la clave del elemento que queremos seleccionar.
  1467. *
  1468. * @return Devuelve un booleano que indica si ha podido procesar la operación o no.
  1469. * @example selectCombo(document.frmMain.inpCombo, '12');
  1470. */
  1471. function selectCombo(combo, clave) {
  1472. if (!combo || combo==null) return false;
  1473. var total = combo.length;
  1474. for (var i=0;i<total;i++) {
  1475. combo.options[i].selected = (combo.options[i].value == clave);
  1476. }
  1477. return true;
  1478. }
  1479. function updateMenuIcon(id) {
  1480. if (!top.frameMenu) return false;
  1481. else {
  1482. var frame = top.document;
  1483. var frameset = frame.getElementById("framesetMenu");
  1484. if (!frameset) return false;
  1485. try {
  1486. if (frameset.cols.substring(0,1)=="0") changeClass(id, "_hide", "_show", true);
  1487. else changeClass(id, "_show", "_hide", true);
  1488. } catch (ignored) {}
  1489. return true;
  1490. }
  1491. }
  1492. /**
  1493. * @name mostrarMenu
  1494. * @format function mostrarMenu()
  1495. * @comment Muestra u oculta el menu de la ventana de la aplicación.
  1496. *
  1497. * @return Devuelve un booleano que indica si ha podido procesar la operación o no.
  1498. * @example onClick="mostrarMenu();return false;"
  1499. */
  1500. function mostrarMenu(id) {
  1501. if (!top.frameMenu) window.open(baseFrameServlet, "_blank");
  1502. else {
  1503. var frame = top.document;
  1504. var frameset = frame.getElementById("framesetMenu");
  1505. if (!frameset) return false;
  1506. /*try {
  1507. var frm2 = frame.getElementById("frameMenu");
  1508. var obj = document.onresize;
  1509. var obj2 = frm2.onresize;
  1510. document.onresize = null;
  1511. frm2.document.onresize = null;
  1512. progressiveHideMenu("framesetMenu", 30);
  1513. document.onresize = obj;
  1514. frm2.document.onresize = obj2;
  1515. } catch (e) {*/
  1516. if (frameset.cols.substring(0,1)=="0") frameset.cols = "25%,*";
  1517. else frameset.cols = "0%,*";
  1518. //}
  1519. try {
  1520. changeClass(id, "_hide", "_show");
  1521. } catch (e) {}
  1522. return true;
  1523. }
  1524. }
  1525. function progressiveHideMenu(id, topSize, newSize, grow) {
  1526. var frame = top.document;
  1527. var object = frame.getElementById(id);
  1528. if (newSize==null) {
  1529. var sizes = object.cols.split(",");
  1530. size = sizes[0];
  1531. size = size.replace("%", "");
  1532. size = size.replace("px", "");
  1533. newSize = parseInt(size);
  1534. }
  1535. if (grow==null) grow = !(newSize>0);
  1536. if (grow) {
  1537. newSize += 5;
  1538. if (newSize>=topSize) {
  1539. object.cols = topSize + "%, *";
  1540. return true;
  1541. } else object.cols = newSize + "%, *";
  1542. } else {
  1543. newSize -= 5;
  1544. if (newSize<=0) {
  1545. object.cols = "0%, *";
  1546. return true;
  1547. } else object.cols = newSize + "%, *";
  1548. }
  1549. return setTimeout('progressiveHideMenu("' + id + '", ' + topSize + ', ' + newSize + ', ' + grow + ')', 100);
  1550. }
  1551. function changeClass(id, class1, class2, forced) {
  1552. if (forced==null) forced = false;
  1553. var element = document.getElementById(id);
  1554. if (!element) return false;
  1555. if (element.className.indexOf(class1)!=-1) element.className = element.className.replace(class1, class2);
  1556. else if (!forced && element.className.indexOf(class2)!=-1) element.className = element.className.replace(class2, class1);
  1557. return true;
  1558. }
  1559. /**
  1560. * @name getReference
  1561. * @format function getReference(id)
  1562. * @comment Función interna para obtener la referencia a un objeto de la ventana del que recivimos
  1563. * su id.
  1564. *
  1565. * @param <b>id</b> - Es el id del elemento.
  1566. *
  1567. * @return Devuelve una referencia al objeto o null si no lo encuentra.
  1568. * @example getReference('paramField');
  1569. */
  1570. function getReference(id) {
  1571. if (document.getElementById) return document.getElementById(id);
  1572. else if (document.all) return document.all[id];
  1573. else if (document.layers) return document.layers[id];
  1574. else return null;
  1575. }
  1576. /**
  1577. * @name getStyle
  1578. * @format function getStyle(id)
  1579. * @comment Función interna para obtener la propiedad style de un elemento del que se pasa su id.
  1580. *
  1581. * @param <b>id</b> - Es el id del elemento del que queremos obtener su style.
  1582. *
  1583. * @return Devuelve una referencia a la propiedad style del elemento o null si no lo encuentra.
  1584. * @example getStyle('paramField');
  1585. */
  1586. function getStyle(id) {
  1587. var ref = getReference(id);
  1588. if (ref==null || !ref) return null;
  1589. return ((document.layers) ? ref : ref.style);
  1590. }
  1591. /**
  1592. * @name idName
  1593. * @format function idName(name)
  1594. */
  1595. function idName(name) {
  1596. return (name.substring(0,9) + name.substring(10));
  1597. }
  1598. /**
  1599. * @name findElementPosition
  1600. * @format function findElementPosition(Formulario, name)
  1601. */
  1602. function findElementPosition(Formulario, name) {
  1603. var total = Formulario.length;
  1604. for (var i=0;i<total;i++) {
  1605. if (Formulario.elements[i].name==name) return i;
  1606. }
  1607. return null;
  1608. }
  1609. /**
  1610. * @name deselectActual
  1611. * @format function deselectActual(Formulario, field)
  1612. */
  1613. function deselectActual(Formulario, field) {
  1614. if (field==null || field.value==null || field.value=="") return null;
  1615. var i=findElementPosition(Formulario, "inpRecordW" + field.value);
  1616. if (i==null) return null;
  1617. recordSelectExplicit("inpRecord" + field.value, false);
  1618. field.value="";
  1619. return i;
  1620. }
  1621. /**
  1622. * @name findFirstElement
  1623. * @format function findFirstElement(Formulario)
  1624. */
  1625. function findFirstElement(Formulario) {
  1626. if (Formulario==null) return null;
  1627. var n=null;
  1628. var total = Formulario.length;
  1629. for (var i=0;i<total;i++) {
  1630. if (Formulario.elements[i].name.indexOf("inpRecordW")==0) {
  1631. n=i;
  1632. break;
  1633. }
  1634. }
  1635. return n;
  1636. }
  1637. /**
  1638. * @name findLastElement
  1639. * @format function findLastElement(Formulario)
  1640. */
  1641. function findLastElement(Formulario) {
  1642. if (Formulario==null) return null;
  1643. var n=null;
  1644. for (var i=Formulario.length-1;i>=0;i--) {
  1645. if (Formulario.elements[i].name.indexOf("inpRecordW")==0) {
  1646. n=i;
  1647. break;
  1648. }
  1649. }
  1650. return n;
  1651. }
  1652. /**
  1653. * @name nextElement
  1654. * @format function nextElement(Formulario, field)
  1655. */
  1656. function nextElement(Formulario, field) {
  1657. var i=deselectActual(Formulario, field);
  1658. if (i==null) {
  1659. i=findFirstElement(Formulario);
  1660. if (i==null) return;
  1661. } else if (i<findLastElement(Formulario)) i++;
  1662. field.value = Formulario.elements[i].name.substring(10);
  1663. recordSelectExplicit("inpRecord" + Formulario.elements[i].name.substring(10) , true);
  1664. Formulario.elements[i].focus();
  1665. return true;
  1666. }
  1667. /**
  1668. * @name previousElement
  1669. * @format function previousElement(Formulario, field)
  1670. */
  1671. function previousElement(Formulario, field) {
  1672. var i=deselectActual(Formulario, field);
  1673. var menor = findFirstElement(Formulario);
  1674. if (menor==null) return;
  1675. else if (i==null) {
  1676. i=menor;
  1677. if (i==null) return;
  1678. } if (i>menor) i--;
  1679. field.value = Formulario.elements[i].name.substring(10);
  1680. recordSelectExplicit("inpRecord" + Formulario.elements[i].name.substring(10) , true);
  1681. Formulario.elements[i].focus();
  1682. return true;
  1683. }
  1684. /**
  1685. * @name firstElement
  1686. * @format function firstElement(Formulario, field)
  1687. */
  1688. function firstElement(Formulario, field) {
  1689. var i=deselectActual(Formulario, field);
  1690. i=findFirstElement(Formulario);
  1691. if (i==null) return;
  1692. field.value = Formulario.elements[i].name.substring(10);
  1693. recordSelectExplicit("inpRecord" + Formulario.elements[i].name.substring(10) , true);
  1694. Formulario.elements[i].focus();
  1695. return true;
  1696. }
  1697. /**
  1698. * @name lastElement
  1699. * @format function lastElement(Formulario, field)
  1700. */
  1701. function lastElement(Formulario, field) {
  1702. var i=deselectActual(Formulario, field);
  1703. i=findLastElement(Formulario);
  1704. if (i==null) return;
  1705. field.value = Formulario.elements[i].name.substring(10);
  1706. recordSelectExplicit("inpRecord" + Formulario.elements[i].name.substring(10) , true);
  1707. Formulario.elements[i].focus();
  1708. return true;
  1709. }
  1710. /**
  1711. * @name recordSelectExplicit
  1712. * @format function recordSelectExplicit(name, seleccionar)
  1713. */
  1714. function recordSelectExplicit(name, seleccionar) {
  1715. var obj = getStyle(name);
  1716. if (obj==null) return false;
  1717. if (document.layers) {
  1718. if (seleccionar) obj.bgColor=gColorSelected;
  1719. else obj.bgColor=gWhiteColor;
  1720. } else {
  1721. if (seleccionar) obj.backgroundColor = gColorSelected;
  1722. else obj.backgroundColor=gWhiteColor;
  1723. }
  1724. return seleccionar;
  1725. }
  1726. /**
  1727. * @name selectRadioButton
  1728. * @format function selectRadioButton(radio, value)
  1729. * @comment Selecciona un valor dentro de un grupo de radio buttons
  1730. *
  1731. * @param <b>radio</b> - Es una referencia al radio button.<BR>
  1732. * <b>value</b> - Es el value del radio button que queremos seleccionar.
  1733. *
  1734. * @return Devuelve <b>true</b> si todo va bien o <b>false</b> en caso contrario.
  1735. * @example selectRadioButton(document.frmMain.inpRadio, '12');
  1736. */
  1737. function selectRadioButton(radio, Value) {
  1738. if (!radio) return false;
  1739. else if (!radio.length) radio.checked=true;
  1740. else {
  1741. var total = radio.length;
  1742. for (var i=0;i<total;i++) radio[i].checked = (radio[i].value==Value);
  1743. }
  1744. return true;
  1745. }
  1746. /**
  1747. * @name selectCheckbox
  1748. * @format function selectCheckbox(obj, value)
  1749. * @comment Selecciona un valor dentro de un grupo de radio buttons
  1750. *
  1751. * @param <b>obj</b> - Es una referencia al checked.<BR>
  1752. * <b>value</b> - Es el value del radio button que queremos seleccionar.
  1753. *
  1754. * @return Devuelve <b>true</b> si todo va bien o <b>false</b> en caso contrario.
  1755. * @example selectCheckbox(document.frmMain.inpChecked, '12');
  1756. */
  1757. function selectCheckbox(obj, Value) {
  1758. if (!obj) return false;
  1759. else {
  1760. obj.checked = (obj.value==Value);
  1761. }
  1762. return true;
  1763. }
  1764. /**
  1765. * @name formElementValue
  1766. * @format function formElementValue(Formulario, ElementName, Value)
  1767. */
  1768. function formElementValue(Formulario, ElementName, Value) {
  1769. var bolReadOnly=false;
  1770. var onChangeFunction = "";
  1771. if (Formulario==null) {
  1772. Formulario=document.forms[0];
  1773. if (Formulario==null) return false;
  1774. } else if (ElementName==null) return false;
  1775. if (ElementName=="MESSAGE") {
  1776. try {
  1777. setValues_MessageBox('messageBoxID', "INFO", "", Value);
  1778. } catch (err) {
  1779. alert(Value);
  1780. }
  1781. } else if (ElementName=="ERROR" || ElementName=="SUCCESS" || ElementName=="WARNING" || ElementName=="INFO") {
  1782. try {
  1783. setValues_MessageBox('messageBoxID', ElementName, "", Value);
  1784. } catch (err) {
  1785. alert(Value);
  1786. }
  1787. } else if (ElementName=="EXECUTE") {
  1788. eval(Value);
  1789. } else if (ElementName=="DISPLAY") {
  1790. displayLogicElement(Value, true);
  1791. } else if (ElementName=="HIDE") {
  1792. displayLogicElement(Value, false);
  1793. } else if (ElementName=="CURSOR_FIELD") {
  1794. var obj = eval("document." + Formulario.name + "." + Value + ";");
  1795. if (obj==null || !obj || !obj.type || obj.type.toUpperCase()=="HIDDEN") return false;
  1796. obj.focus()
  1797. if (obj.type.toUpperCase().indexOf("SELECT")==-1) obj.select();
  1798. //document.focus();
  1799. } else {
  1800. if (ElementName.indexOf("_BTN")!=-1) {
  1801. if (Value==null || Value=="null") Value="";
  1802. layer(ElementName, Value, true);
  1803. return true;
  1804. }
  1805. var obj = eval("document." + Formulario.name + "." + ElementName + ";");
  1806. if (obj==null || !obj || !obj.type) return false;
  1807. if (obj.getAttribute("readonly")=="true") bolReadOnly=true;
  1808. if (bolReadOnly) {
  1809. onChangeFunction = obj.onchange;
  1810. obj.onchange = "";
  1811. obj.setAttribute("readonly", "false");
  1812. //obj.readOnly="false";
  1813. }
  1814. if (obj.type.toUpperCase().indexOf("SELECT")!=-1) {
  1815. if (Value!=null && typeof Value!="object") {
  1816. var total = obj.length;
  1817. var index = -1;
  1818. var hasMultiSelect = false;
  1819. var selectedOption = false;
  1820. if ((Value==null || Value=="") && total>0) Value = obj.options[0].value;
  1821. for (var i=0;i<total;i++) {
  1822. selectedOption = (obj.options[i].value == Value);
  1823. obj.options[i].selected = selectedOption;
  1824. if (selectedOption) {
  1825. if (index!=-1) hasMultiSelect = true;
  1826. index = i;
  1827. }
  1828. }
  1829. if (!hasMultiSelect) obj.selectedIndex = index;
  1830. } else Value = rellenarCombo(obj, Value, true, ((obj.className.toUpperCase().indexOf("REQUIRED")!=-1) || obj.className.toUpperCase().indexOf("KEY")!=-1 || (obj.className.toUpperCase().indexOf("READONLY")!=-1)));
  1831. } else if (obj.type.toUpperCase().indexOf("CHECKBOX")!=-1) {
  1832. selectCheckbox(obj, Value);
  1833. } else if (obj.type.toUpperCase().indexOf("RADIO")!=-1 || obj.type.toUpperCase().indexOf("CHECK")!=-1) {
  1834. selectRadioButton(obj, Value);
  1835. } else {
  1836. if (Value==null || Value=="null") Value="";
  1837. if (typeof Value!="object") {
  1838. obj.value = Value;
  1839. } else //if (obj.className.toUpperCase().indexOf("REQUIRED")!=-1 || obj.className.toUpperCase().indexOf("KEY")!=-1 || obj.className.toUpperCase().indexOf("READONLY")!=-1)
  1840. obj.value = selectDefaultValueFromArray(Value, true);
  1841. }
  1842. if (bolReadOnly && onChangeFunction) {
  1843. var i = onChangeFunction.toString().indexOf("selectCombo(this,");
  1844. var search = "\"";
  1845. if (i!=-1) {
  1846. var first = onChangeFunction.toString().indexOf(search, i+1);
  1847. if (first==-1) {
  1848. search = "'";
  1849. first = onChangeFunction.toString().indexOf(search, i+1);
  1850. }
  1851. if (first!=-1) {
  1852. var end = onChangeFunction.toString().indexOf(search, first+1);
  1853. if (end!=-1) {
  1854. onChangeFunction = onChangeFunction.toString().substring(0, first+1) + Value + onChangeFunction.toString().substring(end);
  1855. onChangeFunction = onChangeFunction.toString().replace("function anonymous()", "");
  1856. }
  1857. }
  1858. }
  1859. if (onChangeFunction.toString().indexOf("function anonymous()")==-1) obj.onchange = new Function("", onChangeFunction.toString());
  1860. else obj.onchange = onChangeFunction.toString();
  1861. //obj.onchange = function anonymous() {selectCombo(this, Value);return true;};
  1862. obj.setAttribute("readonly", "true");
  1863. }
  1864. }
  1865. return true;
  1866. }
  1867. function setClass(id, selectClass) {
  1868. var obj = getReference(id);
  1869. if (obj==null) return null;
  1870. obj.className = selectClass;
  1871. }
  1872. function getObjectClass(id, previousClass) {
  1873. var obj = getReference(id);
  1874. if (obj==null) return previousClass;
  1875. return(obj.className);
  1876. }
  1877. /**
  1878. * @name formElementEvent
  1879. * @format function formElementEvent(Formulario, ElementName, callout)
  1880. */
  1881. function formElementEvent(Formulario, ElementName, calloutName) {
  1882. if (Formulario==null) Formulario=document.forms[0].name;
  1883. else if (ElementName==null) return false;
  1884. var isReload=false;
  1885. if (ElementName!="MESSAGE" && ElementName!="CURSOR_FIELD" && ElementName!="EXECUTE" && ElementName!="DISPLAY" && ElementName!="HIDE" && ElementName.indexOf("_BTN")==-1) {
  1886. var obj = eval("document." + Formulario + "." + ElementName + ";");
  1887. if (obj==null || !obj || !obj.type) return false;
  1888. if (obj.type.toUpperCase().indexOf("RADIO")!=-1) {
  1889. if (obj.onclick!=null && obj.onclick.toString().indexOf(calloutName)==-1) {
  1890. if (obj.onclick.toString().indexOf("callout")!=-1 || obj.onclick.toString().indexOf("reload")!=-1) isReload=true;
  1891. obj.onclick();
  1892. }
  1893. } else {
  1894. var bolReadOnly = false;
  1895. if (obj.onchange!=null && obj.onchange.toString().indexOf(calloutName)==-1) {
  1896. if (obj.onchange.toString().indexOf("callout")!=-1 || obj.onchange.toString().indexOf("reload")!=-1) isReload=true;
  1897. if (obj.getAttribute("readonly")=="true") {
  1898. bolReadOnly=true;
  1899. obj.removeAttribute("readonly");
  1900. }
  1901. obj.onchange();
  1902. if (bolReadOnly) obj.setAttribute("readonly", "true");
  1903. }
  1904. }
  1905. }
  1906. return (isReload);
  1907. }
  1908. /**
  1909. * @name fillElements
  1910. * @format function fillElements(Formulario, name, callout)
  1911. */
  1912. function fillElements(frm, name, callout) {
  1913. this.formName = frm;
  1914. this.name = name;
  1915. this.callout = callout;
  1916. }
  1917. /**
  1918. * @name fillElementsFromArray
  1919. * @format function fillElementsFromArray(arrElements, calloutName, Fromulario)
  1920. */
  1921. function fillElementsFromArray(arrElements, calloutName, Formulario) {
  1922. gWaitingCallOut=false;
  1923. if (arrElements==null && arrGeneralChange==null) return false;
  1924. if (Formulario==null || !Formulario) Formulario=document.forms[0];
  1925. if (arrElements!=null) {
  1926. var total = arrElements.length;
  1927. for (var x=0;x<total;x++) {
  1928. formElementValue(Formulario, arrElements[x][0], arrElements[x][1]);
  1929. }
  1930. }
  1931. if (arrGeneralChange==null) arrGeneralChange=new Array();
  1932. if (arrElements!=null) {
  1933. var n=arrGeneralChange.length;
  1934. var total = arrElements.length;
  1935. for (var x=0;x<total;x++) {
  1936. arrGeneralChange[x+n] = new fillElements(Formulario.name , arrElements[x][0], calloutName);
  1937. }
  1938. }
  1939. while (arrGeneralChange!=null && arrGeneralChange.length>0) {
  1940. var obj = arrGeneralChange[0].formName;
  1941. var name = arrGeneralChange[0].name;
  1942. var callout = arrGeneralChange[0].callout;
  1943. {
  1944. if (arrGeneralChange==null || arrGeneralChange.length==0) return true;
  1945. var arrDataNew = new Array();
  1946. var total = arrGeneralChange.length;
  1947. for (var i=1;i<total;i++) {
  1948. arrDataNew[i-1] = new fillElements(arrGeneralChange[i].formName, arrGeneralChange[i].name, arrGeneralChange[i].callout);
  1949. }
  1950. arrGeneralChange=null;
  1951. arrGeneralChange = new Array();
  1952. total = arrDataNew.length;
  1953. for (var i=0;i<total;i++) {
  1954. arrGeneralChange[i] = new fillElements(arrDataNew[i].formName, arrDataNew[i].name, arrDataNew[i].callout);
  1955. }
  1956. }
  1957. if (formElementEvent(obj, name, callout)) return true;
  1958. }
  1959. /*try {
  1960. document.focus();
  1961. } catch (e) {}*/
  1962. return true;
  1963. }
  1964. function inputValueForms(name, campo) {
  1965. var result = "";
  1966. if (campo==null || !campo) return "";
  1967. if (!campo.type && campo.length>1) campo = campo[0];
  1968. if (campo.type) {
  1969. if (campo.type.toUpperCase().indexOf("SELECT")!=-1) {
  1970. if (campo.selectedIndex==-1) return "";
  1971. else {
  1972. var length = campo.options.length;
  1973. for (var fieldsCount=0;fieldsCount<length;fieldsCount++) {
  1974. if (campo.options[fieldsCount].selected) {
  1975. if (result!="") result += "&";
  1976. result += name + "=" + escape(campo.options[fieldsCount].value);
  1977. }
  1978. }
  1979. return result;
  1980. }
  1981. } else if (campo.type.toUpperCase().indexOf("RADIO")!=-1 || campo.type.toUpperCase().indexOf("CHECK")!=-1) {
  1982. if (!campo.length) {
  1983. if (campo.checked) return (name + "=" + escape(campo.value));
  1984. else return "";
  1985. } else {
  1986. var total = campo.length;
  1987. for (var i=0;i<total;i++) {
  1988. if (campo[i].checked) {
  1989. if (result!="") result += "&";
  1990. result += name + "=" + escape(campo[i].value);
  1991. }
  1992. }
  1993. return result;
  1994. }
  1995. } else return name + "=" + escape(campo.value);
  1996. }
  1997. return "";
  1998. }
  1999. function setFocus(campo) {
  2000. if (campo==null || !campo) return "";
  2001. if (!campo.type && campo.length>1) campo = campo[0];
  2002. try {
  2003. campo.focus();
  2004. } catch (ignored) {}
  2005. return "";
  2006. }
  2007. /**
  2008. * @name inputValue
  2009. * @format function inputValue(campo)
  2010. * @comment Obtiene el valor de un campo. Se encarga de toda la lógica para controlar si el campo
  2011. * existe, o si es un array de campos o un campo simple...
  2012. *
  2013. * @param <b>campo</b> - Es un objeto que referencia al campo del que se quiere obtener el valor.
  2014. *
  2015. * @return Devuelve un valor en blanco si no existe el campo o el valor del campo.
  2016. * @example inputValue(document.frmMain.inpInput);
  2017. */
  2018. function inputValue(campo) {
  2019. if (campo==null || !campo) return "";
  2020. if (!campo.type && campo.length>1) campo = campo[0];
  2021. if (campo.type) {
  2022. if (campo.type.toUpperCase().indexOf("SELECT")!=-1) {
  2023. if (campo.selectedIndex==-1) return "";
  2024. else return campo.options[campo.selectedIndex].value;
  2025. } else if (campo.type.toUpperCase().indexOf("RADIO")!=-1 || campo.type.toUpperCase().indexOf("CHECK")!=-1) {
  2026. if (!campo.length)
  2027. return ((campo.checked)?campo.value:"N");
  2028. var total = campo.length;
  2029. for (var i=0;i<total;i++) {
  2030. if (campo[i].checked) return campo[i].value;
  2031. }
  2032. return "N";
  2033. } else return campo.value;
  2034. }
  2035. return "";
  2036. }
  2037. function setInputValue(campo, myvalue) {
  2038. if (campo==null || campo=="") return false;
  2039. var obj = document.forms[0].elements[campo];
  2040. if (obj==null) return false;
  2041. if (obj.length>1) {
  2042. var total = obj.length;
  2043. for (var i=0;i<total;i++) obj[i].value = myvalue;
  2044. } else obj.value = myvalue;
  2045. return true;
  2046. }
  2047. /**
  2048. * @name displayLogicElement
  2049. * @format function displayLogicElement(id, display)
  2050. * @comment Es la función que presenta u oculta elementos de la página, es decir, es la que
  2051. * implementa el display logic de la ventana.
  2052. *
  2053. * @param <b>id</b> - Es el id del objeto que queremos ocultar o presentar.<BR>
  2054. * <b>display</b> - Booleano que nos indica si tenemos que ocultarlo o presentarlo.
  2055. *
  2056. * @return Devuelve <b>true</b> si se procesa correctamente o <b>false</b> en caso contrario.
  2057. * @example displayLogicElement('buttonField', true);
  2058. */
  2059. function displayLogicElement(id, display) {
  2060. var obj = getStyle(id);
  2061. if (obj==null) return false;
  2062. if (id.indexOf("_td")!=-1) {
  2063. obj = getReference(id);
  2064. if (display) obj.className = obj.className.replace("_Nothing","");
  2065. else {
  2066. obj.className = obj.className.replace("_Nothing","");
  2067. obj.className = obj.className + "_Nothing";
  2068. }
  2069. } else {
  2070. if (display) obj.display="";
  2071. else obj.display="none";
  2072. }
  2073. return true;
  2074. }
  2075. /**
  2076. * @name estaEnCombo
  2077. * @format function estaEnCombo(combo, clave)
  2078. * @comment Busca una clave entre los elementos de un combo. Es una función de utilidad, es decir, es
  2079. * utilizada por otras funciones para realizar sus operaciones.
  2080. *
  2081. * @param <b>combo</b> - Es un objeto que referencia al combo en el que queremos buscar.<BR>
  2082. * <b>clave</b> - Es la clave que queremos buscar en el combo.
  2083. *
  2084. * @return Devuelve un booleano que será <b>true</b> si la encuentra en el combo o <b>false</b>.
  2085. * @example estaEnCombo(documento.frmMain, '12');
  2086. */
  2087. function estaEnCombo(combo, clave) {
  2088. if (combo==null || clave==null) return false;
  2089. var total = combo.options.length;
  2090. for (var i=0;i<total;i++) {
  2091. if (combo.options[i].value == clave) return true;
  2092. }
  2093. return false;
  2094. }
  2095. /**
  2096. * @name auto_completar_numero
  2097. * @format function auto_completar_numero(campo, decimal, negativo)
  2098. * @comment Es una función de control de evento de pulsación de teclado que nos permite
  2099. * controlar si se trata de una pulsación numérica permitida o no. Se colocará
  2100. * en el evento onKeyDown u onKeyUp del campo sobre el que queremos controlar
  2101. * que sólo se introduzcan números.
  2102. *
  2103. * @param <b>campo</b> - Es el campo sobre el que queremos controlar la introducción de números.
  2104. * Lo normal es que utilicemos el objeto this.<BR>
  2105. * <b>decimal</b> - Booleano que indica si queremos que se admitan decimales para el número.<BR>
  2106. * <b>negativo</b> - Booleano que indica si admitimos números negativos.
  2107. *
  2108. * @example onKeyUp="auto_completar_numero(this, true, true);return true;"
  2109. */
  2110. function auto_completar_numero(obj, bolDecimal, bolNegativo, evt) {
  2111. var numero;
  2112. if (document.all) evt = window.event;
  2113. if (document.layers) { numero = evt.which; }
  2114. if (document.all) { numero = evt.keyCode;}
  2115. if (numero != obtenerCodigoTecla("ENTER") && numero != obtenerCodigoTecla("LEFTARROW") && numero != obtenerCodigoTecla("RIGHTARROW") && numero != obtenerCodigoTecla("UPARROW") && numero != obtenerCodigoTecla("DOWNARROW") && numero != obtenerCodigoTecla("DELETE") && numero != obtenerCodigoTecla("BACKSPACE") && numero != obtenerCodigoTecla("END") && numero != obtenerCodigoTecla("HOME") && !evt["ctrlKey"]) {
  2116. if (numero>95 && numero <106) { //Teclado numérico
  2117. numero = numero - 96;
  2118. if(isNaN(numero)) {
  2119. if (document.all) evt.returnValue = false;
  2120. return false;
  2121. }
  2122. } else if (numero!=obtenerCodigoTecla("DECIMAL") && numero != obtenerCodigoTecla("NUMBERDECIMAL") && numero != obtenerCodigoTecla("NEGATIVE") && numero != obtenerCodigoTecla("NUMBERNEGATIVE")) { //No es "-" ni "."
  2123. numero = String.fromCharCode(numero);
  2124. if(isNaN(numero)) {
  2125. if (document.all) evt.returnValue = false;
  2126. return false;
  2127. }
  2128. } else if (numero==obtenerCodigoTecla("DECIMAL") || numero==obtenerCodigoTecla("NUMBERDECIMAL")) { //Es "."
  2129. if (bolDecimal) {
  2130. if (obj.value==null || obj.value=="") return true;
  2131. else {
  2132. var point = obj.value.indexOf(".");
  2133. if (point != -1) {
  2134. point = obj.value.indexOf(".", point+1);
  2135. if (point==-1) return true;
  2136. } else return true;
  2137. }
  2138. }
  2139. if (document.all) evt.returnValue = false;
  2140. return false;
  2141. } else { //Es "-"
  2142. if (bolNegativo && (obj.value==null || obj.value.indexOf("-")==-1)) return true;
  2143. if (document.all) evt.returnValue = false;
  2144. return false;
  2145. }
  2146. }
  2147. return true;
  2148. }
  2149. /**
  2150. * @name logChanges
  2151. * @format function logChanges(campo)
  2152. * @comment Se trata de un log para controlar si se han producido cambios en una ventana. Se
  2153. * pone en el evento onChange de los campos a registrar y, requiere que exista, en
  2154. * la propia ventana, un campo llamado inpLastFieldChanged.<BR>
  2155. * Utiliza la función setChangedField para realizar el log.
  2156. *
  2157. * @param <b>campo</b> - Es el campo de la ventana sobre el que queremos registrar si se han
  2158. * producido cambios. Normalmente se colocará esta función en el evento onChange del
  2159. * propio campo, por lo que utilizaremos el objeto this en este parámetro.
  2160. *
  2161. * @return Devuelve <b>true</b> si se ha procesado correctamente o <b>false</b> si el campo no
  2162. * existe o se produce algún error.
  2163. * @example onChange="logChanges(this);return true;"
  2164. */
  2165. function logChanges(campo) {
  2166. if (campo==null || !campo) return false;
  2167. return setChangedField(campo, campo.form);
  2168. }
  2169. /**
  2170. * @name processingPopUp
  2171. * @format function processingPopUp()
  2172. * @comment Se trata de una función que se encarga de la presentación de un popUp con un texto
  2173. * de procesando y una barra de progreso en movimiento, pero que sólo serviría para
  2174. * presentarlo mientras se está ejecutando una llamada larga y se debería cerrar después.
  2175. *
  2176. * @return Devuelve un objeto que permite manejar la ventana.
  2177. */
  2178. function processingPopUp() {
  2179. var complementosNS4 = ""
  2180. var strHeight=100, strWidth=200;
  2181. var strTop=parseInt((screen.height - strHeight)/2);
  2182. var strLeft=parseInt((screen.width - strWidth)/2);
  2183. if (navigator.appName.indexOf("Netscape"))
  2184. complementosNS4 = "alwaysRaised=1, dependent=1, directories=0, hotkeys=0, menubar=0, ";
  2185. var complementos = complementosNS4 + "height=" + strHeight + ", width=" + strWidth + ", left=" + strLeft + ", top=" + strTop + ", screenX=" + strLeft + ", screenY=" + strTop + ", location=0, resizable=0, status=0, toolbar=0, titlebar=0";
  2186. var winPopUp = window.open("", "_blank", complementos);
  2187. if (winPopUp!=null) {
  2188. document.onunload = function(){winPopUp.close();};
  2189. document.onmousedown = function(){winPopUp.close();};
  2190. winPopUp.document.writeln("<html>\n");
  2191. winPopUp.document.writeln("<head>\n");
  2192. winPopUp.document.writeln("<title>Proceso petici&oacute;n</title>\n");
  2193. winPopUp.document.writeln("<script language=\"javascript\" type=\"text/javascript\">\n");
  2194. winPopUp.document.writeln("function selectTD(name, seleccionar) {\n");
  2195. winPopUp.document.writeln(" var obj = getStyle(name);\n");
  2196. winPopUp.document.writeln(" if (document.layers) {\n");
  2197. winPopUp.document.writeln(" if (seleccionar) obj.bgColor=\"" + gColorSelected + "\";\n");
  2198. winPopUp.document.writeln(" else obj.bgColor=\"" + gWhiteColor + "\";\n");
  2199. winPopUp.document.writeln(" } else {\n");
  2200. winPopUp.document.writeln(" if (seleccionar) obj.backgroundColor = \"" + gColorSelected + "\";\n");
  2201. winPopUp.document.writeln(" else obj.backgroundColor=\"" + gWhiteColor + "\";\n");
  2202. winPopUp.document.writeln(" }\n");
  2203. winPopUp.document.writeln(" return seleccionar;\n");
  2204. winPopUp.document.writeln("}\n");
  2205. winPopUp.document.writeln("function getReference(id) {\n");
  2206. winPopUp.document.writeln(" if (document.getElementById) return document.getElementById(id);\n");
  2207. winPopUp.document.writeln(" else if (document.all) return document.all[id];\n");
  2208. winPopUp.document.writeln(" else if (document.layers) return document.layers[id];\n");
  2209. winPopUp.document.writeln(" else return null;\n");
  2210. winPopUp.document.writeln("}\n");
  2211. winPopUp.document.writeln("function getStyle(id) {\n");
  2212. winPopUp.document.writeln(" var ref = getReference(id);\n");
  2213. winPopUp.document.writeln(" if (ref==null || !ref) return null;\n");
  2214. winPopUp.document.writeln(" return ((document.layers) ? ref : ref.style);\n");
  2215. winPopUp.document.writeln("}\n");
  2216. winPopUp.document.writeln("var total=5;\n");
  2217. winPopUp.document.writeln("function loading(num) {\n");
  2218. winPopUp.document.writeln(" if (num>=total) {\n");
  2219. winPopUp.document.writeln(" for (var i=0;i<total;i++) {\n");
  2220. winPopUp.document.writeln(" selectTD(\"TD\" + i, false);\n");
  2221. winPopUp.document.writeln(" }\n");
  2222. winPopUp.document.writeln(" num=-1;\n");
  2223. winPopUp.document.writeln(" } else {\n");
  2224. winPopUp.document.writeln(" selectTD(\"TD\" + num, true);\n");
  2225. winPopUp.document.writeln(" }\n");
  2226. winPopUp.document.writeln(" setTimeout('loading(' + (++num) + ')', 1000);\n");
  2227. winPopUp.document.writeln(" return true;\n");
  2228. winPopUp.document.writeln("}\n");
  2229. winPopUp.document.writeln("</script>\n");
  2230. winPopUp.document.writeln("</head>\n");
  2231. winPopUp.document.writeln("<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onLoad=\"loading(0);\">\n");
  2232. winPopUp.document.writeln(" <table width=\"80%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" align=\"center\">\n");
  2233. winPopUp.document.writeln(" <tr>\n");
  2234. winPopUp.document.writeln(" <td colspan=\"5\" align=\"center\"><font color=\"navy\" size=\"5\">PROCESSING...</font></td>\n");
  2235. winPopUp.document.writeln(" </tr>\n");
  2236. winPopUp.document.writeln(" <tr bgcolor=\"" + gWhiteColor + "\">\n");
  2237. winPopUp.document.writeln(" <td width= \"20%\" id=\"TD0\" bgcolor=\"" + gWhiteColor + "\">&nbsp;</td>\n");
  2238. winPopUp.document.writeln(" <td width=\"20%\" id=\"TD1\" bgcolor=\"" + gWhiteColor + "\">&nbsp;</td>\n");
  2239. winPopUp.document.writeln(" <td width=\"20%\" id=\"TD2\" bgcolor=\"" + gWhiteColor + "\">&nbsp;</td>\n");
  2240. winPopUp.document.writeln(" <td width=\"20%\" id=\"TD3\" bgcolor=\"" + gWhiteColor + "\">&nbsp;</td>\n");
  2241. winPopUp.document.writeln(" <td width=\"20%\" id=\"TD4\" bgcolor=\"" + gWhiteColor + "\">&nbsp;</td>\n");
  2242. winPopUp.document.writeln(" </tr>\n");
  2243. winPopUp.document.writeln(" </table>\n");
  2244. winPopUp.document.writeln("</body>\n");
  2245. winPopUp.document.writeln("</html>\n");
  2246. winPopUp.document.close();
  2247. winPopUp.focus();
  2248. }
  2249. return winPopUp;
  2250. }
  2251. /**
  2252. * @name round
  2253. * @format function round(nummero, decimales)
  2254. * @comment Realiza el redondeo de un valor numérico al número de decimales indicado
  2255. *
  2256. * @param <b>numero</b> - Es el número que queremos redondear.<BR>
  2257. * <b>decimales</b> - Es el número de decimales al que queremos redondear el número.
  2258. *
  2259. * @return Devuelve el número redondeado o 0 si no es un número válido.
  2260. * @example round(12.234, 2);
  2261. */
  2262. function round(number,X) {
  2263. X = (!X ? 2 : X);
  2264. if (!number || isNaN(number)) return 0;
  2265. return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
  2266. }
  2267. function ReplaceText(texto, replaceWhat, replaceWith) {
  2268. if (texto==null || texto.length==0) return "";
  2269. texto += "";
  2270. var i = texto.indexOf(replaceWhat);
  2271. var j = 0;
  2272. while (i!=-1) {
  2273. var partial = texto.substring(0, i);
  2274. texto = texto.substring(i+replaceWhat.length);
  2275. texto = partial + replaceWith + texto;
  2276. j = i + replaceWith.length;
  2277. i = texto.indexOf(replaceWhat, j);
  2278. }
  2279. return texto;
  2280. }
  2281. function updateOnChange(field) {
  2282. if (field==null) return false;
  2283. try {
  2284. var lastChanged = inputValue(document.forms[0].inpLastFieldChanged);
  2285. if (field.name!="inpadClientId" && field.name!="inpadOrgId") field.onchange();
  2286. setInputValue(document.forms[0].inpLastFieldChanged, lastChanged);
  2287. } catch (e) {}
  2288. return true;
  2289. }
  2290. /**
  2291. * @name xx
  2292. * @format function xx()
  2293. * @comment Esta función no hace nada, simplemente sirve para ponerla en el diseño para ser sustituida,
  2294. * pero hacer que el diseño siga funcionando
  2295. */
  2296. function xx()
  2297. {
  2298. return true;
  2299. }
  2300. /**
  2301. * @name menuContextual
  2302. * @format function menuContextual()
  2303. * @comment Se trata de un función manejadora de eventos que sirve para el control del click con el
  2304. * botón derecho sobre la página. Esta función no permite dicho evento, presentando un mensaje
  2305. * en tal caso.
  2306. */
  2307. function menuContextual(evt) {
  2308. var boton = (evt==null)?event.button:evt.which;
  2309. if (boton == 3 || boton == 2) {
  2310. if (document.all) alert('El boton derecho está deshabilitado por pruebas');
  2311. return false;
  2312. }
  2313. return true;
  2314. }
  2315. /*
  2316. COMPATIBILIDAD DEL CALENDARIO CON ELEMENTOS EXTERNOS
  2317. */
  2318. // This function gets called when the end-user clicks on some date.
  2319. function selected(cal, date) {
  2320. cal.sel.value = date; // just update the date in the input field.
  2321. if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
  2322. // if we add this call we close the calendar on single-click.
  2323. // just to exemplify both cases, we are using this only for the 1st
  2324. // and the 3rd field, while 2nd and 4th will still require double-click.
  2325. cal.callCloseHandler();
  2326. }
  2327. // And this gets called when the end-user clicks on the _selected_ date,
  2328. // or clicks on the "Close" button. It just hides the calendar without
  2329. // destroying it.
  2330. function closeHandler(cal) {
  2331. cal.hide(); // hide the calendar
  2332. // cal.destroy();
  2333. _dynarch_popupCalendar = null;
  2334. }
  2335. function getDateFormat(str_format) {
  2336. var format = "";
  2337. if (str_format!=null && str_format!="" && (str_format.substring(0,1) == "M" || str_format.substring(0,1) == "m")) {
  2338. format = "%m-%d-%Y";
  2339. } else if (str_format!=null && str_format!="" && (str_format.substring(0,1) == "D" || str_format.substring(0,1) == "d")) {
  2340. format = "%d-%m-%Y";
  2341. }
  2342. if (str_format==null || str_format=="") str_format = defaultDateFormat;
  2343. else if (str_format.indexOf(" %H:%M:%S")!=-1) format += " %H:%M:%S";
  2344. else if (str_format.indexOf(" %H:%M")!=-1) format += " %H:%M";
  2345. return format;
  2346. }
  2347. function showCalendar(id, value, debug, format, showsTime, showsOtherMonths) {
  2348. //var el = document.getElementById(id);
  2349. var el = eval("document." + id);
  2350. if (showsTime==null) showsTime = "";
  2351. if (showsOtherMonths==null) showsOtherMonths = false;
  2352. if (format==null || format=="") format = getDateFormat(el.getAttribute("displayformat"));
  2353. else format = getDateFormat(format);
  2354. if (format.indexOf(" %H:%M")!=-1) showsTime = "24";
  2355. if (_dynarch_popupCalendar != null) {
  2356. // we already have some calendar created
  2357. _dynarch_popupCalendar.hide(); // so we hide it first.
  2358. } else {
  2359. // first-time call, create the calendar.
  2360. var cal = new Calendar(1, null, selected, closeHandler);
  2361. // uncomment the following line to hide the week numbers
  2362. cal.weekNumbers = false;
  2363. if (typeof showsTime == "string" && showsTime!="") {
  2364. cal.showsTime = true;
  2365. cal.time24 = (showsTime == "24");
  2366. }
  2367. if (showsOtherMonths) {
  2368. cal.showsOtherMonths = true;
  2369. }
  2370. _dynarch_popupCalendar = cal; // remember it in the global var
  2371. cal.setRange(1900, 2070); // min/max year allowed.
  2372. cal.create();
  2373. }
  2374. dateFormat = format;
  2375. _dynarch_popupCalendar.setDateFormat(format); // set the specified date format
  2376. _dynarch_popupCalendar.parseDate(el.value); // try to parse the text in field
  2377. _dynarch_popupCalendar.sel = el; // inform it what input field we use
  2378. // the reference element that we pass to showAtElement is the button that
  2379. // triggers the calendar. In this example we align the calendar bottom-right
  2380. // to the button.
  2381. _dynarch_popupCalendar.showAtElement(el, "Br"); // show the calendar
  2382. return false;
  2383. }
  2384. function datecmp(date1, date2, fmt) {
  2385. if (date1==null || date1 == "") return null;
  2386. else if (date2==null || date2 == "") return null;
  2387. fmt = getDateFormat(fmt);
  2388. var mydate1 = Date.parseDate(date1, fmt);
  2389. var mydate2 = Date.parseDate(date2, fmt);
  2390. if (mydate1==null || mydate1=="" || mydate2==null || mydate2=="") return null;
  2391. if (mydate1.getFullYear() > mydate2.getFullYear()) return 1;
  2392. else if (mydate1.getFullYear() == mydate2.getFullYear()) {
  2393. if (mydate1.getMonth() > mydate2.getMonth()) return 1;
  2394. else if (mydate1.getMonth() == mydate2.getMonth()) {
  2395. if (mydate1.getDate() > mydate2.getDate()) return 1;
  2396. else if (mydate1.getDate() == mydate2.getDate()) {
  2397. if (mydate1.getHours() > mydate2.getHours()) return 1;
  2398. else if (mydate1.getHours() == mydate2.getHours()) {
  2399. if (mydate1.getMinutes() > mydate2.getMinutes()) return 1;
  2400. else if (mydate1.getMinutes() == mydate2.getMinutes()) return 0;
  2401. else return -1;
  2402. } else return -1;
  2403. } else return -1;
  2404. } else return -1;
  2405. } else return -1;
  2406. }
  2407. function checkFormat(formatType) {
  2408. switch (formatType) {
  2409. case 'Y': return 4;
  2410. case 'm': return 2;
  2411. case 'd': return 2;
  2412. default: return 2;
  2413. }
  2414. return 0;
  2415. }
  2416. function getSeparators(format) {
  2417. if (format==null || format.length==0) return null;
  2418. var result = new Array();
  2419. var pos = format.indexOf("%");
  2420. var last = 0;
  2421. var i=0;
  2422. while (pos!=-1) {
  2423. if (pos>last) {
  2424. result[i++] = format.substring(last, pos);
  2425. }
  2426. last = pos+2;
  2427. pos = format.indexOf("%", last);
  2428. }
  2429. if (last < format.length) result[i] = format.substring(last);
  2430. return result;
  2431. }
  2432. function isInArray(obj, text) {
  2433. if (obj==null || obj.length==0) return false;
  2434. if (text==null || text.length==0) return false;
  2435. var total = obj.length;
  2436. for (var i = 0;i<total;i++) {
  2437. if (obj[i].toUpperCase()==text.toUpperCase()) return true;
  2438. }
  2439. return false;
  2440. }
  2441. function about() {
  2442. var complementosNS4 = ""
  2443. var strHeight=500;
  2444. var strWidth=600;
  2445. var strTop=parseInt((screen.height - strHeight)/2);
  2446. var strLeft=parseInt((screen.width - strWidth)/2);
  2447. if (navigator.appName.indexOf("Netscape"))
  2448. complementosNS4 = "alwaysRaised=1, dependent=1, directories=0, hotkeys=0, menubar=0, ";
  2449. var complementos = complementosNS4 + "height=" + strHeight + ", width=" + strWidth + ", left=" + strLeft + ", top=" + strTop + ", screenX=" + strLeft + ", screenY=" + strTop + ", location=0, resizable=yes, scrollbars=yes, status=0, toolbar=0, titlebar=0";
  2450. var winPopUp = window.open(baseDirection + "../ad_forms/about.html", "ABOUT", complementos);
  2451. if (winPopUp!=null) {
  2452. winPopUp.focus();
  2453. document.onunload = function(){winPopUp.close();};
  2454. document.onmousedown = function(){winPopUp.close();};
  2455. }
  2456. return winPopUp;
  2457. }
  2458. function resizeArea(isOnResize) {
  2459. if (isOnResize==null) isOnResize = false;
  2460. var mnu = document.getElementById("client");
  2461. var mleft = document.getElementById("tdLeftTabsBars");
  2462. var mleftSeparator = document.getElementById("tdleftSeparator");
  2463. var mright = document.getElementById("tdrightSeparator");
  2464. var mtop = document.getElementById("tdtopNavButtons");
  2465. var mtopToolbar = document.getElementById("tdToolBar");
  2466. var mtopTabs = document.getElementById("tdtopTabs");
  2467. var mbottombut = document.getElementById("tdbottomButtons");
  2468. var mbottom = document.getElementById("tdbottomSeparator");
  2469. var body = document.getElementsByTagName("BODY");
  2470. var h = body[0].clientHeight;
  2471. var w = body[0].clientWidth;
  2472. var name = window.navigator.appName;
  2473. mnu.style.width = w - ((mleft?mleft.clientWidth:0) + (mleftSeparator?mleftSeparator.clientWidth:0) + (mright?mright.clientWidth:0)) - ((name.indexOf("Microsoft")==-1)?2:0);
  2474. mnu.style.height = h -((mtop?mtop.clientHeight:0) + (mtopToolbar?mtopToolbar.clientHeight:0) + (mtopTabs?mtopTabs.clientHeight:0) + (mbottom?mbottom.clientHeight:0) + (mbottombut?mbottombut.clientHeight:0)) - ((name.indexOf("Microsoft")==-1)?1:0);
  2475. /* try {
  2476. dojo.addOnLoad(dojo.widget.byId('grid').onResize);
  2477. } catch (e) {}*/
  2478. try {
  2479. if (isOnResize) dojo.widget.byId('grid').onResize();
  2480. } catch (e) {}
  2481. mnu.style.display = "";
  2482. }
  2483. function resizeAreaHelp() {
  2484. var mnu = document.getElementById("client");
  2485. var mnuIndex = document.getElementById("clientIndex");
  2486. var mTopSeparator = document.getElementById("tdSeparator");
  2487. var mTopNavigation = document.getElementById("tdNavigation");
  2488. var body = document.getElementsByTagName("BODY");
  2489. var h = body[0].clientHeight;
  2490. var w = body[0].clientWidth;
  2491. var name = window.navigator.appName;
  2492. // mnu.style.width = w - 18 - ((name.indexOf("Microsoft")==-1)?2:0);
  2493. mnu.style.height = h -(mTopSeparator.clientHeight + mTopNavigation.clientHeight) - 2;
  2494. mnuIndex.style.height = mnu.style.height;
  2495. mnu.style.display = "";
  2496. mnuIndex.style.display = "";
  2497. }
  2498. function resizeAreaUserOps() {
  2499. var mnu = document.getElementById("client");
  2500. var mnuIndex = document.getElementById("clientIndex");
  2501. var mTopSeparator = document.getElementById("tdSeparator");
  2502. var mVerSeparator = document.getElementById("tdVerSeparator");
  2503. var mTopNavigation = document.getElementById("tdNavigation");
  2504. var body = document.getElementsByTagName("BODY");
  2505. var h = body[0].clientHeight;
  2506. var w = body[0].clientWidth;
  2507. var name = window.navigator.appName;
  2508. // mnu.style.width = w - 18 - ((name.indexOf("Microsoft")==-1)?2:0);
  2509. mnu.style.height = h -(mTopSeparator.clientHeight + mTopNavigation.clientHeight) - 2;
  2510. mnuIndex.style.height = mnu.style.height;
  2511. mnuIndex.style.display = "";
  2512. mnu.style.width= w - (mVerSeparator.clientWidth + mnuIndex.clientWidth) - 2;
  2513. mnu.style.display = "";
  2514. }
  2515. /*if (!document.all)
  2516. document.captureEvents(Event.MOUSEDOWN);
  2517. document.onmousedown=menuContextual;*/
  2518. //-->