/*
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 = 10;
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); }
	}
	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){
	obj.className = (obj.className == 'button')?'pressedButton':'button';
	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);
}