var DLEGEND_CLICK=1;var DLEGEND_CHECKSTYLE="check";var DLEGEND_RADIOSTYLE="radio";function dLegend(){}dLegend.prototype.initialize=function(a,b){this.treeLegend=new YAHOO.widget.TreeView(a);buildMenu(b,this.treeLegend);this.treeLegend.draw()};dLegend.prototype.update=function(a){this.treeLegend.update(a)};dLegend.prototype.setHandler=function(b,a){this.treeLegend.setHandler(b,a)};dLegend.prototype.changeNodeStatus=function(b,a){this.treeLegend.changeNodeStatus(b,a)};function buildMenu(c,p){var A=new XMLDoc(c,this.xmlError);var r=A.docNode;var v=r.getElements("server")[0].getText();for(var t=0;t<r.getElements("metagroup").length;t++){var e=r.getElements("metagroup")[t];var b=e.getAttribute("name");var w=e.getAttribute("element");if(!w){w=DLEGEND_CHECKSTYLE}b+=(w==DLEGEND_CHECKSTYLE?"":" (Select One)");var n=new LegendMetagroup(b,p.getRoot(),w);for(var s=0;s<e.getElements().length;s++){if(e.getElements()[s].tagName=="group"){var u=e.getElements()[s];var l=u.getAttribute("name");if(!l){l=u.getAttribute("id")}var g=d(u,n);for(var q=0;q<u.getElements("layer").length;q++){var f=u.getElements("layer")[q];var B=d(f,g,true);for(x=0;x<f.getElements("class").length;x++){var h=y(f.getElements("class")[x],B)}}}else{if(e.getElements()[s].tagName=="layer"){var f=e.getElements()[s];var B=d(f,n);for(var o=0;o<f.getElements("class").length;o++){var h=y(f.getElements("class")[o],B)}}}}}function d(k,F,G){var j=k.getAttribute("name");var C=k.getAttribute("id");var m=k.getAttribute("minscale");var D=k.getAttribute("maxscale");var E=z(k.getAttribute("icon"));return new LegendLayer(E+j,F,C,m,D,G)}function y(j,C){var m=z(j.getAttribute("icon"));var k=j.getAttribute("name");return new LegendClass(m+k,C)}function z(j){if(j){return"<img src='http://"+v+j+"' align='absmiddle' />&nbsp;"}else{return""}}function a(j){alert(j)}}YAHOO.widget.TreeView.prototype.update=function(e){for(var c=0;c<this.getRoot().children.length;c++){for(var b=0;b<this.getRoot().children[c].children.length;b++){var a=false;var d=this.getRoot().children[c].children[b];if((d.minscale==0&&d.maxscale==0)){}else{if(e<=d.minscale||e>=d.maxscale){a=true;d.disableNode()}else{if(d.disabled){d.enableNode()}}}if(a){d.collapse()}}}};YAHOO.widget.TreeView.prototype.onClickHandler;YAHOO.widget.TreeView.prototype.setHandler=function(b,a){if(b==DLEGEND_CLICK){this.onClickHandler=a}};YAHOO.widget.TreeView.prototype.changeNodeStatus=function(c,a){for(var d=0;d<this.getRoot().children.length;d++){for(var b=0;b<this.getRoot().children[d].children.length;b++){var e=this.getRoot().children[d].children[b];if(e.layerName&&e.layerName==c){if(a){e.check()}else{e.uncheck()}break}}}};LegendNode=function(d,c,a,b){if(c){this.init(d,c,a);this.setUpLabel(d);this.checked=b;if(b){this.check()}}};LegendMetagroup=function(d,c,b,a){this.optionStyle=b;this.checked=true;if(c){this.init(d,c,this.checked);this.setUpLabel(d)}};LegendLayer=function(e,f,c,b,d,a){this.layerName=c;if(b){this.minscale=b}if(d){this.maxscale=d}this.noCheckbox=a;this.disabled=false;if(f){this.init(e,f,false);this.setUpLabel(e)}};LegendClass=function(b,a){this.noCheckbox=true;this.disabled=false;if(a){this.init(b,a,false);this.setUpLabel(b);this.checked=false}};LegendNode.prototype=new YAHOO.widget.TextNode();LegendMetagroup.prototype=new LegendNode();LegendLayer.prototype=new LegendNode();LegendClass.prototype=new LegendNode();LegendLayer.prototype.minscale=0;LegendLayer.prototype.maxscale=0;LegendLayer.prototype.toString=function(){return"LegendLayer"};LegendClass.prototype.toString=function(){return"LegendClass"};LegendMetagroup.prototype.toString=function(){return"LegendMetagroup"};LegendNode.prototype.checked=false;LegendNode.prototype.noCheckbox=false;LegendNode.prototype.checkState=0;LegendNode.prototype.getCheckElId=function(){return"ygtvcheck"+this.index};LegendNode.prototype.getRadioElId=function(){return"ygtvcheck"+this.index};LegendNode.prototype.getCheckEl=function(){return document.getElementById(this.getCheckElId())};LegendNode.prototype.getRadioEl=function(){return document.getElementById(this.getRadioElId())};LegendNode.prototype.getCheckStyle=function(){return"ygtvcheck"+this.checkState};LegendNode.prototype.getRadioStyle=function(){return"ygtvcheck"+this.checkState};LegendNode.prototype.getCheckLink=function(){return"YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+").checkClick(); "};LegendNode.prototype.getRadioLink=function(){return"YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+").radioClick()"};LegendNode.prototype.checkClick=function(){if(this.checkState===0&&this.disabled==false){this.check()}else{this.uncheck()}};LegendNode.prototype.radioClick=function(){if(this.checkState===0&&this.disabled==false){this.radioSelect()}else{if(this.checkState===1){this.radioUncheck()}}};LegendNode.prototype.updateCheckParent=function(){var d=this.parent;if(!d||!d.updateCheckParent){return}var a=false;var c=false;for(var b=0;b<d.children.length;++b){if(d.children[b].checked){a=true;if(d.children[b].checkState==1){c=true}}else{c=true}}if(a){d.setCheckState((c)?1:2)}else{d.setCheckState(0)}d.updateCheckHtml();d.updateCheckParent()};LegendNode.prototype.updateRadioParent=function(){var b=this.parent;if(!b||!b.updateRadioParent){return}for(var a=0;a<b.children.length;++a){if(b.children[a].checked){b.children[a].radioUncheck()}}b.setCheckState(1);b.updateRadioHtml();b.updateRadioParent()};LegendLayer.prototype.getRootOptionStyle=function(){var a=this.parent;if(a&&a.getRootOptionStyle){return a.getRootOptionStyle()}if(a&&a.optionStyle){return a.optionStyle}if(this.optionStyle){return this.optionStyle}};LegendNode.prototype.updateCheckHtml=function(){if(this.parent&&this.parent.childrenRendered){if(!this.noCheckbox){this.getCheckEl().className=this.getCheckStyle();this.performCallback()}}};LegendNode.prototype.updateRadioHtml=function(){if(this.parent&&this.parent.childrenRendered){if(!this.noCheckbox){this.getRadioEl().className=this.getRadioStyle();this.performCallback()}}};LegendNode.prototype.performCallback=function(){if(this.layerName&&this.tree.onClickHandler&&(this.checkState==0||this.checkState==2)){this.tree.onClickHandler(this.layerName,(this.checkState==2)?true:false)}};LegendNode.prototype.setCheckState=function(a){this.checkState=a;this.checked=(a>0)};LegendNode.prototype.disableNode=function(){for(var a=0;a<this.children.length;++a){this.children[a].disableNodeStyle();this.children[a].uncheck()}this.disableNodeStyle();this.uncheck();this.updateCheckParent()};LegendNode.prototype.enableNode=function(){for(var a=0;a<this.children.length;++a){this.children[a].enableNodeStyle()}this.enableNodeStyle()};LegendNode.prototype.disableNodeStyle=function(){this.disabled=true;label=document.getElementById(this.labelElId);if(label){label.className="disablednode"}};LegendNode.prototype.enableNodeStyle=function(){this.disabled=false;label=document.getElementById(this.labelElId);if(label){label.className="ygtvlabel"}};LegendNode.prototype.check=function(){this.setCheckState(2);for(var a=0;a<this.children.length;++a){this.children[a].check()}this.updateCheckHtml();this.updateCheckParent()};LegendNode.prototype.radioSelect=function(){for(var a=0;a<this.children.length;++a){this.children[a].radioUncheck()}this.updateRadioParent();if(this.hasChildren()){this.setCheckState(1)}this.setCheckState(2);this.updateRadioHtml()};LegendNode.prototype.uncheck=function(){this.setCheckState(0);for(var a=0;a<this.children.length;++a){this.children[a].uncheck()}this.updateCheckHtml();this.updateCheckParent()};LegendNode.prototype.radioUncheck=function(){this.setCheckState(0);for(var a=0;a<this.children.length;++a){this.children[a].radioUncheck()}this.updateRadioHtml()};LegendNode.prototype.getNodeHtml=function(){var a=new Array();a[a.length]='<table border="0" cellpadding="0" cellspacing="0">';a[a.length]="<tr>";for(i=0;i<this.depth;++i){a[a.length]='<td class="'+this.getDepthStyle(i)+'">&nbsp;</td>'}a[a.length]="<td";a[a.length]=' id="'+this.getToggleElId()+'"';a[a.length]=' class="'+this.getStyle()+'"';if(this.hasChildren(true)){a[a.length]=' onmouseover="this.className=';a[a.length]="YAHOO.widget.TreeView.getNode('";a[a.length]=this.tree.id+"',"+this.index+').getHoverStyle()"';a[a.length]=' onmouseout="this.className=';a[a.length]="YAHOO.widget.TreeView.getNode('";a[a.length]=this.tree.id+"',"+this.index+').getStyle()"'}a[a.length]=' onclick="javascript:'+this.getToggleLink()+'">&nbsp;';a[a.length]="</td>";if((this.optionStyle&&this.optionStyle==DLEGEND_CHECKSTYLE)||(this.getRootOptionStyle&&this.getRootOptionStyle()==DLEGEND_CHECKSTYLE)){if(!this.noCheckbox){a[a.length]="<td";a[a.length]=' id="'+this.getCheckElId()+'"';a[a.length]=' class="'+this.getCheckStyle()+'"';a[a.length]=' onclick="javascript:'+this.getCheckLink()+'">';a[a.length]="&nbsp;</td>"}else{a[a.length]="<td";a[a.length]=' id="'+this.getCheckElId()+'"';a[a.length]=" >&nbsp;</td>"}}else{if(!this.noCheckbox){a[a.length]="<td";a[a.length]=' id="'+this.getRadioElId()+'"';a[a.length]=' class="'+this.getRadioStyle()+'"';a[a.length]=' onclick="javascript:'+this.getRadioLink()+'">';a[a.length]="&nbsp;</td>"}}a[a.length]="<td>";a[a.length]="<a";a[a.length]=' id="'+this.labelElId+'"';a[a.length]=' class="'+this.labelStyle+'"';a[a.length]=' href="'+this.href+'"';a[a.length]=' target="'+this.target+'"';if(this.hasChildren(true)){a[a.length]=" onmouseover=\"document.getElementById('";a[a.length]=this.getToggleElId()+"').className=";a[a.length]="YAHOO.widget.TreeView.getNode('";a[a.length]=this.tree.id+"',"+this.index+').getHoverStyle()"';a[a.length]=" onmouseout=\"document.getElementById('";a[a.length]=this.getToggleElId()+"').className=";a[a.length]="YAHOO.widget.TreeView.getNode('";a[a.length]=this.tree.id+"',"+this.index+').getStyle()"'}a[a.length]=" >";a[a.length]=this.label;a[a.length]="</a>";a[a.length]="</td>";a[a.length]="</tr>";a[a.length]="</table>";return a.join("")};
