// Deploy the bottom overlay

// The bottom overlay should be located in an element of id 'bottom_overlay' and should be hidden
// out of view

var bottomOverlay;

function deployBottomOverlay()
// initializing
{
 bottomOverlay = document.getElementById('bottom_overlay');
 bottomOverlayHeight = 116; // total height of bottom overlay in pixels
 bottomOverlayOverlap = 30; // height of the 'overlap' portion only (semi-transparent)
 bottomOverlayTimeout = setTimeout(startBottomOverlay, 2000);
}

function startBottomOverlay()
// starts the catfish sliding up
{
 bottomOverlayPosition = 0; // bottomOverlayPosition is expressed in percentage points (out of 100)
 bottomOverlayTimeout = setInterval(positionBottomOverlay, 25);
}

function positionBottomOverlay()
{
 bottomOverlayPosition += 10;
 bottomOverlay.style.marginBottom = '-' + (((100 - bottomOverlayPosition) / 100) * bottomOverlayHeight) + 'px';
 if (bottomOverlayPosition >= 100)
 {
 clearTimeout(bottomOverlayTimeout);
 bottomOverlayTimeout = setTimeout(finishBottomOverlay, 1);
 }
}

function finishBottomOverlay()
{
 bottomOverlay.style.marginBottom = '0';
 // jump the bottom of the document to give room for the bottom overlay when scrolled right down
 document.body.parentNode.style.paddingBottom = (bottomOverlayHeight - bottomOverlayOverlap) +'px';

 // here you could use AJAX (or similar) to log the popup hit for tracking purposes
}

addLoadEvent(deployBottomOverlay); 
