// JavaScript Document

var timer = null;
var speed = 3; //1 is  slow
var endTop = 0;
var endLeft = 0;

//******************************************************
// Simple little function to get Elements as an object
//******************************************************
function getEl(id)
{
	var el = document.getElementById(id);
	return el;
}
//******************************************************
// Function to show Elements
//******************************************************
function showEl(id)
{
	getEl(id).style.display ="";
}
//******************************************************
// Function to hide Elements
//******************************************************
function hideEl(id)
{
	getEl(id).style.display ="none";
}

//******************************************************
// Function to move Element
//******************************************************
function moveEl(id)
{
	var popup = getEl(id);
	var currentTop = parseInt(popup.offsetTop);
	var currentLeft = parseInt(popup.offsetLeft);
	
	var keepMoving = false;
	//Move
	if (currentTop <= endTop)
	{
		popup.style.top = (currentTop + speed) + "px";
		keepMoving = true;
	}
	if(currentLeft <= endLeft)
	{	
		popup.style.left = (currentLeft + speed) + "px";
		keepMoving = true;
	}
	if (keepMoving)
	{
		startMove(id);
	}
	else
	{
		endMove();
	}
}
//******************************************************
// Function to start the move
//******************************************************
function startMove(id)
{
	timer = setTimeout("moveEl('"+id+"')", 1);
}
//******************************************************
// Function to end the move
//******************************************************
function endMove()
{
	clearTimeout(timer);
}