var msDelay = 100;
var flashObjects = [];
var flashIDs = [];
var hasSetSWFObjectLoadEvent = false;
function forceRedrawOfAllSWFs() {
	var id = '';
	for (var i=0; i < flashIDs.length; i++) {
		id = flashIDs[i];
		var obj = document.getElementById(id);
		if(obj != null)
			obj.style.display = "block";
	};
}
function smForceEmbedOfAllSWFs() {
	for (var i=0; i < flashObjects.length; i++) {
		var o = flashObjects[i];
		swfobject.embedSWF(o.swf, o.id, o.w, o.h, o.ver, o.expressInstall, o.flashvars, o.params, o.attributesArray, null);
	};
}

function smQueueEmbed(swf, id, w, h, ver, expressInstall, flashvars, params, attributes) {
	if(Browser.Engine.gecko == true) {
		flashIDs.push(attributes.id);
		// swf = swf + '?nocache=' + Math.floor(Math.random() * 10000).toString();
		var o = {
					swf: swf,
					id: id,
					w: w,
					h: h,
					ver: ver,
					expressInstall: expressInstall,
					flashvars: flashvars,
					params: params,
					attributesArray: attributes
				};
		flashObjects.push(o);
		msDelay += 0;
		
		if(hasSetSWFObjectLoadEvent == false) {
			hasSetSWFObjectLoadEvent = true;
			swfobject.addLoadEvent(smForceEmbedOfAllSWFs);
		}
	} else {
		swfobject.embedSWF(swf, id, w, h, ver, expressInstall, flashvars, params, attributes);
	}
}

function smEmbedSWF(swfURL, holderID, swfID, width, height, targetURL, targetWindow, isLightbox, mediaTitle, mediaWidth, mediaHeight) {
	if(isLightbox == undefined || isLightbox == null)
		isLightbox = false;
	if(mediaWidth == undefined || mediaWidth == null) {
		mediaWidth = "0";
		mediaHeight = "0";
	}
	if(mediaTitle == undefined || mediaTitle == null)
		mediaTitle = '';
	mediaWidth = mediaWidth.toString();
	mediaHeight = mediaHeight.toString();
	if(targetWindow == undefined || targetWindow == null)
		targetWindow = '_self'
	// define flashVars
	var fv = {
						targetURL: targetURL,
						targetWindow: targetWindow,
						isLightbox: isLightbox,
						mediaTitle: mediaTitle,
						mediaWidth: mediaWidth,
						mediaHeight: mediaHeight
					};
	// define params
	var pa = {
					wmode: 'transparent',
					menu: 'false',
					allowfullscreen: 'false',
					allowscriptaccess: 'always',
					quality: 'high',
					scale: 'noscale',
					salign: 'tl',
					base: '/',
					bgcolor: '#FFFFFF'
				 };
	// define attributes
	var at = {
					id: swfID
				 };
	smQueueEmbed(swfURL, holderID, width, height, "9.0.115", "/swf/expressInstall.swf", fv, pa, at);
}

function smLightbox(url, title, width, height) {
	// Add pixels if this is a Quicktime movie for the video control bar.
	if(url.indexOf('.mov') > -1 || url.indexOf('.mp4') > -1) {
		height = parseInt(height, 10) + 16;
	}
	Mediabox.open(url, title, width.toString() + ' ' + height.toString());
	return false;
}