$(document).ready(function() {
	oPotter = new potter();
});

function potter() {

	this.init = function() {
		var that = this;
		$('.systemrequirements').click(function() { that.showRequirements(); return false; });
		$('.viewtips').click(function() { that.showTips(); return false; });
		$('.forward').click(function() { window.location.href=this.href; return false; });
		$('#launch a').click(function() { that.launch(); return false; });
		$('#flashmovie').click(function() { that.showVideo(); return false; });

		var flashvars = {};
		flashvars.video = "video.flv";
		flashvars.autoplay = true;
		flashvars.videowidth = "600";
		flashvars.videoheight = "338";
		flashvars.autoscale = false;
		flashvars.playerpath = "flash/";
		var params = {};
		params.allowfullscreen = "true";
		params.allowscriptaccess = "always";
		params.scale = "noscale";
		params.salign = "tl";
		params.wmode = "transparent";
		var attributes = {};

		swfobject.embedSWF("flash/flvplayer.swf", "videoplayer", "600", "377", "9.0.0", "/videos/player/expressInstall.swf", flashvars, params, attributes);

		if (isReleased()) {
			window.setTimeout(function() { that.showVideo(); }, 3000);
		}

	};

	this.showRequirements = function() {
		$('#requirementsmodal').modal();
	};

	this.showTips = function() {
		$('#tipsmodal').modal();
	};

	this.emailUpdates = function() {
		$('#emailmodal').modal();
		pngfix($('#emailmodal img').get(0));
	};

	this.showVideo = function() {
		$('#videomodal').modal();
		$('#videoplayer').click(function() { return false; });
	};

	this.launch = function() {
		window.open('main.html', 'arplayer', 'width=640,height=480');
	};

	this.init();

};

function isReleased() {
	var Release = new Date("January 29, 2010 00:00:00");
	var Now = new Date();
	return Release < Now;
};

function pngfix(img) {

	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);

	if ((version >= 5.5) && (document.body.filters)) {

		if (img != undefined) {
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
			}
		}

	}

};