
function aqstree(arr,idPrefix,imgPath,ck0,ck1,ck2){this.imgPath=imgPath;this.tsp=new Image();this.tsp.src=imgPath+'/tsp.gif';this.tt=new Image();this.tt.src=imgPath+'/tt.gif'
this.tl=new Image();this.tl.src=imgPath+'/tl.gif';this.tbar=new Image();this.tbar.src=imgPath+'/tbar.gif';this.ck0=imgPath+'/'+ck0;this.ck1=imgPath+'/'+ck1;this.ck2=imgPath+'/'+ck2;this.im0=new Image();this.im0.src=this.ck0;this.im1=new Image();this.im1.src=this.ck1;this.im2=new Image();this.im2.src=this.ck2;this.idPrefix=idPrefix;this.nodes=new Object();this.root=new node(arr,null,this);this.countElement=this.idPrefix+'tree_count';this.selectedNodesCount=0;this.treeElements=['<table cellspacing="0" cellpadding="0" border="0">','</table>','<tr><td><table cellspacing="0" cellpadding="0" border="0"><tr>','</tr></table></td></tr>','<td class="tl"><img width="16" height="16" src="'+this.tbar.src+'"></td>','<td><img width="16" height="16" src="'+this.tsp.src+'"></td>','<td class="tl"><img src="'+this.tt.src+'"></td>','<td><img width="16" height="16" src="'+this.tl.src+'"></td>'];this.getSelected=function(){var sel='';for(var id in this.nodes){var c=this.nodes[id];if(c.state==1&&!c.isGroup){if(sel.length>0)sel+=',';sel+=c.id;}}
return sel;};this.getNodeForTag=function(tag){return this.nodes[tag.id.substring(this.idPrefix.length)];};this.getTagById=function(id){return document.getElementById(this.idPrefix+id);};this.updateStates=function(){for(var id in this.nodes){var node=this.nodes[id];var imga=this.getTagById(id);if(imga==null)continue;var src=imga.firstChild.src;if(src.substring(src.length-this.ck0.length)==this.ck0)
node.state=0;else if(src.substring(src.length-this.ck1.length)==this.ck1)
node.state=1;else if(src.substring(src.length-this.ck2.length)==this.ck2)
node.state=2;}};this.init=function(){for(var id in this.nodes){var imga=this.getTagById(id);if(imga!=null){var txta=imga.parentNode.nextSibling.firstChild;var theTree=this;imga.href="javascript:"+idPrefix+"treeLink('"+id+"');";txta.href="javascript:"+idPrefix+"treeLink('"+id+"');";}}
this.updateStates();this.root.updateMixed();selectedNodes=this.getSelected();if(selectedNodes!='')
this.selectedNodesCount=this.getSelected().split(',').length;this.updateTotalCount();};this.drawVTree=function(elements){for(var i=0;i<elements.length;i++){var e=elements[i];if(typeof(e)=="object"){document.write('<td><a id="v'+e[0]+'" style="border:none;"><img width="18" height="16" src="'+this.imgPath+'/ck'+e[1]+'.gif"></a></td>'+'<td><a'+(e[2]==0?' class="int"':'')+'>'+e[3]+(e[5]&&e[4]==1?('&nbsp;['+e[5]+']'):'')+'</a>'+
(e[6]==1?'<img onclick="showDefn(\''+e[5]+'\');" width="16" height="12" src="'+this.imgPath+'/info.gif" style="margin-bottom:-3px;cursor:pointer;"/>':'')+'</td>');}else{document.write(this.treeElements[e]);}}};this.drawCTree=function(elements){for(var i=0;i<elements.length;i++){var e=elements[i];if(typeof(e)=="object"){document.write('<td><a id="c'+e[0]+'" style="border:none;"><img width="18" height="16" src="'+this.imgPath+'/ck'+e[1]+'.gif"></a></td>'+'<td><a>'+e[2]+'</a></td>');}else{document.write(this.treeElements[e]);}}};this.drawRTree=function(elements){for(var i=0;i<elements.length;i++){var e=elements[i];if(typeof(e)=="object"){document.write('<td><a id="r'+e[0]+'" style="border:none;"><img width="18" height="16" src="'+this.imgPath+'/ck'+e[1]+'.gif"></a></td>'+'<td><a>'+e[2]+'</a></td>');}else{document.write(this.treeElements[e]);}}};this.updateTotalCount=function(){var elem=document.getElementById(this.countElement);if(elem){if(this.selectedNodesCount==0){elem.innerHTML='';}
else{elem.innerHTML='('+this.selectedNodesCount+')';}}};}
function vtreeLink(id){var imga=vtree.getTagById(id);var node=vtree.getNodeForTag(imga);node.updateImg();vtree.updateTotalCount();}
function rtreeLink(id){var imga=rtree.getTagById(id);var node=rtree.getNodeForTag(imga);node.updateImg();rtree.updateTotalCount();}
function ctreeLink(id){var imga=ctree.getTagById(id);var node=ctree.getNodeForTag(imga);node.updateImg();ctree.updateTotalCount();}
function node(arr,parent,tree){this.setChkImg=function(img){var elem=tree.getTagById(this.id);if(elem){var imgtag=elem.firstChild;imgtag.src=img;}};this.check=function(){this.setChkImg(tree.ck1);this.state=1;if(!this.isGroup){tree.selectedNodesCount++;}else if(this.isGroup&&this.id!="*"){var elem=document.getElementById("grp_"+this.id);if(elem&&elem.style.display=="none"){var img=document.getElementById("img_"+this.id);var ch=img.src.substring(img.src.length-7,img.src.length)=="ttC.gif"?"t":"l";img.src='../images/t'+ch+'O.gif';elem.style.display='inline';}}};this.uncheck=function(){this.setChkImg(tree.ck0);this.state=0;if(!this.isGroup){tree.selectedNodesCount--;}};this.semicheck=function(){this.setChkImg(tree.ck2);this.state=2;if(this.isGroup&&this.id!="*"){var elem=document.getElementById("grp_"+this.id);if(elem&&elem.style.display=="none"){var img=document.getElementById("img_"+this.id);var ch=img.src.substring(img.src.length-7,img.src.length)=="ttC.gif"?"t":"l";img.src='../images/t'+ch+'O.gif';elem.style.display='inline';}}};this.checkChildren=function(){if(this.children!=null)
for(var i=0;i<this.children.length;i++){var child=this.children[i];if(child.state!=1){child.check();child.checkChildren();}}};this.uncheckChildren=function(){if(this.children!=null)
for(var i=0;i<this.children.length;i++){var child=this.children[i];if(child.state!=0){child.uncheck();child.uncheckChildren();}}
if(this.id=='*'||this.id=='root'){var allclear=true;var sibs=this.children;for(var i=0;i<sibs.length;i++)
if(sibs[i].state!=0){allclear=false;break;}
if(allclear)this.uncheck();else this.semicheck();}};this.updateParents=function(set){if(this.parent==null||this.parent.id=='root')
return;if(set){var allset=true;var sibs=this.parent.children;for(var i=0;i<sibs.length;i++)
if(sibs[i].state!=1){allset=false;break;}
if(allset)this.parent.check();else this.parent.semicheck();}else{var allclear=true;var sibs=this.parent.children;for(var i=0;i<sibs.length;i++)
if(sibs[i].state!=0){allclear=false;break;}
if(allclear)this.parent.uncheck();else this.parent.semicheck();}
this.parent.updateParents(set);};this.inheritedState=function(){var s=this.children[0].state;for(var i=1;i<this.children.length;i++){if(this.children[i].state!=s)
return 2;}
return s;}
this.updateMixed=function(){if(this.children!=null){for(var i=0;i<this.children.length;i++)
this.children[i].updateMixed();var s=this.inheritedState();if(this.state!=s&&this.id!='root'){if(s==2)this.semicheck();else if(s==1)this.check();else if(s==0)this.uncheck();}}};this.updateImg=function(){if(this.state==1){this.uncheck();this.uncheckChildren();this.updateParents(false);}else{this.check();this.checkChildren();this.updateParents(true);}}
this.parent=parent;this.state=0;if(arr.length==1){this.id=arr[0];this.children=null;}else{this.id=arr[0]==''?'root':arr[0];this.children=new Array(arr.length-1);for(var i=1;i<arr.length;i++)
this.children[i-1]=new node(arr[i],this,tree);}
this.isGroup=(this.id.substring(tree.idPrefix.length,1)=='g'||this.id=='root'||this.id.substring(0,1)=='g'||this.id=='*');tree.nodes[this.id]=this;};function toggleSubTree(id,ch){var elemId="grp_"+id;var elem=document.getElementById(elemId);var img=document.getElementById("img_"+id);if(elem.style.display=='none'){img.src='../images/t'+ch+'O.gif';elem.style.display='inline';}else{img.src='../images/t'+ch+'C.gif';elem.style.display='none';}};