var onLoad=function()
{
	var mainMenu=new CMainMenu($$('.leftMainMenu')[0]);
};

var CMainMenu=new Class(
{
	items: false,
	init: function(root)
	{
		this.items=[];
		var prev, item, node, ind;
		var open=parseInt(Cookie.get('foldOpen'));
		for(var j=0; j<root.childNodes.length; j++)
			if(root.childNodes[j].nodeName=='DIV')
				for(var i=0; i<root.childNodes[j].childNodes.length; i++)
				{
					node=root.childNodes[j].childNodes[i];
					if(node.nodeName=='A') prev=node;
					if(node.nodeName=='DIV')
					{
						prev.firstChild.style['backgroundImage']='url(/images/design/leftMenuClose.gif)';
						prev.firstChild.style['backgroundRepeat']='no-repeat';
						prev.firstChild.style['backgroundPosition']='left top';
						ind=this.items.push({'control': prev, 'container': node, 'visible': false});
						item=this.items[ind-1];
						item.fx=new TFx(node);
						item.fx.fps=30;
						var curHeight=tool.getStyleProp(node,'height');
						if(tool.ie && curHeight=='auto')
						{
							curHeight=node.offsetHeight-24;
							node.style['height']=curHeight+'px';
							prev.style['display']='inline-block';
						}
						if(open!=ind-1) node.style['height']='0px';
						else
						{
							item.visible=true;
							prev.firstChild.style['backgroundImage']='url(/images/design/leftMenuOpen.gif)';
						}
						item.fx.setActions(
						{
							'show': {'height': [false, curHeight, [TFx.style.pow,[0.5]]]},
							'hide': {'height': [false, 0, [TFx.style.pow,[0.5]]]}
						});
						tool.addEvent(prev, 'click', tool.bind(this.toggle, this, [this.items.length-1]));
					}
				}
	},
	
	hideItems: function(noHide)
	{
		for(var i=0; i<this.items.length; i++)
			if(!noHide.contains(i) && this.items[i].visible)
			{
				this.items[i].control.firstChild.style['backgroundImage']='url(/images/design/leftMenuClose.gif)';
				this.items[i].fx.stop();
				this.items[i].fx.start(700,'hide'); this.items[i].visible=false;
			}
	},
	
	toggle: function(ind,e)
	{
		var item=this.items[ind];
		this.hideItems([ind]);
		item.fx.stop();
		if(item.visible)
		{
			Cookie.del('foldOpen');
			this.items[ind].control.firstChild.style['backgroundImage']='url(/images/design/leftMenuClose.gif)';
			item.fx.start(700,'hide');
			item.visible=false;
		}
		else
		{
			Cookie.set('foldOpen', ind);
			this.items[ind].control.firstChild.style['backgroundImage']='url(/images/design/leftMenuOpen.gif)';
			item.fx.start(700,'show');
			item.visible=true;
		}
		e.stopPropogation();
		e.preventDefault();
		return false;
	}
});

var printAbout=function()
{
	var orig=document.body.cloneNode(true);
	var div=document.getElementById('printBody').cloneNode(true);
	div.style['display']='block';
	document.body.innerHTML='';
	document.body.appendChild(div);
	document.body.style['width']='720px';
	document.body.style['backgroundColor']='#ffffff';
	var tmr=new Timer({'delay': 1000});
	tmr.addEvent('timer', function(){ document.body.parentNode.replaceChild(orig,document.body); this.stop(); });
	window.print();
	tmr.start();
};
