﻿var openNav = null;
var theDiv = null;
var cont = null;
var topBar = null;
var navCont = null;
var menuInt = null;

function swapImg(name, state) {
	theDiv = document.getElementById(name);
	cont = document.getElementById("_globalNav");
	topBar = document.getElementById("_globalNavContainer");
	navCont = document.getElementById("_globalNavWrapper");
	
	if (openNav && state == "On") {
		hideDiv();
	}
	if (theDiv && state == "On") {
		showDiv(20, name);
	} else if (theDiv && state == "Off") {
		openNav = theDiv;
		startTO();
	}
}

function showDiv(paddingTop, buttonName) {
	theDiv.style.left = (topBar.offsetLeft) + "px";
	theDiv.style.top = paddingTop + topBar.offsetTop + cont.offsetTop + "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);
}