/**
 * ÇöÀç¹®¼­¿Í iframe ÀÇ ¹®¼­°¡ µ¿ÀÏÇÑ µµ¸ÞÀÎ ³»ÀÇ ¹®¼­ÀÌ¸é 
 * iframe ÀÇ ³ôÀÌ¸¦ iframe ¹®¼­ÀÇ ³ôÀÌ¿Í ¸ÂÃÄ ½ºÅ©·ÑÀ» ¾ø¾Ø´Ù.
 * µÎ ¹®¼­°¡ µ¿ÀÏÇÑ host ¸¦ °®´Â´Ù¸é document.domain ÀÇ º¯°æ¾øÀÌ
 * °´Ã¼¿¬»êÀÌ °¡´ÉÇÏ³ª
 * µÎ ¹®¼­ÀÇ µµ¸ÞÀÎ ¸¸ÀÌ µ¿ÀÏÇÏ´Ù¸é document.domain °ªÀ» º¯°æÇÑ´Ù.
 * µµ¸ÞÀÎ ÀÚÃ¼°¡ Æ²¸®´Ù¸é °´Ã¼ÀÇ Åë½ÅÀº ºÒ°¡´ÉÇÏ´Ù.
 */

function replaceIframe( returnUrl) {
	
	
	try{			
	var iframeObj = document.contentFrame;
	iframeObj.location = returnUrl;
}catch(e){
		//alert("error : " + e);
	}
}

function initIframe(iframeObj) {
	// Check host and domain
//	iframeObj.style.visibility = "hidden";
	var thisHost = self.location.host;
	var thisDomain = thisHost.split(".")[thisHost.split(".").length-2] + 
			"." + thisHost.split(".")[thisHost.split(".").length-1];
	var iframeHost = (iframeObj.src.indexOf("/") == 0) ?
			thisHost : (iframeObj.src.split("/"))[2];
	var iframeDomain = iframeHost.split(".")[iframeHost.split(".").length-2] + 
			"." + iframeHost.split(".")[iframeHost.split(".").length-1];
	
	if (iframeHost != thisHost && iframeDomain == thisDomain) {
		document.domain = thisDomain;
	}
	
	// Try change to iframe height
	if (iframeDomain == thisDomain) {
		var currentIframeHeight = iframeObj.height;
		try {
		//	iframeObj.height = 0; // initialize iframe height
			var DEFAULT_MARGIN = 2;
			var iframeDocument = document.frames(iframeObj.name).document;
			var newIframeHeight = iframeDocument.body.scrollHeight + (DEFAULT_MARGIN * 2);
			iframeObj.height = newIframeHeight ;
			
			//alert(newIframeHeight + "/" + currentIframeHeight);
		/*
			if(newIframeHeight > currentIframeHeight) {
				iframeObj.height = newIframeHeight ;
			} else {
				iframeObj.height = currentIframeHeight;
			}
		*/
		} catch (e) {
			// default max size setting
			iframeObj.height = "1300";
			//alert("IFRAME ³»¿¡ document.domain À» " + thisDomain + " À¸·Î º¯°æÇÏ¼¼¿ä !!");
		} finally {
			iframeObj.style.visibility = "visible";
		}
	}
}