/*
	2006-02-03 object ÅÂ±× »ý¼º

	+ ÀÌÀü js¹öÀü¿¡¼­ Áö¿øÇÏÁö ¸øÇÏ´Â undefined, push È£È¯µÇ´Â Çü½ÄÀ¸·Î ¹Ù²Ù°Å³ª »õ·Î Á¤ÀÇ
	+ (2006-02-28) insertHTML Ãß°¡ - ÃÖÃÊ ¼º°ÝÁø´Ü¿¡¼­ »ç¿ë
	+ (2006-12-13) _typeSet¿¡ activetutor Ãß°¡

	-- »ç¿ë ¹æ¹ý
	- ¹Ìµð¾î Å¸ÀÔÀº ¾È¾²¸é ±âº» flash ÀÔ´Ï´Ù. (flash | mediaplayer | correction(Ã·»è))
	var obj = new objectTag("ÆÄÀÏ°æ·Î", width, height [, ¹Ìµð¾î Å¸ÀÔ]);
	obj.write();

	-- ¿É¼Ç
	obj.param("name1:value1,name2:value2,...");
	obj.debug = [true|false] - ³Ñ°Ü ¹ÞÀº param °ªµé È®ÀÎ, ±âº»°ª false
	obj.embedTag = [true|false] - embed ÅÂ±× »ç¿ë¿©ºÎ, ±âº»°ª true
	- object, embed ÅÂ±× ±âº»¼³Á¤, Ã·»è°°Àº °æ¿ì ¿ÜºÎ¿¡¼­ µû·Î ÁöÁ¤ÇØ Áà¾ß ÇÒ¶§°¡ ÀÖ´Ù.
	- ¾Æ·¡ objectTag.prototype._typeSet ¼³Á¤ Âü°í
	obj.classid = °ª, obj.codebase = °ª, obj.pluginspage = °ª, obj.embedType = °ª

	param ³Ñ±â´Â ´Ù¸¥ ¹æ¹ý - ÇÏ³ª¾¿ ³ÖÀ»¶§, param¿Í È¥¿ëÇØµµ µÈ´Ù.
	obj.paramAppend(name1, value1);
	obj.paramAppend(name2, value2);

	** ÁÖÀÇ: param »ç¿ëÇÒ¶§ :³ª ,°¡ µé¾î°¡´Â ¹®ÀÚ¿­ÀÏ°æ¿ì ÇØ´ç ÆÄ¶ó¸ÞÅ¸¸¸ paramAppend ¸¦ »ç¿ëÇÏ¼¼¿ä.
		Æ¯¼ö¹®ÀÚ Ã³¸®°¡ ¾ÈµÇ¾î ÀÖ½À´Ï´Ù.  Æ¯È÷ http:// ÀÌ·±½ÄÀ¸·Î ÁÖ¼Ò°¡ µé¾î°¥°æ¿ì

	# flash
	<script>
	var activeX1 = new objectTag("Video_Control.swf?title=Á¦¸ñ", 640, 79);
		activeX1.param("id:navmovie,quality:high,bgcolor:#FFFFFF");
		activeX1.debug = true <- param ¼³Á¤ ³»¿ëÀ» alert Ã¢À¸·Î º¼ ¼ö ÀÖ´Ù.
		activeX1.write();
	</script>
	´Ù¸¥ ¿¹
	var activeX1 = new objectTag("", 640, 79);
		activeX1.paramAppend("movie","Video_Control.swf?title=Á¦¸ñ");
		activeX1.param("id:navmovie,quality:high,bgcolor:#FFFFFF");
		or
		activeX1.param("movie:Video_Control.swf?title=Á¦¸ñ,id:navmovie,quality:high,bgcolor:#FFFFFF");

	# mediaplayer
	<script>
	var activeX1 = new objectTag("¹Ìµð¾î ÆÄÀÏ °æ·Î...", 640, 480, "mediaplayer");
		activeX1.param("id:MediaPlayer,AutoStart:1,EnableContextMenu:0,displaySize:0,ShowControls:0,SendMouseClickEvents:0") // ¿É¼Ç
		activeX1.write();
	</script>

	insertHTML »ç¿ë
		activeX.insertHTML(document.getElementById("ObjflaPbl"));
		activeX.insertHTML("ObjflaPbl");
		activeX.insertHTML(ObjflaPbl); <- ie¿¡¼­¸¸ ÀÛµ¿
*/

// trim ±¸Çö
String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")}
// push ±¸Çö
if(typeof([].push) == "undefined") Array.prototype.push = function(v){return this[this.length] = v}

// °´Ã¼ Á¤ÀÇ
var objectTag = function(src, width, height, mediatype){
	this._objectStrBuf = [];
	this._embedStrBuf = [];
	this._defaultChk = [];
	this._src = src
	this._id = ""
	this._width = width;
	this._height = height;
	this._type = (typeof(mediatype) != "undefined")? mediatype.trim().toLowerCase() : "flash"
	this._srcParamName = ""
	// ¾Æ·¡´Â ¿ÜºÎ¿¡¼­ ¼³Á¤ °¡´É
	this.classid = ""
	this.codebase = ""
	this.pluginspage = ""
	this.embedType = ""
	this.embedTag = true
	this.debug = false
	// ±âº» ¼³Á¤°ª
	switch(this._type){
		case "flash":
			this._defaultChk.push(["menu", false, "false"]);
			this._defaultChk.push(["quality", false, "high"]);
			break;
	}
}
objectTag.prototype._typeSet = function(){
	switch(this._type){
		case "flash":
			this._srcParamName = "movie";
			this.classid = "CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000";
			//this.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
			this.codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0";
			this.embedType = "application/x-shockwave-flash";
			this.pluginspage = "http://www.macromedia.com/go/getflashplayer_kr";
			break;
		case "mediaplayer":
			this._srcParamName = "filename";
			this.classid = "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
			this.embedType = "application/x-mplayer2";
			break;
		case "director":
			this._srcParamName = "src"
			this.classid = "CLSID:166B1BCA-3F9C-11CF-8075-444553540000";
			this.codebase = "http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0";
			this.embedType = "application/x-director";
			this.pluginspage = "http://www.macromedia.com/shockwave/download/";
			break;
	}
}
// ¾²±â
objectTag.prototype.write = function(){
	// object ÅÂ±× ¼³Á¤
	this._typeSet();
	// ±âº» ¼³Á¤°ª Àû¿ë
	for(_x=0;_x<this._defaultChk.length;_x++){
		if(!this._defaultChk[_x][1]) this.paramAppend(this._defaultChk[_x][0], this._defaultChk[_x][2]);
	}
	if(this._src != "") this.paramAppend(this._srcParamName, this._src);
	if(this.debug) alert(this._objectStrBuf.join("\n")+"\n\n"+this._embedStrBuf.join("\n"));
	document.write('<object classid="'+ this.classid +'" ');
	document.write('codebase="'+ this.codebase +'" ');
	if(this._width != "") document.write('width="'+ this._width +'" ');
	if(this._height != "") document.write('height="'+ this._height +'" ');
	if(this._id != "") document.write(' id="'+ this._id +'"');
	document.write('>');
	document.write(this._objectStrBuf.join(""));
	// embed tag¿ë
	if(this.embedTag){
		document.write('<embed swLiveConnect="true" pluginspage="'+ this.pluginspage +'" ');
		if(this._width != "") document.write('width="'+ this._width +'" ');
		if(this._height != "") document.write('height="'+ this._height +'" ');
		if(this._id != "") document.write(' name="'+ this._id +'" ');
		if(this.embedType != "") document.write('type="'+ this.embedType +'" ');
		document.write(this._embedStrBuf.join(""));
		document.write('></embed>');
	}
	document.write("</object>");
	this.clear();
}

objectTag.prototype.insertHTML = function(target){
	var returnStr
	// object ÅÂ±× ¼³Á¤
	this._typeSet();
	// ±âº» ¼³Á¤°ª Àû¿ë
	for(_x=0;_x<this._defaultChk.length;_x++){
		if(!this._defaultChk[_x][1]) this.paramAppend(this._defaultChk[_x][0], this._defaultChk[_x][2]);
	}
	if(this._src != "") this.paramAppend(this._srcParamName, this._src);
	if(this.debug) alert(this._objectStrBuf.join("\n")+"\n\n"+this._embedStrBuf.join("\n"));
	returnStr = ('<object classid="'+ this.classid +'" ');
	returnStr += ('codebase="'+ this.codebase +'" ');
	if(this._width != "") returnStr += ('width="'+ this._width +'" ');
	if(this._height != "") returnStr += ('height="'+ this._height +'" ');
	if(this._id != "") returnStr += (' id="'+ this._id +'"');
	returnStr += ('>');
	returnStr += (this._objectStrBuf.join(""));
	// embed tag¿ë
	if(this.embedTag){
		returnStr += ('<embed swLiveConnect="true" pluginspage="'+ this.pluginspage +'" ');
		if(this._width != "") returnStr += ('width="'+ this._width +'" ');
		if(this._height != "") returnStr += ('height="'+ this._height +'" ');
		if(this._id != "") returnStr += (' name="'+ this._id +'" ');
		if(this.embedType != "") returnStr += ('type="'+ this.embedType +'" ');
		returnStr += (this._embedStrBuf.join(""));
		returnStr += ('></embed>');
	}
	returnStr += ("</object>");
	this.clear();
	if(typeof(target)=="string") document.getElementById(target).innerHTML = returnStr
	else target.innerHTML = returnStr
}

// param µî·Ï
objectTag.prototype.paramAppend = function(paramName, paramVal){
	_addObject = true;
	_addEmbed = true;
	paramName = paramName.toLowerCase().trim();
	paramVal = paramVal.toString().trim();
	switch(paramName){
	case "movie": case "filename":
		if(this.embedTag) this._embedStrBuf.push(' src="'+ paramVal +'" ');
		_addEmbed = false
		break;
	case "id":
		this._id = paramVal
		_addObject = false
		_addEmbed = false
		break;
	}
	for(_x=0;_x<this._defaultChk.length;_x++){
		if(this._defaultChk[_x][0] == paramName) this._defaultChk[_x][1] = true;
	}
	if(_addObject) this._objectStrBuf.push('<param name="'+paramName+'" value="'+paramVal+'"/>');
	if(_addEmbed && this.embedTag) this._embedStrBuf.push(paramName+'="'+ paramVal +'" ');
}
// Ãß°¡
objectTag.prototype.param = function(){
	if(arguments.length <= 0){alert("Àü´Þ°ªÀÌ ¾ø½À´Ï´Ù."); return;}
	_paramArr = arguments[0].split(",")
	for(_i = 0;_i < _paramArr.length ;_i++){
		_paramSplit = _paramArr[_i].trim().split(":")
		this.paramAppend(_paramSplit[0], _paramSplit[1])
	}
}
objectTag.prototype.clear = function(){}