function swfObjectStatus(e) {
	if (e.success == true) {
		// The SWF was embedded successfully, but we still need an exit function to allow SWFObject to
		// finish writing before activating any third party libraries that need to access the SWF
		setTimeout( function() {
			swffit.fit("runtimeID", 870, 600);
			swfmacmousewheel.registerObject("runtimeID");
		}, 1 );
	}
	else {
		// The SWF was not embedded, replacement content is shown
	}
}

function swfObjectExpressInstallCanceled() {
	// The user selected to cancel the express install process
}

function domLoadedHandler(){
	// If the user has FP 10 or above, go ahead and embed the real Flash site
	if (swfobject.hasFlashPlayerVersion("10")) {
		var flashvars = {
			region:region,
			configuration:flashConfigurationXML
		};
		var params = {
			wmode: "window", 
			allowScriptAccess:"always"
		};
		var attributes = {
			id: "runtimeID", 
			name: "runtimeID"
		};
		
		if (swfobject.getQueryParamValue("s")) {
			if( window.location.href.indexOf("#")!=-1 ) {
				window.location.href = '';
			}
			flashvars.sharedId = swfobject.getQueryParamValue("s");
		}
		
		swfobject.embedSWF(preloader || "preloader.swf", "container", "100%", "100%", "10.0.0", "expressInstall.swf", flashvars, params, attributes, swfObjectStatus);
	}
	else {
		$("#container div").show();
		$("#container img").show();
		
		swfobject.showExpressInstall({data: "expressInstall.swf", width: "100%", height: "240"}, {menu: false}, "expressInstall", swfObjectExpressInstallCanceled);
	}
}

/* Opens a popup window with the Facebook sharer */
function shareOnFacebook( u, t ) {
	var url = 'http://www.facebook.com/sharer.php';
	
	// We can only share if the URL (u) is specified
	if (u) {
		url += '?u=' + u; // url to share
		if (t) url += '&t=' + t; // title to share
		
		window.open(url, 'Facebook', 'toolbar=0,status=0,width=726,location=no,menubar=no,height=436');
	}
}

/* Opens a popup window for updating your Twitter status */
function shareOnTwitter( s ) {
	var url = 'http://twitter.com/home?status=' + s;
	
	window.open(url,'Twitter','toolbar=0,status=0,width=820,location=no,menubar=no,height=436');
}

swfobject.addDomLoadEvent(domLoadedHandler);
