// JavaScript Document

/*
positionLayer() moves a layer to any specified point on the screen based on the location of any image.
The layer position can be adjusted up adn down or side to side with top and left.
currentMenu, and startingPoint are the id attributes of a the laeyr being moved and the image used a reference point.
*/
function positionLayer(currentMenu, startingPoint, top, left)
{
	menuLocator = document.images[startingPoint];
	menuStartleft = getRealLeft(menuLocator);
	menuStartTop = getRealTop(menuLocator);

	document.getElementById(currentMenu).style.top = (menuStartTop + top) + "px";
	document.getElementById(currentMenu).style.left = (menuStartleft + left) + "px";
}

//This Function gets a starting left point from which we set the hidden menus
function getRealLeft(el) 
{
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) 
	{
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}




//This Function gets a starting top point from which we set the hidden menus
function getRealTop(el) 
{
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) 
	{
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}





function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
