
var timer = null;
var speed = 1; //1 is  slow
var endTop = 100;
var endLeft = -300;

//******************************************************
// 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 ="block";
    if (document.getElementById(id)) { getEl(id).style.visibility = "visible"; };
}
//******************************************************
// Function to hide Elements
//******************************************************
function hideEl(id)
{
    if (document.getElementById(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);

	endMove();
	
	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+"')", 14);
}
//******************************************************
// Function to end the move
//******************************************************
function endMove()
{
	clearTimeout(timer);
	setTimeout(' fechar()',30000);
}
//******************************************************
// Function timer
//******************************************************

function fechar(){
		document.getElementById('popup').style.display="none";
}


