// trim function trim(str) { if (!str.match(/\S/)) return '' str = str.replace(/^(\s*)(\S)(.*)$/,'$2$3') // trim left str = str.replace(/^(.*)(\S)(\s*)$/,'$1$2') // trim right return str } /* * preloading an image. creating an image object with given source * imgObj: name of object to be created * imgSrc: URL of image */ function preload(imgObj,imgSrc) { if (document.images) { eval(imgObj+' = new Image()'); eval(imgObj+'.src = "'+imgSrc+'"'); } } /* * This function receives a comma separated string where each * pair is an image object name and an image URL. * the function then goes over these pairs array and invokes the * preload function to load the images into the browser's memory */ function preloadThem(str) { var arr = str.split(/\s*,\s*/) for (i = 0; i < arr.length; i += 2) { //alert(arr[i]+"\n"+arr[i+1]) preload(arr[i],arr[i+1]) }; } /* * Used to invoke preloadThem() function. * Please read the preloadThem() documentation. */ function preloadImages(str) { document.onload = preloadThem(str); } /* * change a layer's image elemnt's source * layer: name of a non nesting layer. if null look for image in document.images * img: name of image element or an image object (or input type="image") * imgObjName: name of preloaded image object * -> image element of layer source would be replaced with image object's source */ function changeImage(img,imgObjName,layer) { var imgObjSrc = eval(imgObjName+".src"); // handle image object if (typeof(img) == 'object') img.src = imgObjSrc // handle image name else if (document.images && typeof(img) == 'string') { if (document.all || document.getElementById || layer == null) document.images[(img)].src = imgObjSrc; else eval('document.'+layer+'.document.images["'+img+'"].src = ' + imgObjSrc); } } // parse file name from file's path function getFileName(filePath) { var p = Math.max(filePath.lastIndexOf('/'),filePath.lastIndexOf('\\')) return filePath.substring(p + 1,filePath.length) } // This function opens a new window in the middle of the screen // Parameters: // w - the width of the window // h - the height of the window // ur - the URL of the window // target - optional target of the window // params - optional window parameters function openwindow(w,h,ur,target,params) { var winleft = screen.width/2 - w/2 var wintop = screen.height/2 - h/2 - 30 var fullParams = 'width=' + w + ',height=' + h + ',' + 'top=' + wintop + ',left=' + winleft + ',' if (!params) params = 'scrollbars=auto,menubar=no,resizable=yes,toolbar=no,location=no,status=no' fullParams += params if (!target) target = '' var newWinObj = window.open(ur,target,fullParams) if (newWinObj) newWinObj.focus() return newWinObj } // return reference to an object. // compatible with IE4 and above, NS6 and above function getObjectById(id) { if (document.all) return document.all(id) else if (document.getElementById) return document.getElementById(id) else return null } // display number with given precision // returns a string function precision(num,p) { if (!p || isNaN(num) || num.length == 0) return num num *= Math.pow(10,p) num = Math.round(num) num = num*10 + 1 num /= Math.pow(10,p+1) num = num.toString() num = num.substring(0,num.length-1) return num } // trim long strings to a limit of chars and replace with ... function RTrimWith3dots(str, nChars) { var reg = new RegExp('^(.{' + (nChars - 3) + '})(.{4,})$') if (reg.test(str)) str = str.replace(reg,'$1...') return str } // Function for the public download //This function is called during onLoad. if dl_id contains a value, download it //to the client as the page loads function download_pending() { if (data.dl_id.value != "") { publicDownload(data.dl_id.value); } } function publicDownload(id) { self.location.href = "http://www.optier.com/public/download.asp?id="+id } function showDiv(divId,imgId) { if (document.getElementById(divId).style.display == "none") { document.getElementById(divId).style.display = "inline"; if (imgId) document.getElementById(imgId).src = "http://www.optier.com/GUI/images/bullets/arrowDown.gif"; } else { document.getElementById(divId).style.display = "none"; if (imgId) document.getElementById(imgId).src = "http://www.optier.com/GUI/images/bullets/arrowRight.gif"; } }