// JavaScript Document

var windowPos = "";
var init = false
function initMenu(){
	//menuLayer = refLayer("slideMenu");
	menuLyr = document.getElementById("calls");
	winPosFix = parseInt(menuLyr.style.top);
	windowPos = winPosFix;
	menuSlide = setInterval("moveMenu()", 30);
	YOffset = 0;
	init = true;
}
function moveMenu(){
	if(init){
		//YOffset = (window.pageYOffset) ? window.pageYOffset : (document.body.scrollTop + document.documentElement.scrollTop);
		if (self.pageYOffset) // all except Explorer
		{
			YOffset = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			YOffset = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			YOffset = document.body.scrollTop;
		}
		if (YOffset <= windowPos && windowPos == winPosFix) return;
		if (YOffset > windowPos) {
		deltaY = Math.ceil(Math.abs(YOffset - windowPos) / 20);
		}
		else {
		if (YOffset > winPosFix) {
		  deltaY = Math.ceil(Math.abs(YOffset - windowPos) / 20);
		}
		else {
		  deltaY = Math.ceil(Math.abs(winPosFix - windowPos) / 20);
		}
		}
		if (YOffset <= windowPos) deltaY = 0 - deltaY;
		menuLyr.style.top = (parseInt(menuLyr.style.top)+deltaY)+"px";
		windowPos += deltaY;
	}
}
var menuSlide = 0;
function stopMenu(){
	clearInterval(menuSlide);
}
function startMenu() {
	clearInterval(menuSlide);
	menuSlide = setInterval("moveMenu()", 30);
}

function getRealLeft(el) {
    if (arguments.length==0) el = this;
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    if (arguments.length==0) el = this;
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

// Function to (re)position sideNav --- why oh why oh why?
function sideNavPos(){
	var sideNav = document.getElementById("calls");
	var positionMarker = document.getElementById("sideNavMarker");
	sideNav.style.top = getRealTop(positionMarker)+"px";
	sideNav.style.left = getRealLeft(positionMarker)+"px";
}



