//must be used in conjunction with SWFObject script, otherwise nothing will happen

function embedSWFObjects() {
	var swfcontainer = new Array(), swfCount = 0, allDivs = document.getElementsByTagName('div');
	
	for(var i = 0; i<allDivs.length; i++){
		if(allDivs[i].className =='swfcontainer'){
			swfcontainer[swfCount] = allDivs[i];
			swfCount++;
		}
	}
	
	if( swfcontainer.length > 0 && typeof(SWFObject) == 'function' ){ //test for presence of element, and function
		//loop through array of matched containers
		for(var i = 0; i<swfcontainer.length; i++){
			//get attributes of the container to define sfw src, dims, etc
			var thisinfo = stripSpaces(swfcontainer[i].id);
			var swfinfo = thisinfo.split('__'); // pattern is [path]__[width]__[height]
			var swfpath = 'cmsflash/'+swfinfo[0]+'.swf', swfwidth = swfinfo[1], swfheight = swfinfo[2];
			var so = new SWFObject(swfpath, 'SWFObject_instance'+i, swfwidth, swfheight, "8", "#ffffff");
			so.addParam("wmode", "opaque");
			so.write(swfcontainer[i]);
		}
	} else {
		//do nothing
	}
	function stripSpaces(string){
		while(string.indexOf(' ') != -1){
			string = string.replace(' ', '');
		}
		return string;
	}
}

//always check to see if the addLoadEvent function exists before trying to call it!
if(typeof addLoadEvent == 'function'){
	addLoadEvent(embedSWFObjects);
}