/******************************************************************
	title : mEmbed v1.1
	contents : IEÆÐÄ¡·Î ÀÎÇÑ embed ÅÂ±×¸¦ js·Î Ãâ·ÂÇÑ´Ù.
	ÀÌ ¼Ò½º°¡ µé¾î°¡´Â JSÆÄÀÏÀº ¹Ýµå½Ã src·Î ¿ÜºÎ¿¡¼­ È£ÃâµÇ¾î¾ßÇÏ°í
	<script>mEmbed("src=source.swf","width=100","height=100", "wmode=Tranpsarent");</script>
	¿Í °°Àº Çü½ÄÀ¸·Î ÇÃ·¡½¬ ÅÂ±×¸¦ ´ë½ÅÇØ¼­ ³Ö¾îÁØ´Ù.
	mGET ÇÔ¼ö´Â µÎ¹è¿­À» ÀÌ¿ëÇÑ Å°°ªÀÇ Data ¸¦ °¡Á®¿À´Â ÇÔ¼ö.(mEmbed¿¡ ÇÊ¿ä)
	ex) srcdata = mGET(key,value,'src'); -> phpÀÇ $srcdata = $array['src'];
	by : http://blog.daum.net/battlej
	******************************************************************/

	function mGET(arrayKey, arrayValue, Value) {
		count = arrayKey.length;
		for(i=0;i<count;i++) {
			if(arrayKey[i]==Value) {
				return arrayValue[i];
				break;
			}
		}
	}

	function mEmbed() {
		var key = new Array();
		var value = new Array();
		var contents;
		var embed_type;
		var error_check=0;
		var i, j;
		var count;
		var data;
		var temp;
		if(mEmbed.arguments.length==1) {
			contents = mEmbed.arguments[0];
		} else {
			for(i=0;i<mEmbed.arguments.length;i++) {
				temp = mEmbed.arguments[i].replace(/"|'/g,"");
				data = temp.split('=');
				key[i] = data[0];
				value[i] = data[1];
				count = data.length;

				for(j=2;j<count;j++) {
					value[i] += '=' + data[j];
				}
			}

			contents='';
			srcdata = mGET(key,value,'src');

			if(/\.(swf)$/.test(srcdata)) {
				embed_type = 1;
			} else if(/\.(mov|avi|wma|wmv)$/.test(srcdata)) {
				embed_type = 2;
			}

			var classid = mGET(key,value,'classid');
			var codebase = mGET(key,value,'codebase');

			if(embed_type==1) {
				classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
				codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0';
			} else if(embed_type==2) {
				classid = 'clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95';
				codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715';
			}

			if(classid && codebase) {
				contents += '<object';
				if(classid) {
					contents += ' classid="' + classid + '"';
				}
				if(codebase) {
					contents += ' codebase="' + codebase + '"';
				}
				count = key.length;
				for(i=0;i<count;i++) {
					if(value[i]!='') {
						if(key[i]!='src') {
							contents += ' ' + key[i] + '="' + value[i] + '"';
						}
					}
				}
				contents += '>';
				for(i=0;i<count;i++) {
					if(value[i]!='') {
						if(embed_type==1 && key[i]=='src') {
							contents += '<param name="movie" value="' + value[i] + '" />';
						} else {
							contents += '<param name="' + key[i] + '" value="' + value[i] + '" />';
						}
					}
				}
			}
			count = key.length;
			contents += '<embed';
			for(i=0;i<count;i++) {
				if(value[i]!='') {
					contents += ' ' + key[i] + '="' + value[i] + '"';
				}
			}
			contents += '>';
			contents += '</embed>';
			if(classid && codebase) {
				contents += '</object>';
			}
		}
		document.write(contents);
	}



// ==========================================================================================================================================================================================================
// embed swf
// ==========================================================================================================================================================================================================

/*	¢Æ  USAGE Example:

	<html>
		<head>
			<title>aaa</title>
			<script type="text/javascript" src="include/js/common.js"></script>
		</head>

		<body bgcolor="#FFE38A" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
			<div id="aaa">
			<script>
				jfN_swf("include/swf/aaa.swf", "100%", "100%", "swf=include/swf/&xml=include/xml/");
			</script>
		</body>
	</html>
*/

function jfN_swf(p_url, p_width, p_height, p_vars, p_id, p_mode, p_access, p_quality, p_color) {
	var start_idx = p_url.lastIndexOf("/");
	var end_idx = p_url.lastIndexOf(".");
	var start_idx = (start_idx == -1) ? 0 : start_idx+1;

	if(!p_id) p_url.substring(start_idx, end_idx);
	if(!p_mode) p_mode = "window";			// window | opaque | transparent
	if(!p_access) p_access = "always";		// always | never | samedomain
	if(!p_quality) p_quality = "high";				// low | medium | high | best
	if(!p_color) p_color = "#ffffff";

	var jsTag_str = 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+p_width+"' height='"+p_height+"' id='"+p_id+"' align='middle'>"+ 
	"<param name='allowScriptAccess' value='always' />"+ 
	"<param name='movie' value='"+p_url+"' />"+ 
	"<param name='FlashVars' value='"+p_vars+"' />"+ 
	"<param name='wmode' value='"+p_mode+"' />"+ 
	"<param name='menu' value='false' />"+
	"<param name='scaleMode' value='noScale' />"+
	"<param name='showMenu' value='false' />"+
	"<param name='align' value='CT' />"+ 
	"<param name='quality' value='"+p_quality+"' />"+ 
	"<param name='bgcolor' value='"+p_color+"' />"+ 
	"<embed src='"+p_url+"' FlashVars='"+p_vars+"' wmode='"+p_mode+"' menu='false' quality='high' bgcolor='"+p_color+"' width='"+p_width+"' height='"+p_height+"' name='"+p_id+"' align='middle' allowScriptAccess='"+p_access+"' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+ 
	"</object>"; 

	document.write(jsTag_str); 
}