// version 2.0 by Wouter Smit
var swf = {

	// collection of all flash objects
	flashObjects: new Array(),

	// write a flash embed with full browser compatibility
	writeFlash: function($src, $width, $height, $params, $flashVars, $targetElement) {
		var $code = '<div style="display:none;">&nbsp;</div>'; // IE6 fix
		$code += '<object width="' + $width + '" height="' + $height + '" ';
		$code += 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ';
		$code += 'id="swf' + this.flashObjects.length + '">';
		$code += '<param name="movie" value="' + $src + '" />';

		var $paramArr = $params.split("&");
		var $paramAttributes = "";
		for ( var i = 0; i < $paramArr.length; i++ ) {
			var $param = $paramArr[i].split("=");
			$code += '<param name="' + $param[0] + '" value="' + $param[1] + '" />';
			$paramAttributes += ' ' + $param[0] + '="' + $param[1] + '"';
		}

		if ( $flashVars ) {
			$code += '<param name="flashvars" value="' + $flashVars + '" />';
			$paramAttributes += ' flashvars="' + $flashVars + '"';
		}
		$code += '<embed width="' + $width + '" height="' + $height + '" src="' + $src + '" ';
		$code += 'name="swf' + this.flashObjects.length + '" type="application/x-shockwave-flash"';
		$code += $paramAttributes;
		$code += ' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

		if ( $targetElement ) {
			$targetElement.innerHTML = $code;
		} else {
			document.write($code);
		}

		if ( window.event ) {
			var $obj = document.getElementsByTagName("OBJECT");
			for (var i = 0; i < $obj.length; i++) {
				$obj[i].outerHTML = $obj[i].innerHTML;
			}
			this.flashObjects.push(document.getElementById("swf" + this.flashObjects.length));
		} else {
			var $emb = document.getElementsByTagName("EMBED");
			for (var i = 0; i < $emb.length; i++) {
				if ( $emb[i].name = "swf" + this.flashObjects.length ) {
					this.flashObjects.push($emb[i]);
				}
			}
		}
	}

}