// com.nivaria.ncm.component.sitebranch.js, nivaria.com, 2007-05-01 cGuyomard

var SITE_BRANCH_CLASS="SiteBranch";function SiteBranchManager(){this.componentClass=SITE_BRANCH_CLASS;}
SiteBranchManager.prototype=new AbstractComponentManager();SiteBranchManager.prototype.constructor=AbstractComponentManager;SiteBranchManager.prototype.toString=function(){return"SiteBranchManager"};SiteBranchManager.prototype.registerComponent=function registerComponent(id,props){this._nComponents.push(new SiteBranch(id,props));};function SiteBranch(id,props){AbstractComponent.apply(this,[id,props]);}
SiteBranch.SWITCHED_ON="switched-on";SiteBranch.SWITCHED_OFF="switched-off";SiteBranch._messages={"switchOn":"Expand","switchOff":"Collapse"};SiteBranch.addMessage=function addMessage(key,msg){SiteBranch._messages[key]=msg;};SiteBranch.prototype=new AbstractComponent();SiteBranch.prototype.constructor=SiteBranch;SiteBranch.prototype.toString=function(){return"SiteBranch, id: "+this._id;};SiteBranch.prototype.init=function init(){this.setDomElementById(this._id);if(!this.requireInit()){return;}
try{var currentPageNodes=$jq("#"+this._id+" .currentPage");if(0==currentPageNodes.size()){var resourceName=window.location.pathname;if(0<=resourceName.lastIndexOf("/")){var stringIndex=resourceName.lastIndexOf("/");resourceName=resourceName.substring(stringIndex+1,resourceName.length);}
var currentPagelinkNodes=$jq("#"+this._id+" a[@href$="+resourceName+"]");currentPagelinkNodes.each(function(i){if("LI"!=this.parentNode.tagName.toUpperCase()){var msg="Assertion error, "+this._id+", currentPagelink.parentNode.tagName should be 'LI'";alert(msg);throw new Error(msg);}
this.parentNode.className+=" currentPage";});currentPageNodes=$jq("#"+this._id+" .currentPage");}
currentPageNodes.each(function(i){var node=this.parentNode;while(node&&/(UL)|(LI)/.test(node.tagName.toUpperCase())){if("UL"==node.tagName.toUpperCase()&&"LI"==node.parentNode.tagName.toUpperCase()){node.className=SiteBranch.SWITCHED_ON;}
node=node.parentNode;}});$jq("#"+this._id+" .currentPage > ul").each(function(i){this.className=SiteBranch.SWITCHED_ON;});$jq("#"+this._id+" ul ul").each(function(i){if(SiteBranch.SWITCHED_ON!=this.className){this.className=SiteBranch.SWITCHED_OFF;}});}catch(exception){alert(exception);}
this.setInitialized(true);};application.addComponentManager(new SiteBranchManager(application));
