
var esy_clicked;

function esy_load() {
	//opactity('esy_layer', 0, 100, 500);
	
	preload = Array('topleft', 'top', 'close', 'left', 'right', 'bottomleft', 'bottom', 'bottomright');
	for(i = 0; i < preload.length; i++) {
		img = new Image()
		img.src = 'http://www.kazek.org/esy_layer/img/' + preload[i] + '.gif';
	}
	
	document.write('<div id="esy_layer" style="position: fixed; opacity: 0; -moz-opacity: 0; -khtml-opacity: 0; filter: alpha(opacity=0); display: none;  top: 100px; left: 150px;">' + 
 '	<table cellspacing="0" cellpadding="0">' + 
 '		<tr>' + 
 '			<td background="http://www.kazek.org/esy_layer/img/topleft.gif"></td>' + 
 '			<td background="http://www.kazek.org/esy_layer/img/top.gif"></td>' + 
 '			<td><a href="#" onclick="esy_close(); return false;"><img src="http://www.kazek.org/esy_layer/img/close.gif" alt="X" title="" border="0" /></a></td>' + 
 '		</tr>' + 
 '		<tr>' + 
 '			<td background="http://www.kazek.org/esy_layer/img/left.gif"></td>' + 
 '			<td bgcolor="#c0c0c0;"><div id="layer_content" onclick="esy_click();" style="width: 787px; height: 387px; overflow: auto;"><style type="text/css"><!--#layer_content { background-color: #999999;}--></style>' + 
 '' + 
 '<a href="http://www.gegner-suche.de/" target="_blank"><img src="http://www.kazek.org/werbelayer/img/gs_logo.jpg" alt="Special One" width="700" height="400" border="0" /></a></div></td>' + 
 '			<td background="http://www.kazek.org/esy_layer/img/right.gif"></td>' + 
 '		</tr>' + 
 '		<tr>' + 
 '			<td width="29" height="24" background="http://www.kazek.org/esy_layer/img/bottomleft.gif"></td>' + 
 '			<td background="http://www.kazek.org/esy_layer/img/bottom.gif" align="center"><a href="http://www.easycore.de/werbung" target="_blank" style="color: #000000; font-size: 15px; font-weight: normal; text-decoration: none; font-style: normal; font-family: Tahoma, Arial, sans-serif;">Ihre Werbung in diesem Layer</a></td>' + 
 '			<td width="29" background="http://www.kazek.org/esy_layer/img/bottomright.gif"></td>' + 
 '		</tr>' + 
 '	</table>' + 
 '</div>');
	document.getElementById('esy_layer').style.display = 'block';
	
	setTimeout("opacity('esy_layer', 0, 100, 500)", 200);
	
	count = new Image();
	count.src = 'http://www.kazek.org/esy_layer/layer_rep.php?ad=4&count=view';
}

function esy_close() {
	count = new Image();
	count.src = 'http://www.kazek.org/esy_layer/layer_rep.php?ad=4&count=close';
	opacity('esy_layer', 100, 0, 500)
	setTimeout("document.getElementById('esy_layer').style.display = 'none'", 1000);
}

function esy_click() {
	if(!esy_clicked)
	{
		count = new Image();
		count.src = 'http://www.kazek.org/esy_layer/layer_rep.php?ad=4&count=click';
		esy_clicked = 1;
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

esy_load();