var TreeViewer=Class.create();TreeViewer.prototype={initialize:function(c,g,f,b,a,e,d){this.treeId=c;this.loadingImg=g;this.nodeStatusOpenImg=f;this.nodeStatusCloseImg=b;this.nodeStatusLeafImg=a;this.requestURI=e;this.requestMethod=d;this._processInitialize()},_processInitialize:function(){this._fontSize="1.0em";this._levelDifferenceWidth="16px";this._loadingImgHeight="20px";this._loadingImgWidth="20px";this._nodeImgHeight="12px";this._nodeImgWidth="12px";this._nodeImgMargin="1px 2px";this._nodeHeight="14px";this._nodePadding="1px 0px";this._operationalParentObj=null;this._operationalObj=null;this._tmpEmphaticObj=null;var a=$(this.treeId);if(a){Element.setStyle(a,{fontSize:this._fontSize,backgroundColor:"#ffffff",margin:"0px",padding:"0px"})}else{throw"Error: Not found the tree view id."}},displayDefaultView:function(){var a=this.createParameter("createDefaultView",null);this._operationalParentObj=$(this.treeId);this._createRequest(a)},_checkRequestNow:function(){if(this._operationalParentObj==null&&this._operationalObj==null){return false}else{return true}},_getChildNode:function(a){var c=a.readAttribute("id");var b=this.createParameter("getChildNode",c);this._operationalParentObj=a;this._createRequest(b)},createParameter:function(a,c){var b=new String;b+="action="+encodeURIComponent(a);if(c){b+="&nodeId="+encodeURIComponent(c)}return b},_createRequest:function(a){new Ajax.Request(this.requestURI,{method:this.requestMethod,parameters:a,onCreate:this._processLoading.bind(this),onComplete:this._processCallback.bind(this)})},_processLoading:function(){var d=null;var a=this._operationalParentObj.childElements();if(a){a.each(function(e){if(e.match("ul")){d=e}})}var b=new Element("ul",{"class":"treeViewLoading"}).update("Now Loading...");if(d){Element.replace(d,b)}else{Element.insert(this._operationalParentObj,{bottom:b})}this._operationalObj=b;var c=this._getTreeLevelMarginLeft(b);Element.setStyle(this._operationalObj,{backgroundColor:"#ffffff",backgroundImage:"url("+this.loadingImg+")",backgroundPosition:"center left",backgroundRepeat:"no-repeat",lineHeight:this._loadingImgHeight,marginBotton:"0px",marginLeft:c,marginRight:"0px",marginTop:"0px",overflow:"hidden",paddingBotton:"0px",paddingLeft:this._loadingImgWidth,paddingRight:"0px",paddingTop:"0px"})},_processCallback:function(b){var a=b.responseText;Element.replace(this._operationalObj,a);this._operationalObj=null;this._setStyleTree()},_setStyleTree:function(){var e=this._operationalParentObj.select("ul");e.each(function(f){var g=this._getTreeLevelMarginLeft(f);Element.setStyle(f,{marginBotton:"0px",marginLeft:g,marginRight:"0px",marginTop:"0px",padding:"0px"})},this);var a=this._operationalParentObj.select("ul li");a.each(function(f){Element.setStyle(f,{listStyle:"none",margin:"2px 0px",padding:"0px"})});var c=this._operationalParentObj.select("ul li div");c.each(function(f){Element.setStyle(f,{lineHeight:this._nodeHeight,padding:this._nodePadding})},this);var d=this._operationalParentObj.select("ul li img");d.each(function(f){Element.setStyle(f,{border:"none",height:this._nodeImgHeight,margin:this._nodeImgMargin,verticalAlign:"middle",width:this._nodeImgWidth},this);if(f.readAttribute("class").match("open")){this._changeNodeStatusOpenImg(f);Event.observe(f,"click",this._processNodeOnClick.bind(this))}else{if(f.readAttribute("class").match("close")){this._changeNodeStatusCloseImg(f);Event.observe(f,"click",this._processNodeOnClick.bind(this))}else{if(f.readAttribute("class").match("leaf")){f.writeAttribute("src",this.nodeStatusLeafImg)}}}},this);var b=this._operationalParentObj.select("ul li div > span:first-of-type");b.each(function(f){Element.setStyle(f,{margin:"0px 0px 0px 1px",verticalAlign:"middle"})});this._operationalParentObj=null},_getTreeLevelMarginLeft:function(b){var a=b.up("ul");if(a&&a.descendantOf(this.treeId)){return this._levelDifferenceWidth}else{return"0px"}},_processNodeOnClick:function(b){var a=b.element();if(a.readAttribute("class").match("open")){this._processCollapseNodeOnClick(a)}else{if(a.readAttribute("class").match("close")){this._processExpandNodeOnClick(a)}}},_processCollapseNodeOnClick:function(b){var c=b.up(1).down("ul");c.hide();Element.removeClassName(b,"open");Element.addClassName(b,"close");this._changeNodeStatusCloseImg(b);var a=b.up("li",0);this._accentuateNodeOnClick(a)},_processExpandNodeOnClick:function(b){if(b.readAttribute("class").match("childIsCompleted")){var c=b.up(1).down("ul");c.show();Element.removeClassName(b,"close");Element.addClassName(b,"open");this._changeNodeStatusOpenImg(b);var a=b.up("li",0);this._accentuateNodeOnClick(a)}else{if(!this._checkRequestNow()){var a=b.up(1);this._getChildNode(a);Element.removeClassName(b,"childIsUncompleted");Element.addClassName(b,"childIsCompleted");Element.removeClassName(b,"close");Element.addClassName(b,"open");this._changeNodeStatusOpenImg(b);var a=b.up("li",0);this._accentuateNodeOnClick(a)}}},_changeNodeStatusOpenImg:function(a){a.writeAttribute("src",this.nodeStatusOpenImg);a.writeAttribute("alt","close");a.writeAttribute("title","close");Element.setStyle(a,{cursor:"pointer"})},_changeNodeStatusCloseImg:function(a){a.writeAttribute("src",this.nodeStatusCloseImg);a.writeAttribute("alt","open");a.writeAttribute("title","open");Element.setStyle(a,{cursor:"pointer"})},_accentuateNodeOnClick:function(a){this._cancelEmphaticNodeOnClick();var d=a.down("span",0);var e=false;var c=a.down("div",0).childElements();c.each(function(f){if(f.match("span")){e=true}});if(e){Element.setStyle(d,{fontWeight:"bold"});var b=d.select("a");b.each(function(f){Element.setStyle(f,{fontWeight:"bold"})});this._tmpEmphaticObj=a}},_cancelEmphaticNodeOnClick:function(){var a=this._tmpEmphaticObj;if(a){var d=a.down("span",0);var e=false;var c=a.down("div",0).childElements();c.each(function(f){if(f.match("span")){e=true}});if(e){Element.setStyle(d,{fontWeight:"normal"});var b=d.select("a");b.each(function(f){Element.setStyle(f,{fontWeight:"normal"})})}}}};