// JavaScript Document

<!--

/*
if(	(navigator.userAgent.match(/iPhone/i))
		||
	(navigator.userAgent.match(/iPod/i))
		||
	(navigator.userAgent.match(/iPad/i))
		||
	(navigator.userAgent.match(/blackberry/i))
		||
	(navigator.userAgent.match(/android/i))
		||
	(navigator.userAgent.match(/IEMobile/i)) )
{
	
	//if(navigator.userAgent.match(/IEMobile/i)) alert(navigator.userAgent);
	location.replace("http://www.youtube.com/user/BlinderCommercials");
}
*/
	
var requiredVersion = "9.0.0";
	
$(document).ready(
	function() {
		var flashvars = {};
		var params = { bgcolor:"#FFFFFF", allowFullScreen:"true" };
		var attributes = { id:"site" };
		swfobject.embedSWF("site.swf", "flash", "100%", "100%", requiredVersion, "expressinstall.swf", flashvars, params, attributes, handleEmbed);
		MM_preloadImages("news/wp-content/uploads/2010/04/mastercard-sleepers.jpg");
	}
);

function handleEmbed(e)
{
	if(!e.success)
	{
		var playerVersion = swfobject.getFlashPlayerVersion();
		var playerInstalled = playerVersion.major != 0;
		if (playerInstalled)
		{
			var installedVersion = playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release;
			$("#noFlash").html("<h1>Hello!</h1><p>We've detected that you have Adobe Flash Player<sup>&reg;</sup> <strong>" + installedVersion + "</strong> installed, whereas this site requires version <strong>" + requiredVersion + "</strong> or higher.</p><p>Please <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">upgrade your Flash Player</a> and then return to us. It's free and only takes a moment.</p><br/><a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"><img src=\"images/get_flash_player.png\" alt=\"Get Adobe Flash Player&reg;\" title=\"Get Adobe Flash Player&reg;\" border=\"0\" width=\"113\" height=\"34\"/></a>");
		} else {
			$("#noFlash").html("<h1>Please install Flash Player!</h1><p>Hello! &nbsp;The free <a href=\"http://www.adobe.com/products/flashplayer/\">Adobe Flash Player<sup>&reg;</sup></a> is required to view this site.</p><p>Flash Player is a browser plug-in that delivers rich internet applications to over 99% of Internet users.</p><p>Please take a moment to <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">install Flash Player</a> and then return to us!</p><br/><a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"><img src=\"images/get_flash_player.png\" alt=\"Get Adobe Flash Player&reg;\" title=\"Get Adobe Flash Player&reg;\" border=\"0\" width=\"113\" height=\"34\"/></a>");
		}
	}
}

function getViewPort()
{
	//http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
	  viewportwidth = window.innerWidth,
	  viewportheight = window.innerHeight
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0)
	{
	   viewportwidth = document.documentElement.clientWidth,
	   viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	else
	{
	   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}

	return [viewportwidth, viewportheight];
}

//-->

//	called by flash to extend according to tiles
function resizeContentDiv(height)
{
	//alert(document.getElementById("flash"));
	//document.getElementById("content").style.width = getViewPort()[0]+"px";
	if(getViewPort()[1] > height) height = getViewPort()[1];
	document.getElementById("content").style.height = height+"px";
	//alert("ok " + document.getElementById("flash").style.height);
}

function scrollUp()
{
	window.scroll(0,0);	
}

//	handle user changing window size
window.onresize=function()
{
	//var currentWidth = document.getElementById("content").style.width;
	//var currentHeight = document.getElementById("content").style.height;
	//resizeContentDiv(getViewPort()[1]);
}

//-->
