Ajax.abortError=false;Ajax.errorCallback=function(){};Ajax.responseObject={};Ajax.analyzeResponse=function(A,B){if(typeof B!="undefined"){Ajax.errorCallback=B}setTimeout("Ajax.throwError('Incorrect response')",300);Ajax.abortError=true;Ajax.responseObject=({code:200,body:A});return true};Ajax.throwError=function(A){if(!Ajax.abortError){alert(A);Ajax.errorCallback()}Ajax.abortError=false};Phi={};Phi.dictionary=[];Phi.language="en";Phi.lang=function(A){return Phi.dictionary[A]?Phi.dictionary[A]:A};Phi.page=0;Phi.url="http://"+location.hostname;Phi.removeModule=function(A){A=($(A)||$("phimodule_"+A));Effect.Fade(A,{duration:0.5,afterfinish:function(){A.parentNode.removeChild(A)}})};Phi.copyModule=function(A,B){new Ajax.Request(B)};Phi.cutModule=function(A,B){new Ajax.Request(B,{onComplete:function(C){Phi.removeModule(A)}})};Phi.prepareModule=function(B){var C=$A(B.getElementsByTagName("DIV"));C.map(function(D){if(D.className=="phi_options"){B.options=D;Element.hide(B.options);B.options.onclick=function(E){B.hideOptions(E)}}else{if(D.className=="phi_tooltip"){B.tooltip=D;B.invoker=B.tooltip.getElementsByTagName("H1")[0];B.tooltip.onmouseover=function(E){Element.addClassName(this,"toolhover")};B.tooltip.onmouseout=function(E){Element.removeClassName(this,"toolhover")};B.invoker.onclick=function(E){if(!E){E=event}B.toggleOptions(E)}}}});if(B.options){$A(B.options.getElementsByTagName("LI")).map(function(D){if(D.getElementsByTagName("UL").length>0){D.onmouseover=function(){D.getElementsByTagName("UL")[0].style.display="block"};D.onmouseout=function(){D.getElementsByTagName("UL")[0].style.display="none"}}})}B.showTT=function(D){return ;if(!this.tooltip||!this.validateOver(D)){return }this.tooltip.style.width=this.offsetWidth+"px";Element.show(this.tooltip)};B.hideTT=function(D){return ;if(!this.tooltip||!this.validateOut(D)){return }Element.hide(this.tooltip)};B.showOptions=function(E){if(!this.options){return }var D=this.options;while(D.nodeName!="BODY"){D.style.zIndex=15;D=D.parentNode}Element.show(this.options)};B.hideOptions=function(){if(!this.options){return }var D=this.options;while(D.nodeName!="BODY"){D.style.zIndex=1;D=D.parentNode}Element.hide(this.options)};B.toggleOptions=function(D){if(!this.options){return }if(Element.visible(this.options)){this.hideOptions(D)}else{this.showOptions(D)}};B.validateOver=function(G){return 1;var F=(window.event)?G.srcElement:G.target;var D=(G.relatedTarget)?G.relatedTarget:G.fromElement;var E=D;while(E.id!=this.id&&E.nodeName!="HTML"){E=E.parentNode}if(E.id==this.id){return false}while(D!=F&&D.nodeName!="HTML"){D=D.parentNode}if(D==F){return false}return true};B.validateOut=function(G){return 1;var F=(window.event)?G.srcElement:G.target;var D=(G.relatedTarget)?G.relatedTarget:G.toElement;var E=D;while(E.id!=this.id&&E.nodeName!="HTML"){E=E.parentNode}if(E.id==this.id){return false}while(D!=F&&D.nodeName!="HTML"){D=D.parentNode}if(D==F){return false}return true};B.onmouseover=function(D){if(!this.tooltip){return }if(!D){D=event}this.showTT(D)};B.onmouseout=function(D){if(!this.tooltip){return }if(!D){D=event}this.hideTT(D)};B.content=document.getElementsByClassName("phi_content",B)[0];B.instance_id=B.id.match(/[0-9]+/);B.loadContent=function(D){B.setActivity(Phi.lang("loading"));new Ajax.Request(D,{method:"get",onComplete:function(E){if(Ajax.analyzeResponse(E.responseText,function(){B.setContent(E.responseText)})){B.setContent(Ajax.responseObject.body)}}})};B.setContent=function(D){Effect.Fade(B.content,{duration:0.5,afterFinish:function(){B.content.innerHTML=D;frms=B.getElementsByTagName("FORM");$A(frms).map(function(F){var E=F.onsubmit;F._onsubmit=E;F.onsubmit=function(){if(!this._onsubmit||this._onsubmit()){B.setActivity(Phi.lang("sending"));new Ajax.Request(this.action,{parameters:Form.serialize(this),onComplete:function(G){B.refresh();if(G.responseText){G.responseText.split(",").map(function(H){if($("phimodule_"+H)){$("phimodule_"+H).refresh()}})}}})}return false}});btns=B.getElementsByTagName("INPUT");$A(btns).map(function(E){if(E.type=="button"&&E.value.toLowerCase()==Phi.lang("cancel").toLowerCase()){E.onclick=function(){B.refresh();return false}}});Effect.Appear(B.content,{duration:0.5})}})};B.setActivity=function(D){Effect.Fade(B.content,{duration:0.5,afterFinish:function(){B.content.innerHTML='<div class="phi_module_loader"><h1>'+D+"</h1></div>";Effect.Appear(B.content,{duration:0.5})}})};B.refresh=function(){var D=Phi.url_rw?Phi.url+"instance/run/inst=":Phi.linkbase+"instance/run&inst=";new Ajax.Request(D+this.instance_id+"&page="+Phi.page,{onComplete:function(E){dummy=document.createElement("DIV");dummy.innerHTML=E.responseText;B.setContent(document.getElementsByClassName("phi_content",dummy)[0].innerHTML);B.className=dummy.firstChild.className;if(!document.getElementsByClassName("phi_title",dummy)[0]){B.removeChild(document.getElementsByClassName("phi_title",B)[0])}else{if(!document.getElementsByClassName("phi_title",B)[0]){var F=document.createElement("H1");F.className="phi_title";F.innerHTML=document.getElementsByClassName("phi_title",dummy)[0].innerHTML;B.insertBefore(F,document.getElementsByClassName("phi_content",dummy)[0])}else{document.getElementsByClassName("phi_title",B)[0].innerHTML=document.getElementsByClassName("phi_title",dummy)[0].innerHTML}}}})};if(B.options){var A=B.options.getElementsByTagName("A");$A(A).map(function(D){if(Element.hasClassName(D,"phi_modifier")){D.module=B;if(Element.hasClassName(D,"phi_modifier_instance_kill")){D.onclick=function(){if(!confirm(Phi.lang("remove this module")+" ?")){return false}new Ajax.Request(this.href,{onComplete:function(E){Phi.removeModule(D.module);E.responseText.split(",").map(Phi.removeModule)}});return false}}else{if(Element.hasClassName(D,"phi_modifier_instance_audit")){}else{if(Element.hasClassName(D,"phi_modifier_instance_cut")){D.onclick=function(){Phi.cutModule(D.module,this.href);return false}}else{if(Element.hasClassName(D,"phi_modifier_instance_copy")){D.onclick=function(){Phi.copyModule(D.module,this.href);return false}}else{D.onclick=function(){this.module.loadContent(this.href);return false}}}}}}})}};if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",phiInitializeNavigator)}if(typeof window.addEventListener!="undefined"){window.addEventListener("load",phiInitializeNavigator,false)}function phiInitializeNavigator(){document.getElementsByClassName("phi_module").map(Phi.prepareModule)};