var O2Core={msOnLoadFunctionList:new Array(),bLoaded:false,bScriptLoaded:false,msJSLoadedVariable:new Array(),insertScript:function(p_sUrl,p_bAsync,p_sScriptElementId,p_sLoadedVarName){O2Core.insertScriptP({sUrl:p_sUrl,bAsync:p_bAsync,sScriptElementId:p_sScriptElementId,sLoadedVarName:p_sLoadedVarName});},insertScriptP:function(p){var s="script",sc=document.createElement(s);if(p.sScriptElementId){sc.id=p.sScriptElementId;}if(p.bAsync){sc.async="async";}if(p.sCharset){sc.charset=p.sCharset;}sc.src=p.sUrl;var s=document.getElementsByTagName(s)[0];s.parentNode.insertBefore(sc,null);if(p.sLoadedVarName){O2Core.msJSLoadedVariable.push(p.sLoadedVarName);}},checkJSLoaded:function(){for(var i=0;i<O2Core.msJSLoadedVariable.length;i++){var s=O2Core.msJSLoadedVariable[i];if(eval("typeof "+s)!="undefined"){continue;}window.setTimeout("O2Core.checkJSLoaded()",25);return;}O2Core.bScriptLoaded=true;},loadProto:function(){O2Core.insertScript(O2Core.isDev()?"/com/js/aculous/prototype.js":"/com/js/comp/prototype.jsgz");},protoLoaded:function(){return !((typeof Prototype=="undefined")||(typeof Element=="undefined")||(typeof Element.Methods=="undefined"));},isDev:function(){return(0==document.location.host.indexOf("dev."));},isProd:function(){return(!document.location.href.match("http(s)?://(dev|test)"));},addOnLoad:function(p_sExpr,p_sContId){if(!p_sContId){throw'addOnLoad : target container id mandatory ! Use "_XXX" for a frame named XXX.\n'+p_sExpr;}if(!p_sContId.match(/^_.*/)){var oCont=findContainerById(p_sContId);if(!oCont.msOnLoadFunctionList){oCont.msOnLoadFunctionList=new Array();}oCont.msOnLoadFunctionList.push(p_sExpr);}else{O2Core.msOnLoadFunctionList.push(p_sExpr);}},getClassName:function(obj){if(typeof(obj)!="object"||obj===null){return false;}if(obj._class){return obj._class;}var msRes=/(\w+)\(/.exec(obj.constructor.toString());if(!msRes){msRes=/\[([\w ]+)\]/.exec(obj.constructor.toString());}return msRes?msRes[1]:"object";},errorToStr:function(p_oErr){if(!p_oErr){return"";}var sStack=p_oErr.stack||"-";var msStack=sStack.split("\n");var sMsg="Error : "+"\n\t Class = "+(O2Core.getClassName(p_oErr)||"<not an object>")+"\n\t Code  = "+(p_oErr.code||"-")+"\n\t Msg    = "+p_oErr+"\n\t Stack  =\n";var sMax=75;for(var i=0;i<msStack.length;i++){var p_s=msStack[i];if(p_s==""){continue;}var s=p_s.replace(/http:\/\/[\w\.]*\//,"/");if(s.length>sMax){var i=s.lastIndexOf("@");var s2=s.substr(i);s=s.substr(0,Math.min(sMax-(s.length-i-6),i))+"(...) "+s2;}sMsg+="* "+s+"\n";}return sMsg;},windowOnLoad:function(p_oCont){if(!O2Core.bScriptLoaded){window.setTimeout("O2Core.windowOnLoad()",25);return;}if(p_oCont&&p_oCont!=window&&p_oCont!=window.document&&!p_oCont.tagName){p_oCont=null;}var oWin=p_oCont&&p_oCont.document?p_oCont:window;var bIsIframe=(oWin.frameElement!=null);if(bIsIframe&&window!=oWin){oWin.O2Core.windowOnLoad(oWin);return;}var msTbl=p_oCont&&p_oCont!=oWin?p_oCont.msOnLoadFunctionList:O2Core.msOnLoadFunctionList;if(msTbl){for(var i=0,l=msTbl.length;i<l;i++){var sScript=msTbl[i];try{if(typeof sScript=="function"){sScript.call();}eval(sScript);}catch(e){var sMsg="windowOnLoad["+(p_oCont?p_oCont.id:"-")+"] : Failed to execute script.\n"+O2Core.errorToStr(e)+"\n\n Executing script : "+sScript;throw e;}}}if(p_oCont&&p_oCont.setAttribute){p_oCont.setAttribute(ODYCont.sATTR_LOADED,"true");}else{O2Core.bLoaded=true;}},initOnLoad:function(){window.onload=function(e){O2Core.windowOnLoad(this);};},initOnLoadDOMLoaded:function(){if(!O2Core.protoLoaded()){window.setTimeout("O2Core.initOnLoadDOMLoaded()",25);return;}document.observe("dom:loaded",O2Core.windowOnLoad);}};
