var Rico={Version:"2.0 beta2",loadRequested:1,loadComplete:2,init:function(){try{document.execCommand("BackgroundImageCache",false,true)}catch(E){}this.preloadMsgs="";var F=document.getElementsByTagName("script");this.baseHref=location.protocol+"//"+location.host;this.loadedFiles={};this.loadQueue=[];this.windowIsLoaded=false;this.onLoadCallbacks=[];for(var C=0;C<F.length;C++){if(!F[C].src){continue}var H=F[C].src;var B=H.lastIndexOf("/");var G=H.substring(0,B+1);var A=H.substring(B+1);this.loadedFiles[A]=this.loadComplete;if(A=="rico.js"){this.jsDir=G;this.cssDir=G+"css/";this.imgDir=G+"images/";this.htmDir=G;this.xslDir=G}}if(typeof Prototype=="undefined"){this.include("prototype.js")}this.include("ricoCommon.js");var D=function(){Rico.windowLoaded()};if(window.addEventListener){window.addEventListener("load",D,false)}else{if(window.attachEvent){window.attachEvent("onload",D)}}this.onLoad(function(){Rico.writeDebugMsg("Pre-load messages:\n"+Rico.preloadMsgs)})},moduleDependencies:{Accordion:["ricoBehaviors.js","ricoEffects.js","ricoComponents.js"],Color:["ricoColor.js"],Corner:["ricoStyles.js"],DragAndDrop:["ricoDragDrop.js"],Effect:["ricoEffects.js"],Calendar:["ricoCalendar.js","ricoCalendar.css"],Tree:["ricoTree.js","ricoTree.css"],ColorPicker:["ricoColorPicker.js","ricoStyles.js"],SimpleGrid:["ricoCommon.js","ricoGridCommon.js","ricoGrid.css","ricoSimpleGrid.js"],LiveGrid:["ricoCommon.js","ricoGridCommon.js","ricoGrid.css","ricoBehaviors.js","ricoLiveGrid.js"],CustomMenu:["ricoMenu.js","ricoMenu.css"],LiveGridMenu:["+CustomMenu","ricoLiveGridMenu.js"],LiveGridAjax:["+LiveGrid","ricoLiveGridAjax.js"],LiveGridForms:["+LiveGridAjax","+LiveGridMenu","+Accordion","+Corner","ricoLiveGridForms.js","ricoLiveGridForms.css"],SpreadSheet:["+SimpleGrid","ricoSheet.js"]},loadModule:function(A){var C=this.moduleDependencies[A];if(!C){return }for(var B=0;B<C.length;B++){if(C[B].substring(0,1)=="+"){this.loadModule(C[B].slice(1))}else{this.include(C[B])}}},include:function(A){if(this.loadedFiles[A]){return }this.addPreloadMsg("include: "+A);var C=A.substr(A.lastIndexOf(".")+1);switch(C.toLowerCase()){case"js":this.loadQueue.push(A);this.loadedFiles[A]=this.loadRequested;this.checkLoadQueue();return ;case"css":var B=document.createElement("link");B.type="text/css";B.rel="stylesheet";B.href=this.cssDir+A;this.loadedFiles[A]=this.loadComplete;document.getElementsByTagName("head")[0].appendChild(B);return }},checkLoadQueue:function(){if(this.loadQueue.length==0){return }if(this.inProcess){return }this.addScriptToDOM(this.loadQueue.shift())},addScriptToDOM:function(A){this.addPreloadMsg("addScriptToDOM: "+A);var C=document.createElement("script");C.type="text/javascript";C.src=this.jsDir+A;this.loadedFiles[A]=this.loadRequested;this.inProcess=A;var B=document.getElementsByTagName("head")[0];if(A.substring(0,4)=="rico"){B.appendChild(C)}else{if(/WebKit|Khtml/i.test(navigator.userAgent)){B.appendChild(C);this.includeLoaded(A)}else{C.onload=C.onreadystatechange=function(){if(C.readyState&&C.readyState!="loaded"&&C.readyState!="complete"){return }C.onreadystatechange=C.onload=null;Rico.includeLoaded(A)};B.appendChild(C)}}},includeLoaded:function(A){this.addPreloadMsg("loaded: "+A);this.loadedFiles[A]=this.loadComplete;if(A==this.inProcess){this.inProcess=null;this.checkLoadQueue();this.checkIfComplete()}},windowLoaded:function(){this.windowIsLoaded=true;this.checkIfComplete()},checkIfComplete:function(){var C=this.windowIsLoaded?"":"window";for(var A in this.loadedFiles){if(this.loadedFiles[A]==this.loadRequested){C+=" "+A}}this.addPreloadMsg("waitingFor: "+C);if(C.length==0){this.addPreloadMsg("Processing callbacks");while(this.onLoadCallbacks.length>0){var B=this.onLoadCallbacks.pop();if(B){B()}}}},onLoad:function(A){this.onLoadCallbacks.push(A);this.checkIfComplete()},isKonqueror:navigator.userAgent.toLowerCase().indexOf("konqueror")>=0,startTime:new Date(),timeStamp:function(){var A=new Date();return(A.getTime()-this.startTime.getTime())+": "},setDebugArea:function(C,A){if(!this.debugArea||A){var B=document.getElementById(C);if(!B){return }this.debugArea=B;B.value=""}},addPreloadMsg:function(A){this.preloadMsgs+=Rico.timeStamp()+A+"\n"},writeDebugMsg:function(B,A){if(this.debugArea){if(A){this.debugArea.value=""}this.debugArea.value+=this.timeStamp()+B+"\n"}}};Rico.init()
