		
		
		
function initServices(rel){
			var collection = document.getElementById('left').getElementsByTagName('DIV');			
			for(var i=0; i<collection.length; i++)
			{	
					if(collection[i].getAttribute('rel') == rel)
					{						
						collection[i].onmouseover = function()
						{							
							this.className = this.className.replace('top','bottom');
						}
						collection[i].onmouseout = function()
						{							
							this.className = this.className.replace('bottom','top');
						}
					}
				
			}
		}

function initDepartment(rel, totalId){
	var total = 'undefined' !== typeof totalId ? document.getElementById(totalId):'';
	var ul = document.getElementById('left').getElementsByTagName('UL')[0];
	var act = false;
	total.onclick = function()
	{
		this.innerHTML = !act ? 'cвернуть все': 'развернуть все';
		act = false == act ? true :false;
		if(ul.getAttribute('rel') == rel)
		{
			var li = ul.childNodes;
				for(var i = 0; i<li.length; i++)
					if(li[i].tagName == 'LI')
						aActions(li[i].getElementsByTagName('DIV')[0].getElementsByTagName('A')[0], act);	}
		return false;
	}
		
		if(ul.getAttribute('rel') == rel)
		{
			var li = ul.childNodes;
			for(var i = 0; i<li.length; i++)
			{
				if(li[i].tagName == 'LI')
				{
					var a = li[i].getElementsByTagName('DIV')[0].getElementsByTagName('A')[0];					a.onclick = function()
					{
						aActions(this)
						return false;
					}
				}	
			}
		}
}
function aActions(o, action){
	var li = o.parentNode.parentNode;
	var liChilds  = li.childNodes;
	
	for(var i=0; i<liChilds.length; i++)
	{//alert(liChilds[i].tagName)
		if(liChilds[i].tagName == 'DIV')
			var div = liChilds[i];
		if(liChilds[i].tagName == 'UL')
			var ul = liChilds[i];
	}
	if('undefined'!= typeof action && !action)
	{
		deactivate(o, div, ul, li);
	}
	
	else if(-1 != o.href.indexOf('?rel=') || action)
	{
		activate(o, div, ul);		
	}
	else
	{
		deactivate(o, div, ul, li);
	}
}

function activate(o, div, ul){
	o.href =  o.href.substring(0, o.href.indexOf('?rel='));
	o.innerHTML = 'свернуть';
	o.parentNode.className = 'active';
	//alert(div)
	div.className = div.className.replace('show','hide');
	ul.className = ul.className.replace('hide','show');
}
function deactivate(o, div, ul, li){
	o.href =  o.href+'?rel='+li.getAttribute('rel');
	o.innerHTML = 'развернуть';
	o.parentNode.className = '';
	div.className = div.className.replace('hide','show');
	ul.className = ul.className.replace('show','hide');
}

