/* UnrealIRCd Website
** Date: 7-21-2007
** Build: 1.1.0
** Script: $/scripts/navigation.js
** Developer: Nate
** Description: Navigation junk (Scroller scripting mainly)
** Code Author: Nathan (nate) Bishop
*/

// Open window
function openWindow(url, title, properties) {
	newwindow = window.open(url, title, ((!properties) ? 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,' : properties));
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

// Layer Positioning
var positions = new Array();
positions['top'] = 11; positions['bottom'] = 37; positions['current'] = null;

// Layer/Function Variables
var last_object = ""; var previous_layer = "";
var is_shifting = false; var has_shifted = false;
var shifting_down = null; var shifting_up = null;

/* %function initNav()
** @var    layer        (string)    : Name of the layer
*/
function initNav(layer) {
	if (is_shifting || (previous_layer == layer)) {
		return;
	}

	if (has_shifted) {
		layerUp(previous_layer);	
	}
	document.getElementById(layer).style.display = "inline";
	layerDown(layer);
}

/* %function layerDown()
** @var    layer        (string)    : Layer name
*/
function layerDown(layer){
	is_shifting = true;

	last_object = previous_layer;
	positions['current'] = parseInt(document.getElementById(layer).style.top);
	if (positions['current'] < positions['bottom']) {
		positions['current'] += 2;
	}
	document.getElementById(layer).style.top = positions['current'] + "px";

	shifting_down = setTimeout("layerDown('" + layer + "')", 10);
	if (positions['current'] >= positions['bottom']) {
		positions['current'] == positions['bottom']

		clearTimeout(shifting_down);
		is_shifting = false; has_shifted = true; previous_layer = layer;
	}
	if (!is_shifting) {
		positions['current'] = null;
	}
}
positions['current_return'] = positions['bottom'];

/* %function layerUp()
** @var    layer        (string)    : Layer name
*/
function layerUp(layer) {
	is_shifting = true;

	if (positions['current_return'] > positions['top']) {
		positions['current_return'] -= 2;
	}
	document.getElementById(layer).style.top = positions['current_return'] + "px";
	
	shifting_up = setTimeout("layerUp('" + layer + "')", 10);
	if (positions['current_return'] == positions['top']) {
		is_shifting = false;

		clearTimeout(shifting_up);
		document.getElementById(layer).style.top = positions['top'] + "px";
		positions['current_return'] = positions['bottom'];

		document.getElementById(layer).style.display = "none";
	}
}