// JavaScript Document
if(flashDetect()){
	var url = document.URL;	
	
	var live = liveFlashvars.appMode != "local";
	var livePattern = new RegExp("(http[s]?:\/\/[\\w]*\\.jaguar\\.(?:[\\w]{1,3})(?:\\.[\\w]{1,3})?\/[\\w]{2}\/[\\w]{2}\/)(.*)");
	
	var redirect =  url.indexOf('#') == -1 ;
	var params = {bgcolor:'#000000',allowscriptaccess:'always'};
	var attributes = { id:'my_flash', styleclass:'noOutline'};
	var flashvars = liveFlashvars;
	var swfURL = live ? "/content/global/flash/Main.swf" : "Main.swf";
		
	if( redirect && live){
		
		var redirectURL= url.replace(livePattern, '$1#/$2');
		var isMainPage = redirectURL.search( /(#\/)$/g ) + 2 == redirectURL.length; // nothing after #/ so no deep link. In this case wee need reload instead of redirect
		if( isMainPage ){ 
			location.hash = '#/';
			location.reload();
		}
		location.href = redirectURL;
	}
	
	embeddSWF(swfURL,flashvars,params,attributes);
	
	
	
	if( isSafari() ){
		params.wmode = "transparent";			 
	}
}

function isSafari() {
	var agent=navigator.userAgent.toLowerCase();
	if (agent.indexOf("safari") != -1) return true;
	return false;
}
function embeddSWF(url,vars,params,attributes){
	
		swfobject.embedSWF(url, "my_flash", "980", "576", "9.0.0", "/content/global/js/expressInstall.swf", vars, params, attributes);
		swffit.fit('my_flash', '980', '576', '980', '576', true, true);
	
}

var flashed;
function flashDetect( ){

	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
	if(plugin){		
		flashed = plugin;		
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0  && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('flashed = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash")))\n');
		document.write('</SCR' + 'IPT\> \n');
	}
	return flashed	
}
