
/*
Script by RoBorg
RoBorg@geniusbug.com
http://javascript.geniusbug.com | http://www.roborg.co.uk
Please do not remove or edit this message
Please link to this website if you use this script!
*/



slideSpeed = 25;

function initMenus()
{
	
	if(!document.getElementsByTagName) return;
	
	slider = new Array();
	var divs = document.getElementsByTagName('div');

	for(var x=0; x<divs.length; x++)
	{	

		divs[x].originalHeight = divs[x].offsetHeight;
		if(divs[x].className == 'menu') divs[x].speed =1;
	  if(divs[x].className == 'button') divs[x].onclick = function() { toggle(this); }
		
		 if(divs[x].className == 'button_sec') divs[x].onclick = function() { toggle(this); }
		 // if(divs[x].className == 'button_thr') divs[x].onclick = function() { toggle(this); }
		//   if(divs[x].className == 'button_four') divs[x].onclick = function() { toggle(this); }
		      if(divs[x].className == 'button_five') divs[x].onclick = function() { toggle(this); }
			     if(divs[x].className == 'button_six') divs[x].onclick = function() { toggle(this); }
				   if(divs[x].className == 'button_seven') divs[x].onclick = function() { toggle(this); }
		
	
		
	}
return;

	for(var x=0; x<divs.length; x--)
	{
		
		if(divs[x].className != 'menu')
		continue;
		divs[x].style.height = '1px';
		divs[x].style.display = 'none';
		
	}
	
	
}



function toggle(obj)
{
	
	if (obj.className == "button" || obj.className == "pressedButton")
	{
			obj.className = (obj.className == 'button')?'pressedButton':'button';
			
			
			
			var divs = document.getElementsByTagName('div');
			
			
			if (obj.className == "pressedButton")
			{
			
			document.getElementById("plusminus").innerHTML='<img src="images/rhs-plus.jpg" />';
			
			}
			if (obj.className == "button" )
			{
			document.getElementById("plusminus").innerHTML='<img src="images/rhs-minus.jpg" />';
			}
	
	}
	/*condition for 2nd menu*/
	if (obj.className == "button_sec" || obj.className == "pressedButton_sec")
	{
				obj.className = (obj.className == 'button_sec')?'pressedButton_sec':'button_sec';
				
				
				
				if (obj.className == "pressedButton_sec")
				{
				
				document.getElementById("plusminus1").innerHTML='<img src="images/rhs-plus.jpg" />';
				
				}
				if (obj.className == "button_sec" )
				{
				
				document.getElementById("plusminus1").innerHTML =  '<img src="images/rhs-minus.jpg" />';
				
				}
	
	}
	
	///*condition for 3rd menu*/
//	if (obj.className == "button_thr" || obj.className == "pressedButton_thr")
//	{
//				obj.className = (obj.className == 'button_thr')?'pressedButton_thr':'button_thr';
//				
//				
//				
//				if (obj.className == "pressedButton_thr")
//				{
//				
//				document.getElementById("plusminus2").innerHTML='<img src="images/rhs-plus.jpg" />';
//				
//				}
//				if (obj.className == "button_thr" )
//				{
//				
//				document.getElementById("plusminus2").innerHTML =  '<img src="images/rhs-minus.jpg" />';
//				
//				}
//	
//	}
	
	///*condition for 4th menu*/
//	if (obj.className == "button_four" || obj.className == "pressedButton_four")
//	{
//				obj.className = (obj.className == 'button_four')?'pressedButton_four':'button_four';
//				
//				
//				
//				if (obj.className == "pressedButton_four")
//				{
//				
//				document.getElementById("plusminus3").innerHTML='<img src="images/rhs-plus.jpg" />';
//				
//				}
//				if (obj.className == "button_four" )
//				{
//				
//				document.getElementById("plusminus3").innerHTML =  '<img src="images/rhs-minus.jpg" />';
//				
//				}
//	
//	}
//	
	/*condition for 5th menu*/
	if (obj.className == "button_five" || obj.className == "pressedButton_five")
	{
				obj.className = (obj.className == 'button_five')?'pressedButton_five':'button_five';
				
				
				
				if (obj.className == "pressedButton_five")
				{
				
				document.getElementById("plusminus4").innerHTML='<img src="images/rhs-plus.jpg" />';
				
				}
				if (obj.className == "button_five" )
				{
				
				document.getElementById("plusminus4").innerHTML =  '<img src="images/rhs-minus.jpg" />';
				
				}
	
	}
	
	/*condition for 6th menu*/
	if (obj.className == "button_six" || obj.className == "pressedButton_six")
	{
				obj.className = (obj.className == 'button_six')?'pressedButton_six':'button_six';
				
				
				
				if (obj.className == "pressedButton_six")
				{
				
				document.getElementById("plusminus5").innerHTML='<img src="images/rhs-plus.jpg" />';
				
				}
				if (obj.className == "button_six" )
				{
				
				document.getElementById("plusminus5").innerHTML =  '<img src="images/rhs-minus.jpg" />';
				
				}
	
	}
	
	/*condition for 7 menu*/
	if (obj.className == "button_seven" || obj.className == "pressedButton_seven")
	{
				obj.className = (obj.className == 'button_seven')?'pressedButton_seven':'button_seven';
				
				
				
				if (obj.className == "pressedButton_seven")
				{
				
				document.getElementById("plusminus6").innerHTML='<img src="images/rhs-plus.jpg" />';
				
				}
				if (obj.className == "button_seven" )
				{
				
				document.getElementById("plusminus6").innerHTML =  '<img src="images/rhs-minus.jpg" />';
				
				}
	
	}
	
	
	
	
	while(obj.nextSibling && (obj.className != 'menu')) obj = obj.nextSibling;
	
	obj.speed = -1 * obj.speed;
	if(obj.slideTimer) return;	//Already moving

	var x = slider.length;
	slider[x] = obj;
	slide(x);
}



function slide(x)
{
	var obj = slider[x];
	if(obj.style.display != 'block') obj.style.display = 'block';
	var height = obj.offsetHeight + obj.speed * slideSpeed;
	var targetHeight = getChildrensHeights(obj);

	if(height > targetHeight)
	{
		
		obj.style.height = targetHeight + 'px';
		obj.slideTimer = false;
		resizeParents(obj, 0);
		return;
	}
	
	if(height <= 1)
	{
		
		obj.style.height = '1px';
		obj.style.display = 'none';
		obj.slideTimer = false;
		resizeParents(obj, 0);
		return;
	}
	
	obj.style.height = height + 'px';
	obj.slideTimer = setTimeout('slide(' + x + ');', 50);
	resizeParents(obj, targetHeight - height);
}



function getChildrensHeights(obj)
{
	if(!obj.firstChild) return 0;
	if(!obj.tagName.match(/div/i)) return 0;

	var height = 0;
	tmp = obj;
	obj = obj.firstChild;
	do height += getChildrensHeights(obj);
	while(obj = obj.nextSibling);
	
	if(height == 0) height = tmp.offsetHeight;
	
	return height;
}



function resizeParents(obj, diff)
{
	if(obj.className == 'menuContainer') return;
	obj = obj.parentNode;
	height = getChildrensHeights(obj) - diff;
	obj.style.height = height + 'px';
	resizeParents(obj, diff);
}


