//Define global variables

var timerID = null;
var timerOn = false;
var timecount = 500;
var browser = null;
var newbrowser = true;
var check = false;

function init(){
	//  alert ("Running Init");

	if (document.layers) {
		//  alert ("Running Netscape 4");
		layerRef="document.layers";
		styleSwitch="";
		visibleVar="show";
		screenSize = window.innerWidth;
		browser ="ns4";

	} else if (document.all) {
		//  alert ("Running IE");
		layerRef="document.all";
		styleSwitch=".style";
		visibleVar="visible";
		screenSize = document.body.clientWidth + 18;
		browser ="ie";

	} else if (document.getElementById) {
		//  alert ("Running Netscape 6");
		layerRef="document.getElementByID";
		styleSwitch=".style";
		visibleVar="visible";
		browser="moz";

	} else {
		//alert("Older than 4.0 browser.");
		browser="none";
		newbrowser = false;
	}

	//window.status='status bar text to go here';
	check = true;
}

// Turns the layers on and off
function showLayer(layerName) {
	if(check){
		stopTime();
		
		if (browser == "none") {
			return;
		} else if (browser == "moz") {
			document.getElementById(layerName).style.visibility="visible";			
			document.getElementById('iframe_' + layerName).style.visibility="visible";			
		} else {
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
			eval(layerRef+'["iframe_'+layerName+'"]'+styleSwitch+'.visibility="visible"');
		}
	} else {
		// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function hideLayer(layerName) {
	if(check){
		if (browser =="none") {
			return;
		} else if (browser == "moz") {
			document.getElementById(layerName).style.visibility="hidden";
			document.getElementById('iframe_' + layerName).style.visibility="hidden";
		} else {
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
			eval(layerRef+'["iframe_'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}
	} else {
		// alert ("Please wait for the page to finish loading.");
		return;
	}
}

function startTime() {
	if (timecount <= 0) {
		hideAllLayer();
	} else if (timerOn == false) {
		timerID=setTimeout("hideAllLayer()", timecount);
		timerOn = true;
	}
}

function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

function hideAllLayer() {
	// The TopNavHideAllLayer() function is generated in the 
	// Header.ascx.cs file
	
	TopNavHideAllLayer();	
	
	// This portion of the code will help changing images based on Dropdown timing
	// The change(id, newSrc) function is in the "Nav.js" javascript file
	if (imgID != "" && imgNewSrc != "") {
		change(imgID, imgNewSrc);
		
		imgID = "";
		imgNewSrc = "";
	}	
}

// Initialize variables
init();

