/***************************************************************************                                                                                                       
 *   Copyright (C) 2009 by Vitaly Gnidenko                                 *                                                                                                       
 *   lart@rambler.ru                                                       *                                                                                                       
 ***************************************************************************/  
/*$Id: Ajax.js 72 2009-02-25 01:26:21Z root $*/
YD=YAHOO.util.Dom;
YE=YAHOO.util.Event;
cLeftMenu=function(){
	this.mainDiv=YD.get(arguments[0].mainDiv);
	var divs=YD.getChildrenByTag(this.mainDiv,'div');
	if (divs.length==0)
		return;
	this.mainLevelA=new Array();
	this.childLevelDiv=new Array();
	var uls=YD.getChildrenByTag(divs[0],'ul');
	for(var i=0;i<uls.length;i++){
		var li=YD.getChildrenByTag(uls[i],'li');
		this.mainLevelA[i]=YD.getChildrenByTag(li[0],'a')[0];
		//this.mainLevelA[i].href='javascript:;';
		this.mainLevelA[i].id='mainLevel_'+i;
		this.childLevelDiv[i]=YD.getChildrenByTag(li[0],'div')[0];
		YD.setStyles(this.childLevelDiv[i],{display:'none'});
		YE.addListener(this.mainLevelA[i],'click',this.showSubmenu,this,true);
	}
	if (arguments[0].visibleId!=null){
		this.showIndex=arguments[0].visibleId;
		YD.setStyles(this.childLevelDiv[this.showIndex],{display:'block'});
	}
		
}

cLeftMenu.prototype={
	mainDiv:null,
	mainLevelA:null,
	childLevelDiv:null,
	showIndex:-1,
	showSubmenu:function(e){
		var a=YE.getTarget(e);
		for(var i=0;i<this.mainLevelA.length;i++){
			if (this.mainLevelA[i].id==a.id){
				YD.setStyles(this.childLevelDiv[this.showIndex],{display:'none'});
				this.showIndex=i;
				YD.setStyles(this.childLevelDiv[i],{display:'block'});
				YE.stopEvent(e);
				break;
			}
		}
	}
}
