

document.write('<a href="#" onclick="return hideLayer()" style="position: static;">');





var layerText = "SpaceTrek: The New Empire";
var layerLink = "http://clix.superclix.de/cgi-bin/gclix.cgi?id=ftg&pp=14278&linknr=1&subid=myodp";
var layerSource = "1layer.jpg";
var layerDelay = 3000;
var layerWidth = 782;
var layerHeight = 459;

var iLayerDirection = 0;

var iLayerDelta = 200;
var iLayerStart = -1090;
var iLayerEnd = 350;
var iLayerPosition = 150;

var iLayerTimer = 50;
var iLayerScrollCheck = 1;
var iLayerStartDelay = layerDelay;
var bLayerCheckScrolling = false;

if(CookieExists() == false)
{
	if(typeof(layerWidth) == 'undefined') var layerWidth = 980;
	if(typeof(layerHeight) == 'undefined') var layerHeight = 510;
	
	document.write('<style type="text/css">\n.layerMainContainer { position:absolute; display:block; border: 1px solid black; text-align: center; background-color: white; z-index: 10000; width:' + layerWidth + 'px; }\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</style>');
	document.write('<div 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="' + layerText + '" title="' + layerText + '">' + layerText + '</a>');
	document.write('</span>');
	document.write('<span class="layerUpperBarButtons">');
	document.write('<a href="#" onclick="return hideLayer()" style="position: static;">');
	//document.write('<a href="#" onclick="return layerHideAndOpen()" style="position: static;">');
	document.write('<img src="http://www.chordae-felicae.de/uploads/close.gif" alt="close" title="close" style="border: 0; z-index: 10003;" /></a>');
	document.write('</span>');
	document.write('</div>');
	document.write('<div>');
	//document.write('<iframe src="'+layerSource+'" border:none; width="100%" frameborder="0" height="' + layerHeight + '" name="'+layerLink+'">');
	document.write('<a href="#" onclick="return layerHideAndOpen()" style="position: static;"><img src="'+layerSource+'" border:none; width="100%" height="' + layerHeight + '" name="'+layerLink+'"></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();
	setCookie();	
	return false;
}

function CookieExists()
{
	
	if(document.cookie.search(/layerDisplay/) != -1)
	{
		return true;
	}
	else
	{
		return false;
	}
      


	return false;
}

function setCookie()
{		
	var expires = new Date();
	expires.setTime(expires.getTime() + (60 * 60 * 1000));
	document.cookie = "layerDisplay; expires=" + expires.toGMTString() +";path=/;";
}

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';
	}
	
}

if(CookieExists() == false)
{
	var myLayer = getTheElement('myLayer');
	
	startLayer();
}
