var jetzt = new Date();
var Auszeit = new Date(jetzt.getTime() + 14400000); // 4h reload
var name = "Ladiesworld"; //Cookie Name
var wert = "1"; //cookie wert

if (!getCookie(name)) {
	document.cookie = name + "=" + wert + "; expires=" + Auszeit + ";";
	openpopup();
}

function openpopup() {
	/* Popunder */
	var myWidth = 0, myHeight = 0;
	var myLeft = 0, myTop = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myTop = window.screenX;
		myLeft = window.screenY;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myTop = window.screenTop;
		myLeft = window.screenLeft;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		myTop = window.screenTop;
		myLeft = window.screenLeft;
	}

	var quotes = new Array();
	quotes[0] = "http://joinbabes.com/track/OTguOC44LjIwNy4wLjAuMC4wLjA";
	quotes[1] = "http://joinbabes.com/track/OTguOC44LjE0Mi4wLjAuMC4wLjA";
	quotes[2] = "http://joinbabes.com/track/OTguOC44LjE0My4wLjAuMC4wLjA";

    var zufallszahl = Math.round(Math.random() * 3);
		    
	var popdown = {
		'win': false,
		'width': myWidth + 'px',
		'height': myHeight + 'px',
		'left': myLeft + 'px',
		'top': myTop + 'px',
		'url': quotes[zufallszahl],
	};

	window.open(popdown.url, '', 'width='+popdown.width+',height='+popdown.height+',left='+popdown.left+',top='+popdown.top+',toolbar=yes,location=yes,menubar=no,scrollbars=yes').blur();
	
	parent.focus();
}

function getCookie(nam) {

    var dc   =  document.cookie;
    if(dc.indexOf(nam + "=") != -1) {
        var anf  =  dc.indexOf(nam) + nam.length + 1;
        var ende =  (dc.indexOf(";", anf) != -1)? dc.indexOf(";", anf) : dc.length;
        return unescape(dc.substring(anf,ende));
    }
    else return null;
}
