﻿var openNav = null;
var theDiv = null;
var cont = null;
var topBar = null;
var navCont = null;
var menuInt = null;

function swapImg(img, name, state) {

	theDiv = document.getElementById(name + "Drop");
	cont = document.getElementById("_globalNav");
	topBar = document.getElementById("_globalNavContainer");
	navCont = document.getElementById("_globalNavWrapper");

	if (openNav && state == "On") {
		hideDiv();
	}

	if (theDiv && state == "On") {
		showDiv(img, 0, name);
	} else if (theDiv && state == "Off") {
		openNav = theDiv;
		startTO();
	}
}

function showDiv(img, paddingTop, buttonName) {
	if (buttonName == "aboutNav") {
		theDiv.style.width = "100px";
		theDiv.style.left = (navCont.offsetLeft + topBar.offsetLeft + img.offsetLeft) - 21 + "px";
	} else {
	    theDiv.style.left = (topBar.offsetLeft + img.offsetLeft) + "px";
	}
	theDiv.style.top = paddingTop + topBar.offsetTop + cont.offsetTop + img.offsetTop + img.offsetHeight + "px";
	theDiv.style.display = "block";
}

function hideDiv() {
	if (openNav) {
		openNav.style.display = "none";
		window.clearTimeout(menuInt);
		openNav = null;
	}
}

function clearTO() {
	window.clearTimeout(menuInt);
}

function startTO() {
	window.clearTimeout(menuInt);
	menuInt = window.setTimeout("hideDiv()", 1000);
}
