function puInit(data) {
	var getCookie = function (name) {
		var val = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
		return val? unescape(val[2]) : null;
	}
	var setCookie = function (name, value, exdays) {
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + exdays);
		var c_value=escape(value) + "; path=/" + ((exdays == null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=name + "=" + c_value;
	}
	var pu = function(e) {
		var ok = false;
		var elem = e.target;
		while (typeof elem == "object") {
			if (elem.tagName == undefined) {
				return;
			}
			if (elem.tagName.toLowerCase() == "a") {
				ok = true;
				break;
			}
			elem = elem.parentNode;
		}
		if (data.url != undefined && ok && this.alreadyClicked == undefined) {
			this.alreadyClicked = true;
		} else {
			return;
		}
		if (data.frequency == undefined) {
			data.frequency = 0;
		}
		if (data.height == undefined) {
			data.height = 600;
		}
		if (data.width == undefined) {
			data.width = 1000;
		}

		var count = parseInt(getCookie("popunder_count"));
		count = count? (count + 1) : 1;
		setCookie("popunder_count", count);
		if ((data.frequency == 0 && count > 1) || (data.frequency > 0 && count % data.frequency != 0)) {
			return;
		}
		var screenTop = (window.screenTop != undefined) ? window.screenTop : window.screenY;
		var screenLeft = (window.screenLeft != undefined) ? window.screenLeft : window.screenX;
		var screenW = 0;
		var screenH = 0;
		if (typeof window.innerWidth == "number") { 
			screenW = window.innerWidth;
			screenH = window.innerHeight; 
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
			screenW = document.documentElement.clientWidth; 
			screenH = document.documentElement.clientHeight; 
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { 
			screenW = document.body.clientWidth; 
			screenH = document.body.clientHeight; 
		}
		var pxLeft = (screenLeft + (screenW / 2) - (data.width / 2));
		var pxTop = (screenTop + (screenH / 2) - (data.height / 2));
		var win = window.open(data.url, "pornpop", "width=" + data.width + ", height=" + data.height + ", scrollbars=yes,resizable=yes,toolbar=no, menubar=no,status=no,location=no,left=" + pxLeft + ",top=" + pxTop);
		win.blur();
		window.focus();
		if (typeof win.window.mozPaintCount != "undefined") {
			win.window.open("about:blank").close();
			window.focus();
		}
	}
	var waiting = function () {
		if (document.body == null) {
			setTimeout(waiting, 50);
		} else {
			document.body.onclick = pu;
		}
	}
	waiting();
}
