/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this scriptt and the associated (x)html
is available at http://www.stunicholls.com/menu/pro_slidedrop_1.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 getCurrent = document.getElementById('menu').getElementsByTagName("LI");

	var getEls = document.getElementById('menu').getElementsByTagName("LI");
	var getListElts = document.getElementById('submenus').getElementsByTagName("DIV");
	var getAgn = getEls;
	

	for (var i=0; i<getEls.length; i++) {
		getEls[i].onmouseover=function() {
		for (var z=0; z<getAgn.length; z++) {
			if (this.id != getAgn[z].id) {
				getAgn[z].className="";
				}

		}
		if (this.className == "") {
		this.className = 'clicked';
		}
		ulId = this.id.replace("li", "ul");




		eLeft = this.offsetLeft;

		eNext = document.getElementById(ulId).firstChild;
		while (eNext.nodeType!=1) {eNext = eNext.nextSibling;}

		document.getElementById(ulId).style.left = eLeft + "px";

if (this.className=='clicked') {
slideOut ()
this.className="shrink";
}
else {
contractOnce (eNext.offsetHeight,-1,ulId)
this.className="";
}

slideIn ()


		}

	}



function expand (cY, fY, subY) {
cY=cY+2;
if (cY <= fY) {
document.getElementById(subY).style.height = cY + "px";
setTimeout ("expand("+cY+","+fY+",'"+subY+"')", 10);
}
slideIn ()

}

function contract (cZ, fZ, subZ) {
cZ=cZ-4;
if (cZ >= fZ) {
document.getElementById(subZ).style.height = cZ + "px";
setTimeout ("contract("+cZ+","+fZ+",'"+subZ+"')", 10);
}
slideOut ()
}


function contractOnce (cW, fW, subW) {
cW=cW-4;
if (cW >= fW) {
document.getElementById(subW).style.height = cW + "px";
setTimeout ("contractOnce("+cW+","+fW+",'"+subW+"')", 100);
}
}


function slideOut () {
		startPos = parseInt(document.getElementById(ulId).offsetHeight);
		if (startPos == 0) {
		expand (0,eNext.offsetHeight+1,ulId)
		}
	}

function slideIn () {
for (var t=0; t<getListElts.length; t++) {
		if (ulId != getListElts[t].id && getListElts[t].style.height > 0 + "px"){
		currentHeightt = parseInt(getListElts[t].style.height);
		eNextt = document.getElementById(getListElts[t].id).firstChild;
		while (eNextt.nodeType!=1) {eNextt = eNextt.nextSibling;}

				if (currentHeightt == parseInt(eNextt.offsetHeight)) {
				thisSubt = getListElts[t].id;
				contract (currentHeightt,-1,thisSubt)
				}
			}
		}
}