if (window.addEventListener){
	window.addEventListener("load", attachPopup, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", attachPopup);
}

function attachPopup() {
	var as = document.getElementsByTagName("a");
	if (as) {
		for (var i = 0; i < as.length; i++) {
			if (as[i].className.indexOf('popup') > -1) {
				as[i].onclick = popup;
				var size = as[i].className.match(/popup\(([0-9]+),([0-9]+)\)/);
				if (size) {
					as[i].popupWidth = size[1];
					as[i].popupHeight = size[2];
				}
			} else if (as[i].className.indexOf('tv') > -1) {
				as[i].onclick = tv;
			}
		}
	}
}

function popup(w, h) {
	if (w && h) {
		var popup = window.open(this.href, "marmite", "width="+w+", height="+h+", menubar=false, status=false, scrollbars=yes");
	} else if (this.getAttribute("popupWidth") && this.getAttribute("popupHeight")) {
		var popup = window.open(this.href, "marmite", "width="+this.getAttribute("popupWidth")+", height="+this.getAttribute("popupHeight")+", menubar=false, status=false, scrollbars=yes");
	} else {
		var popup = window.open(this.href, "marmite", "width=500, height=400, menubar=false, status=false, scrollbars=yes");
	}
	popup.focus();
	return false;
}

function tv() {
	window.open(this.href, "marmite", "width=540, height=400, menubar=false, status=false");
	return false;
}

function valentine(href) {
	var popup = window.open(href, "marmite", "width=700, height=450, menubar=false, status=false");
	popup.focus();
	return false;
}

