function daumActiveX(obj,div,events){
	// generate html code
	// for ie obejct
	var html = '<object ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	if (events) {
	    for (var i in events){
		    html += ' '+events[i][0]+'="javascript:'+events[i][1]+'"';
	    }
	}
	
	html += '>\n';
	// append params
	for (var i in obj.param){
		html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';

	html += 'allowScriptAccess="always" ';
	
	// append params
	for (var i in obj.param){
		if (obj.param[i] && obj.param[i][0] && obj.param[i][1]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src = obj.param[i][1];
			}
			if (obj.param[i][0].toLowerCase()=='flashvars'){
				if (_src){
					var tmpArr = html.split('src="'+_src+'"');
					html = tmpArr[0]+' src="'+_src+'?'+obj.param[i][1]+'" '+tmpArr[1];
				} else {
					obj.param[obj.param.length] = obj.param[i];
				}
			} else {
				html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
			}
		}
	}
	html += '/>\n';
	html += '</object>';

	var isIE = (document.all)?true:false;
	if (isIE){
		document.getElementById(div).innerHTML = html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie외의 브라우저에서 activex가 flash인 경우만 노출
		document.getElementById(div).innerHTML = html;
	}
}
// 한페이지에 한종류의 activeX가 복수개 삽입되는 경우 하단과 같이 function을 만들어서 사용
function daumFlash(src,width,height,div){
	var obj = new Object();
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	obj.wmode = 'transparent';
	obj.width = width;
	obj.height = height;

	var param = [
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['bgcolor','#FFFFFF'],
		['pluginspage','http://www.macromedia.com/go/getflashplayer'],
		["AllowScriptAccess","always"]
	];
	obj.param = param;
	daumActiveX(obj,div);
}

function createAmsFlashObject(src, width, height) {
	var obj = new Object();
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	obj.wmode = 'transparent';
	obj.width = width;
	obj.height = height;

	var param = [
		["movie", src],
		["src", src],
		["quality", "high"],
		["wmode", "transparent"],
		["bgcolor", "#FFFFFF"],
		["pluginspage", "http://www.macromedia.com/go/getflashplayer"],
		["swLiveConnect", "false"]
	];
	obj.param = param;
	return obj;
}

function setObjectId(obj, id) {
    obj.id = id;
}

function setParam(obj, name, value) {
	if(obj == null) {
	    return;
	}
	
	var param = obj.param; 
	if(param == null) {
	    param = [[name, value]];
	    return;
	}
	
	for (var i in param){
	    if(param[i][0] == name) {
	        param[i][1] = value;
	        return;
	    }
	}
	
	param[param.length] = [name, value];
}
