/* This script used the slide-up function of "Amazon style Drop-in content box" from Dynamic Drive as an example,      */
/* and was based in part on this code.  View this script at: http://www.dynamicdrive.com/dynamicindex17/amazondrop.htm */

var ie=document.all;
var dom=document.getElementById;

var menu = (dom) ? document.getElementById("menuContainer") : document.all.menuContainer;
var menuItems = (dom) ? document.getElementById("menuItems") : document.all.menuItems;

var dropboxleft;            // set left position of box (no need to set this manually anymore, it aligns to the menu automatically)
var dropboxtop;             // set top position of box ((no need to set this manually anymore, it aligns to the menu automatically)

var offsetTop = 20;
var offsetLeft = 0;

var intervalCount;

var closeTimer;
var closeDelay = 500;

function swapMenuContent(contentContainer)
{
	var content = document.getElementById(contentContainer);
	var menuContent = document.getElementById("menuContent");

	menuContent.innerHTML = content.innerHTML;
}

function openMenu()
{
	dropboxleft = findPosX(menu) + offsetLeft;
	dropboxtop  = findPosY(menu) + offsetTop;

	// -- Kill this script on dumb browsers
	if (!dom&&!ie)
		return;

	// -- Find the elements involved
	menuboxcover=(dom) ? document.getElementById("dropDownContainer") : document.all.dropDownContainer;
	menubox=(dom) ? document.getElementById("dropDownMenu"): document.all.dropDownMenu;

	menubox.height=menubox.offsetHeight;

	menubox.style.width = parseInt(menuItems.style.width) - 20 + "px";
	menuboxcover.style.width = parseInt(menuItems.style.width) - 20 + "px";

	// -- Set the container to hold the menu box
	menuboxcover.style.height=parseInt(menubox.height)+"px";

	// -- Set the menu box to have its bottom edge on the top edge of the container
	menubox.style.top=menubox.height*(-1)+"px";

	// -- Fixes some bugginess in IE with the position setting in CSS - the JS setting doesn't have the bug (?!?!?)
	menuboxcover.style.left=dropboxleft+"px";
	menuboxcover.style.top=dropboxtop+"px";

	// -- Show the box
	menuboxcover.style.visibility=(dom||ie)? "visible" : "show";

	menubox.style.top = 0;
}

function closeMenu()
{
	dropboxleft = findPosX(menu);
	dropboxtop  = findPosY(menu) + menu.offsetHeight;

	// -- Kill this script on dumb browsers
	if (!dom&&!ie)
		return;

	// -- Find the elements involved
	menuboxcover = (dom) ? document.getElementById("dropDownContainer") : document.all.dropDownContainer;
	menubox = (dom) ? document.getElementById("dropDownMenu"): document.all.dropDownMenu;

	menuboxcover.style.visibility=(dom||ie)? "hidden" : "hidden";   // as far as I know, these are the same for both here
}

function shouldWeCloseMenu()
{
	closeMenu();
}