/*
 * function : define flash tag and write
 * @info    : ActivX IE modify
 * @param fID(Flash ID), fURL(Flash URL), w(width), h(height)
 *        wmode(wmode value[null,0 - non select mode, 1 - select mode])
 *        bgClr(background color[null - no value, value - set value])
 *        lstate(loop value[null,0 - not define loop, 2 - loop false])
 *        rtnV(return type[null,0 - null, 1 - string])
 */
function drawFlash(fID, fURL, w, h, wmode, bgClr, lstate, rtnV) {
	var tmpStr = "";
	tmpStr += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + w + "' height='" + h + "' id='" + fID + "' name='" + fID + "' align='middle' type='application/x-shockwave-flash'>";
	tmpStr += "<param name='allowScriptAccess' value='always' />";
	tmpStr += "<param name='movie' value='" + fURL + "' />";
	tmpStr += "<param name='quality' value='high' />";
	tmpStr += "<param name='menu' value='false' />";

	if (lstate == 2) tmpStr += "<param name='loop' value='false' />";
	if (wmode == 1) tmpStr += "<param name='wmode' value='transparent' />";
	if (wmode == 2) tmpStr += "<param name='wmode' value='opaque' />";
	if (bgClr != null && bgClr != "undefined") tmpStr += "<param name='bgcolor' value='" + bgClr + "' />";

	tmpStr += "<embed src='" + fURL + "' quality='high' ";
	if (lstate == 2) tmpStr += "loop='false' ";
	if (wmode == 1) tmpStr += "wmode='transparent' ";
	if (wmode == 2) tmpStr += "wmode='opaque' ";
	if (bgClr != null && bgClr != "undefined") tmpStr += "bgcolor='" + bgClr + "' ";

	tmpStr += "width='" + w + "' height='" + h + "' name='" + fID + "' menu='false' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'  />";
	tmpStr += "</object>";

	if (rtnV && rtnV == 1) { // return string
		return tmpStr;
	} else {
		document.write(tmpStr);
		eval("window."+fID+"=document.getElementById('"+fID+"');");
	}
}


/*
 * PNG ÀÌ¹ÌÁö Ã³¸® ÇÔ¼ö
 */
function setPng24(obj) {
	try {
		obj.width=obj.height=1;
		obj.className=obj.className.replace(/\bpng24\b/i,'');
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
		obj.src='';
		return '';
	} catch(e) {}
}


/* function : check null */
function isNull(tObj) {
	if (tObj == null || tObj == "undefined") return true;
	return false;
}


/* function : add onload function */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof(window.onload) != "function") {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


/* function : add onresize function */
function addResizeEvent(func) {
	var oldonresize = window.onresize;
	if (typeof(window.onresize) != "function") {
		window.onresize = func;
	} else {
		window.onresize = function() {
			oldonresize();
			func();
		}
	}
}

/*
 * ·Ñ¿À¹ö ÀÌ¹ÌÁö
 */
function swapImg(tObj, mState) {
	if (tObj && tObj.src) {
		tObj.src = (mState == "o")?tObj.src.replace("x.gif","o.gif"):tObj.src.replace("o.gif","x.gif");
	}
}


/*
 * ·Ñ¿À¹ö DIV
 */
function chgDiv(tObj, mState) {
	if (tObj) {
		if (typeof(tObj) == "string") tObj = document.getElementById(tObj);
		tObj.style.display = (mState == "o")?"block":"none";
	}
}


/*
 * function : define popup window
 * @param url(page url), wname(popup name), w(width), h(height)
 *        ptype(popup type), t(top position), l(left position)
 */
function popWin(url,wname,w,h,ptype,t,l){
	var popupWin;
	var popOpt = "width="+w+",height="+h+"";
	if (!isNull(t)) popOpt += ",top="+t;
	if (!isNull(l)) popOpt += ",left="+l;
	if(ptype == 0){
		popOpt += ",scrollbars=no";
	}
	if(ptype == 1){
		popOpt += ",scrollbars=yes";
	}
	if(ptype == 2){
		popOpt += ",scrollbars=yes,resizable=yes";
	}
	if(ptype == 3){
		popOpt += ",scrollbars=no,resizable=yes";
	}
	popupWin = window.open(url,wname,popOpt);
	popupWin.focus();
}


/*
 * function : define popup close
 */
function closePop() {
	try {
		top.window.opener = top;
		top.window.open('','_parent','');
		top.window.close('');
//		if (window.opener != null && window.opener.closed) window.opener = self;
	} catch (e) {
		top.window.opener = self;
		self.close();
	}
}


/*
 * ¸Þ¼¼Áö Ã¢¿¡ URL È£Ãâ
 */
function sendURLMsg(url, target, params) {
	if (url) {
		var tmpForm = (document.getElementById("hfrm"))?document.getElementById("hfrm"):parent.document.getElementById("hfrm");
		if (tmpForm) {
			if (target == "m2ifrsub") { // ¼­¹ö iframe ¸í
				var tmpIfrSubDiv = parent.document.getElementById("isubmsg");
				if (tmpIfrSubDiv) tmpIfrSubDiv.style.display = "block";
			}
			tmpForm.target = (target)?target:"m2ifr";
			tmpForm.method = "post";
			tmpForm.action = url;
			if (params) {
				for (var i = 0; i < params.length; i++) {
					setFormParams(tmpForm, params[i].id, params[i].value);
				}
			}
			tmpForm.submit();
			clearFormParams(tmpForm);
		}
	}
}



/*
 * ¸Þ¼¼Áö ·¹ÀÌ¾î ´Ý±â ÇÔ¼ö
 */
function closeMsg() {
	try {
		var tmpDiv = (document.getElementById("cmask"))?document.getElementById("cmask"):parent.document.getElementById("cmask");
		var tmpIfrDiv = (document.getElementById("imsg"))?document.getElementById("imsg"):parent.document.getElementById("imsg");
		var tmpIfrSubDiv = (document.getElementById("isubmsg"))?document.getElementById("isubmsg"):parent.document.getElementById("isubmsg");

		if (tmpIfrSubDiv && tmpIfrSubDiv.style.display == "block") { // ¼­ºê Msg Ã¢ÀÌ ¶°ÀÖ´Â °æ¿ì
			tmpIfrSubDiv.style.display = "none";
		} else {
			if (tmpIfrDiv) tmpIfrDiv.style.display = "none";
			if (tmpDiv) tmpDiv.style.display = "none";
		}

		window.location.href = "about:blank"; // ºó ¹®¼­
	} catch(e) {}
}