var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
var winwidth = document.body.clientWidth;
var winheight = document.body.clientHeight;
  
function load(){
var x = readCookie('reklama')
 if (!x) {
    createCookie('reklama','reklama',3); //jak často bude zobrazováno min
    createWindow();
    setTimeout("show();",4000); //zpoždění zobrazení 1000=1s
    setTimeout("hidebox();",20000); //jak dlouho bude zobrazeno
 }
}

function rand(l,u) // lower bound and upper bound
{
 return Math.floor((Math.random() * (u-l+1))+l);
}

function show(){
    var divbox=document.getElementById("showimage")
    // Get the dimensions of the layer
    var layerwidth = divbox.clientWidth;
    var layerheight = divbox.clientHeight;
    // Centre the layer
    if (((winheight - layerheight)/2)>350){horni=225;}else{horni=(winheight - layerheight)/2;}
    divbox.style.left = ((winwidth - layerwidth)/2) + "px";
    divbox.style.top = horni + "px";
  if (ns4||ns6) {
    divbox.style.visibility="visible";
  }else{
    divbox.style.filter="progid:DXImageTransform.Microsoft.Wheel(spokes=8) progid:DXImageTransform.Microsoft.Alpha( style=0,opacity=90)";
    divbox.filters[0].Apply();
    divbox.style.visibility="visible";
    divbox.style.backgroundColor="#e4e4e4";
    divbox.filters[0].Play();
  }
}

function createWindow(){
 document.write("<div id=\"showimage\" style=\"background-color:#e4e4e4;visibility:hidden;-moz-opacity:.90;opacity:.90;position:absolute;width:250px;height:270px;\">");
 document.write("<table border=\"0\" width=\"250px\" cellspacing=\"0\" cellpadding=\"0\"><tr height=\"14px\">");
 document.write("<td align=\"left\" valign=\"middle\" id=\"dragbar\" style=\"background-color:#9a9a9a;cursor:hand; cursor:pointer\" onMousedown=\"initializedrag(event)\">");
 document.write("<ilayer width=\"100%\" onSelectStart=\"return false\">");
 document.write("<layer width=\"100%\" onMouseover=\"dragswitch=1;if (ns4) drag_dropns(showimage)\" onMouseout=\"dragswitch=0\">");
 document.write("<font face=\"Verdana\" color=\"#FFFFFF\"><strong><small>&nbsp;Reklama</small></strong></font>");
 document.write("</layer></ilayer></td><td align=\"right\" valign=\"middle\" style=\"background-color:#9a9a9a;cursor:hand; cursor:pointer\" wigth=\"16px\">");
 document.write("<a href=\"#\" onClick=\"hidebox();return false\"><img src=\"close.gif\" width=\"16px\" height=\"14px\" border=0>");
 document.write("</a>&nbsp;</td></tr><tr><td colspan=\"2\">");
 //text reklamy
 tmp = new Date(); 
 tmp = "?"+tmp.getTime(); 
 switch (rand(1,5)){
   case 1:
    document.write("<a href=\"http://sex.pavlinka.cz\" target=\"_blank\"><img src=\"sex.pavlinka.gif"+tmp+"\" title=\"SEX.PAVLINKA.CZ\" border=\"0\" style=\"width:250px;height:250px;\"></a>");
   break
  case 2:
    document.write("<a href=\"http://sexshop.pavlinka.cz/\" target=\"_blank\"><img src=\"sexshop.pavlinka.gif"+tmp+"\" title=\"SEXSHOP.PAVLINKA.CZ\" border=\"0\" style=\"width:250px;height:250px;\"></a>");
   break
  case 3:
    document.write("<a href=\"http://sex.pavlinka.cz\" target=\"_blank\"><img src=\"sex.pavlinka.gif"+tmp+"\" title=\"SEX.PAVLINKA.CZ\" border=\"0\" style=\"width:250px;height:250px;\"></a>");
   break
  case 4:
    document.write("<a href=\"http://sexshop.pavlinka.cz/\" target=\"_blank\"><img src=\"sexshop.pavlinka.gif"+tmp+"\" title=\"SEXSHOP.PAVLINKA.CZ\" border=\"0\" style=\"width:250px;height:250px;\"></a>");
   break
  case 5:
    document.write("<a href=\"http://sexshop.pavlinka.cz/\" target=\"_blank\"><img src=\"sexshop.pavlinka.gif"+tmp+"\" title=\"SEXSHOP.PAVLINKA.CZ\" border=\"0\" style=\"width:250px;height:250px;\"></a>");
   break
 }
 document.write("</td></td></table>");
 //konec textu reklamy
 document.write("</div>");
}
 
//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}

function createCookie(name,value,minutes) {
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

load(); 
