var pu_url = "http://www.filthads.com/filth.html";
var pu_reruntime = 3; //hours
var pu_width = 800;
var pu_height = 1100;

function createCookie(b, e, f) {
	var d = 60 * 60 * 1000 * f;
	var a = new Date();
	a.setTime(a.getTime() + (d));
	var c = "; expires=" + a.toGMTString();
	document.cookie = b + "=" + e + c + "; path=/";
}

function getCookie(a) {
	var b = document.cookie.match("(^|;) ?" + a + "=([^;]*)(;|$)");
	if (b) {
		return (unescape(b[2]));
	}
	else {
		return null;
	}
}

function pu() {
	if (getCookie("fdp_timeout") == 1) {
		return true;
	}

	createCookie("fdp_timeout", 1, pu_reruntime);
	var b = "toolbar=1,statusbar=1,resizable=1,scrollbars=1,menubar=1,location=1,directories=0";

	if (navigator.userAgent.indexOf("Chrome") != -1) {
		b = "scrollbar=yes";
	}

	var a = window.open("about:blank", "", b + ",height=" + pu_width + ",width=" + pu_height);

	if (navigator.userAgent.indexOf("rv:2.") != -1 || navigator.userAgent.indexOf("rv:5.") != -1) {
		a.puPop = function (c) {
			if (navigator.userAgent.indexOf("rv:2.") != -1 || navigator.userAgent.indexOf("rv:5.") != -1) {
				this.window.open("about:blank").close();
			}
			this.document.location.href = c;
		};
		a.puPop(pu_url)
	}
	else {
		a.document.location.href = pu_url;
	}

	setTimeout(window.focus);
	window.focus();

	if (a) {
		a.blur();
	}
	else {
		done_pu = null;
		ifSP2 = false;

		if (typeof (pu_window) == "undefined") {
			pu_window = false;
		}
		if (window.SymRealWinOpen) {
			open = SymRealWinOpen;
		}
		if (window.NS_ActualOpen) {
			open = NS_ActualOpen;
		}

		ifSP2 = (navigator.userAgent.indexOf("SV1") != -1);

		if (!ifSP2) {
			doPu();
		}
		else {
			if (window.Event) {
				document.captureEvents(Event.CLICK);
			}
			document.onclick = doClickedPu;
		}

		self.focus();
		doClickedPu();
	}

	trackClick('friend', 207);
}

function doPu() {
	if (!pu_window) {
		done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");

		if (done_pu) {
			pu_window = true;
			self.focus();
		}
	}
}

function doClickedPu() {
	if (!pu_window) {
		if (!ifSP2) {
			done_pu = open(pu_url, "", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");
			self.focus();

			if (done_pu) {
				pu_window = true;
			}
		}
	}

	if (!pu_window) {
		if (window.Event) {
			document.captureEvents(Event.CLICK);
		}

		document.onclick = doPu;
		self.focus();
	}
}

function initPu() {
	if (document.attachEvent) {
		document.attachEvent("onclick", pu);
	}
	else if (document.addEventListener) {
		document.addEventListener("click", pu, false);
	}

	return true;
}

initPu();

