function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function'){ window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } function sessionExpired() { redirect("/ppi/index.jsp"); } function removeAllChildren(id) { $(id).childElements().each(function(element) { element.remove() }); } function removeAllOptions(id) { $(id).options.length = 0; } function setOption(id, optionvalue) { ($A($(id).options)).each(function(opt) { if (opt.value == optionvalue) { opt.selected = true; } else { opt.selected = false; } }); } function setOptionDisabled(id, optionvalue, disabled) { ($A($(id).options)).each(function(opt) { if (opt.value == optionvalue) { opt.disabled = (disabled ? "disabled" : ""); } }); } function addOptions(id, options, valueprop, textprop) { if (options == null) { return; } if (arguments.length == 2) { valueprop = 'id'; textprop = 'name'; } options.each(function(opt) { var entry = new Option(opt[textprop], opt[valueprop]); $(id).options[$(id).length] = entry; }); } function isOptionChecked(elem, value) { elem=arrayrize(elem); for (var i=0; i < elem.length;i++) { if (elem[i].checked) { if (typeof value != "undefined") { if (elem[i].value == value) { return true; } } else { return true; } } } return false; } function getOptionChecked(elem) { elem=arrayrize(elem); for (var i=0; i < elem.length;i++) { if (elem[i].checked) { return elem[i]; } } return false; } function getOptionsChecked(elem) { elem=arrayrize(elem); chks = []; for (var i=0; i < elem.length;i++) { if (elem[i].checked) { chks.push(elem[i]); } } if (chks.length > 0) { return chks; } return false; } function getNumOptionsChecked(elem) { var numOptions = 0; elem=arrayrize(elem); for (var i=0; i < elem.length;i++) { if (elem[i].checked) { numOptions++; } } return numOptions; } function arrayrize(obj) { if(typeof obj.length == "undefined") { obj=[obj]; } return obj; } function trimmed(sText) { var tmpStr=new String(sText); return tmpStr.strip(); } function equalsIgnoreCase(arg1, arg2) { return ( (new String(trimmed(arg1))).toLowerCase() == (new String(trimmed(arg2))).toLowerCase()); } function isEmpty(sText) { return trimmed(sText)==""; } function htmlEscape(sText) { var tmpStr=new String(sText); return sText.escapeHTML(); } validNumericChars = "0123456789"; function isNumeric(sText,allowMinus) { var tmpStr=trimmed(sText); for(var i=0; i < tmpStr.length; i++) { var char = tmpStr.charAt(i); if(allowMinus && i==0 && char=='-') { continue; } if(validNumericChars.indexOf(char) == -1) { return false; } } return true; } function countNumbers(sText) { var lastCharWasNum=false; var counter=0; var tmpStr=trimmed(sText); for(var i=0; i < tmpStr.length; i++) { var char = tmpStr.charAt(i); if(validNumericChars.indexOf(char) != -1) { if(!lastCharWasNum) { counter++; } lastCharWasNum=true; } else { lastCharWasNum=false; } } return counter; } function isFloat(sText) { sText = sText.replace(",","."); var floatValue = parseFloat(sText) return !isNaN(floatValue); } function arrayAsString(aArray) { var values = ""; for (var i=0; i < aArray.length; i++) { values = values + aArray[i]; if (i < aArray.length - 1) { values = values + ","; } } return values; } function isPassword(sText) { var p = sText.length; var illegalChars = /[\W_]/; if (p < 6 || p > 15 || illegalChars.test(sText)) { return false; } return true; } function isUrl(sText) { var v = new RegExp(); v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); if (!v.test(sText)) { return false; } return true; } ERROR=1 INFO=2 OK=3 NOT_LOGGED=4 function showMessage(msg,type,noScroll) { if($("popup_msg_div")!=null) { if(type==INFO) { $("popup_msg_img").src="/ppi/images/alert/alert_info.gif"; } else if(type==OK) { $("popup_msg_img").src="/ppi/images/alert/alert_ok.gif"; } else { $("popup_msg_img").src="/ppi/images/alert/alert_error.gif"; } $("popup_msg_span").innerHTML=msg; new Effect.Appear("popup_msg_div"); if(!modalDialog.popMsg) { var msgHeight=$("popup_msg_div").getHeight()+25; modalDialog.relativeResize(0,msgHeight); modalDialog.popMsg=true; } } else { if(type==INFO) { $("top_msg_img").src="/ppi/images/alert/alert_info.gif"; } else if(type==OK) { $("top_msg_img").src="/ppi/images/alert/alert_ok.gif"; } else { $("top_msg_img").src="/ppi/images/alert/alert_error.gif"; } $("top_msg_span").innerHTML=msg; new Effect.Appear("top_msg_div"); if(noScroll!=true) { var alertAnchor=$("top_msg_img"); var delta=alertAnchor.offsetTop - document.viewport.getScrollOffsets().top; new Effect.Scroll(window,{y:delta,duration: 0.7}); } } } function hideMsg(canFade) { if($("popup_msg_div")!=null) { if(modalDialog.popMsg) { var msgHeight=$("popup_msg_div").getHeight()+25; $("popup_msg_div").hide(); modalDialog.relativeResize(0,-msgHeight); } else { $("popup_msg_div").hide(); } modalDialog.popMsg=false; } else if($("top_msg_div")!=null) { if(typeof canFade!="undefined" && canFade==true) { new Effect.Fade("top_msg_div"); } else { $("top_msg_div").hide(); } } } function moveWindowToAnchor(anchorElem) { var delta = anchorElem.offsetTop - document.viewport.getScrollOffsets().top; new Effect.Scroll(window,{y:delta,duration: 0.7}); } function showException(errorString, exception) { if (exception.javaClassName == "netquest.generic.lang.LogicalException") { showMessage(exception.message, exception.messageType); } else { showMessage(errorString); } } function ppiLoadingMessage() { dwr.engine.setPreHook(showLoadingMessage); dwr.engine.setPostHook(hideLoadingMessage); } function showLoadingMessage() { var disabledZone = $("disabledZone"); if (!disabledZone) { var messageZone = Builder.node("div", { id: "messageZone" }, ["Loading..."]); document.body.appendChild(messageZone); disabledZone = Builder.node("div", { id: "disabledZone" }); document.body.appendChild(disabledZone); } else { $("messageZone").show(); disabledZone.hide(); } } function hideLoadingMessage() { $("disabledZone").hide(); new Effect.Fade("messageZone"); } function highlightError(tagId,endColor) { if(endColor) { new Effect.Highlight($(tagId), {startcolor:"#FF3333",restorecolor:endColor}); } else { new Effect.Highlight($(tagId), {startcolor:"#FF3333",restorecolor:"#ffffff"}); } } function highlightInput(input) { new Effect.Highlight(input,{restorecolor:"#ffffff"}); } function redirect(page) { window.location = page; } function secureRemove(elem) { if($(elem)!=null) { try { $(elem).remove(); }catch(ex){}; } } replacedClasses=new Object(); function replaceClass(elementId,className) { replacedClasses[elementId]=$(elementId).className; $(elementId).className=className; } function restoreClass(elementId) { $(elementId).className=replacedClasses[elementId]; } function addClass(elementId,className) { $(elementId).addClassName(className); } function removeClass(elementId,className) { $(elementId).removeClassName(className); } function runningInIE() { var ua = navigator.userAgent.toLowerCase(); return ua.indexOf("msie")!=-1; } function fadeIn(id,from,to) { var objToFade=$(id); if(objToFade==null) { return; } if(from==0) { objToFade.style.display='block'; } objToFade.setOpacity(from); if(to>from) { setTimeout("fadeIn('"+id+"',"+(from+0.04)+","+to+")",25); } } function fadeOut(id,from,to) { var objToFade=$(id); if(objToFade==null) { return; } if(from<=0) { objToFade.style.display='none'; } if(from<0) { return; } objToFade.setOpacity(from); if(from>to) { setTimeout("fadeOut('"+id+"',"+(from-0.04)+","+to+")",25); } } Element.addMethods({ scrollTo: function(element, left, top){ var element = $(element); if (arguments.length == 1){ var pos = element.cumulativeOffset(); window.scrollTo(pos[0], pos[1]); } else { element.scrollLeft = left; element.scrollTop = top; } return element; } }); Effect.Scroll = Class.create(); Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); if(!this.element) throw(Effect._elementDoesNotExistError); this.start(Object.extend({x: 0, y: 0}, arguments[1] || {})); }, setup: function() { var scrollOffsets = (this.element == window) ? document.viewport.getScrollOffsets() : Element._returnOffset(this.element.scrollLeft, this.element.scrollTop) ; this.originalScrollLeft = scrollOffsets.left; this.originalScrollTop = scrollOffsets.top; }, update: function(pos) { this.element.scrollTo(Math.round(this.options.x * pos + this.originalScrollLeft), Math.round(this.options.y * pos + this.originalScrollTop)); } }); if(!runningInIE()) { document.observe('dom:loaded', function(event) { $$('a[href*="#"]').each(function(anchor){ anchor.observe('click', function(event) { var pageAnchor = $$('a[name~="#{href}"]'.interpolate({href: this.href.split('#')[1]})).first(); var delta = pageAnchor.offsetTop - document.viewport.getScrollOffsets().top; var updateUrl = function(){ location.href = this.href }.bind(this); new Effect.Scroll(window, { y: delta, afterFinish: updateUrl, duration: 0.7 }); Event.stop(event); }); }); }); } function showOverlib(mainText,title,width) { if(typeof width == "undefined") { overlib(mainText,CAPTION,title, VAUTO,CELLPAD,5,SHADOW,SHADOWOPACITY,85, FGCLASS,'overlib_mainBG',BGCLASS,'overlib_titleBG',TEXTFONTCLASS,'overlib_mainFG',CAPTIONFONTCLASS,'overlib_titleFG'); } else { overlib(mainText,CAPTION,title, VAUTO,CELLPAD,5,SHADOW,SHADOWOPACITY,85,WIDTH,width, FGCLASS,'overlib_mainBG',BGCLASS,'overlib_titleBG',TEXTFONTCLASS,'overlib_mainFG',CAPTIONFONTCLASS,'overlib_titleFG'); } } function showTimedOverlib(mainText,title) { overlib(mainText,CAPTION,title, TIMEOUT,2000,DELAY,1000,SHADOW,SHADOWOPACITY,85, FGCLASS,'overlib_mainBG',BGCLASS,'overlib_titleBG',TEXTFONTCLASS,'overlib_mainFG',CAPTIONFONTCLASS,'overlib_titleFG'); } // Copyright (c) 2005 Thomas Fakes (http://craz8.com) var Resizeable = Class.create(); Resizeable.prototype = { initialize: function(element) { var options = Object.extend({ bottom : 6, left : 6, right : 6, zindex : 1000, onStart : null, onEnd : null, callback : null }, arguments[1] || {}); this.element = $(element); this.handle = this.element; Element.makePositioned(this.element); // fix IE this.options = options; this.active = false; this.resizing = false; this.currentDirection = ''; this.eventMouseDown = this.startResize.bindAsEventListener(this); this.eventMouseUp = this.endResize.bindAsEventListener(this); this.eventMouseMove = this.update.bindAsEventListener(this); this.eventCursorCheck = this.cursor.bindAsEventListener(this); this.eventKeypress = this.keyPress.bindAsEventListener(this); this.registerEvents(); }, destroy: function() { Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); this.unregisterEvents(); }, registerEvents: function() { Event.observe(document, "mouseup", this.eventMouseUp); Event.observe(document, "mousemove", this.eventMouseMove); Event.observe(document, "keypress", this.eventKeypress); Event.observe(this.handle, "mousedown", this.eventMouseDown); Event.observe(this.element, "mousemove", this.eventCursorCheck); }, startResize: function(event) { if(this.options.onStart) { eval(this.options.onStart()); } if(Event.isLeftClick(event)) { // abort on form elements, fixes a Firefox issue var src = Event.element(event); if(src.tagName && (src.tagName=='INPUT' || src.tagName=='SELECT' ||src.tagName=='BUTTON' || src.tagName=='TEXTAREA')) { return; } var dir = this.directions(event); if (dir.length > 0) { this.active = true; var offsets = Position.cumulativeOffset(this.element); this.startTop = offsets[1]; this.startLeft = offsets[0]; this.startWidth = parseInt(Element.getStyle(this.element, 'width')); this.startHeight = parseInt(Element.getStyle(this.element, 'height')); this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop; this.currentDirection = dir; Event.stop(event); } } }, finishResize: function(event, success) { if(this.options.onEnd) { eval(this.options.onEnd()); } // this.unregisterEvents(); this.active = false; this.resizing = false; if(this.options.zindex) { this.element.style.zIndex = this.originalZ; } }, keyPress: function(event) { if(this.active && event.keyCode==Event.KEY_ESC) { this.finishResize(event, false); Event.stop(event); } }, endResize: function(event) { if(this.active && this.resizing) { this.finishResize(event, true); Event.stop(event); } this.active = false; this.resizing = false; }, draw: function(event) { var pointer = [Event.pointerX(event), Event.pointerY(event)]; var style = this.element.style; if (this.currentDirection.indexOf('w') != -1) { var pointerMoved = this.startX - pointer[0]; var margin = Element.getStyle(this.element, 'margin-left') || "0"; var newWidth = this.startWidth + pointerMoved; if (newWidth < 100) { newWidth=100; } style.left = (this.startLeft - pointerMoved - parseInt(margin)) + "px"; style.width = newWidth + "px"; if(this.options.extraDiv) { $(this.options.extraDiv).style.width=(newWidth-1) + "px"; } } if (this.currentDirection.indexOf('s') != -1) { var newHeight = this.startHeight + pointer[1] - this.startY; if (newHeight < 50) { newHeight=50; } style.height = newHeight + "px"; if(this.options.extraDiv) { $(this.options.extraDiv).style.height=style.height; } } if (this.currentDirection.indexOf('e') != -1) { var newWidth = this.startWidth + pointer[0] - this.startX; if (newWidth < 100) { newWidth=100; } style.width = newWidth + "px"; if(this.options.extraDiv) { $(this.options.extraDiv).style.width=(newWidth-1) + "px"; } } if(style.visibility=="hidden") { style.visibility = ""; // fix gecko rendering } if(this.options.callback!=null) { eval(this.options.callback()); } }, between: function(val, low, high) { return (val >= low && val < high); }, directions: function(event) { var pointer = [Event.pointerX(event), Event.pointerY(event)]; var offsets = Position.cumulativeOffset(this.element); var cursor = ''; if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1], 0, this.options.bottom)) { cursor += 's'; } if (this.between(pointer[0] - offsets[0], 0, this.options.left)) { cursor += 'w'; } if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) { cursor += 'e'; } return cursor; }, cursor: function(event) { var cursor = this.directions(event); if (cursor.length > 0) { cursor += '-resize'; } else { cursor = ''; } this.element.style.cursor = cursor; }, update: function(event) { if(this.active) { if(!this.resizing) { var style = this.element.style; this.resizing = true; if(Element.getStyle(this.element,'position')=='') { style.position = "relative"; } if(this.options.zindex) { this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); style.zIndex = this.options.zindex; } } this.draw(event); // fix AppleWebKit rendering if(navigator.appVersion.indexOf('AppleWebKit')>0) { window.scrollBy(0,0); } Event.stop(event); return false; } } } function setTableHover(elementId) { if(runningInIE() && !window.XMLHttpRequest) { var allRows=$(elementId).select("tr"); allRows.each( function(e) { Event.observe(e, 'mouseover', function() { replaceClass(this.id,'mouseoverRow'); }); Event.observe(e, 'mouseout', function() { restoreClass(this.id); }); }); } } function setTableDesign(elementId, evenRow, oddRow) { var allRows = $(elementId).select("tr"); var even = true; allRows.each( function(e) { even = !even; var rowStyle = even ? evenRow : oddRow; e.className = rowStyle; }); } function getCheckedRadio(radioGroupName,formName) { if(typeof formName == "undefined") { var form=$(document.forms[0]); } else { var form=$(document.forms[formName]); } var radios=form.getInputs("radio",radioGroupName); for(var i=0;radios.length>i;i++) { if(radios[i].checked==true) { return radios[i].value } } return null; } function sortTable(tbody, index, type, evenclass, oddclass, orderType) { var rows = $A(tbody.rows); rows.sort( function(c,d) { if (type == "number") { var a = getCellNumber(c.cells[index]); var b = getCellNumber(d.cells[index]); } else { var a = getCellText(c.cells[index]).toLowerCase(); var b = getCellText(d.cells[index]).toLowerCase(); } if(orderType == "asc") return a < b ? -1 : a == b ? 0 : 1; return a > b ? -1 : a == b ? 0 : 1; }); var i = 0; rows.each(function(r) { tbody.appendChild(r); r.className = i%2 == 0 ? evenclass : oddclass; i++; }); } function getCellText(cell) { if (!cell) return ""; return cell.textContent ? cell.textContent : cell.innerText; } function getCellNumber(cell) { var a = getCellText(cell); a = parseFloat(a.replace(/^.*?([-+]?[\d]*\.?[\d]+(?:[eE][-+]?[\d]+)?).*$/,"$1")); return isNaN(a) ? 0 : a; }