/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html
is available at http://www.stunicholls.com/menu/pro_concertinaslide_3.html
Copyright (c) 2005-2008 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */
var ex=new Array();

var getdd = document.getElementById("slide").getElementsByTagName("dd");
var getdt = document.getElementById("slide").getElementsByTagName("dt");
var getMenu = document.getElementById("menuOuter").getElementsByTagName("dt");

clt = function()
{
	if (this.id == "men1" && document.getElementById('smenu').className=='')
	{
		expand (0,document.getElementById('slide')+"20".offsetHeight+20,'smenu')
		document.getElementById('smenu').className = "clicked";
		this.className="expand";
	}
	else
	{
		for (var q=0; q<getdd.length; q++)
		{
			eNext = getdd[q].firstChild;
			while (eNext.nodeType!=1)
			{
				eNext = eNext.nextSibling;
			}
			
			ulHeight = eNext.offsetHeight;
			if (getdd[q].offsetHeight > 0)
			{
				getdd[q].className='';
				getdt[q+1].className='';
				contract (ulHeight+20,0,getdd[q].id)
			}
		}
		document.getElementById('slide').style.position = "absolute";
		document.getElementById('smenu').style.overflow = "hidden";
		contract (document.getElementById('slide').offsetHeight+20,0,'smenu')
		document.getElementById('smenu').className = '';
		this.className='';
	}
}

cld = function()
{
	//document.getElementById('slide').style.position = "relative";
	//document.getElementById('smenu').style.overflow = "visible";
	if (this.id.indexOf('item') != -1)
	{
		for (var z=0; z<getdd.length; z++)
		{
			if (getdd[z].id.indexOf(this.id) !=-1 && getdd[z].className=='')
			{
				eNext = getdd[z].firstChild;
				while (eNext.nodeType!=1)
				{
					eNext = eNext.nextSibling;
				}
				ulHeight = eNext.offsetHeight;
				expand (0,ulHeight+20,getdd[z].id,0)
				
				getdd[z].className='selected';
				$("#smenu dt").removeClass("open-s");
				this.className='slide open-s';
			}
			else
			{
				if(getdd[z].className=='selected')
				{
					eNext = getdd[z].firstChild;
					while (eNext.nodeType!=1)
					{
						eNext = eNext.nextSibling;
					}
					ulHeight = eNext.offsetHeight;
					if (getdd[z].offsetHeight > 0)
					{
						contract (ulHeight+20,0,getdd[z].id,0)
					}
					getdd[z].className='';
					this.className='slide close-s';
				}
			}
		}
	}
	//return false;
}

for (var x=0; x<getMenu.length; x++)
{
	//getMenu[x].onclick=clt;
}

	
for (var i=0; i<getdt.length; i++)
{
	getdt[i].onclick=cld;
}




function m1(x,y){
	return x>y?x:y;
}

function expand (cY1, fY1, subY1) {
	
	var el = document.getElementById(subY1);
	
	cY1=cY1+(m1(5,(fY1-cY1)/5));
	
	if (cY1 <= fY1) {
		el.style.height = cY1 + "px";
		setTimeout ("expand("+cY1+","+fY1+",'"+subY1+"')", 10);
	}
}

function contract (cZ1, fZ1, subZ1) {
	
	var el = document.getElementById(subZ1);

	cZ1=cZ1-(m1(5,(cZ1-fZ1)/5));

	if (cZ1 >= fZ1) {
		if(cZ1<5) cZ1 = 0;
		el.style.height = cZ1 + "px";
		setTimeout ("contract("+cZ1+","+fZ1+",'"+subZ1+"')", 10);
	}
}

