String.prototype.countOccuranceOf=function(s1){return(this.length-this.replace(new RegExp(s1,"g"),"").length)/s1.length};var Core={googleAnalytics:function(accountNumber){if(accountNumber!=null){var gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");new Asset.load(gaJsHost+"google-analytics.com/ga.js",function(){var pageTracker=_gat._getTracker(accountNumber);pageTracker._trackPageview()})}},confirmSubmit:function(word){var agree=confirm("Are you sure you wish to "+word+"?");if(agree){return true}else{return false}},expBox:function(boxCtrlImg,divBox,imgPath){if(!imgPath){imgPath="../jsp/common_webapp/common/img/"}var image1=new Image();image1.src=imgPath+"expand.gif";var image2=new Image();image2.src=imgPath+"contract.gif";if($(boxCtrlImg).get("alt")=="show"){$(boxCtrlImg).set("src",image2.src);$(divBox).set("style",{display:"block"});$(boxCtrlImg).set("alt","hide")}else{if($(boxCtrlImg).get("alt")=="hide"){$(boxCtrlImg).set("src",image1.src);$(divBox).set("style",{display:"none"});$(boxCtrlImg).set("alt","show")}}},expDivBox:function(boxCtrlImg,divBox){if($(boxCtrlImg).get("alt")=="show"){$(boxCtrlImg).removeClass("expand");$(boxCtrlImg).addClass("contract");$(divBox).show();$(boxCtrlImg).set("alt","hide")}else{if($(boxCtrlImg).get("alt")=="hide"){$(boxCtrlImg).removeClass("contract");$(boxCtrlImg).addClass("expand");$(divBox).hide();$(boxCtrlImg).set("alt","show")}}},limitText:function(text,span,limitNum,dyns){var tl=$(text).get("value").length;var tv=$(text).get("value");if(!tv){tl=0}if(dyns){dyns.each(function(tag){var occ=tv.countOccuranceOf(tag.key);if(occ>0){tl=tl-(tag.key.length*occ)+(tag.value*occ)}})}if(tl>limitNum){$(span).addClass("errors")}else{$(span).removeClass("errors")}$(span).set("text",limitNum-tl)},toggleCustomDates:function(){if($$("select#interval").get("value")=="custom"){$$("input#customStartDate").enable();$$("input#customEndDate").enable()}else{$$("input#customStartDate").disable();$$("input#customEndDate").disable()}},ajax:function(url,updateEle,getOpts){Loading.show();var myHTMLRequest=new Request.HTML({url:url,update:updateEle,evalScripts:true,onComplete:function(){Loading.hide()}}).get(getOpts)}};var Loading={id:"AjaxLoading",show:function(){if($(this.id)!=null){$(this.id).set("styles",{top:$(window).getScrollTop()});$(this.id).show();return }div=document.createElement("div");document.body.appendChild(div);div.id=this.id;$(div).set("styles",{top:$(window).getScrollTop()});div.innerHTML="<img src='../jsp/common_webapp/common/img/wait-inverted.gif' /><span>Loading...</span>"},hide:function(){if($(this.id)){$(this.id).hide()}}};var Form={disableAllButtonsExcept:function(button){$(button.form).getFormElements().each(function(el){if((el.type=="button"||el.type=="submit")&&(el.name!=button.name)){el.set("disabled","true")}})},enableButtons:function(form){$(form).getFormElements().each(function(el){if(el.type=="button"||el.type=="submit"){el.removeProperty("disabled")}})},send:function(button,options){Loading.show();var form=$(button.form);Form.disableAllButtonsExcept(button);options=$merge({evalScripts:true,onComplete:function(){Loading.hide();Form.enableButtons(form)}},options);form.send(options)},getValue:function(name){var elems=$$("input[name="+name+"]");var value=false;elems.each(function(el){if($(el).get("value")){value=$(el).get("value");return }return false});return value}};$F=Form.getValue;Element.implement({show:function(){this.set("style",{display:"block"});this.set("style",{visibility:"visible"});this.removeClass("hidden")},hide:function(){this.set("styles",{display:"none",visibility:"hidden"})},isVisible:function(){return(this.getStyle("display")!="none"&&this.getStyle("visibility")!="hidden")},toggle:function(){if(this.isVisible()){this.hide()}else{this.show()}},disable:function(){switch(this.get("type")){case"button":this.addClass("buttonDisabled");break;default:}this.set("disabled","true");return this},enable:function(){switch(this.get("type")){case"button":this.removeClass("buttonDisabled");break;default:}this.removeProperty("disabled","false");return this}});Element.Events.keyenter={base:"keyup",condition:function(e){return e.key=="enter"}};var OverlayFix=new Class({element:null,initialize:function(el){if(!this.isIE6()){return }this.element=$(el);var width=$(el).getSize().x;var height=$(el).getSize().y;if(!this.fix){this.fix=new Element("iframe",{frameborder:"0",scrolling:"no",styles:{filter:"mask()",display:"block",position:"absolute",top:"0",left:"0","z-index":"-1",width:width+"px",height:height+"px"}}).inject(this.element)}},hide:function(){this.fix.hide()},isIE6:function(){if(!Browser.Engine.trident){return false}if(Browser.Engine.version!=4){return false}return true},getFix:function(){return this.fix}});var Error={fatal:function(){var bg=$("systemErrorRefreshNeeded");if(bg==null){bg=new Element("div",{id:"systemErrorRefreshNeeded"}).inject(document.body);bg.set("styles",{display:"block",height:$(document.body).getScrollSize().y});new OverlayFix(bg);var div=new Element("div",{id:"systemErrorRefreshNeededMessageBox"});div.inject(document.body);div.set("styles",{display:"block"});var ds=div.getSize();var ws=window.getSize();div.setStyle("top",(ws.y/2)-(ds.y/2)+"px");div.setStyle("left",(ws.x/2)-(ds.x/2)+"px");div.adopt(new Element("div",{"class":"title"}).set("text","An error has occurred!"));div.adopt(new Element("div",{"class":"text"}).set("text","Please refresh this page by hitting F5 on your keyboard or the refresh button in your browser."));div.adopt(new Element("div",{"class":"text"}).set("text","If the problem persists, please contact an Administrator."))}}};