// We'll add back the closure and makeit a real object soon
// do not add the closure, the myplate uses this file and dynamically loads and calls its functions.
// (function(){

	var siteWidth = 990; // 990;
	var headerHeight = 144;

	var originalOnLoad = window.onload;
	window.onload = function() {
		if(typeof originalOnLoad == "function") {
			originalOnLoad();
		}
		document.onclick = sidesClickable;
		document.onmousemove = sidesClickableCursor;

		// Show the word advertisement at the upper right.
		var div = document.createElement("div");
		div.innerHTML = "Advertisement";
		div.style.position = "absolute";
		div.style.top = "155px";
		div.style.right = "10px";
		div.style.color = "#666";
		document.body.appendChild(div);
	}

	function sidesClickable(e) {
		if(detect(e)) {
			// document.location = takeover_link;
			window.open (takeover_link);
		}
	}

	function sidesClickableCursor(e) {
		if(detect(e)) {
			document.body.style.cursor = "pointer";
		} else {
			document.body.style.cursor = "default";
		}
	}

	function detect(e) {
		if (!e) var e = window.event;

		var windowWidth = document.body.clientWidth;
		var marginWidth = (windowWidth - siteWidth) / 2;

		if(
			(
				(e.clientX > 0 && e.clientX < marginWidth)
				||
				(e.clientX > siteWidth+marginWidth && e.clientX < windowWidth)
			)
			&& 
			(
				(e.clientY > headerHeight)
			)
		) {
			return(true);
		}

		return(false);
	}

// })();