/* Parts Copyright (c) 2006 Yahoo! Inc. All rights reserved. */

var YAHOO=function(){return{util:{},widget:{},example:{},namespace:function(sNameSpace){if(!sNameSpace||!sNameSpace.length){return null;}
var levels=sNameSpace.split(".");var currentNS=YAHOO;for(var i=(levels[0]=="YAHOO")?1:0;i<levels.length;++i){currentNS[levels[i]]=currentNS[levels[i]]||{};currentNS=currentNS[levels[i]];}
return currentNS;}};}();YAHOO.widget.TreeView=function(id){if(id){this.init(id);}};YAHOO.widget.TreeView.nodeCount=0;YAHOO.widget.TreeView.prototype={id:null,_nodes:null,locked:false,_expandAnim:null,_collapseAnim:null,_animCount:0,maxAnim:2,setExpandAnim:function(_2){if(YAHOO.widget.TVAnim.isValid(_2)){this._expandAnim=_2;}},setCollapseAnim:function(_3){if(YAHOO.widget.TVAnim.isValid(_3)){this._collapseAnim=_3;}},animateExpand:function(el){if(this._expandAnim&&this._animCount<this.maxAnim){var _5=this;var a=YAHOO.widget.TVAnim.getAnim(this._expandAnim,el,function(){_5.expandComplete();});if(a){++this._animCount;a.animate();}
return true;}
return false;},animateCollapse:function(el){if(this._collapseAnim&&this._animCount<this.maxAnim){var _7=this;var a=YAHOO.widget.TVAnim.getAnim(this._collapseAnim,el,function(){_7.collapseComplete();});if(a){++this._animCount;a.animate();}
return true;}
return false;},expandComplete:function(){--this._animCount;},collapseComplete:function(){--this._animCount;},init:function(id){this.id=id;this._nodes=new Array();YAHOO.widget.TreeView.trees[id]=this;this.root=new YAHOO.widget.RootNode(this);},draw:function(){var _8=this.root.getHtml();document.getElementById(this.id).innerHTML=_8;this.firstDraw=false;},regNode:function(_9){this._nodes[_9.index]=_9;},getRoot:function(){return this.root;},setDynamicLoad:function(_10){this.root.setDynamicLoad(_10);},expandAll:function(){if(!this.locked){this.root.expandAll();}},collapseAll:function(){if(!this.locked){this.root.collapseAll();}},getNodeByIndex:function(_11){var n=this._nodes[_11];return(n)?n:null;},getNodeByProperty:function(_13,_14){for(var i in this._nodes){var n=this._nodes[i];if(n.data&&_14==n.data[_13]){return n;}}
return null;},onExpand:function(_16){},onCollapse:function(_17){}};YAHOO.widget.TreeView.trees=[];YAHOO.widget.TreeView.getTree=function(_18){var t=YAHOO.widget.TreeView.trees[_18];return(t)?t:null;};YAHOO.widget.TreeView.getNode=function(_20,_21){var t=YAHOO.widget.TreeView.getTree(_20);return(t)?t.getNodeByIndex(_21):null;};YAHOO.widget.TreeView.addHandler=function(el,_22,fn,_24){_24=(_24)?true:false;if(el.addEventListener){el.addEventListener(_22,fn,_24);}else{if(el.attachEvent){el.attachEvent("on"+_22,fn);}else{el["on"+_22]=fn;}}};YAHOO.widget.TreeView.preload=function(){var _25=["ygtvtn","ygtvtm","ygtvtmh","ygtvtp","ygtvtph","ygtvln","ygtvlm","ygtvlmh","ygtvlp","ygtvlph","ygtvloading"];var sb=[];for(var i=0;i<_25.length;++i){sb[sb.length]="<span class=\""+_25[i]+"\">&nbsp;</span>";}
var f=document.createElement("div");var s=f.style;s.position="absolute";s.top="-1000px";s.left="-1000px";f.innerHTML=sb.join("");document.body.appendChild(f);};YAHOO.widget.TreeView.addHandler(window,"load",YAHOO.widget.TreeView.preload);YAHOO.widget.Node=function(_29,_30,_31){if(_30){this.init(_29,_30,_31);}};YAHOO.widget.Node.prototype={index:0,children:null,tree:null,data:null,parent:null,depth:-1,href:null,target:"_self",expanded:false,multiExpand:true,renderHidden:false,childrenRendered:false,previousSibling:null,nextSibling:null,_dynLoad:false,dataLoader:null,isLoading:false,hasIcon:true,init:function(_32,_33,_34){this.data=_32;this.children=[];this.index=YAHOO.widget.TreeView.nodeCount;++YAHOO.widget.TreeView.nodeCount;this.expanded=_34;if(_33){this.tree=_33.tree;this.parent=_33;this.href="javascript:"+this.getToggleLink();this.depth=_33.depth+1;this.multiExpand=_33.multiExpand;_33.appendChild(this);}},appendChild:function(_35){if(this.hasChildren()){var sib=this.children[this.children.length-1];sib.nextSibling=_35;_35.previousSibling=sib;}
this.tree.regNode(_35);this.children[this.children.length]=_35;return _35;},getSiblings:function(){return this.parent.children;},showChildren:function(){if(!this.tree.animateExpand(this.getChildrenEl())){if(this.hasChildren()){this.getChildrenEl().style.display="";}}},hideChildren:function(){if(!this.tree.animateCollapse(this.getChildrenEl())){this.getChildrenEl().style.display="none";}},getElId:function(){return"ygtv"+this.index;},getChildrenElId:function(){return"ygtvc"+this.index;},getToggleElId:function(){return"ygtvt"+this.index;},getEl:function(){return document.getElementById(this.getElId());},getChildrenEl:function(){return document.getElementById(this.getChildrenElId());},getToggleEl:function(){return document.getElementById(this.getToggleElId());},getToggleLink:function(){return"YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+").toggle()";},collapse:function(){if(!this.expanded){return;}
if(!this.getEl()){this.expanded=false;return;}
this.hideChildren();this.expanded=false;if(this.hasIcon){this.getToggleEl().className=this.getStyle();}
this.tree.onCollapse(this);},expand:function(){if(this.expanded){return;}
if(!this.getEl()){this.expanded=true;return;}
if(!this.childrenRendered){this.getChildrenEl().innerHTML=this.renderChildren();}
this.expanded=true;if(this.hasIcon){this.getToggleEl().className=this.getStyle();}
if(this.isLoading){this.expanded=false;return;}
if(!this.multiExpand){var _37=this.getSiblings();for(var i=0;i<_37.length;++i){if(_37[i]!=this&&_37[i].expanded){_37[i].collapse();}}}
this.showChildren();this.tree.onExpand(this);},getStyle:function(){if(this.isLoading){return"ygtvloading";}else{var loc=(this.nextSibling)?"t":"l";var _39="n";if(this.hasChildren(true)||this.isDynamic()){_39=(this.expanded)?"m":"p";}
return"ygtv"+loc+_39;}},getHoverStyle:function(){var s=this.getStyle();if(this.hasChildren(true)&&!this.isLoading){s+="h";}
return s;},expandAll:function(){for(var i=0;i<this.children.length;++i){var c=this.children[i];if(c.isDynamic()){alert("Not supported (lazy load + expand all)");break;}else{if(!c.multiExpand){alert("Not supported (no multi-expand + expand all)");break;}else{c.expand();c.expandAll();}}}},collapseAll:function(){for(var i=0;i<this.children.length;++i){this.children[i].collapse();this.children[i].collapseAll();}},setDynamicLoad:function(_41){this.dataLoader=_41;this._dynLoad=true;},isRoot:function(){return(this==this.tree.root);},isDynamic:function(){var _42=(!this.isRoot()&&(this._dynLoad||this.tree.root._dynLoad));return _42;},hasChildren:function(_43){return(this.children.length>0||(_43&&this.isDynamic()&&!this.childrenRendered));},toggle:function(){if(!this.tree.locked&&(this.hasChildren(true)||this.isDynamic())){if(this.expanded){this.collapse();}else{this.expand();}}},getHtml:function(){var sb=[];sb[sb.length]="<div class=\"ygtvitem\" id=\""+this.getElId()+"\">";sb[sb.length]=this.getNodeHtml();sb[sb.length]=this.getChildrenHtml();sb[sb.length]="</div>";return sb.join("");},getChildrenHtml:function(){var sb=[];sb[sb.length]="<div class=\"ygtvchildren\"";sb[sb.length]=" id=\""+this.getChildrenElId()+"\"";if(!this.expanded){sb[sb.length]=" style=\"display:none;\"";}
sb[sb.length]=">";if(this.hasChildren(true)&&this.expanded){sb[sb.length]=this.renderChildren();}
sb[sb.length]="</div>";return sb.join("");},renderChildren:function(){var _44=this;if(this.isDynamic()&&!this.childrenRendered){this.isLoading=true;this.tree.locked=true;if(this.dataLoader){setTimeout(function(){_44.dataLoader(_44,function(){_44.loadComplete();});},10);}else{if(this.tree.root.dataLoader){setTimeout(function(){_44.tree.root.dataLoader(_44,function(){_44.loadComplete();});},10);}else{return"Error: data loader not found or not specified.";}}
return"";}else{return this.completeRender();}},completeRender:function(){var sb=[];for(var i=0;i<this.children.length;++i){sb[sb.length]=this.children[i].getHtml();}
this.childrenRendered=true;return sb.join("");},loadComplete:function(){this.getChildrenEl().innerHTML=this.completeRender();this.isLoading=false;this.expand();this.tree.locked=false;},getAncestor:function(_45){if(_45>=this.depth||_45<0){return null;}
var p=this.parent;while(p.depth>_45){p=p.parent;}
return p;},getDepthStyle:function(_47){return(this.getAncestor(_47).nextSibling)?"ygtvdepthcell":"ygtvblankdepthcell";},getNodeHtml:function(){return"";}};YAHOO.widget.RootNode=function(_48){this.init(null,null,true);this.tree=_48;};YAHOO.widget.RootNode.prototype=new YAHOO.widget.Node();YAHOO.widget.RootNode.prototype.getNodeHtml=function(){return"";};YAHOO.widget.TextNode=function(_49,_50,_51){if(_50){this.init(_49,_50,_51);this.setUpLabel(_49);}};YAHOO.widget.TextNode.prototype=new YAHOO.widget.Node();YAHOO.widget.TextNode.prototype.labelStyle="ygtvlabel";YAHOO.widget.TextNode.prototype.labelElId=null;YAHOO.widget.TextNode.prototype.label=null;YAHOO.widget.TextNode.prototype.setUpLabel=function(_52){if(typeof _52=="string"){_52={label:_52};}
this.label=_52.label;if(_52.href){this.href=_52.href;}
if(_52.target){this.target=_52.target;}
this.labelElId="ygtvlabelel"+this.index;};YAHOO.widget.TextNode.prototype.getLabelEl=function(){return document.getElementById(this.labelElId);};YAHOO.widget.TextNode.prototype.getNodeHtml=function(){var sb=new Array();sb[sb.length]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length]="<tr>";for(i=0;i<this.depth;++i){sb[sb.length]="<td class=\""+this.getDepthStyle(i)+"\">&nbsp;</td>";}
var _53="YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+")";sb[sb.length]="<td";sb[sb.length]=" id=\""+this.getToggleElId()+"\"";sb[sb.length]=" class=\""+this.getStyle()+"\"";if(this.hasChildren(true)){sb[sb.length]=" onmouseover=\"this.className=";sb[sb.length]=_53+".getHoverStyle()\"";sb[sb.length]=" onmouseout=\"this.className=";sb[sb.length]=_53+".getStyle()\"";}
sb[sb.length]=" onclick=\"javascript:"+this.getToggleLink()+"\">&nbsp;";sb[sb.length]="</td>";sb[sb.length]="<td>";sb[sb.length]="<a";sb[sb.length]=" id=\""+this.labelElId+"\"";sb[sb.length]=" class=\""+this.labelStyle+"\"";sb[sb.length]=" href=\""+this.href+"\"";sb[sb.length]=" target=\""+this.target+"\"";if(this.hasChildren(true)){sb[sb.length]=" onmouseover=\"document.getElementById('";sb[sb.length]=this.getToggleElId()+"').className=";sb[sb.length]=_53+".getHoverStyle()\"";sb[sb.length]=" onmouseout=\"document.getElementById('";sb[sb.length]=this.getToggleElId()+"').className=";sb[sb.length]=_53+".getStyle()\"";}
sb[sb.length]=" >";sb[sb.length]=this.label;sb[sb.length]="</a>";sb[sb.length]="</td>";sb[sb.length]="</tr>";sb[sb.length]="</table>";return sb.join("");};YAHOO.widget.MenuNode=function(_54,_55,_56){if(_55){this.init(_54,_55,_56);this.setUpLabel(_54);}
this.multiExpand=false;};YAHOO.widget.MenuNode.prototype=new YAHOO.widget.TextNode();YAHOO.widget.HTMLNode=function(_57,_58,_59,_60){if(_58){this.init(_57,_58,_59);this.initContent(_57,_60);}};YAHOO.widget.HTMLNode.prototype=new YAHOO.widget.Node();YAHOO.widget.HTMLNode.prototype.contentStyle="ygtvhtml";YAHOO.widget.HTMLNode.prototype.contentElId=null;YAHOO.widget.HTMLNode.prototype.content=null;YAHOO.widget.HTMLNode.prototype.initContent=function(_61,_62){if(typeof _61=="string"){_61={html:_61};}
this.html=_61.html;this.contentElId="ygtvcontentel"+this.index;this.hasIcon=_62;};YAHOO.widget.HTMLNode.prototype.getContentEl=function(){return document.getElementById(this.contentElId);};YAHOO.widget.HTMLNode.prototype.getNodeHtml=function(){var sb=new Array();sb[sb.length]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length]="<tr>";for(i=0;i<this.depth;++i){sb[sb.length]="<td class=\""+this.getDepthStyle(i)+"\">&nbsp;</td>";}
if(this.hasIcon){sb[sb.length]="<td";sb[sb.length]=" id=\""+this.getToggleElId()+"\"";sb[sb.length]=" class=\""+this.getStyle()+"\"";sb[sb.length]=" onclick=\"javascript:"+this.getToggleLink()+"\">&nbsp;";if(this.hasChildren(true)){sb[sb.length]=" onmouseover=\"this.className=";sb[sb.length]="YAHOO.widget.TreeView.getNode('";sb[sb.length]=this.tree.id+"',"+this.index+").getHoverStyle()\"";sb[sb.length]=" onmouseout=\"this.className=";sb[sb.length]="YAHOO.widget.TreeView.getNode('";sb[sb.length]=this.tree.id+"',"+this.index+").getStyle()\"";}
sb[sb.length]="</td>";}
sb[sb.length]="<td";sb[sb.length]=" id=\""+this.contentElId+"\"";sb[sb.length]=" class=\""+this.contentStyle+"\"";sb[sb.length]=" >";sb[sb.length]=this.html;sb[sb.length]="</td>";sb[sb.length]="</tr>";sb[sb.length]="</table>";return sb.join("");};YAHOO.widget.TVAnim=new function(){this.FADE_IN="YAHOO.widget.TVFadeIn";this.FADE_OUT="YAHOO.widget.TVFadeOut";this.getAnim=function(_63,el,_64){switch(_63){case this.FADE_IN:return new YAHOO.widget.TVFadeIn(el,_64);case this.FADE_OUT:return new YAHOO.widget.TVFadeOut(el,_64);default:return null;}};this.isValid=function(_65){return("undefined"!=eval("typeof "+_65));};};YAHOO.widget.TVFadeIn=function(el,_66){this.el=el;this.callback=_66;};YAHOO.widget.TVFadeIn.prototype={animate:function(){var _67=this;var s=this.el.style;s.opacity=0.1;s.filter="alpha(opacity=10)";s.display="";var dur=0.4;var a=new YAHOO.util.Anim(this.el,{opacity:{from:0.1,to:1,unit:""}},dur);a.onComplete.subscribe(function(){_67.onComplete();});a.animate();},onComplete:function(){this.callback();}};YAHOO.widget.TVFadeOut=function(el,_69){this.el=el;this.callback=_69;};YAHOO.widget.TVFadeOut.prototype={animate:function(){var _70=this;var dur=0.4;var a=new YAHOO.util.Anim(this.el,{opacity:{from:1,to:0.1,unit:""}},dur);a.onComplete.subscribe(function(){_70.onComplete();});a.animate();},onComplete:function(){var s=this.el.style;s.display="none";s.filter="alpha(opacity=100)";this.callback();}};var DLEGEND_CLICK=1;var DLEGEND_CHECKSTYLE="check";var DLEGEND_RADIOSTYLE="radio";dLegend.prototype=new YAHOO.widget.TreeView();dLegend.prototype.onClickHandler;dLegend.prototype.setHandler=function(type,handler){if(type==DLEGEND_CLICK)this.onClickHandler=handler;};function dLegend(){this.initialize=function(elementId,config,callback_function,dynamic_icons){this.init(elementId)
this.executable=config['executable']
this.mapfile=config['mapfile']
this.iconurl=config['iconurl']
this.imgtype=config['imgtype']
if(callback_function){this.setHandler(DLEGEND_CLICK,callback_function)}
if(typeof(dynamic_icons)=='boolean'){this.dynamic_icons=dynamic_icons}else{this.dynamic_icons=false}
buildMenu(this,config);this.draw();if(typeof(config['collapsed_nodes'])!='undefined'){for(var i=0;i<config['collapsed_nodes'].length;i++){this.collapse(config['collapsed_nodes'][i])}}
if(typeof(config['checked_nodes'])!='undefined'){for(var i=0;i<config['checked_nodes'].length;i++){this.check(config['checked_nodes'][i])}}}
function buildMenu(self,config){for(var i=0;i<config.data.length;i++){var node=config.data[i]
if(node.type=='metagroup'){createMetagroup(node,self.getRoot())}}
function createMetagroup(node,parent){var metagroup=new LegendMetagroup(parent,node);for(var i=0;i<node.layers_and_groups.length;i++){var childnode=node.layers_and_groups[i]
if(childnode.type=="metagroup"){createMetagroup(childnode,metagroup)}else if(childnode.type=="group"){var group=new LegendLayer(metagroup,childnode);for(var j=0;j<childnode.layers.length;j++){var grandchildnode=childnode.layers[j];var layer=new LegendLayer(group,grandchildnode);if(grandchildnode.classes){for(var k=0;k<grandchildnode.classes.length;k++){var legendClass=new LegendClass(layer,grandchildnode.classes[k]);}}}}else if(childnode.type=="layer"){var layer=new LegendLayer(metagroup,childnode);if(childnode.classes){for(var j=0;j<childnode.classes.length;j++){var legendClass=new LegendClass(layer,childnode.classes[j]);}}}}}}}
dLegend.prototype.changeNodeStatus=function(id,status){var n=this.getNodeById(id)
if((n.noCheckbox==null||n.noCheckbox==false)){if(status==null){n.checked?n.uncheck():n.check()}else if(status==true){n.check()}else if(status==false){n.uncheck()}}}
dLegend.prototype.toggleCheck=function(id){this.changeNodeStatus(id)}
dLegend.prototype.check=function(id){this.changeNodeStatus(id,true)}
dLegend.prototype.uncheck=function(id){this.changeNodeStatus(id,false)}
dLegend.prototype.checkAll=function(){for(var i=0;i<this.getRoot().children.length;i++){this.getRoot().children[i].check()}}
dLegend.prototype.uncheckAll=function(){for(var i=0;i<this.getRoot().children.length;i++){this.getRoot().children[i].uncheck()}}
dLegend.prototype.changeNodeExpansion=function(id,status){var n=this.getNodeById(id)
if(n!=null&&n.hasChildren()){if(status==null){n.toggle()}else if(status==true){n.expand()}else if(status==false){n.collapse()}}}
dLegend.prototype.toggleTree=function(id){this.changeNodeExpansion(id)}
dLegend.prototype.expand=function(id){this.changeNodeExpansion(id,true)}
dLegend.prototype.collapse=function(id){this.changeNodeExpansion(id,false)}
dLegend.prototype.getNodeById=function(id){for(var i=1;i<this._nodes.length;i++){var n=this._nodes[i];if(n.id==id){return n;}}
return null;}
LegendNode=function(oData,oParent,expanded,checked){if(oParent){this.init(oData,oParent,expanded);this.setUpLabel(oData);this.checked=checked;if(checked)this.check();}};LegendMetagroup=function(parent,child){var optionStyle=child.element;if(!optionStyle)optionStyle=DLEGEND_CHECKSTYLE;var label=child.label;this.type=child.type
this.id=child.id;this.optionStyle=optionStyle;this.noCheckbox=(optionStyle==DLEGEND_RADIOSTYLE)?true:false
this.init(label,parent,true);this.setUpLabel(label);}
LegendLayer=function(parent,child){this.type=child.type
this.id=child.id;this.icon_class=child.icon_class;if(child.minscaledenom)this.minscaledenom=child.minscaledenom;if(child.maxscaledenom)this.maxscaledenom=child.maxscaledenom;this.icon_class=child.icon_class;this.noCheckbox=(child.type=='class'||parent.type=='group');var expanded=(child.type=='group'||(child.type=='layer'&&child.classes))
this.init(child.label,parent,expanded);this.setUpLabel(child.label);}
LegendClass=function(parent,child){this.type=child.type
this.noCheckbox=true;this.icon_class=child.icon_class;if(child.minscaledenom)this.minscaledenom=child.minscaledenom;if(child.maxscaledenom)this.maxscaledenom=child.maxscaledenom;this.init(child.label,parent,false);this.setUpLabel(child.label);}
LegendNode.prototype=new YAHOO.widget.TextNode();LegendNode.prototype.noCheckbox=false;LegendNode.prototype.checkState=0;LegendNode.prototype.checked=false;LegendNode.prototype.hasLegendIcon=function(){return(typeof(this.icon_class)=='undefined')?false:true;}
LegendMetagroup.prototype=new LegendNode();LegendMetagroup.prototype.className="LegendMetagroup";LegendLayer.prototype=new LegendNode();LegendLayer.prototype.minscaledenom=0;LegendLayer.prototype.maxscaledenom=0;LegendLayer.prototype.className="LegendLayer";LegendLayer.prototype.getRootOptionStyle=function(){var p=this.parent;if(p&&p.getRootOptionStyle)return p.getRootOptionStyle();if(p&&p.optionStyle){return p.optionStyle;}
if(this.optionStyle){return this.optionStyle;}};LegendClass.prototype=new LegendNode();LegendClass.prototype.className="LegendClass";LegendNode.prototype.getCheckElId=function(){return"ygtvcheck"+this.index;};LegendNode.prototype.getRadioElId=function(){return"ygtvcheck"+this.index;};LegendNode.prototype.getLegendIconImgId=function(){return"legend_icon"+this.index;};LegendNode.prototype.getCheckEl=function(){return document.getElementById(this.getCheckElId());};LegendNode.prototype.getRadioEl=function(){return document.getElementById(this.getRadioElId());};LegendNode.prototype.getLegendIconImg=function(){return document.getElementById(this.getLegendIconImgId());};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.getNodeHtml=function(){var sb=new Array();sb[sb.length]='<table border="0" cellpadding="0" cellspacing="0">';sb[sb.length]='<tr>';for(i=0;i<this.depth;++i){sb[sb.length]='<td class="'+this.getDepthStyle(i)+'">&nbsp;</td>';}
sb[sb.length]='<td';sb[sb.length]=' id="'+this.getToggleElId()+'"';sb[sb.length]=' class="'+this.getStyle()+'"';if(this.hasChildren(true)){sb[sb.length]=' onmouseover="this.className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getHoverStyle()"';sb[sb.length]=' onmouseout="this.className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getStyle()"';}
sb[sb.length]=' onclick="javascript:'+this.getToggleLink()+'">&nbsp;';sb[sb.length]='</td>';var buttonStyle='none';if((this.optionStyle&&this.optionStyle==DLEGEND_CHECKSTYLE)||(this.getRootOptionStyle&&this.getRootOptionStyle()==DLEGEND_CHECKSTYLE)){if(!this.noCheckbox){buttonStyle='check';sb[sb.length]='<td';sb[sb.length]=' id="'+this.getCheckElId()+'"';sb[sb.length]=' class="'+this.getCheckStyle()+'"';sb[sb.length]=' onclick="javascript:'+this.getCheckLink()+'">';sb[sb.length]='&nbsp;</td>';}else{sb[sb.length]='<td';sb[sb.length]=' id="'+this.getCheckElId()+'"';sb[sb.length]=' >&nbsp;</td>';}}else{if(!this.noCheckbox){buttonStyle='radio';sb[sb.length]='<td';sb[sb.length]=' id="'+this.getRadioElId()+'"';sb[sb.length]=' class="'+this.getRadioStyle()+'"';sb[sb.length]=' onclick="javascript:'+this.getRadioLink()+'">';sb[sb.length]='&nbsp;</td>';}}
sb[sb.length]='<td>';sb[sb.length]='<a';sb[sb.length]=' id="'+this.labelElId+'"';sb[sb.length]=' class="'+this.labelStyle+'"';if(buttonStyle=='check'){sb[sb.length]=' href="javascript:'+this.getCheckLink()+'"';}else if(buttonStyle=='radio'){sb[sb.length]=' href="javascript:'+this.getRadioLink()+'"';}else{sb[sb.length]=' href="'+this.href+'"';}
sb[sb.length]=' target="'+this.target+'"';if(this.hasChildren(true)){sb[sb.length]=' onmouseover="document.getElementById(\'';sb[sb.length]=this.getToggleElId()+'\').className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getHoverStyle()"';sb[sb.length]=' onmouseout="document.getElementById(\'';sb[sb.length]=this.getToggleElId()+'\').className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getStyle()"';}
sb[sb.length]=' >';sb[sb.length]=this.getLegendIconImgTag()+this.label;sb[sb.length]='</a>';sb[sb.length]='</td>';sb[sb.length]='</tr>';sb[sb.length]='</table>';return sb.join("");};LegendNode.prototype.updateMetagroup=function(){if(!this.parent||this.parent.className!='LegendMetagroup'){return;}
node=this.parent;var somethingChecked=false;var somethingNotChecked=false;for(var i=0;i<node.children.length;++i){if(node.children[i].checked){somethingChecked=true;if(node.children[i].checkState==1){somethingNotChecked=true;}}else{somethingNotChecked=true;}}
if(somethingChecked){node.setCheckState((somethingNotChecked)?1:2);}else{node.setCheckState(0);}
node.updateMetagroup();};LegendNode.prototype.updateStyling=function(){if(!this.noCheckbox){this.getCheckEl().className=this.getCheckStyle();this.performCallback();}
if(this.outOfScale){this.outOfScaleTextStyle();}else{this.inScaleTextStyle();}};LegendNode.prototype.performCallback=function(){if(this.className=='LegendLayer'&&this.tree.onClickHandler&&this.checkState!=1){this.tree.onClickHandler(this.id,(this.checkState==2||this.checkState==4)?true:false);}};LegendNode.prototype.inScaleTextStyle=function(){label=document.getElementById(this.labelElId);if(label)label.className="ygtvlabel";}
LegendNode.prototype.outOfScaleTextStyle=function(){label=document.getElementById(this.labelElId);if(label)label.className="disablednode";}
LegendNode.prototype.getLegendIconImgTag=function(){var tag='';if(this.hasLegendIcon()){tag="<img id='"+this.getLegendIconImgId()+"' class='keyimg' src='"+this.getLegendIconImgSrc()+"' align='absmiddle' />&nbsp;"}
return tag;}
LegendNode.prototype.getLegendIconImgSrc=function(scale,extent){var icon_src='';if(this.hasLegendIcon()){if(this.tree.iconurl==null){icon_src=this.tree.executable+'?map='+this.tree.mapfile+'&mode=legendicon&icon='+this.icon_class;}else{icon_src=this.tree.iconurl+"/"+this.icon_class.replace(',','')+this.tree.imgtype;}
if(scale){icon_src+='&scaledenom='+scale}
if(extent){icon_src+='&mapext='+extent.join('+')}}
return icon_src;}
LegendNode.prototype.updateLegendIcon=function(scale,extent){this.getLegendIconImg().src=this.getLegendIconImgSrc(scale,extent)}
dLegend.prototype.update=function(currentScale,currentExtent){for(var i in this._nodes){var node=this._nodes[i]
if(this.dynamic_icons&&node.hasLegendIcon()){node.updateLegendIcon(currentScale,currentExtent)}
if(node.minscaledenom==0&&node.maxscaledenom==0){}else if(currentScale<=node.minscaledenom||currentScale>=node.maxscaledenom){if(!node.outOfScale)
node.shiftOutOfScale();}else{if(node.outOfScale)
node.shiftInScale();}}}
LegendNode.prototype.setCheckState=function(state){this.checkState=state;this.checked=(state>0&&state!=3);this.outOfScale=(state==3||state==4)?true:false;this.updateStyling();};LegendNode.prototype.checkClick=function(){(this.checked==true)?this.uncheck():this.check()};LegendNode.prototype.check=function(){if(this.checkState==0||this.checkState==1){this.setCheckState(2);}else if(this.checkState==3){this.setCheckState(4);}
for(var i=0;i<this.children.length;++i){this.children[i].check();}
this.updateMetagroup();};LegendNode.prototype.uncheck=function(){if(this.checkState==1||this.checkState==2){this.setCheckState(0);}else if(this.checkState==4){this.setCheckState(3);}
for(var i=0;i<this.children.length;++i){this.children[i].uncheck();}
this.updateMetagroup();};LegendNode.prototype.radioClick=function(){(this.checked==true)?this.uncheck():this.radioSelect()};LegendNode.prototype.radioSelect=function(){for(var i=0;i<this.getSiblings().length;i++){this.getSiblings()[i].uncheck()}
this.check()};LegendNode.prototype.shiftOutOfScale=function(){for(var i=0;i<this.children.length;++i){shiftCheckState(this.children[i]);}
shiftCheckState(this);function shiftCheckState(node){if(node.checkState==0){node.setCheckState(3);}else if(node.checkState==2){node.setCheckState(4)}}};LegendNode.prototype.shiftInScale=function(){for(var i=0;i<this.children.length;++i){shiftCheckState(this.children[i]);}
shiftCheckState(this);function shiftCheckState(node){if(node.checkState==3){node.setCheckState(0);}else if(node.checkState==4){node.setCheckState(2)}}};