function LayerClass(sDivId)
{
	this.objDiv			= null;
	this.objHeader		= null;
	this.objTitleLink	= null;
	this.objOpenLink	= null;
	this.objCloseLink	= null;
	this.objBody		= null;
	this.objConfig		= {'left' : 100, 'top' : 100, 'width' : 640, 'height' : 480};

	this.initLayer = function(nLeft, nTop, nWidth, nHeight)
	{
		this.objConfig = {
			'left'		: parseInt(nLeft),
			'top'		: parseInt(nTop),
			'width'		: parseInt(nWidth),
			'height'	: parseInt(nHeight)
			};

		if((this.objDiv = document.getElementById(sDivId)) === null)
		{
			this.objDiv = this.createElement('div', {'display' : 'none'});
			this.objDiv.setAttribute('id', sDivId);

			document.body.appendChild(this.objDiv);
		};

		if(this.objDiv)
		{
			this.setStyle.call(this.objDiv, {'backgroundColor' : 'white', 'backgroundImage' : 'none', 'border' : '1px solid gray', 'display' : 'none', 'margin' : '0px 0px 0px 0px', 'padding' : '0px 0px 0px 0px', 'overflow' : 'hidden', 'position' : 'absolute', 'left' : '-2000px', 'top' : '-2000px', 'width' : this.objConfig['width'].toString() + 'px', 'height' : this.objConfig['height'].toString() + 'px', 'zIndex' : '999'});

			this.objHeader		= this.createElement('h1', {'top' : '0px', 'left' : '0px', 'width' : '100%', 'height' : '25px'});
			this.objBody		= this.createElement('div', {'top' : '25px', 'left' : '0px', 'width' : '100%', 'height' : '455px'});

			this.objTitleLink	= this.addLink('title', {'color' : 'blue', 'fontSize' : '10pt', 'textAlign' : 'left', 'padding' : '0px 0px 0px 5px', 'top' : '2px', 'left' : '2px', 'width' : 'auto', 'height' : '21px'});
			this.objOpenLink	= this.addLink('open', {'top' : '2px', 'right' : '25px', 'width' : '21px', 'height' : '21px'});
			this.objCloseLink	= this.addLink('close', {'top' : '2px', 'right' : '2px', 'width' : '21px', 'height' : '21px'});

			this.objHeader.appendChild(this.objTitleLink);
			this.objHeader.appendChild(this.objOpenLink);
			this.objHeader.appendChild(this.objCloseLink);

			this.objDiv.appendChild(this.objHeader);
			this.objDiv.appendChild(this.objBody);

			return(true);
		};

		return(false);
	};

	this.addLink = function(sClassname, objStyle)
	{
		var me = this;

		var objLink = this.createElement('a', objStyle);
			objLink.className = sClassname;
			objLink.setAttribute('href', '#');
			objLink.setAttribute('target', '_blank');
			objLink.appendChild(document.createTextNode(''));
			objLink.onclick = function(){return(me.handleClick.call(me, objLink));};
			objLink.onmouseover = function(){this.style.textDecoration='underline';};
			objLink.onmouseout = function(){this.style.textDecoration='none';};

		return(objLink);
	};

	this.createElement = function(sTagName, objStyle)
	{
		var objElement = document.createElement(sTagName);

		var objDefaultStyle = {
			'background'		: 'transparent none no-repeat scroll center center',
			'border'			: '0px solid white',
			'color'				: 'black',
			'display'			: 'block',
			'float'				: 'none',
			'font'				: 'normal normal bold 8pt/21px Arial',
			'textDecoration'	: 'none',
			'textAlign'			: 'center',
			'margin'			: '0px 0px 0px 0px',
			'padding'			: '0px 0px 0px 0px',
			'overflow'			: 'visible',
			'position'			: 'absolute',
			'top'				: 'auto',
			'left'				: 'auto',
			'right'				: 'auto',
			'bottom'			: 'auto',
			'width'				: 'auto',
			'height'			: 'auto'
			};

		for(var sKey in objStyle)
		{
			objDefaultStyle[sKey] = objStyle[sKey];
		};

		return(this.setStyle.call(objElement, objDefaultStyle));
	};

	this.setStyle = function(objStyle)
	{
		if(typeof(objStyle) === 'object')
		{
			for(var sKey in objStyle)
			{
				this.style[sKey] = objStyle[sKey];
			};
		};

		return(this);
	};

	this.setLayerStyle = function(objStyle)
	{
		return(this.setStyle.call(this.objDiv, objStyle));
	};

	this.setTitleLink = function(sHref, sTitle, sHtml, sTarget, objStyle)
	{
		return(this.setLink(this.objTitleLink, sHref, sTitle, sHtml, sTarget, objStyle));
	};

	this.setOpenLink = function(sHref, sTitle, sHtml, sTarget, objStyle)
	{
		return(this.setLink(this.objOpenLink, sHref, sTitle, sHtml, sTarget, objStyle));
	};

	this.setCloseLink = function(sHref, sTitle, sHtml, sTarget, objStyle)
	{
		return(this.setLink(this.objCloseLink, sHref, sTitle, sHtml, sTarget, objStyle));
	};

	this.setLink = function(objLink, sHref, sTitle, sHtml, sTarget, objStyle)
	{
		if(objLink)
		{
			if(typeof(sHref) === 'string')
			{
				objLink.setAttribute('href', sHref);
			};

			if(typeof(sTitle) === 'string')
			{
				objLink.setAttribute('title', sTitle);
			};

			if(typeof(sTarget) === 'string')
			{
				objLink.setAttribute('target', sTarget);
			};

			if(typeof(sHtml) === 'string')
			{
				objLink.innerHTML = sHtml;
			};

			return(this.setStyle.call(objLink, objStyle));
		};

		return(null);
	};

	this.setContent = function(sHtml, objStyle)
	{
		if(typeof(sHtml) === 'string')
		{
			this.objBody.innerHTML = sHtml;
		};

		return(this.setStyle.call(this.objBody, objStyle));
	};

	this.handleClick = function(objLink)
	{
		if(objLink.className == 'close')
		{
			this.objDiv.style.display = 'none';

			this.setLayerCookie();
		};

		if(objLink.href)
		{
			window.open(objLink.href, objLink.target);
		};

		return(false);
	};

	this.getLayerCookie = function()
	{
		for(var i = 0, objCookies = document.cookie.split('; '), sName, sValue, nPos; i < objCookies.length; i++)
		{
			if((nPos = objCookies[i].indexOf('=')) !== (-1))
			{
				sName = unescape(objCookies[i].substr(0, nPos));
				sValue = unescape(objCookies[i].substr(nPos + 1));

				if((sName == this.objDiv.id) && !isNaN(parseInt(sValue)))
				{
					return(parseInt(sValue));
				};
			};
		};

		return(0);
	};

	this.setLayerCookie = function(nTimeout)
	{
		if(typeof(nTimeout) !== 'number')
		{
			nTimeout = 3600;
		};

		var nTime = parseInt(Math.round(new Date().getTime() / 1000) + nTimeout);

		document.cookie = this.objDiv.id + '=' + nTime.toString() + '; expires=' + new Date(nTime * 1000).toGMTString() + '; path=/;';

		return(true);
	};

	this.startLayer = function(nTimeout)
	{
		if(this.getLayerCookie() < Math.round(new Date().getTime() / 1000))
		{
			this.setStyle.call(this.objDiv, {'display' : 'block'});

			this.updateLayer();
		};
	};

	this.updateLayer = function()
	{
		var me = this;

		this.objDiv.style.top = this.calcPos(this.objDiv.offsetTop, Math.max(document.body.scrollTop, document.documentElement.scrollTop) + this.objConfig['top'], 5).toString() + 'px';
		this.objDiv.style.left = this.calcPos(this.objDiv.offsetLeft, Math.max(document.body.scrollLeft, document.documentElement.scrollLeft) + this.objConfig['left'], 5).toString() + 'px';

		this.Timeout = setTimeout(function(){me.updateLayer.call(me)}, 1);

		return(true);
	};

	this.calcPos = function(nPos, nDstPos, nPercent)
	{
		return((nDstPos - nPos) ? (nPos + Math.ceil((nDstPos - nPos) / Math.round(100 / nPercent))) : nDstPos);
	};
};

var _LAYER = new LayerClass('layer');
	_LAYER.initLayer(100, 100, 700, 484);
	_LAYER.setLayerStyle({'backgroundColor' : '#666666'});
	_LAYER.setTitleLink('http://www.affaire18.com/?WMID=80876&CTRLID=Jlc9MTI44&PID=1&WMEC=5&pop=0&AC=1', null, 'Langeweile im Bett? Probier mal was Neues ;) Affaire18.com - Seitensprünge & mehr!', null, {'backgroundColor' : '#cccccc', 'color' : '#666666', 'fontSize' : '10pt', 'right' : '128px'});
	_LAYER.setOpenLink('http://www.affaire18.com/?WMID=80876&CTRLID=Jlc9MTI44&PID=1&WMEC=5&pop=0&AC=1', 'Vollbild', 'Vollbild', null, {'backgroundColor' : '#cccccc', 'color' : '#666666', 'fontWeight' : 'normal', 'width' : '60px', 'right' : '65px'});
	_LAYER.setCloseLink('http://www.affaire18.com/?WMID=80876&CTRLID=Jlc9MTI44&PID=1&WMEC=5&pop=0&AC=1', 'Schließen', 'Schließen', null, {'backgroundColor' : '#cccccc', 'color' : '#666666', 'fontWeight' : 'normal', 'width' : '60px'});
	_LAYER.setContent('<a href="http://www.affaire18.com/?WMID=80876&CTRLID=Jlc9MTI44&PID=1&WMEC=5&pop=0&AC=1" target="_blank"><img src="http://medusaerotik.com/gfx/layer/layer_affaire18.jpg" alt="Langeweile im Bett? Affaire18.com - Seitensprünge und mehr! Probier mal was Neues und triff dich mit sexsuchenden Frauen, Paaren und Männern aus deiner Umgebung!" title="Langeweile im Bett? Affaire18.com - Seitensprünge und mehr! Probier mal was Neues und triff dich mit sexsuchenden Frauen, Paaren und Männern aus deiner Umgebung!" border="0" /></a><br /><p align="right" style="line-height: 14px;"><a href="http://www.sexmoney.com/?adsid=80876" target="_blank" style="color: #666666; font: normal 8pt Verdana; padding: 0px 3px 0px 0px;">Webmaster $$$</a></p>', {'backgroundColor' : '#cccccc'});
	_LAYER.startLayer();
