// NHN Flash UI common - Flash Contents
// v1.0 update : 2007. 6. 14
// v1.1 update : 2007. 12. 17 : add allowFullScreen parameter
// v1.2 update : 2008. 9. 3 : customize for NHN Japan (showFlash -> makeFlashObj)
// v1.3 update : 2008. 10. 20 : add showFlash2layer Function

var fc_isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var fc_isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var fc_isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function makeFlashObj(_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_,_menu_){
	_wmode_ = (_wmode_ == undefined)? "transparent" : _wmode_;		// wmode = "window/ opaque/ transparent"
	_bgColor_ = (_bgColor_ == undefined)? "#FFFFFF" : _bgColor_;		// default "#000000" -> "#FFFFFF" _change 2007. 6. 14
	_allowFullScreen_ = (_allowFullScreen_ == undefined)? true : _allowFullScreen_;		// allowFullScreen = true / false
	_menu_ = (_menu_ == undefined)? false : _menu_;
	var _object_;
	if(fc_isIE && fc_isWin && !fc_isOpera){
		var arr_obj = [];
		arr_obj.push('<object width="'+_width_+'" height="'+_height_+'" id="'+_flashID_+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" >');
		arr_obj.push('<param name="allowScriptAccess" value="always" />');
		arr_obj.push('<param name="quality" value="high" />'); 
		arr_obj.push('<param name="menu" value="'+_menu_+'" />'); 
		arr_obj.push('<param name="movie" value="'+_swfURL_+'" />');
		arr_obj.push('<param name="wmode" value="'+_wmode_+'" />'); 
		arr_obj.push('<param name="bgcolor" value="'+_bgColor_+'" />');
		arr_obj.push('<param name="FlashVars" value="'+_flashVars_+'">');
		arr_obj.push('<param name="allowFullScreen" value="'+_allowFullScreen_+'">');
		arr_obj.push('</object>');
		_object_ =  arr_obj.join("");
	}else{
		_object_ = '<embed src="'+_swfURL_+'" quality="high" wmode="'+_wmode_+'" menu= "'+_menu_ +'" FlashVars="'+_flashVars_+'" bgcolor="'+_bgColor_+'" width="'+_width_+'" height="'+_height_+'" name="'+_flashID_+'" allowFullScreen="'+_allowFullScreen_+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'; 
	}
	return _object_;
	//document.write(_object_);
}

// 1.1 version support
//showFlash("swfURLh.swf", "flashID", width, height, "transparent", flashVars, bgColor,allowFullScreen);
function showFlash(_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_){
	document.write(makeFlashObj(_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_));
}

//showFlash2layer(document.getElementById("layerID"),"swfURLh.swf", "flashID", width, height, "transparent", flashVars,bgColor,allowFullScreen);
function showFlash2layer(target,_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_){
	//if(fc_isIE) target.insertAdjacentHTML('afterBegin',makeFlashObj(_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_));
	target.innerHTML = makeFlashObj(_swfURL_,_flashID_,_width_,_height_,_wmode_,_flashVars_,_bgColor_,_allowFullScreen_); 
}

function findFlashObj(_flashID_){
	var tarObj = fc_isIE ? document.all[_flashID_] : document[_flashID_];	
	return tarObj;
}

function fc_checkFlashPlayerVersion(){
	var _version;
	var _e;
	try {
		var _axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5");		// check flash player ver. 5 or higher
		_version = _axo.GetVariable("$version");
	} catch (_e) {
		_version = -1;
	}
	return _version;
}

// for 'Out of memory line at 56' error _add 2007. 6. 12
function flashExternalCleanup() {
	__flash_unloadHandler = function(){
		externalProbSet = true;
		obj = document.getElementsByTagName('OBJECT');
	  	for (i=0;i<obj.length;i++){
			var theObj = eval(obj[i]);
			theObj.style.display = "none";
			for (var prop in theObj){
				if (typeof(theObj[prop]) == "function"){
					theObj[prop]=null
				}
			}
	  	}
	}
	if (window.onunload != __flash_unloadHandler){
		__flash_savedUnloadHandler = window.onunload;
		window.onunload = __flash_unloadHandler;
	}
}
window.onbeforeunload=flashExternalCleanup;

	