var IMF_targetClassAll = "IMF_product-trees";
var IMF_targetClass = "IMF_product-tree_current";
var IMF_targetClassLast = "IMF_product-tree_last";
var IMF_targetClassOpen = "IMF_product-trees_open";
var IMF_targetClassClose = "IMF_product-trees_close";
var IMF_productTree = function(option){
	if(!$(option.parent))
	{
		return false;
	}
	var h5s=$(option.parent).getElementsByTagName("h5");
	if(h5s.length<1) return false;
	if($(option.parent).getElementsByTagName("ul").length<1) return false;
	this.block=$(option.parent);
	this.root=h5s[0];
	if($(option.current)) Element.addClassName($(option.current),IMF_targetClass);
	
	this.ifopen=option.open;
	
	this.child=this.block.getElementsByTagName("ul")[0];
	var lis=$A(this.child.getElementsByTagName("li"));
	
	Element.addClassName((lis.pop()),IMF_targetClassLast);
	
	if(this.ifopen) {
		this.openTree();
	} else {
		this.closeTree();
	}
	
	Event.observe(this.root,"click",this.click.bind(this),false);
	var as=$A(this.root.getElementsByTagName("a"));
	if(as.length>0) Event.observe(as[0],"click",this.linkClick.bind(this),false);
	
	
}
IMF_productTree.prototype.openTree=function(){
	this.child.className=this.root.className=IMF_targetClassOpen;
}
IMF_productTree.prototype.closeTree=function(){
	this.child.className=this.root.className=IMF_targetClassClose;
}
IMF_productTree.prototype.click=function(e){
	this.ifopen=(!this.ifopen);
	if(this.ifopen) {
		this.openTree();
	} else {
		this.closeTree();
	}	
}
IMF_productTree.prototype.linkClick=function(e){
	Event.stop(e);
	location.href=Event.element(e).href;
}

document.write("<style>div." + IMF_targetClassAll + " ul{display:none;}</style>");
