// ********************************************************************************************* Error
// ================================================================================= 
function getError(e) {
	msg = "";
	if (arguments.length > 1) msg += arguments[1] +"\n=====================\n";
	msg += "msg  : "+ e +"\n";
	msg += "num  : "+ e.number +"\n";
	msg += "desc : "+ e.description +"\n";
	return msg;
}
// ================================================================================= 
function alertError(e) {
	msg = "";
	if (arguments.length > 1) msg += arguments[1] +"\n=====================\n";
	msg += "msg  : "+ e +"\n";
	msg += "error name : "+ e.name +"\n";
	msg += "message    : "+ e.message +"\n";
	msg += "num 16  : "+ e.number +"\n";
	msg += "num 10  : "+ (e.number & 0xFFFF) +"\n";
	msg += "desc : "+ e.description +"\n";
	alert(msg);
}
// ********************************************************************************************* Event
// ================================================================================= 
function addEvent(obj, eve, func) {
	if (obj.addEventListener) {
		obj.addEventListener(eve.replace('on',''), func, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent(eve, func);
		return r;
	} else {
		return false;
	}
}
// ================================================================================= Popup
var popupWindow = null;
function windowOpen(src, width, height, prop) {
	if (popupWindow != null) popupWindow.close();
	var option = "width="+ width +", height="+ height;
	if (prop != undefined) option += ", "+ prop;
	popupWindow = window.open(src, "popupWindow", option);
	popupWindow.focus();
}
function getQueryString() {
	var path = window.location.protocol +"//"+ window.location.hostname + window.location.pathname +"?";
	var path_len = path.length;
	var href = window.location.href;
	if (href.substr(0, path_len) == path) {
		return href.substr(path_len);
	}
	return "";
}
// ********************************************************************************************* Embed
// ================================================================================= 
function playMedia(pSrc, pWidth, pHeight) {
	var arg_len = arguments.length;
	var pElementID = "";
	var pAutoStart = "";
	if (arg_len > 3) pElementID = arguments[3];
	if (arg_len > 4) pAutoStart = arguments[4];
	if (pWidth  == undefined || pWidth  == "") pWidth  = "100%";
	if (pHeight == undefined || pHeight == "") pHeight = "100%";

	var varText = "<embed";
	if (pElementID != "") varText += " id=\""+ pElementID +"\"";
	varText += " type=\"application/x-mplayer2\"";
	varText += " src=\""+ pSrc +"\"";
	varText += " width=\""+ pWidth +"\"";
	varText += " height=\""+ pHeight +"\"";
	varText += " loop=\"-1\"";
	varText += " EnableContextMenu=\"true\"";
	varText += " ShowControls=\"true\"";
	if (pAutoStart != "") varText += " AutoStart=\""+ pAutoStart +"\"";
	varText += " />";
	document.write(varText);
}
// ================================================================================= 
function playMediaObject(param) {
	pSrc = "about:blank";
	if (param != undefined) {
		var jsonParam = eval(param);
		pElementID = jsonParam.element_id == undefined ? "" : jsonParam.element_id;
		pWidth  = jsonParam.width == undefined ? "" : jsonParam.width;
		pHeight = jsonParam.height == undefined ? "" : jsonParam.height;
		pSrc    = jsonParam.url == undefined ? "" : jsonParam.url;
		pAutoStart = jsonParam.auto_start == undefined ? "" : jsonParam.auto_start;
	}
	varText  = "<object CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"";
	if (pElementID != "") varText += " id=\""+ pElementID +"\"";
	varText += " width=\""+ pWidth +"\" height=\""+ pHeight +"\"";
	varText += ">";
	varText += "<param name=\"url\" value=\""+ pSrc +"\" />";
	varText += "<param name=\"loop\" value=\"-1\" />";
	if (pAutoStart != "") varText += "<param name=\"autostart\" value=\""+ pAutoStart +"\" />";
	varText += "<param name=\"uiMode\" value=\"none\" />";
	varText += "</object>";
	document.write(varText);
}
function controlMediaPlayObject(el_id, action) {
	var media_player = $(el_id);
	if (media_player == null) return;
	var btn_play  = $("imgMediaPlayerControlPlay["+ el_id +"]");
	var btn_stop  = $("imgMediaPlayerControlStop["+ el_id +"]");
	var btn_pause = $("imgMediaPlayerControlPause["+ el_id +"]");
	var tbl_start = $("tableMediaPlayerControlStart["+ el_id +"]");
	switch (action) {
		case "start" :
		case "play" :
			media_player.controls.play();
			if (btn_play  != null) btn_play.style.display  = "none";
			if (btn_pause != null) btn_pause.style.display = "";
			if (tbl_start != null) tbl_start.style.zIndex = -1;
			break;
		case "stop" :
			media_player.controls.stop();
			if (btn_pause != null) btn_pause.style.display = "none";
			if (btn_play  != null) btn_play.style.display  = "";
			break;
		case "pause" :
			media_player.controls.pause();
			if (btn_pause != null) btn_pause.style.display = "none";
			if (btn_play  != null) btn_play.style.display  = "";
			break;
		case "full" :
			media_player.controls.stop();
			if (btn_pause != null) btn_pause.style.display = "none";
			if (btn_play  != null) btn_play.style.display  = "";
			src = "/common/?p=media_full_play&media_url="+ encodeURIComponent(media_player.url);
			width = "655";
			height = "560";
			prop = "";
			windowOpen(src, width, height, prop);
			break;
	}
}
// ================================================================================= 
var flashNum = 0;
function playFlash(pSrc, pWidth, pHeight) {
	/*
	var retText = "";
	retText += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
	retText += " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,22,87\"";
	retText += " width=\""+ pWidth +"\" height=\""+ pHeight +"\">";
	retText += "<param name=\"movie\" value=\""+ pSrc +"\" />";
	retText += "<param name=\"quality\" value=\"high\" />";
	retText += "<embed src=\""+ pSrc +"\" quality=\"high\"";
	retText += " pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"";
	retText += " type=\"application/x-shockwave-flash\" width=\""+ pWidth +"\" height=\""+ pHeight +"\"></embed>";
	retText += "</object>";
	document.write(retText);
	*/
	var pPath = pSrc.substr(0, pSrc.length-4);
	flashNum++;
	var flashID = "flashObject";
	AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
			'width', pWidth,
			'height', pHeight,
			'src', pPath,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', flashID + flashNum.toString(),
			'bgcolor', '#ffffff',
			'name', flashID + flashNum.toString(),
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', pPath,
			'salign', ''
			); 
}
// ********************************************************************************************* DreamWeaver
// ================================================================================= 
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i=0; i<(a.length-2); i+=3) {
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) x.oSrc = x.src;
			x.src = a[i+2];
		}
	}
}
// ================================================================================= 
function MM_swapImgRestore() { //v3.0
	var i,x,a = document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) x.src=x.oSrc;
}
// ================================================================================= 
function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if (!d) d = document;
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if (!(x=d[n]) && d.all) x=d.all[n];
	for (i=0; !x && i<d.forms.length; i++) x = d.forms[i][n];
	for (i=0; !x && d.layers && i<d.layers.length; i++) x = MM_findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n);
	return x;
}
// ********************************************************************************************* DHTML Editor
// ================================================================================= 
function initDhtmlEditor(pAreaName, pElementName) {
	var divDHTMLEditor = $(pAreaName);
	if (divDHTMLEditor == null) {
		alert("DHTML Editor ¿µ¿ªÀ» È®ÀÎ ¹Ù¶ø´Ï´Ù.");
		return;
	}
	if (divDHTMLEditor.childNodes.length > 0) return;
	var el_iframe = document.createElement("iframe");
	el_iframe.id   = _getDhtmlEditorIFrameName(pElementName);
	el_iframe.name = _getDhtmlEditorIFrameName(pElementName);
	el_iframe.width = "100%";
	el_iframe.height = "350";
	el_iframe.frameBorder = 0;
	el_iframe.src = "/inc/editor/?content_el_name="+ pElementName;
	var el_textarea = document.createElement("textarea");
	el_textarea.id = pElementName;
	el_textarea.name = pElementName;
	el_textarea.style.display = "none";
	divDHTMLEditor.appendChild(el_iframe);
	divDHTMLEditor.appendChild(el_textarea);
}
// ================================================================================= 
function getDhtmlEditorValue(el_id) {
	var ret = "";

	var iframe_editor = document.frames[_getDhtmlEditorIFrameName(el_id)];
	if (iframe_editor == undefined) return ret;

	var iframe_content_element = iframe_editor.document.frames['tbContentElement'];
	if (iframe_content_element == undefined) return ret;

	var htmlSrcView = iframe_editor.document.getElementById("htmlSrcView");
	var edit_mode = htmlSrcView.checked ? "text" : "html";

	if (edit_mode == "text") {
		ret = iframe_content_element.document.body.innerText;
	} else {
		ret = iframe_content_element.document.body.innerHTML;
	}
	return ret;
}
// ================================================================================= 
function resetDhtmlEditorValue(el_id, cont_value) {
	var el_content = document.getElementById(el_id);
	if (el_content == null) {
		alert("DHTML EDITOR TEXTAREA¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù.");
		return;
	}
	if (cont_value != undefined) el_content.value = cont_value;

	var iframe_editor = document.frames[_getDhtmlEditorIFrameName(el_id)];
	if (iframe_editor == undefined) {
		alert("DHTML EDITOR¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù.");
		return;
	}
	iframe_editor.varConentElementName = el_id;
	iframe_editor.setTimeout("isLoading(varConentElementName);", 500);
}
// ================================================================================= 
function _getDhtmlEditorIFrameName(param) {
	return "iframe_editor_"+ param;
}
// ********************************************************************************************* 
// ================================================================================= 
var __GlobalJs = new Array();
__GlobalJs.push("global.dom.js");
__GlobalJs.push("global.string.js");
__GlobalJs.push("global.form.js");
__GlobalJs.push("ajax.js");
__GlobalJs.push("flash.js");
for (var i=0, max=__GlobalJs.length; i<max; i++) {
	js_file = "/inc/js/"+ __GlobalJs[i];
	document.write ("<script language=\"javascript\" type=\"text/javascript\" src=\""+ js_file +"\"></script>");
}