//milliseconds until the arrow animation is complete
var timeToElapse = 400;

function arrowUp(arrowId) {
	if (document.getElementById(arrowId).mousedOver == false) {
		document.getElementById(arrowId).src = '/images/arrow_up.gif';
		setTimeout("arrowRest('" + arrowId + "')",timeToElapse);
	}
}

function arrowRest(arrowId) {
	if (document.getElementById(arrowId).mousedOver == false) {
		document.getElementById(arrowId).src = '/images/arrow.gif';
	}
}

function arrowOn(arrowId) {
	document.getElementById(arrowId).src = '/images/arrow_on.gif';
}

function initializeNavigation() {
	var navDivs = new Array("Services","Portfolio","Solutions","Contact");
	for (var i=0; i<navDivs.length; i++) {
		currentDiv = document.getElementById(navDivs[i]);
		if (currentDiv) {
			currentDiv.arrowDiv = document.getElementById(currentDiv.id + 'Arrow');
			if (currentDiv.getAttribute('currentPage')) {
				currentDiv.arrowDiv.src = '/images/arrow_down.gif';
				setTimeout("arrowOn('" + currentDiv.arrowDiv.id + "')", timeToElapse);
			} else {
				currentDiv.onmouseover = function() {
					this.arrowDiv.mousedOver = true;
					this.arrowDiv.src = '/images/arrow_down.gif';
					var timeStmp = new Date();
					this.arrowDiv.startTime = timeStmp.getTime();
				}
				currentDiv.onmouseout = function() {
					this.arrowDiv.mousedOver = false;
					var timeStmp = new Date();
					var currentTime = timeStmp.getTime();
					if (currentTime >= this.arrowDiv.startTime + timeToElapse) {
						arrowUp(this.arrowDiv.id);
					} else {
						setTimeout( "arrowUp('" + this.arrowDiv.id + "')", timeToElapse - (currentTime - this.arrowDiv.startTime) );
					}
				}
				currentDiv.onclick = function() {
					window.location = this.getAttribute('href');
				}
			}
		}
	}
}
initialize.extend(initializeNavigation);
