var iLayerDirection = 0;

var iLayerDelta = 200;
var iLayerStart = -900;
var iLayerEnd = 10;
var iLayerPosition = 20;

var iLayerTimer = 50;
var iLayerScrollCheck = 1;
var iLayerStartDelay = 3000;
var bLayerCheckScrolling = false;

document.write('<s');
document.write('tyle type="text/css">\n.layerMainContainer { position:absolute; display:block; border: 1px solid black; text-align: center; background-color: white; z-index: 10000; width:800px; }\n.layerUpperBar { background:#eee;width: 100%; height: 21px; padding: 0px; border-bottom: 1px solid black; z-index: 10001; overflow: hidden;}\n.layerUpperBarTeaser { float: left; margin-top: 3px; margin-right: 3px; margin-left:10px; }\n.layerUpperBarButtons { float: right; margin-top: 3px; margin-right: 3px; }\n.layerLowerBar { background:#eee;width: 100%; height: 21px; padding: 0px; border-top: 1px solid black; z-index: 10001; overflow: hidden; }\n.layerLowerBarTeaser {float: left; margin-top: 2px; margin-left: 10px;}\n.layerLowerBarButtons {float: right; margin-top: 2px; margin-right: 3px;}\n</');
document.write('style>');
document.write('<d');
document.write('iv id="myLayer" class="layerMainContainer"><');
document.write('div id="bar_up" class="layerUpperBar"><');
document.write('span class="layerUpperBarTeaser"><');
document.write('a href="' + layerLink + '" target="_blank" onclick="javascript:layerHideAndOpen(); return false;" style="position:static; font:11pt arial, helvetica, sans-serif; color: #000; text-decoration: none;" alt="UseNeXT - Next Generation Downloading"" title="UseNeXT - Next Generation Downloading">Faster than Emule, Kazaa and Bit Torrent!! - Test it yourself today - Download 1GB FREE...</');
document.write('a><');
document.write('/span><');
document.write('span class="layerUpperBarButtons"><');
document.write('a href="#" onclick="return hideLayer()" style="position: static;"><');
document.write('img src="'+images[0]+'" alt="close" title="close" style="border: 0; z-index: 10003;" /><');
document.write('/a><');
document.write('/span><');
document.write('/div><');
document.write('div style="width:100%; background-color:#000; padding-bottom:20px; padding-top:20px;"><');
document.write('a target="_blank" href="' + layerLink + '" onclick="javascript:layerHideAndOpen(); return false;"><img border="0" src="'+images[1]+'" alt="UseNeXT - Next Generation Downloading"" title="UseNeXT - Next Generation Downloading" style="cursor:pointer"><');
document.write('/a><');
document.write('/div><');
document.write('/div>');

function getTheElement(sId)
{
	if (document.getElementById) {
		return document.getElementById(sId)
	}
	else if (document.all) {
		return document.all[sId]
	}
	else if (document.layers) {
		return document.layers[sId]
	}
}

function moveLayer()
{
	myLayer.style.display = 'block';
	if (iLayerDirection == 0 && getX(myLayer) < iLayerEnd) {
		myLayer.style.left = Math.min(iLayerEnd, getX(myLayer) + iLayerDelta) + 'px';
		if (getX(myLayer) < iLayerEnd) {
			setTimeout("moveLayer()", iLayerTimer);
		}
	}
	else if (iLayerDirection == 1 && getY(myLayer) < iLayerEnd) {
		myLayer.style.top = Math.min(iLayerEnd, getY(myLayer) + iLayerDelta) + 'px';
		if (getY(myLayer) < iLayerEnd) {
			setTimeout("moveLayer()", iLayerTimer);
		}
	}
}

function getX(el)
{
	if (el.offsetParent) {
		return (el.offsetLeft + getX(el.offsetParent));
	}
	else {
		return (el.offsetLeft);
	}
}

function getY(el)
{
	if (el.offsetParent) {
		return (el.offsetTop + getY(el.offsetParent));
	}
	else {
		return (el.offsetTop);
	}
}

function layerHideAndOpen()
{
	hideLayer();
	window.open(layerLink);
	return false;
}

function hideLayer()
{
	removeLayer();
	return false;
}

function removeLayer()
{
	if (iLayerDirection == 0 && getX(myLayer) > iLayerStart) {
		myLayer.style.left = Math.max(iLayerStart, getX(myLayer) - iLayerDelta) + 'px';
	}

	if (iLayerDirection == 1 && getY(myLayer) > iLayerStart) {
		myLayer.style.top = Math.max(iLayerStart, getY(myLayer) - iLayerDelta) + 'px';
	}

	if (iLayerDirection == 0) {
		if (getX(myLayer) > iLayerStart) {
			setTimeout("removeLayer()", iLayerTimer);
		}
		else {
			myLayer.style.display = 'none';
			bLayerCheckScrolling = true;
		}
	}
	else if (iLayerDirection == 1) {
		if (getY(myLayer) > iLayerStart) {
			setTimeout("removeLayer()", iLayerTimer);
		}
		else {
			myLayer.style.display = 'none';
			bLayerCheckScrolling = true;
		}
	}
}

function startLayer()
{
	bLayerCheckScrolling = true;
	checkScroll();
	if (iLayerDirection == 0) {
		myLayer.style.left = iLayerStart + 'px';
		myLayer.style.top = iLayerPosition + 'px';
	}
	if (iLayerDirection == 1) {
		myLayer.style.top = iLayerStart + 'px';
		myLayer.style.left = iLayerPosition + 'px';
	}
	setTimeout("moveLayer()", iLayerStartDelay);
}

function checkScroll()
{
	if (!bLayerCheckScrolling) return;
	if(document.all)
	{
		if (document.documentElement && document.documentElement.scrollTop) {
			pos = document.documentElement.scrollTop
		}
		else if (document.body)	{
			pos = document.body.scrollTop
		}

		if (iLayerDirection == 0) {
			m = iLayerEnd;
		}
		else {
			m = iLayerPosition;
		}
		myLayer.style.top = pos + m + 'px';
		setTimeout("checkScroll()", iLayerScrollCheck);
	}
	else {
		myLayer.style.position = 'fixed';
	}
	
}

var myLayer = getTheElement('myLayer');
startLayer();
