var NN 		 = (document.layers ? true : false);
var hideName = (NN ? 'hide' : 'hidden');
var showName = (NN ? 'show' : 'visible');
var zIdx  = -1;
//var popurl = "http://cams.com/go/g1202317-pct";
var popurl = "http://cluster.adultadworld.com/redir/default.aspx?s=19708&c=2409";

function genLayer(sName, sLeft, sTop, sWdh, sHgt, sVis)
{
        var title = "7 Pics";
        var please = "Please leave this site if you are under 18";
        var agree = "I agree with this rule and I wish to";
        var linkEnter = "<A id='popup' HREF='javascript:hideSlide();'><font color='green' size=5>ENTER</font></A>";
        var linkExit = "<A HREF='javascript:window.close();'><font color='red' size=5>LEAVE</font></A>";
        var myBody = "<TABLE><TR><TD bgcolor='#E0E0E0' align='center' width='"+sWdh+"'><font color='black' size=5><br><br>"+title+"</font><br><br><font size=5>"+please+"</font><br><br><font color='black' size=5>"+agree+"</font><br><br><b>"+linkEnter+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+linkExit+"</b><br><br><br><br></TD></TR></TABLE>";

        var winwidth = document.body.clientWidth;
        var winheight = document.body.clientHeight;

        // Get the dimensions of the layer
        var layerwidth = sWdh;
        var layerheight = sHgt;

        // Centre the layer
        var sLeft = ((winwidth - layerwidth)/2) + "px";
        var sTop = ((winheight - layerheight)/2 - 50) + "px";

	if (NN)
        {
		document.write('<LAYER NAME="' + sName + '" LEFT=' + sLeft + ' TOP=' + sTop +
		' WIDTH=' + sWdh + ' HEIGHT=' + sHgt + ' VISIBILITY="' + sVis + '"' +
		' z-Index=' + zIdx + '>' + myBody + '</LAYER>');
	}
	else
        {
		document.write('<DIV ID="' + sName + '" STYLE="position:absolute; overflow:visible; left:' +
			sLeft + '; top:' + sTop + '; width:' + sWdh + 'px; height:' + sHgt + 'px;' +
			' visibility:' + sVis + '; z-Index:' + (++zIdx) + '">' +
			myBody + '</DIV>'
			);
	}
}

function hideSlide(name)
{
  var lastvisit = getCookie('7lastvisit');
  var exdate=new Date();
  var ms = exdate.getTime();
  exdate.setDate(exdate.getDate()+1);
  var timeSeconds = parseInt(ms/1000);
  if (!lastvisit || (timeSeconds - lastvisit) > 86400)
  {
     document.cookie = '7lastvisit='+timeSeconds+'; expires='+exdate.toGMTString()+'; path=/';
  }
  name = 'myLayer';
  refSlide(name).visibility = hideName;
  
  //window.open(popurl).blur();
  //window.focus();
}

function showSlide(name)
{
        name = 'myLayer';
        refSlide(name).visibility = showName;
}

function refSlide(name)
{
	if (NN) { return document.layers[name]; }
	else { return eval('document.all.' + name + '.style'); }
}