
/*
 * ¸¶½ºÅ© ÃÊ±â »ý¼º / Msg ÇÁ·¹ÀÓ »ý¼º ÇÔ¼ö
 */
function setMaskDiv() {
	var tmpBody = (document.compatMode=="CSS1Compat")?document.documentElement:document.body; //create reference to common "body" across doctypes
	var tmpForm  = document.createElement("form");
	var tmpDiv1 = document.createElement("div");
	var tmpDiv2 = document.createElement("div");
	var tmpDiv3 = document.createElement("div");
	try {
		if (tmpForm) {
			tmpForm.setAttribute("id","hfrm");
			tmpForm.setAttribute("name","hfrm");
			tmpForm.setAttribute("target","m2ifr");
		}
		if (tmpDiv1) tmpDiv1.setAttribute("id","cmask");
		if (tmpDiv2) {
			tmpDiv2.setAttribute("id","imsg");
			tmpDiv2.setAttribute("style","position:absolute;");
			tmpDiv2.innerHTML = "<iframe name=\"m2ifr\" id=\"m2ifr\" src=\"about:blank\" width=\"474\" height=\"405\" frameborder=\"0\" frame=\"no\" allowTransparency=\"true\" onload=\"initIfraMsg(this.id)\" scrolling=\"no\"><\/iframe>";
		}
		if (tmpDiv3) {
			tmpDiv3.setAttribute("id","isubmsg");
			tmpDiv3.setAttribute("style","position:absolute");

			tmpDiv3.innerHTML = "<iframe name=\"m2ifrsub\" id=\"m2ifrsub\" src=\"about:blank\" width=\"363\" height=\"200\" frameborder=\"0\" frame=\"no\" allowTransparency=\"true\" onload=\"initIfraMsg(this.id)\" scrolling=\"no\"><\/iframe>";
		}
		tmpBody.appendChild(tmpForm);
		tmpBody.appendChild(tmpDiv1);
		tmpBody.appendChild(tmpDiv2);
		tmpBody.appendChild(tmpDiv3);

	} catch(e) {}
	initDiv();
	initIfraMsg();
}


/*
 * ¸¶½ºÅ© À§Ä¡ ÇÔ¼ö
 */
function initMaskDiv() {
	var tmpBody = (document.compatMode=="CSS1Compat")?document.documentElement:document.body; //create reference to common "body" across doctypes
	var tmpDiv = document.getElementById("cmask");
	var minW = 474, minH = 750;//ÇÊÅÍ¸µ¿µ¿ª
	var tmpW = (tmpBody.offsetWidth <= minW)?minW+"px":"100%";
	var tmpH = (tmpBody.offsetHeight <= minH)?minH+"px":"100%";
	if (tmpDiv) {
		tmpDiv.style.width = tmpW;
		tmpDiv.style.height = tmpH;
	}
}

function toggleMaskDiv() {
	var tmpDiv = document.getElementById("cmask");
	if (tmpDiv) {
		tmpDiv.style.display =(tmpDiv.style.display != "block")?"block":"none";
	}
}



/*
 * ÃÊ±â ·¹ÀÌ¾îÀ§Ä¡ Á¶Á¤ ÇÔ¼ö
 */
function initDiv() {
	initMaskDiv();
}


/*
 * ¸Þ¼¼Áö Ã¢ È°¼ºÈ­ ÇÔ¼ö
 */
function initIfraMsg() {
	var tmpDiv = document.getElementById("cmask");
	var tmpIfrDiv = document.getElementById("imsg");
	var tmpIfrObj = document.getElementById("m2ifr");
	var tmpIfrSubDiv = document.getElementById("isubmsg");
	var tmpIfrSubObj = document.getElementById("m2ifrsub");
	if (tmpDiv && tmpDiv.style.display == "block") {
		if (tmpIfrSubDiv.style.display == "block") {
			posIfraMsg(tmpIfrSubDiv, tmpIfrSubObj);
		} else {
			tmpIfrDiv.style.display = "block";
			posIfraMsg(tmpIfrDiv, tmpIfrObj);
		}
	} else {
		posIfraMsg(tmpIfrDiv, tmpIfrObj);
		if (tmpIfrDiv) tmpIfrDiv.style.display = "none";
		if (tmpIfrSubDiv) tmpIfrSubDiv.style.display = "none";
	}
}

/*
 * ¸Þ¼¼Áö Ã¢ À§Ä¡ ¹× »çÀÌÁî Á¶Á¤ ÇÔ¼ö
 */
function posIfraMsg(tDiv, tIfra) {
	var minH = 100, maxH = 735, minW = 300, maxW = document.body.scrollWidth;
	var tmpH, tmpW;
	try {
		if (tIfra) {
			var tmpBody = (document.compatMode=="CSS1Compat")?tIfra.contentWindow.document.documentElement:tIfra.contentWindow.document.getElementsByTagName('body')[0]; //create reference to common "body" across doctypes
			tmpH = (tmpBody.scrollHeight < minH)?minH:((tmpBody.scrollHeight > maxH)?maxH:tmpBody.scrollHeight+5);
			tmpW = (tmpBody.scrollWidth < minW)?minW:((tmpBody.scrollWidth > maxW)?maxW:tmpBody.scrollWidth);
			tIfra.style.height = tmpH;
			tIfra.style.width = tmpW;
			if (tDiv) {
				//alert(maxW+"/"+tmpW);
				tDiv.style.top = ((maxH - tmpH)/2)+"px";
				tDiv.style.left = ((maxW - tmpW)/2)+"px";
			}
		}
	} catch(e) { } // about:blank ÀÏ°æ¿ì ÇØ´ç ¼Ó¼º ¾øÀ½ Ã³¸®
}



addLoadEvent(setMaskDiv);
addResizeEvent(initDiv);
