//########################################################################
// SUMMARY
// Opens and focuses on a new browser window.
//
// INPUT
// URL = the URL of the new window
// WindowName = the name used by the browser to reference the new window
//
// OUTPUT
// A new window of default size will be opened obtain focus.  The window
// will have no status bar, but will have scroll bars and be resizable.
//########################################################################
function popUp(URL, WindowName){
	var windowHandle = window.open(URL, WindowName, 'status=no,scrollbars=yes,resizable=yes');
	if (windowHandle.opener == null) windowHandle.opener = self;
	window.focus;
}

function popUp(URL, WindowName, Width, Height){
	var windowHandle = window.open(URL, WindowName, 'status=no,scrollbars=yes,resizable=yes,width=' + Width + ',height=' + Height);
	if (windowHandle.opener == null) windowHandle.opener = self;
	window.focus;
}

//########################################################################
// SUMMARY
// Toggles between visible and hidden using the display property.
// The resulting display value is determined by its pre-existing display
// value.  The function expects, but does not require, a div element --
// which is natively displayed as a block element.  The use of inline
// elements will result in them being changed to block upon being made
// visible.
//
// INPUT
// divID = the ID of the element to be toggled
//
// OUTPUT
// The passed element will be made hidden if display is undefined or
// block OR visible if display is hidden.
//########################################################################
function toggleDiv(divID){
	toggleVisibility(divID, 'block');
}

function toggleInline(ID){
	toggleVisibility(ID, 'inline');
}

function toggleBlock(ID){
	toggleVisibility(ID, 'block');
}

function toggleVisibility(ID, Visible){
	if (document.layers){
		document.layers[ID].display = (document.layers[ID].display == 'none') ? Visible:'none';// || document.layers[ID].display == '') ? Visible:'none';
	}else if (document.getElementById){
		var obj = document.getElementById(ID);
		if (obj != null){
			obj.style.display = (obj.style.display == 'none') ? Visible:'none';// || obj.style.display == '') ? Visible:'none';
		}
	}else if (document.all){
		document.all[ID].style.display = (document.all[ID].style.display == 'none') ? Visible:'none';// || document.all[ID].style.display == '') ? Visible:'none';
	}
}

function setVisibility(ID, State){
	if (document.layers){
		document.layers[ID].display = State;
	}
	else if (document.getElementById){
		document.getElementById(ID).style.display = State;
	}
	else if (document.all){
		document.all[ID].style.display = State;
	}
}

//########################################################################
// SUMMARY
// Redirects the page to another page after the specified delay.
// INPUT
// URL = the URL to redirect to
// Delay = the time in SECONDS before redirecting
// OUTPUT
// The browser will navigate to the URL after the Delay
//########################################################################
function redirect(URL, Delay){
	var d = Delay * 1000; // convert to milliseconds
	setTimeout('window.location.replace(URL)', d);
}
