/* PACKAGE : COMMON */ function get_xmlhttp() { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } /* ajax_function * Envia una solicitud GET a ajax_server con la variables "function" y las definidas en parameters. * @author Julio Cesar Laura Avendano * @version 1.0 * @package ajax * @param string ajax_server url de la pagina servidor * @param string function funci�n solicitada en el lado del servidor * @param string parameters variables pasadas por url. Ej. variable=valor&otravariable=suvalor */ function ajax_function(ajax_server, funcion, parameters, method) { var objetus; objetus = get_xmlhttp(); var response; try { if (parameters) parameters = '&' + encodeURI(parameters); if (!method ) method ="POST"; data = "function=" + funcion + parameters; questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?'; var callServer; callServer = new leimnud.module.rpc.xmlhttp({ url : ajax_server, async : false, method : method, args : data }); callServer.make(); response = callServer.xmlhttp.responseText; var scs = callServer.xmlhttp.responseText.extractScript(); scs.evalScript(); delete callServer; } catch(ss){ alert("Error: "+ss.message+var_dump(ss)); } return response;//objetus.responseText; } /* ajax_message * Envia una solicitud GET a ajax_server con la variables "function" y las definidas en parameters. * @author Julio Cesar Laura Avendano * @version 1.0 * @package ajax * @param string ajax_server url de la pagina servidor * @param string function funci�n solicitada en el lado del servidor * @param string parameters variables pasadas por url. Ej. variable=valor&otravariable=suvalor */ function ajax_message(ajax_server, funcion, parameters, method, callback) { var objetus; objetus = get_xmlhttp(); var response; try { if (parameters) parameters = '&' + encodeURI(parameters); if (!method ) method ="POST"; data = "function=" + funcion + parameters; questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?'; objetus.open( method, ajax_server + ((method==='GET')? questionMark+data : '') , true ); objetus.onreadystatechange=function() { if ( objetus.readyState==4) { if( objetus.status==200) { if ( callback ) callback(objetus.responseText); } } } if (method==='POST') objetus.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); objetus.send(((method==='GET')? null : data)); }catch(ss) { alert("error"+ss.message); } } /* ajax_post * Envia una solicitud GET/POST a ajax_server con los parametros definidos * o los campos de un formulario * @author Julio Cesar Laura Avendano * @version 1.0 * @package ajax * @param string ajax_server url de la pagina servidor * @param string function funci�n solicitada en el lado del servidor * @param string parameters variables pasadas por url o formulario. * @example: ajax_post('foo.com', document.form[0], "POST", callback ) */ function ajax_post(ajax_server, parameters, method, callback, asynchronous ) { var objetus; objetus = get_xmlhttp(); var response; try { if (typeof(parameters)==='object') parameters = ajax_getForm(parameters); if (!method ) method ="POST"; if (typeof(asynchronous)==='undefined') asynchronous = false; data = parameters; questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?'; if (method==='GET/POST') { objetus.open( 'POST', ajax_server + ((data.length<1024)?(questionMark+data):''), asynchronous ); } else { objetus.open( method, ajax_server + ((method==='GET')? questionMark+data : '') , asynchronous ); } objetus.onreadystatechange=function() { if ( objetus.readyState==4) { if( objetus.status==200) { if ( callback ) callback(objetus.responseText); } } } if ((method==='POST')||(method==='GET/POST')) objetus.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); objetus.send(((method==='GET')? null : data)); if (!asynchronous) { if ( callback ) callback(objetus.responseText); return objetus.responseText; } }catch(ss) { alert("Error: "+ var_dump(ss)); } } /* * Refactoring....................... * Fixed by checkboxes binary values * By Neyek * Date March 27th, 2009 12:20:00 GMT-4 */ function ajax_getForm( thisform ) { var formdata=''; // Loop through form fields for (var i=0; i < thisform.length; i++) { if ( formdata!=='' ) formdata += '&'; //Build Send String if(thisform.elements[i].type == "text") { //Handle Textbox's formdata += thisform.elements[i].name + "=" + encodeURIComponent(thisform.elements[i].value); } else if(thisform.elements[i].type == "textarea") { //Handle textareas formdata += thisform.elements[i].name + "=" + encodeURIComponent(thisform.elements[i].value); } else if(thisform.elements[i].type == "checkbox") { //Handle checkbox's formdata += thisform.elements[i].name + '=' + ((thisform.elements[i].checked)? '1': '0'); } else if(thisform.elements[i].type == "radio") { //Handle Radio buttons if(thisform.elements[i].checked==true){ formdata += thisform.elements[i].name + "=" + thisform.elements[i].value; } } else if(thisform.elements[i].type == "select-multiple") { //Handle list box for(var j=0; j= '0') && (sCharacter <= '9'))) { return false; } } } else { if (sCharacter == '.') { if (!bDot) { bDot = true; } else { return false; } } else { if (!((sCharacter >= '0') && (sCharacter <= '9') && (sCharacter != '-') || (sCharacter == '+'))) { return false; } } } } return true; } function roundNumber(iNumber, iDecimals) { var iNumber = parseFloat(iNumber || 0); var iDecimals = parseFloat(iDecimals || 2); return Math.round(iNumber * Math.pow(10, iDecimals)) / Math.pow(10, iDecimals); } function toMaskNumber(iNumber,dec) { iNumber = fix(iNumber.toString(),dec || 2); var t=iNumber.split("."); var arrayResult=iNumber.replace(/\D/g,'').replace(/^0*/,'').split("").reverse(); var final=""; var aux=0; var sep=0; for(var i=0;i1 && aux>=3 && ((aux%3)==0)) { final=arrayResult[i]+","+final; aux+=1; sep+=1; } else { final=arrayResult[i]+final; if(i>1) { aux+=1; } } } } return final; } function fix(val, dec) { var a = val.split("."); var r=""; if(a.length==1) { r=a[0]+"."+creaZero(dec); } else { if(a[1].length<=dec) { r=a[0]+"."+a[1]+creaZero(dec-a[1].length); } else { r=a[0]+"."+a[1].substr(0,dec); } } return r; } function creaZero(cant) { var a=""; for(var i=0;i */ function getField( fieldName , formId ) { if (formId) { var form = document.getElementById(formId); if (!form) {form=document.getElementsByName(formId); if (form) { if (form.length > 0) { form = form[0]; } } } if (form.length > 0) { return form.elements[ 'form[' + fieldName + ']' ]; } else { //return null; return document.getElementById( 'form[' + fieldName + ']' ); } } else { return document.getElementById( 'form[' + fieldName + ']' ); } } /* * author */ function getElementByName( fieldName ) { var elements = document.getElementsByName( fieldName ); try{ var x=0; if (elements.length === 1) return elements[0]; else if (elements.length === 0) return elements[0]; else return elements; } catch (E) {} } var myDialog; function commonDialog ( type, title , text, buttons, values, callbackFn ) { myDialog = new leimnud.module.panel(); myDialog.options = { size:{w:400,h:200}, position:{center:true}, title: title, control: { close :false, roll :false, drag :true, resize :false }, fx: { //shadow :true, blinkToFront:false, opacity :true, drag:false, modal: true }, theme:"processmaker" }; myDialog.make(); switch (type) { case 'question': icon = 'question.gif'; break case 'warning': icon = 'warning.gif'; break case 'error': icon = 'error.gif'; break default: icon = 'information.gif'; break } var contentStr = ''; contentStr += "
"; contentStr += ""; contentStr += "
"; contentStr += "" + text + "
"; if ( buttons.custom && buttons.customText ) contentStr += "   "; if ( buttons.cancel ) contentStr += "   "; if ( buttons.yes ) contentStr += "   "; if ( buttons.no ) contentStr += "   "; contentStr += "
"; myDialog.addContent( contentStr ); myDialog.values = values; myDialog.dialogCallback = function ( dialogResult ) { myDialog.remove( ); if ( callbackFn ) callbackFn ( dialogResult ); } } function var_dump(obj) { var o,dump; dump=''; if (typeof(obj)=='object') { for(o in obj) if (typeof(obj[o])!=='function') { dump+=o+'('+typeof(obj[o])+'):'+obj[o]+"\n"; } } else dump=obj; return dump; } /* * @author David Callizaya */ var currentPopupWindow; function popupWindow ( title , url, width, height, callbackFn , autoSizeWidth, autoSizeHeight,modal,showModalColor) { modal = (modal===false)?false:true; showModalColor = (showModalColor===false)?false:true; var myPanel = new leimnud.module.panel(); currentPopupWindow = myPanel; myPanel.options = { size:{w:width,h:height}, position:{center:true}, title: title, theme: "processmaker", control: { close :true, roll :false, drag :true, resize :false}, fx: { //shadow :true, blinkToFront:true, opacity :true, drag:true, modal: modal //opacityModal:{static:'1'} } }; if(showModalColor===true) { //Panel.setStyle={modal:{backgroundColor:"#ECF3F6"}}; } else { myPanel.styles.fx.opacityModal.Static='0'; } myPanel.make(); myPanel.loader.show(); var r = new leimnud.module.rpc.xmlhttp({url:url}); r.callback=leimnud.closure({Function:function(rpc,myPanel){ myPanel.addContent(rpc.xmlhttp.responseText); var myScripts = myPanel.elements.content.getElementsByTagName('SCRIPT'); for(var rr=0; rr'; textfield.innerHTML = dataArray[0].firstChild.xml; } } else { window.alert('error-['+ objetus.status +']-' + objetus.responseText ); } } } objetus.send(null); } function refillDropdown( fldName, ajax_server, values , InitValue) { var objetus; objetus = get_xmlhttp(); objetus.open ("GET", ajax_server + "?" + values, false); objetus.onreadystatechange=function() { if ( objetus.readyState == 1 ) { var dropdown = document.getElementById( 'form[' + fldName + ']' ); while ( dropdown.hasChildNodes() ) dropdown.removeChild(dropdown.childNodes[0]); } else if ( objetus.readyState==4) { if( objetus.status==200) { var xmlDoc = objetus.responseXML; if ( xmlDoc ) { var dropdown = document.getElementById( 'form[' + fldName + ']' ); var dataArray = xmlDoc.getElementsByTagName('item'); itemsNumber = dataArray.length; if(InitValue == true) itemsNumber = dataArray.length-1; for (var i=0; i'; } } else { window.alert('error-['+ objetus.status +']-' + objetus.responseText ); } } } objetus.send(null); } function iframe_get_xmlhttp() { try { xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } function iframe_ajax_init(ajax_server, div_container, values, callback) { var objetus; objetus = iframe_get_xmlhttp(); objetus.open ('GET', ajax_server + '?' + values, true); objetus.onreadystatechange = function() { if ( objetus.readyState == 1 ) { document.getElementById(div_container).style.display = ''; document.getElementById(div_container).innerHTML = '...'; } else if (objetus.readyState==4) { if (objetus.status==200) { document.getElementById(div_container).innerHTML = objetus.responseText; if (callback != '') callback(); } else { window.alert('error-['+ objetus.status +']-' + objetus.responseText ); } } } objetus.send(null); } function iframe_ajax_init_2(ajax_server, div_container, values, callback) { var objetus; objetus = iframe_get_xmlhttp(); objetus.open ('GET', ajax_server + '?' + values, true); objetus.onreadystatechange = function() { if ( objetus.readyState == 1 ) { div_container.style.display = ''; div_container.innerHTML = '...'; } else if (objetus.readyState==4) { if (objetus.status==200) { div_container.innerHTML = objetus.responseText; if (callback != '') callback(); } else { window.alert('error-['+ objetus.status +']-' + objetus.responseText ); } } } objetus.send(null); } function myEmptyCallback() { } function disable (obj) { obj.disabled = true; return; } function enable (obj) { obj.disabled = false; return; } function disableById (id) { obj = getField(id); obj.disabled = true; return; } function enableById (id) { obj = getField(id); obj.disabled = false; return; } function visible (obj) { if (obj.style) { obj.style.visibility = 'visible'; } return; } function hidden (obj) { if (obj.style) { obj.style.visibility = 'hidden'; } return; } function visibleById (id) { obj = getField(id); obj.style.visibility = 'visible'; return; } function hiddenById (id) { obj = getField(id); obj.style.visibility = 'hidden'; return; } function hiddenRowById (id) { row = 'DIV_'+ id +'.style.visibility = \'hidden\';'; hiden = 'DIV_'+ id +'.style.display = \'none\';'; eval(row); eval(hiden); return; } function visibleRowById (id) { row = 'DIV_'+ id +'.style.visibility = \'visible\';'; block = 'DIV_'+ id +'.style.display = \'block\';'; eval(row); eval(block); return; } function setFocus (obj) { obj.focus(); return; } function setFocusById (id) { obj = getField (id); setFocus(obj); return; } function submitForm () { document.webform.submit(); return; } function changeValue(id, newValue) { obj = getField(id); obj.value = newValue; return ; } function getValue(obj) { return obj.value; } function getValueById (id) { obj = getField(id); return obj.value; } function removeCurrencySign (snumber) { var aux = ''; var num = new String (snumber); var len = num.length; var i = 0; for (i=0; !(i>=len); i++) if (num.charAt(i) != ',' && num.charAt(i) != '$' && num.charAt(i) != ' ') aux = aux + num.charAt(i); return aux; } function removePercentageSign (snumber) { var aux = ''; var num = new String (snumber); var len = num.length; var i = 0; for (i=0; !(i>=len); i++) if (num.charAt(i) != ',' && num.charAt(i) != '%' && num.charAt(i) != ' ') aux = aux + num.charAt(i); return aux; } function toReadOnly(obj) { if (obj) { obj.readOnly = 'readOnly'; obj.style.background = '#CCCCCC'; } return; } function toReadOnlyById(id) { obj = getField(id); if (obj) { obj.readOnly = 'readOnly'; obj.style.background = '#CCCCCC'; } return ; } function getGridField(Grid, Row, Field) { obj = document.getElementById('form[' + Grid + ']' + '[' + Row + ']' + '[' + Field + ']'); return obj; } function getGridValueById(Grid, Row, Field) { obj = getGridField(Grid, Row, Field); if (obj) return obj.value; else return ''; } function Number_Rows_Grid(Grid, Field) { Number_Rows = 1; if (getGridField(Grid, Number_Rows, Field)) { Number_Rows = 0; while (getGridField(Grid, (Number_Rows + 1), Field)) Number_Rows++; return Number_Rows; } else return 0; } function attachFunctionEventOnChange(Obj, TheFunction) { Obj.oncustomize = TheFunction; } function attachFunctionEventOnChangeById(Id, TheFunction) { Obj = getField(Id); Obj.oncustomize = TheFunction; } function attachFunctionEventOnKeypress(Obj, TheFunction) { Obj.attachEvent('onkeypress', TheFunction); } function attachFunctionEventOnKeypressById(Id, TheFunction) { Obj = getField(Id); Obj.attachEvent('onkeypress', TheFunction); } function unselectOptions ( field ) { var radios = document.getElementById('form[' + field + ']'); if (radios) { var inputs = radios.getElementsByTagName ('input'); if (inputs) { for(var i = 0; i < inputs.length; ++i) { inputs[i].checked = false; } } } } function validDate(TheField, Required) { TheYear = getField(TheField + '][YEAR'); TheMonth = getField(TheField + '][MONTH'); TheDay = getField(TheField + '][DAY'); if (!TheYear || !TheMonth || !TheDay) return false; if (Required) if ((TheYear.value == 0) || (TheMonth.value == 0) || (TheDay.value == 0)) return false; if (TheMonth.value == 2) if (TheDay.value > 29) return false; if ((TheMonth.value == 4) || (TheMonth.value == 6) || (TheMonth.value == 9) || (TheMonth.value == 11)) if (TheDay.value > 30) return false; return true; } /* @author David S. Callizaya S. */ function globalEval(scriptCode) { if (scriptCode!=='') if (window.execScript) window.execScript( scriptCode, 'javascript' ); else window.setTimeout( scriptCode, 0 ); } function switchImage(oImg,url1,url2){ if (oImg && (url2!=='')) { oImg.src=(oImg.src.substr(oImg.src.length-url1.length,url1.length)===url1)? url2: url1; } } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i * @return false */ function dynaformSetFocus(){ /* looking for the inputs fields */ var inputs = document.getElementsByTagName('input'); if(inputs.length > 0){ for(i in inputs){ type = inputs[i].type; if(type == "text" || type == "radio" || type == "checkbox" || type == "file" || type == "password"){ try { inputs[i].focus(); } catch (e) { //nothing } return false; } } } else { /* if there is no inputs fields, maybe it has a textarea field */ var ta = document.getElementsByTagName('textarea'); if(ta.length > 0){ inputs[0].focus(); return false; } } return false; } /** * ********************************* Misc Functions by Neyek **************************************** */ /** * get the htmlentities from a string * * @Author Erik Amaru Ortiz * @Param (string) string within the htmlentities to parse * @Param (string) quote_style it can be (ENT_QUOTES or ENT_NOQUOTES) * @Return (string) the parsed string with htmlentities at the string passed such as parameter */ function htmlentities (string, quote_style) { var hash_map = {}, symbol = '', tmp_str = '', entity = ''; tmp_str = string.toString(); if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { return false; } hash_map["'"] = '''; for (symbol in hash_map) { entity = hash_map[symbol]; tmp_str = tmp_str.split(symbol).join(entity); } return tmp_str; } function get_html_translation_table (table, quote_style) { //example 1: get_html_translation_table('HTML_SPECIALCHARS'); //returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'} var entities = {}, hash_map = {}, decimal = 0, symbol = ''; var constMappingTable = {}, constMappingQuoteStyle = {}; var useTable = {}, useQuoteStyle = {}; // Translate arguments constMappingTable[0] = 'HTML_SPECIALCHARS'; constMappingTable[1] = 'HTML_ENTITIES'; constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT'; constMappingQuoteStyle[3] = 'ENT_QUOTES'; useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { throw new Error("Table: "+useTable+' not supported'); // return false; } entities['38'] = '&'; if (useTable === 'HTML_ENTITIES') { entities['160'] = ' '; entities['161'] = '¡'; entities['162'] = '¢'; entities['163'] = '£'; entities['164'] = '¤'; entities['165'] = '¥'; entities['166'] = '¦'; entities['167'] = '§'; entities['168'] = '¨'; entities['169'] = '©'; entities['170'] = 'ª'; entities['171'] = '«'; entities['172'] = '¬'; entities['173'] = '­'; entities['174'] = '®'; entities['175'] = '¯'; entities['176'] = '°'; entities['177'] = '±'; entities['178'] = '²'; entities['179'] = '³'; entities['180'] = '´'; entities['181'] = 'µ'; entities['182'] = '¶'; entities['183'] = '·'; entities['184'] = '¸'; entities['185'] = '¹'; entities['186'] = 'º'; entities['187'] = '»'; entities['188'] = '¼'; entities['189'] = '½'; entities['190'] = '¾'; entities['191'] = '¿'; entities['192'] = 'À'; entities['193'] = 'Á'; entities['194'] = 'Â'; entities['195'] = 'Ã'; entities['196'] = 'Ä'; entities['197'] = 'Å'; entities['198'] = 'Æ'; entities['199'] = 'Ç'; entities['200'] = 'È'; entities['201'] = 'É'; entities['202'] = 'Ê'; entities['203'] = 'Ë'; entities['204'] = 'Ì'; entities['205'] = 'Í'; entities['206'] = 'Î'; entities['207'] = 'Ï'; entities['208'] = 'Ð'; entities['209'] = 'Ñ'; entities['210'] = 'Ò'; entities['211'] = 'Ó'; entities['212'] = 'Ô'; entities['213'] = 'Õ'; entities['214'] = 'Ö'; entities['215'] = '×'; entities['216'] = 'Ø'; entities['217'] = 'Ù'; entities['218'] = 'Ú'; entities['219'] = 'Û'; entities['220'] = 'Ü'; entities['221'] = 'Ý'; entities['222'] = 'Þ'; entities['223'] = 'ß'; entities['224'] = 'à'; entities['225'] = 'á'; entities['226'] = 'â'; entities['227'] = 'ã'; entities['228'] = 'ä'; entities['229'] = 'å'; entities['230'] = 'æ'; entities['231'] = 'ç'; entities['232'] = 'è'; entities['233'] = 'é'; entities['234'] = 'ê'; entities['235'] = 'ë'; entities['236'] = 'ì'; entities['237'] = 'í'; entities['238'] = 'î'; entities['239'] = 'ï'; entities['240'] = 'ð'; entities['241'] = 'ñ'; entities['242'] = 'ò'; entities['243'] = 'ó'; entities['244'] = 'ô'; entities['245'] = 'õ'; entities['246'] = 'ö'; entities['247'] = '÷'; entities['248'] = 'ø'; entities['249'] = 'ù'; entities['250'] = 'ú'; entities['251'] = 'û'; entities['252'] = 'ü'; entities['253'] = 'ý'; entities['254'] = 'þ'; entities['255'] = 'ÿ'; } if (useQuoteStyle !== 'ENT_NOQUOTES') { entities['34'] = '"'; } if (useQuoteStyle === 'ENT_QUOTES') { entities['39'] = '''; } entities['60'] = '<'; entities['62'] = '>'; // ascii decimals to real symbols for (decimal in entities) { symbol = String.fromCharCode(decimal); hash_map[symbol] = entities[decimal]; } return hash_map; } function stripslashes (str) { return (str+'').replace(/\\(.?)/g, function (s, n1) { switch (n1) { case '\\': return '\\'; case '0': return '\0'; case '': return ''; default: return n1; } }); } function addslashes (str) { return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\u0000/g, "\\0"); } /** * This function sets netsted properties to dom elements * * @Author Erik Amaru Ortiz * @Param (object) dom element refered by ID * @Param (array) nested array of properties strings * @Param (string) value to set * @Return * * Example: * setNestedProperty(document, ['body','style','backgroundColor'], 'black'); */ function setNestedProperty(obj, propertyName, propertyValue){ var oTarget = obj; for (var i=0; i * @Param * @Return (objeect) {browser:sBrowser, version:sVersion} */ function getBrowserClient(){ var aBrowFull = new Array("opera", "msie", "firefox", "opera", "safari"); var sInfo = navigator.userAgent.toLowerCase(); sBrowser = ""; for (var i = 0; i < aBrowFull.length; i++){ if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){ sBrowser = aBrowFull[i]; sVersion = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowFull[i]) + aBrowFull[i].length + 1))); return {name:sBrowser, browser:sBrowser, version:sVersion} } } return false; }; var _BROWSER = getBrowserClient(); /** * Create and send cookie * * @Author Erik Amaru Ortiz * @Param (string) cookie name * @Param (string) cookie value * @Param (int) cookie number of days for expires * @Return */ function createCookie(name, value, days){ if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } /** * read a cookie * * @Author Erik Amaru Ortiz * @Param cookie name * @Return (string) cookie content */ function readCookie(name){ var ca = document.cookie.split(';'); var nameEQ = name + "="; for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } /** * delete a cookie * * @Author Erik Amaru Ortiz * @Param cookie name * @Return */ function eraseCookie(name){ createCookie(name, "", -1); } /** * highlightRow a html element (setting background) * * @Author Erik Amaru Ortiz * @Param (object) html element * @Param (string) some color in hexadecimal format * @Return */ function highlightRow(o, color){ o.style.background = color } /** * left and right delete the blank characteres (String prototype) * * Example: * var str = String(" some_string_with_spaces "); * str.trim(); //clean the blank characteres * * @Author Erik Amaru Ortiz * @Param * @Return */ String.prototype.trim = function() { return this.replace(/^\s+|\s+get/g,""); } function clearCalendar(id){ document.getElementById(id).value=''; document.getElementById(id+'[div]').innerHTML = ''; setTimeout('enableCalendar()', 350); } function lockCalendar(){ G_CALENDAR_MEM_OFFSET = 'lock'; //G_CALENDAR_CURRENT_OBJ.hide(); } function enableCalendar(){ G_CALENDAR_MEM_OFFSET = 'enable'; } function parseDateFromMask (inputArray, mask){ /* inputArray is an associative array with properties year, month, day, hour, minute */ /* format mask * Y -> 2009 * y -> 09 * m -> 02 * d -> 01 * * h -> 12 * i -> 59 * * d/m/y -> 01/02/09 * d/m/Y -> 01/02/2009 * Y-m-d -> 2009-02-01 * * Y-m-d h:m -> 2009-02-01 12:59 * */ result = mask; result = result.replace("Y", inputArray.year); year = new String(inputArray.year); result = result.replace("y", year.substr(2,3)); result = result.replace("m", inputArray.month); result = result.replace("d", inputArray.day); result = result.replace("h", inputArray.hour); result = result.replace("i", inputArray.minute); return result; } Array.prototype.walk = function( funcionaplicada ) { for(var i=0, parar=false; i * @Param (string) function name * @Param (int) time in seconds * @Return */ function Timer(functionName, time) { setTimeout(functionName, time*1000); } function PMOS_TemporalMessage(timeToHide){ fade('temporalMessageTD', 'inOut'); if( typeof(timeToHide) != 'undefined' ) { Timer( function(){ try{ document.getElementById('temporalMessageTD').style.display = 'none'; }catch(e){} }, timeToHide ); } } /** * fast messagesbox * * @Param msg (string) : your message * @Param type (string): {alert|info|confirm} * @Param type (string): xcallback, callback function name to execute after at user click on Accept * @Author */ function msgBox(msg, type, callbackAccept, callbackCancel){ //setting default type type = typeof(type) != 'undefined'? type: 'info'; //setting up the callback action acceptEv = typeof(callbackAccept) != 'undefined'? callbackAccept: false; cancelEv = typeof(callbackCancel) != 'undefined'? callbackCancel: false; switch(type){ case 'alert': new leimnud.module.app.alert().make({ label: msg, width: 350, action:function(){ if( acceptEv ){ setTimeout(acceptEv, 1); } }.extend(this) }); break; case 'info': new leimnud.module.app.info().make({ label: msg, width: 350, action:function(){ if( acceptEv ){ setTimeout(acceptEv, 1); } }.extend(this) }); break; case 'confirm': if( cancelEv ){ new leimnud.module.app.confirm().make({ label: msg, action: function(){ if( acceptEv ){ setTimeout(acceptEv, 0); } }.extend(this), cancel: function(){ setTimeout(cancelEv, 1); }.extend(this) }); } else { new leimnud.module.app.confirm().make({ label: msg, action: function(){ if( acceptEv ){ setTimeout(acceptEv, 1); } }.extend(this) }); } break; } } function executeEvent(id, ev){ switch(ev){ case 'click': document.getElementById(id).checked = true; if(document.getElementById(id).onclick){ try{ document.getElementById(id).onclick(); }catch(e){} } break; } } /* * @By Erik */ function getClientWindowSize() { var wSize = [0, 0]; if (typeof window.innerWidth != 'undefined'){ wSize = [ window.innerWidth, window.innerHeight ]; } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ wSize = [ document.documentElement.clientWidth, document.documentElement.clientHeight ]; } else { wSize = [ document.getElementsByTagName('body')[0].clientWidth, document.getElementsByTagName('body')[0].clientHeight ]; } return {width:wSize[0], height:wSize[1]}; } function popUp(URL, width, height, left, top, resizable) { window.open(URL, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable='+resizable+',width='+width+',height='+height+',left = '+left+',top = '+top+''); } /** * Alias for tedious large definition for ajax object - By Erik A.O. */ function XHRequest(){ return new leimnud.module.rpc.xmlhttp; } function removeValue(id){ if( document.getElementById('form['+id+']') ) document.getElementById('form['+id+']').value = ''; else if( document.getElementById(id) ) document.getElementById(id).value = ''; } function datePicker4(obj, id, mask, startDate, endDate, showTIme){ new Calendar({ inputField: id, dateFormat: mask, trigger: id+"[btn]", bottomBar: true, min:startDate, max:endDate, animation: _BROWSER.name =='msie'? false: true, showTime: showTIme, opacity: 1, onSelect: function() { this.hide(); }} ); if( _BROWSER.name != 'msie' ) obj.onmouseover = undefined; } function elementAttributesNS(e, ns) { if (!this.__namespaceRegexps) this.__namespaceRegexps = {}; var regexp = this.__namespaceRegexps[ns]; if (!regexp) { this.__namespaceRegexps[ns] = regexp = ns ? eval("/^" + ns + ":(.+)/") : /^([^:]*)$/; } var result = {}; var atts = e.attributes; var l = atts.length; for (var i = 0; i < l; i++) { var m = atts[i].name.match(regexp); if (m) result[m[1]] = atts[i].value; } return result; }