var iClip = 0;
var closeMe = true;
previousDivId = '';

function dropDown(divId, showDiv, scroll) {
	dropDownDiv = document.getElementById(divId);
	if (showDiv) {
		closeMe = false;
		if (document.getElementById(previousDivId)) {
			document.getElementById(previousDivId).style.display = 'none';
		}

		if (scroll && (dropDownDiv.offsetHeight || dropDownDiv.offsetHeight == 0)) {
			dropDownDiv.style.top = -500; //get the div out of the way before displaying it on next line
			dropDownDiv.style.display = 'block'; //needs to be block before offsetHeight returns anything other than 0
			divHeight = dropDownDiv.offsetHeight;
			divWidth = dropDownDiv.offsetWidth;
			dropDownDiv.style.top = -8 - divHeight; //drop downs are currently positioned at top:-8px;
			iClip = 0;
			clipIn();
		} else {
			dropDownDiv.style.display = 'block';
		}
		previousDivId = divId;
	} else {
		closeMe = true;
		setTimeout('closeDiv()',100);
	}
}

function clipIn() {
	if (iClip <= divHeight) {
		dropDownDiv.style.clip = "rect(" + (divHeight - iClip) + "px " + divWidth + "px " + divHeight + "px 0px)";
		dropDownDiv.style.top = -8 - divHeight + iClip;
		iClip += 16;
		setTimeout('clipIn(dropDownDiv)',1);
	} else {
		dropDownDiv.style.clip = "rect(0px " + divWidth + "px " + divHeight + "px 0px)";
		dropDownDiv.style.top = '-8';
	}
}

function closeDiv() {
	if (closeMe) {
		dropDownDiv.style.display = 'none';
	}
}