var o5Flash_SWFContainer = null;
var o5Flash_SWFContainer_count = 0;

var o5Flash_SWFContainer_Special = null; //Assoc-Array of Booleans
var o5Flash_SWFContainer_Special_IDArray = null; // Array of Movie-IDs
var o5Flash_SWFContainer_Special_count = 0;

var o5Flash_GrayLayerMovie = null;
var o5Flash_GrayLayer_TransBG_ID = null;
var o5Flash_GrayLayer_Movie_ID = null;
var o5Flash_GrayLayer_MovieWrapper_ID = null;
var o5Flash_GrayLayer_Movie_Width = null;
var o5Flash_GrayLayer_Movie_Height = null;
var o5Flash_GrayLayer_Close_Button = null;
var o5Flash_GrayLayer_Movie_GrandParentHeight = null;
var o5Flash_GrayLayer_Movie_GrandParent = null;

var o5Flash_GrayLayer_ClickLink_DomObj = null;
var o5Flash_GrayLayer_ClickLink_Url = null;
var o5Flash_GrayLayer_ClickLink_MovieID = null;

$.fn.outerHTML = function() {
    var doc = this[0] ? this[0].ownerDocument : document;
    return $('<div>', doc).append(this.eq(0).clone()).html();
};

function o5Flash_placeFlashMovie(url, loaderGifUrl, movieID, width, height, flashVersion, expressInstallUrl)
{
	var path = ".";//url.substr(0, url.lastIndexOf("/")+1);
//	alert(path);
	if(o5Flash_SWFContainer == null)
		o5Flash_SWFContainer = new Object();
	movie = new Object();
	movie.loaded = false;
	movie.url = url;
	movie.loaderGifUrl = loaderGifUrl;
	movie.movieID = movieID;
	movie.width = width;
	movie.height = height;
	movie.flashVersion = flashVersion;
	movie.expressInstallUrl = expressInstallUrl;
	movie.flashvars = {};
	movie.params = { allowFullScreen: true, wmode: $.browser.msie ? "transparent" : "none"};
	movie.attributes = {};
	o5Flash_SWFContainer[movieID] =  movie;
	o5Flash_SWFContainer_count++;
	
	o5Flash_registerMovieIDForSpecialPurposes(movieID);
}

function o5Flash_registerMovieIDForSpecialPurposes(movieID)
{
	if(o5Flash_SWFContainer_Special == null)
		o5Flash_SWFContainer_Special= new Object();
	if(o5Flash_SWFContainer_Special_IDArray == null)
		o5Flash_SWFContainer_Special_IDArray = new Object();
	if(o5Flash_SWFContainer_Special[movieID] === undefined) {
		o5Flash_SWFContainer_Special[movieID] = true;
		o5Flash_SWFContainer_Special_IDArray[o5Flash_SWFContainer_Special_count] = movieID;
		o5Flash_SWFContainer_Special_count++;
	}
}


function o5Flash_loadMainMovie(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;
		loadedMovie = $("#" + loadingMovie_id);
		
		wrappingMovie_id = "WrappingMovie_" + movieID;
		loadedMovie.wrap("<div id=\"" + wrappingMovie_id + "\"></div");
		movieWrapper = $("#" + wrappingMovie_id);
		movieWrapper.css("width", "0px");
		movieWrapper.css("height", "0px");
		
		movieWrapper.css("position", "absolute");
		movieWrapper.css("left", "0px");
		movieWrapper.css("top", "0px");
		movieWrapper.css("z-index", "2");
		
		swfobject.embedSWF(
    		"/Style%20Library/MovieLoader.swf",
    		loadingMovie_id,
    		movie.width,
    		movie.height,
    		movie.flashVersion,
    		movie.expressInstallUrl,
    		{swfUrl: movie.url, movieID: movieID, movieWidth: movie.width, movieHeight: movie.height},
    		movie.params,
    		{style: "width: 1px; height: 1px;"}
    	);
    	
	}
}

function o5Flash_loadingMainMovieComplete(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;
		
		preloaderMovie = $("#" + movieID);
		preloaderMovie.remove();
		
		$(window).bind('resize', o5Flash_NormalMovie_WindowResize);
		$(window).bind('scroll', o5Flash_NormalMovie_WindowResize);

		o5Flash_positionMovieWrapperNormalized(movieID);
	}
}

function o5Flash_NormalMovie_WindowResize()
{
	if(!$.browser.msie)
		return;
	for (var movieID in o5Flash_SWFContainer)
	{
		movie = o5Flash_SWFContainer[movieID];
		loadingMovie_id = "LoadingMovie_" + movieID;
		
		//only NOT maximized movies get repositioned here
		if(o5Flash_GrayLayerMovie != movie)
			o5Flash_positionMovieWrapperNormalized(movie.movieID);
	}
}

function o5Flash_positionMovieWrapperNormalized(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadedMovie = $("#" + loadingMovie_id);
		loadedMovie.css("width", movie.width + "px");
		loadedMovie.css("height", movie.height + "px");
		
		wrappingMovie_id = "WrappingMovie_" + movieID;
		movieWrapper = $("#" + wrappingMovie_id);
		movieWrapper.css("width", movie.width + "px");
		movieWrapper.css("height", movie.height + "px");
		movieWrapper.parent().parent().css("height", movie.height + "px");
		var offset = movieWrapper.parent().offset();
		if(offset != null) {
			movieWrapper.css("left", offset.left + "px");
			movieWrapper.css("top", offset.top + "px");
		}
	}
}



function o5Flash_loadAVM1Movie(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;
		loadedMovie = $("#" + loadingMovie_id);
		nextMovie = loadedMovie.after("<div id='" + movieID + "'>MOIN</div>");
		loadedMovie.remove();
		swfobject.embedSWF(
    		"/Style%20Library/As2MovieLoader.swf",
    		movieID,
    		movie.width,
    		movie.height,
    		"8",
    		movie.expressInstallUrl,
    		{swfUrl: movie.url, movieID: movieID, movieWidth: movie.width, movieHeight: movie.height},
    		movie.params,
    		{}
    	);

	}
}

function o5Flash_loadingAVM1MovieComplete(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;		
	}
}

function o5Flash_stageResized(width, height)
{
	//alert("RESIZED: " + width + " X " + height);
}

function o5Flash_showGrayLayer(movieID, grayMovWidth, grayMovHeight, showCloseButton, anyData)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;
		grayLayerTransBG_id = "GrayLayerTransBG_" + movieID;
		grayLayerMovie_id = "GrayLayerMovie_" + movieID;
	    wrappingMovie_id = "WrappingMovie_" + movieID;
	    closeButton_id = "CloseButton_" + movieID;

		o5Flash_GrayLayerMovie = movie;
		o5Flash_GrayLayer_TransBG_ID = grayLayerTransBG_id;
		o5Flash_GrayLayer_Movie_ID = grayLayerMovie_id;
		o5Flash_GrayLayer_Movie_Width = grayMovWidth;
		o5Flash_GrayLayer_Movie_Height = grayMovHeight;
		o5Flash_GrayLayer_MovieWrapper_ID = wrappingMovie_id;
		
		if(showCloseButton && o5Flash_GrayLayer_Close_Button == null) {
			$("#" + wrappingMovie_id).prepend("<a style=\"display: inline;\" id=\"" + closeButton_id + "\" href=\"#\"><img style=\"display: inline;\" src=\"/SiteCollectionImages/bu_close.gif\" /></a>");
			o5Flash_GrayLayer_Close_Button = $("#" + closeButton_id);
			o5Flash_GrayLayer_Close_Button.css("position", "absolute");
			//o5Flash_GrayLayer_Close_Button.css("display", "block");
			o5Flash_GrayLayer_Close_Button.css("width", "20px");
			o5Flash_GrayLayer_Close_Button.css("height", "20px");
			
			closeBtn_PosOfs = -20;
			
			o5Flash_GrayLayer_Close_Button.css("left", (grayMovWidth - (20 + closeBtn_PosOfs)) + "px");
			o5Flash_GrayLayer_Close_Button.css("top", closeBtn_PosOfs + "px");
			o5Flash_GrayLayer_Close_Button.css("z-index", "3");
			o5Flash_GrayLayer_Close_Button.click(function() {
				o5Flash_closeGrayLayer(movieID);
			});
		}
		
		$(window).bind('resize', o5Flash_GrayLayer_WindowResize);
		$(window).bind('scroll', o5Flash_GrayLayer_WindowResize);
		
		//if(!$.browser.msie)
		o5Flash_HideOtherFlashMovies(movieID);
		
        o5Flash_createGrayLayer(movieID);
		o5Flash_positionMovieWrapperMaximized(movieID, grayMovWidth, grayMovHeight);    	
		o5Flash_GrayLayer_WindowResize();
	}
}


function o5Flash_positionMovieWrapperMaximized(movieID, maxWidth, maxHeight)
{
	movie = o5Flash_SWFContainer[movieID];
	if(!(movie === undefined) && movie != null)
	{
		loadingMovie_id = "LoadingMovie_" + movieID;
		wrappingMovie_id = "WrappingMovie_" + movieID;
		loadedMovie = $("#" + loadingMovie_id);
		loadedMovie.css("width", maxWidth + "px");
		loadedMovie.css("height", maxHeight + "px");
		movieWrapper = $("#" + wrappingMovie_id);
		movieWrapper.css("width", maxWidth + "px");
		movieWrapper.css("height", maxHeight + "px");
		movieWrapper.css("left", ($(window).width()/2 - maxWidth/2) + "px");
		movieWrapper.css("top", ($(window).height()/2 - maxHeight/2) + "px");
	}
}


function o5Flash_HideOtherFlashMovies(movieID)
{
	for (i = 0; i < o5Flash_SWFContainer_Special_count; i++) {
		currMovieID = o5Flash_SWFContainer_Special_IDArray[i];
		
		if(movieID != o5Flash_SWFContainer_Special_IDArray[i]) {
			objectMovie_id = null;
			if(o5Flash_SWFContainer[currMovieID] === undefined)
				objectMovie_id = currMovieID;
			else
				objectMovie_id = "LoadingMovie_" + currMovieID;
			
			if($.browser.msie) {
				wrappingMovie_id = "WrappingMovie_" + currMovieID;
				movieWrapper = $("#" + wrappingMovie_id);
				movieWrapper.css("z-index", "0");
				continue;
			}
			
			movieObject = $("#" + objectMovie_id);
			
			//create replacing div
			movieReplacer_id = "MovieReplacer_" + currMovieID;
			movieReplacer = $("#" + movieReplacer_id);
			if(movieReplacer.length == 0) {
				movieObject.parent().append("<div id=\"" + movieReplacer_id + "\"></div>");
				movieReplacer = $("#" + movieReplacer_id);
			}
			
			replacerWidth = movieObject.width();
			replacerHeight = movieObject.height();
			
			movieReplacer.css("width", replacerWidth + "px");
			movieReplacer.css("height", replacerHeight + "px");
			
			movieObject.css("width", "0px");
			movieObject.css("height", "0px");
		}
	}
}


function o5Flash_UnHideOtherFlashMovies(movieID)
{
	for (i = 0; i < o5Flash_SWFContainer_Special_count; i++) {
		currMovieID = o5Flash_SWFContainer_Special_IDArray[i];
		
		if(movieID != o5Flash_SWFContainer_Special_IDArray[i]) {
		
			objectMovie_id = null;
			if(o5Flash_SWFContainer[currMovieID] === undefined)
				objectMovie_id = currMovieID;
			else
				objectMovie_id = "LoadingMovie_" + currMovieID;
			
			if($.browser.msie) {
				wrappingMovie_id = "WrappingMovie_" + currMovieID;
				movieWrapper = $("#" + wrappingMovie_id);
				movieWrapper.css("z-index", "2");
				continue;
			}
			
			movieObject = $("#" + objectMovie_id);
			movieReplacer_id = "MovieReplacer_" + currMovieID;
			movieReplacer = $("#" + movieReplacer_id);
			
			if(movieReplacer.length != 0) {
				movieWidth = movieReplacer.width();
				movieHeight = movieReplacer.height();
				movieObject.css("width", movieWidth + "px");
				movieObject.css("height", movieHeight + "px");
				movieReplacer.remove();
			}
			
		}
	}
}


function o5Flash_debug(caption)
{
	alert(caption + "\n" + "-----------------------\n" + 
		  "o5Flash_GrayLayerMovie: " + o5Flash_GrayLayerMovie + "\n" +
	      "o5Flash_GrayLayer_TransBG_ID: " + o5Flash_GrayLayer_TransBG_ID + "\n" +
	      "o5Flash_GrayLayer_Movie_ID: " + o5Flash_GrayLayer_Movie_ID);
}

function o5Flash_grayLayerActivated()
{
	retVal =
		o5Flash_GrayLayerMovie != null && 
		o5Flash_GrayLayer_TransBG_ID != null &&
		o5Flash_GrayLayer_Movie_ID != null &&
		o5Flash_GrayLayer_Movie_Width != null &&
		o5Flash_GrayLayer_Movie_Height != null &&
		o5Flash_GrayLayer_MovieWrapper_ID != null;
	return retVal;
}

function o5Flash_createGrayLayer(movieID)
{
	//alert("o5Flash_createGrayLayer");
	if(o5Flash_grayLayerActivated()) {
		loadingMovie_id = "LoadingMovie_" + movieID;
		movieDiv = $("#" + loadingMovie_id);
		
		movieDiv.parent().parent().after(
			"<div id=\"" + o5Flash_GrayLayer_TransBG_ID + "\" style=\"position: absolute; z-index: 1; left: 0; top: 0; width: " + $(window).width() + "px; height: " + $(window).height() + "px;background-color: #000;\"></div>"
		);
		
		grayLayer = $("#" + o5Flash_GrayLayer_TransBG_ID);
		grayLayer.fadeTo(0, 0.7);
		
		//alert("grayLayer.length: " + grayLayer.length);
		//grayLayer.parent().prepend("<div style=\"position: absolute; z-index: 2; left: 0; top: 0; width: 100px; height: 100px;\"><div id=\"" + o5Flash_GrayLayer_Movie_ID + "\"></div></div>");
	}
}

function o5Flash_GrayLayer_WindowResize()
{
	if(o5Flash_grayLayerActivated()) {
		transBG_Left = $(window).scrollLeft();
		transBG_Top = $(window).scrollTop();
		transBG_Width = $(window).width();
		transBG_Height = $(window).height();

		grayMov_Left = transBG_Left + transBG_Width / 2 - o5Flash_GrayLayer_Movie_Width / 2;
		grayMov_Top = transBG_Top + transBG_Height / 2 - o5Flash_GrayLayer_Movie_Height / 2;
		grayMov_Width = o5Flash_GrayLayer_Movie_Width;
		grayMov_Height = o5Flash_GrayLayer_Movie_Height;
		
		grayMov_Left = (grayMov_Left < transBG_Left ? transBG_Left : grayMov_Left);
		grayMov_Top = (grayMov_Top < transBG_Top ? transBG_Top : grayMov_Top);
	
		grayLayer = $("#" + o5Flash_GrayLayer_TransBG_ID);
		grayLayer.css("left", transBG_Left + "px");
		grayLayer.css("top", transBG_Top + "px");
		grayLayer.css("width", transBG_Width + "px");
		grayLayer.css("height", transBG_Height + "px");
		
		//alert("o5Flash_GrayLayer_MovieWrapper_ID: " + o5Flash_GrayLayer_MovieWrapper_ID);
		wrappingMovie_id = o5Flash_GrayLayer_MovieWrapper_ID;
		movieWrapper = $("#" + wrappingMovie_id);
		movieWrapper.css("left", grayMov_Left + "px");
		movieWrapper.css("top", grayMov_Top + "px");
		movieWrapper.css("width", grayMov_Width + "px");
		movieWrapper.css("height", grayMov_Height + "px");
		
		if(o5Flash_GrayLayer_Movie_GrandParent != null &&
		   o5Flash_GrayLayer_Movie_GrandParentHeight != null) {
			o5Flash_GrayLayer_Movie_GrandParent.css("height", o5Flash_GrayLayer_Movie_GrandParentHeight + "px");		
		}
	}
}


function o5Flash_closeGrayLayer(movieID)
{
	if(o5Flash_grayLayerActivated()) {
		grayLayer = $("#" + o5Flash_GrayLayer_TransBG_ID);
		o5Flash_GrayLayerMovie = null;
		o5Flash_GrayLayer_TransBG_ID = null;
		o5Flash_GrayLayer_Movie_ID = null;
		o5Flash_GrayLayer_Movie_Width = null;
		o5Flash_GrayLayer_Movie_Height = null;
		o5Flash_GrayLayer_MovieWrapper_ID = null;
		o5Flash_GrayLayer_Movie_GrandParentHeight = null;
		o5Flash_GrayLayer_Movie_GrandParent = null;
		
		o5Flash_bind_GrayLayer_ClickLink();
		
		o5Flash_GrayLayer_ClickLink_DomObj = null;
		o5Flash_GrayLayer_ClickLink_Url = null;
		o5Flash_GrayLayer_ClickLink_MovieID = null;
		
		grayLayer.remove();
		
		loadingMovie_id = "LoadingMovie_" + movieID;
		wrappingMovie_id = "WrappingMovie_" + movieID;
		$("#" + loadingMovie_id).remove();
		$("#" + wrappingMovie_id).remove();
		
		if(o5Flash_GrayLayer_Close_Button != null) {
			o5Flash_GrayLayer_Close_Button.remove();
			o5Flash_GrayLayer_Close_Button = null;
		}
		
		$(window).unbind('resize', o5Flash_GrayLayer_WindowResize);
		$(window).unbind('scroll', o5Flash_GrayLayer_WindowResize);

		o5Flash_UnHideOtherFlashMovies(movieID);
	}
}


function o5Flash_hideGrayLayer(movieID, anyData)
{
	if(o5Flash_grayLayerActivated()) {
		grayLayer = $("#" + o5Flash_GrayLayer_TransBG_ID);
		grayMovie = $("#" + o5Flash_GrayLayer_Movie_ID).parent();
		o5Flash_GrayLayerMovie = null;
		o5Flash_GrayLayer_TransBG_ID = null;
		o5Flash_GrayLayer_Movie_ID = null;
		o5Flash_GrayLayer_Movie_Width = null;
		o5Flash_GrayLayer_Movie_Height = null;
		o5Flash_GrayLayer_MovieWrapper_ID = null;
		
		o5Flash_bind_GrayLayer_ClickLink();
		
		o5Flash_GrayLayer_ClickLink_DomObj = null;
		o5Flash_GrayLayer_ClickLink_Url = null;
		o5Flash_GrayLayer_ClickLink_MovieID = null;
		
		grayLayer.remove();
		//grayMovie.remove();
		
		//loadingMovie_id = "LoadingMovie_" + movieID;
		//var obj = $("#" + loadingMovie_id)[0];
		//obj.o5Flash_setNormalizedVideo(anyData);
		
		$(window).unbind('resize', o5Flash_GrayLayer_WindowResize);
		$(window).unbind('scroll', o5Flash_GrayLayer_WindowResize);

		//if(!$.browser.msie)
		o5Flash_UnHideOtherFlashMovies(movieID);
		o5Flash_positionMovieWrapperNormalized(movieID);
	}
}

function o5Flash_createFlashBoxDynamically(domObj)
{

	className = $(domObj).attr("class");
	movieID = $(domObj).attr("id");
	
	var splClassName = className.split("o5Flash::");
	
	if(splClassName.length > 0 && splClassName.length <= 2) {
		funcStr = "";
		if(splClassName.length == 2)
			funcStr = splClassName[1];
		else if(splClassName.length == 1)
			funcStr = splClassName[0];
			
		splOpBrac = funcStr.split("(");
		funcName = splOpBrac[0].replace(" ", "").replace("\t", "").toLowerCase();
		paramList = splOpBrac[1].split(")")[0];
		
		params = paramList.split(",");
		
		paramListStr4Eval = "";
		if(params.length > 0)
			paramListStr4Eval = "'" + params[0] + "'";
		for(i = 1; i < params.length; i++)
			paramListStr4Eval += ", '" + params[i] + "'";
		
		switch(funcName) {
			case "video":
				if(params.length == 3)
					eval("o5Flash_createVideoBoxDynamically(domObj, " + paramListStr4Eval + ");");
				break;
			case "videolink":
				if(params.length == 1)
					eval("o5Flash_createVideoLinkDynamically(domObj, " + paramListStr4Eval + ");");
				break;
			default:
				break;
		}
	}
}


function o5Flash_createVideoBoxDynamically(domObj, width, height, url)
{
	$(domObj).css("width", width + "px");
	$(domObj).css("height", height + "px");
	
	o5Flash_placeFlashMovie(
		url,
		"/SiteCollectionImages/loader.gif",
		$(domObj).attr("id"),
		width, height, "9.0.0"
	);
}


function o5Flash_createVideoLinkDynamically(domObj, url)
{	
	rnd = Math.round(Math.random()*100000000);
	movieID = "o5Flash_Movie_" + rnd;
	$(domObj).bind("click", {domObj: domObj, url: url, movieID: movieID}, o5Flash_videoLink_ClickHandler);
}


function o5Flash_videoLink_ClickHandler(event)
{
	domObj = event.data.domObj;
	url = event.data.url;
	movieID = event.data.movieID;
	
	$(domObj).unbind("click");
	
	o5Flash_GrayLayer_ClickLink_DomObj = domObj;
	o5Flash_GrayLayer_ClickLink_Url = url;
	o5Flash_GrayLayer_ClickLink_MovieID = movieID;

	width = 640;
	height = 360 + 26;
	
	linkID = movieID + "_VideoLink";
	$(domObj).attr("id", linkID);
	
	loadingMovie_id = "LoadingMovie_" + movieID;
	wrappingMovie_id = "WrappingMovie_" + movieID;

	if($("#" + wrappingMovie_id).length == 0) {
			
		$(domObj).after("<div><div id=\"" + wrappingMovie_id + "\"><div id=\"" + loadingMovie_id + "\">Flash player required</div></div></div>");
		movieWrapper = $("#" + wrappingMovie_id);
			
		grandParent = movieWrapper.parent().parent();
		grandParentHeight = grandParent.height();
		o5Flash_GrayLayer_Movie_GrandParent = grandParent;
		o5Flash_GrayLayer_Movie_GrandParentHeight = grandParentHeight;
						
		movieWrapper.css("width", width + "px");
		movieWrapper.css("height", height + "px");
		movieWrapper.css("position", "absolute");
		movieWrapper.css("z-index", "2");
						
		grandParent.css("height", grandParentHeight + "px");
			
		o5Flash_placeFlashMovie(
			url,
			"/SiteCollectionImages/loader.gif",
			movieID,
			width, height, "9.0.0"
		);
			
		swfobject.embedSWF(
	    	url,
	    	loadingMovie_id,
	    	width,
	    	height,
	    	"9",
	    	null,
	    	{movieID: movieID, movieWidth: width, movieHeight: height},
	    	{ allowFullScreen: true, wmode: $.browser.msie ? "transparent" : "none"},
	    	{}//{style: "width: 1px; height: 1px;"}
	    );

	}

}

function o5Flash_bind_GrayLayer_ClickLink()
{
	if(o5Flash_GrayLayer_ClickLink_DomObj != null &&
	   o5Flash_GrayLayer_ClickLink_Url != null &&
	   o5Flash_GrayLayer_ClickLink_MovieID != null)
		$(o5Flash_GrayLayer_ClickLink_DomObj).bind("click", 
			{
				domObj: o5Flash_GrayLayer_ClickLink_DomObj, 
				url: o5Flash_GrayLayer_ClickLink_Url,
				movieID: o5Flash_GrayLayer_ClickLink_MovieID
			}, 
			o5Flash_videoLink_ClickHandler
		);
}


function o5Flash_startLoadingFlashApplication(movieID)
{
	movie = o5Flash_SWFContainer[movieID];
	preloaderMovie = $("#" + movieID);
	loadingMovie_id = "LoadingMovie_" + movieID;
	preloaderMovie.after("<div id='" + loadingMovie_id + "'></div>");

	swfobject.embedSWF(
		"/Style%20Library/SpinningThing.swf",
		movieID,
		movie.width,
		movie.height,
		movie.flashVersion,
		movie.expressInstallUrl,
		{loaderGifUrl: "/SiteCollectionImages/loader.gif", movieID: movieID},
		{},
		{}
	);

}

$(document).ready(function()
{
	//build flash boxes dynamically by special css class names
	$("[class^=o5Flash::]").each(function() {
		o5Flash_createFlashBoxDynamically(this);
	});

	//build flash boxes by membership in list o5Flash_SWFContainer
	for (var movieID in o5Flash_SWFContainer)
		o5Flash_startLoadingFlashApplication(movieID);
});

