var MOVESPEED = 10;
var navChanges = new Array(-2, -2, -2, -2); // controls the direction that the blocks move
var navPositions = new Array (-20, -20, -20, -20); // the top offset of each block
var moveFlag = new Array(false, false, false, false);

function moveBlock1() {
	navPositions[0] += navChanges[0];
	if(navPositions[0] > 0) { // check to fix bizarre PC Firefox bug
		navPositions[0] = 0;
	} else if(navPositions[0] < -20) {
		navPositions[0] = -20;
	}
	document.getElementById("nb1").style.top = navPositions[0] + "px"; // move the gray bar
	document.getElementById("pn1").style.top = navPositions[0] + "px"; // move the HOME link
	if(navPositions[0] < navPositions[1]) { // move the dark orange bar
		document.getElementById("nb2").style.top = navPositions[0] + "px";
	} else {
		document.getElementById("nb2").style.top = navPositions[1] + "px";
	}
	if(navPositions[0] < 0 && navPositions[0] > -20) {
		setTimeout("moveBlock1()", MOVESPEED);
	}
}

function moveBlock2() {
	navPositions[1] += navChanges[1];
	if(navPositions[1] > 0) { // check to fix bizarre PC Firefox bug
		navPositions[1] = 0;
	} else if(navPositions[1] < -20) {
		navPositions[1] = -20;
	}
	document.getElementById("nb3").style.top = navPositions[1] + "px"; // move the orange bar
	document.getElementById("pn2").style.top = navPositions[1] + "px"; // move the LISTEN link
	if(navPositions[0] < navPositions[1]) { // move the dark orange bar
		document.getElementById("nb2").style.top = navPositions[0] + "px";
	} else {
		document.getElementById("nb2").style.top = navPositions[1] + "px";
	}
	if(navPositions[1] < navPositions[2]) { // move the dark green bar
		document.getElementById("nb4").style.top = navPositions[1] + "px";
	} else {
		document.getElementById("nb4").style.top = navPositions[2] + "px";
	}
	if(navPositions[1] < 0 && navPositions[1] > -20) {
		setTimeout("moveBlock2()", MOVESPEED);
	}
}

function moveBlock3() {
	navPositions[2] += navChanges[2];
	if(navPositions[2] > 0) { // check to fix bizarre PC Firefox bug
		navPositions[2] = 0;
	} else if(navPositions[2] < -20) {
		navPositions[2] = -20;
	}
	document.getElementById("nb5").style.top = navPositions[2] + "px"; // move the blue bar
	document.getElementById("pn3").style.top = navPositions[2] + "px"; // move the PARTICIPATE link
	if(navPositions[1] < navPositions[2]) { // move the dark green bar
		document.getElementById("nb4").style.top = navPositions[1] + "px";
	} else {
		document.getElementById("nb4").style.top = navPositions[2] + "px";
	}
	if(navPositions[2] < navPositions[3]) { // move the light green bar
		document.getElementById("nb6").style.top = navPositions[2] + "px";
	} else {
		document.getElementById("nb6").style.top = navPositions[3] + "px";
	}
	if(navPositions[2] < 0 && navPositions[2] > -20) {
		setTimeout("moveBlock3()", MOVESPEED);
	}
}

function moveBlock4() {
	navPositions[3] += navChanges[3];
	if(navPositions[3] > 0) { // check to fix bizarre PC Firefox bug
		navPositions[3] = 0;
	} else if(navPositions[3] < -20) {
		navPositions[3] = -20;
	}
	document.getElementById("nb7").style.top = navPositions[3] + "px"; // move the yellow bar
	document.getElementById("pn4").style.top = navPositions[3] + "px"; // move the CONNECT link
	if(navPositions[2] < navPositions[3]) { // move the light green bar
		document.getElementById("nb6").style.top = navPositions[2] + "px";
	} else {
		document.getElementById("nb6").style.top = navPositions[3] + "px";
	}
	if(navPositions[3] < 0 && navPositions[3] > -20) {
		setTimeout("moveBlock4()", MOVESPEED);
	}
}

function dropBlock(blockNum) {
	navChanges[blockNum - 1] = 2;
	var blockHeight = navPositions[blockNum - 1];
	if(blockHeight == -20) {
		switch(blockNum) {
			case 1:
				setTimeout("moveBlock1()", MOVESPEED);
				break;
			case 2:
				setTimeout("moveBlock2()", MOVESPEED);
				break;
			case 3:
				setTimeout("moveBlock3()", MOVESPEED);
				break;
			case 4:
				setTimeout("moveBlock4()", MOVESPEED);
		}	
	}
}

function raiseBlock(blockNum) {
	navChanges[blockNum - 1] = -2;
	var blockHeight = navPositions[blockNum - 1];
	if(blockHeight == 0) {
		switch(blockNum) {
			case 1:
				setTimeout("moveBlock1()", MOVESPEED);
				break;
			case 2:
				setTimeout("moveBlock2()", MOVESPEED);
				break;
			case 3:
				setTimeout("moveBlock3()", MOVESPEED);
				break;
			case 4:
				setTimeout("moveBlock4()", MOVESPEED);
		}
	}
}

function snRollOver(block) {
	document.getElementById(block).style.backgroundColor="#F19320";
}

function snRollOff(block) {
	document.getElementById(block).style.backgroundColor="transparent";
}