var componentEmbeds = {
	init: function() {
		if (typeof(swfobject) != 'undefined') {
			// get all component embed divs
			var oaComponentEmbeds = document.getElementsByClassName('component-embed');
			// iterate through all of them
			while (oaComponentEmbeds.length > 0) {
				// get or calculate all necessary data
				var iLengthBeforeEmbed = oaComponentEmbeds.length;
				var saIdMatches = oaComponentEmbeds[0].id.match(/ce-(\d+)-([\d\w_-]+)/);
				var saClassMatches = oaComponentEmbeds[0].className.match(/^component-embed et-(standalone|live-demo) (.+\.swf)$/);
				if (saIdMatches && saIdMatches[1] && saIdMatches[2] && saClassMatches && saClassMatches[1] && saClassMatches[2]) {
					var iComponentId = saIdMatches[1];
					var sComponentPermalink = saIdMatches[2];
					var sEmbedType = saClassMatches[1];
					var sSwfName = saClassMatches[2];

					var pathToSwf = window.serverConfigs.docRoot + '/' + window.serverConfigs.dir.itemsData + '/components/' + sComponentPermalink + '/swfs/' + sEmbedType + '/';
					var width = height = 0;

					switch (sEmbedType) {
						case 'standalone':
							width = 500;
							height = 260;
						break;
						case 'live-demo':
							width = 600;
							height = window.serverConfigs.liveDemoHeight ? window.serverConfigs.liveDemoHeight : 865;
						break;
					}

					// move the text (item preview) from the component embed div to the bottom of the swmt-details (item details) div, if it exists
					var oSwmtDetails = document.getElementById('swmt-details');
					if (oSwmtDetails) {
							for (var i = 0; i < oaComponentEmbeds[0].childNodes.length; i++) {
								oSwmtDetails.appendChild(oaComponentEmbeds[0].childNodes[i].cloneNode(true));
								document.getElementById('component-preview').style.display = 'block';
							}
					}

					// embed swf by replacing the whole component embed div with the embed code
					swfobject.embedSWF(
						pathToSwf + sSwfName,
						oaComponentEmbeds[0].id,
						width, height, '9.0.0', false,
						{ folderPath: pathToSwf },
						{ scale: 'noscale', salign: 'tl', wmode: 'transparent', allowScriptAccess: 'sameDomain', allowFullScreen: true },
						null
					);

					// in IE, the component embed divs are not replaced with swfs; so after the embed is finished, the placeholder element needs to be removed manually
					if (iLengthBeforeEmbed == oaComponentEmbeds.length) {
						oaComponentEmbeds.splice(0, 1);
					}
				}
			}
		};
	}
};