
var loaded = false;						// flag to trigger swfobject once only
// jquery cycle (jqc)/flashvars configuration values
var jqcvars = {
	timeout: 7000,						// jqc interval, 7 secs
	speedIn: 2000,						// jquery cycle transition length
	speedOut: 500,						// jquery cycle transition length
	sync: 1,							// simultaneous in/out transitions on/off
	pause: 0,							// pause on target mouseover on/off
	before: null						// interval callback fn, clear unless swfref makes fn available
};
var flvars = {
	timeout: jqcvars.timeout,			// flash interval, cp from jqcvars
	before: "frontApp_cycleHandler",	// function by name to call if external iface fails
	allowbgexec: "true",				// enabled by default, but it's explicit here for readability
	sequence: "exclamation, exclamation, arrow, asterisk, speech, plus"
};

function frontApp_cycleHandler(info) {
	$('#splashText').cycle('next');
}
/**
 * swfobject callback (swfobject.embedSWF),
 * exec'd after the swf is created and initialized
 */	
var swfobject_completeHandler = function (status) {
	if (status.success && status.ref) {
		// flash is available
		var swfref = status.ref;
		var nextfn = function () {
			if (swfref && typeof swfref.next != "undefined") swfref.next();
		};
		if (typeof swfref.check != "undefined"
				&& swfref.check(true)) {
			// Flash external interface is available.
			// Using jqc's timer
			jqcvars.before = nextfn;		// pass external interface delegate fn
			$('#splashText').cycle(jqcvars);	// pass vars, let jqc play
		} else {
			// We have flash but it is not reachable
			// Using flash internal's timer
			jqcvars.timeout = 0;			// disable jqc timer
			$('#splashText').cycle(jqcvars);	// pass vars to jqc
			$('#splashText').cycle('pause');	// but pause it, and wait for flash calls
											// timeout should make this redundant, but seems broken
		}
	} else {
		// No flash, use jqc only
		$('#splashText').cycle(jqcvars);
	}
	swfobject.createCSS("#splashMediaContent", "visibility: visible;");
}; // end of swfobject callback

/**
 * loads and creates FrontApp.swf wrapper
 */
var document_completeHandler = function () {
	var params = { swliveconnect:"true", quality: "high", bgcolor:"#000000", wmode:"opaque", allowscriptaccess:"sameDomain" };
	var attrs = { id: "FrontApp", name: "FrontApp" };
	swfobject.embedSWF("/media/flash/splashpage.swf", "splashMediaContent", "380", "460", "9.0.0", "/js/swfobject/expressInstall.swf", 
		flvars, params, attrs, swfobject_completeHandler);
}; // end of document creation callback

swfobject.addLoadEvent(function () {
	if (loaded) return;
	loaded = true;
	document_completeHandler();
});
swfobject.addDomLoadEvent(function () {
	if (loaded) return;
	loaded = true;
	document_completeHandler();
});
