var Play = {

	iframe : null,

	init : function() {

		$("loading").hide();

		if (window == top) {

			// if the window is not in an iframe, load the iframe
			this.iframe = document.createElement("iframe");
			Element.extend(this.iframe);

			document.getElementsByTagName("body")[0].appendChild(this.iframe);
			this.iframe.setStyle({
					visibility: "hidden",
					position: "absolute",
					top: "0",
					left: "0",
					width: "1px",
					height: "1px",
					zIndex: "0"
			});

		} else {

			// otherwise pass the content on to the parent
			this.pass_content();

		}

	},

	load : function(url) {

		$("content").hide();
		$("loading").show();

		// change the iframe source
		this.iframe.src = "play/" + url;

	},

	loaded : function(content) {

		// write the new content to the page
		$("content").update(content);

		$("loading").hide();
		$("content").show();

	},

	pass_content : function() {

		// pass the content to the parent
		window.parent.Play.loaded($("content").innerHTML);

	}

}

Event.observe(window, "load", function(){ Play.init() });
