// Deploy the footerad

// The footerad should be located in an element of id 'footerad' and should be hidden
// out of view

var footerad;

function deployfooterad()
// initializing
{
	footerad = document.getElementById('footerad');
	
	footeradheight = 79; // total height of footerad in pixels
	footeradoverlap = 21; // height of the 'overlap' portion only (semi-transparent)
	footeradtimeout = setTimeout(startfooterad, 2000);
}

function startfooterad()
// starts the footerad sliding up
{
	footeradposition = 0; // footeradposition is expressed in percentage points (out of 100)
	footeradtimeout = setInterval(positionfooterad, 25);
}

function positionfooterad()
{
	footeradposition += 10;
	footerad.style.marginBottom = '-' + (((100 - footeradposition) / 100) * footeradheight) + 'px';
	if (footeradposition >= 100)
	{
		clearTimeout(footeradtimeout);
		footeradtimeout = setTimeout(finishfooterad, 1);
	}
}

function finishfooterad()
{
	footerad.style.marginBottom = '0';	
	// jump the bottom of the document to give room for the footerad when scrolled right down
	document.body.parentNode.style.paddingBottom = (footeradheight - footeradoverlap) +'px';
	
	// here you could use AJAX (or similar) to log the popup hit for tracking purposes	
}

addLoadEvent(deployfooterad);
