var NS4;
var IE4;
if (document.all)
{
    IE4 = true;
    NS4 = false;
}
else
{
    IE4 = false;
    NS4 = true;
}
isWin = (navigator.appVersion.indexOf("Win") != -1)

var object_tag = {
	refresh : function(id)
	{
		var d = document.getElementById(id);
		d.parentNode.innerHTML = d.innerHTML;
	}
};

function open_window(url, name, width, height, feature)
{
    var oWnd;

    if (IE4 && width < window.screen.width && height < window.screen.height) 
    {
        var windowX = Math.ceil( (window.screen.width  - width) / 2 );
        var windowY = Math.ceil( (window.screen.height - height) / 2 );

        oWnd = window.open(url, name, feature+",width=" + width +",height=" + height+",left="+windowX+",top="+windowY + ",resizable=yes");
    }
    else 
    {
        oWnd = window.open(url, name, feature+",width=" + width +",height=" + height + ",resizable=yes");
    }

    return oWnd;
}
function open_wnd(url, name, width, height)
{
    var oWnd = open_window(url, name, width, height, "toolbar=0,menubar=0,resizable=yes,scrollbars=no");
    return oWnd;
}
function pop(url,width,height,flag)
{
    if (flag == 1 )
        var oPop = open_window(url, "", width, height, "toolbar=0,menubar=0,scrollbars=yes,resizable=yes");    
    else
        var oPop = open_window(url, "", width, height, "toolbar=0,menubar=0,scrollbars=no,resizable=yes");    
    return oPop;        
}

function pop2(url,width,height,flag)
{
    if (flag == 1)
		var oPop = open_window(url, "", width, height, "toolbar=0,menubar=0,scrollbars=no,resizable=yes");    
    else
		var oPop = open_window(url, "", width, height, "toolbar=0,menubar=0,scrollbars=no,resizable=no");
	
	return oPop;
}

function toLoginPage(paramURL)
{
    if (paramURL == null || paramURL == '')
        paramURL = document.location.href;
        
    var url = "http://nid.naver.com/nidlogin.login?mode=form&url=" + paramURL;
    top.location.href = url;
}
function toLogoutPage()
{
    var url = "/common/LogOut.jsp";
    top.location.href = url;
}

LOAD_LIST = new Array();
function LH_create()
{
    this.LIST = LOAD_LIST;
    this.add = LH_add;
    this.exec = LH_exec;
}
function LH_add(strExec)
{
    LOAD_LIST[LOAD_LIST.length] = strExec;
}
function LH_exec()
{
    var list_len = LOAD_LIST.length;
    for (var i = 0; i < list_len; i++)
    {
        eval(LOAD_LIST[i]);
    }
}

function replaceBackslash(paramStr) 
{
    var str = paramStr;
    if (str.indexOf("\\") >= 0) str = str.replace(/\\/g, "\\\\");
    if (str.indexOf("\"") >= 0) str = str.replace(/\"/g, "\\\"");
    return str;
}

function setTop()
{
	window.scrollTo(0,0);
}

var frmMinWidth;
var frmMinHeight;
var applyMinSize = false;
var frmMaxWidth;
var frmMaxHeight;
var applyMaxSize = false;
function setMinSize(width, height)
{
    frmMinWidth = width;
    frmMinHeight = height
    applyMinSize = true;
}
function setMaxSize(width, height)
{
    frmMaxWidth = width;
    frmMaxHeight = height
    applyMaxSize = true;
}

/*
 *	nameÀÌ ¾Æ´Ï¶ó id´Ù.. <iframe> ÅÂ±×¿¡¼­ id¼³Á¤ÀÌ ¾øÀ» °æ¿ì F.F¿¡¼­ ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù.
 *	ÀåÁ¡ : ±Û·Î¹ú º¯¼ö¸¦ ÅëÇØ ÇÁ·¹ÀÓ »çÀÌÁî Á¶ÀýÀ» ÃÖ´ë³ª ÃÖ¼Ò·Î ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.
 *         ÇÁ·¹ÀÓ »çÀÌÁîÀ» ÆäÀÌÁö ¾î´À °÷¿¡¼­µç °¡´ÉÇÏ´Ù.
 *	´Ü´ý : ÄÚµå°¡ ¾à°£ ±æ´Ù.
 *		   »çÀÌÁî Á¶ÀýÀ» ¿äÇÏ´Â iframe¿¡ id¼³Á¤ÀÌ ÇÊ¿äÇØ ¾à°£ÀÇ ¹ø°Å·Î¿òÀÌ ÀÖ´Ù
 */
function resizeIframe(name)
{
    if (name == null || name == "")
    {
        name = "board_main";
    }
        
    try
    {
        if (IE4)
            var oBody   = document.frames(name).document.body;
        else
            var oBody = document.getElementById(name).contentDocument.body;
        var oIFrame = document.getElementById(name);

        var frmWidth  = oBody.scrollWidth;
        var frmHeight = oBody.scrollHeight;

        if (applyMinSize)
        {
            frmWidth  = Math.max(frmWidth, frmMinWidth);
            frmHeight = Math.max(frmHeight, frmMinHeight);
        }
        if (applyMaxSize)
        {
            frmWidth  = Math.min(frmWidth, frmMaxWidth);
            frmHeight = Math.min(frmHeight, frmMaxHeight);
        }

        oIFrame.style.height = frmHeight + "px";
        oIFrame.style.width = frmWidth + "px";
    }
    catch (e) {}
}
function parentResizeIframe(name)
{
    if (parent && parent != this && parent.resizeIframe != null)
    {
        parent.resizeIframe(name);
    }
}

if (NS4) 
{
    document.captureEvents(Event.KEYDOWN)
    document.onkeydown = trapRefreshNS;
} 
else if (IE4) 
{
    document.onkeydown = trapRefreshIE;
}

function trapRefreshNS(e)
{
    if (e.keyCode == 116)
    {
        e.cancelBubble = true; 
        e.returnValue = false;
        document.location.reload();
    }
}

function trapRefreshIE()
{
    if (event.keyCode == 116)
    {
        event.keyCode = 0; 
        event.cancelBubble = true; 
        event.returnValue = false;
        document.location.reload();
    }
}

function parentPlusIframe(name, height)
{
    if (parent && parent != this && parent.plusIframe != null)
    {
        parent.plusIframe(name, height);
    }
}

function plusIframe(name, height)     
{
    if (name == null || name == "")
    {
        name = "cafemain";
    }
    
    try
    {
        if (IE4)
            var oBody   = document.frames(name).document.body;
        else
            var oBody = document.getElementById(name).contentDocument.body;
        var oIFrame = document.getElementById(name);

        var frmWidth  = oBody.scrollWidth;
        var frmHeight  = oBody.scrollHeight;

        if (applyMinSize)
        {
            frmHeight = Math.max(frmHeight, frmMinHeight);
        }
        if (applyMaxSize)
        {
            frmHeight = Math.min(frmHeight, frmMaxHeight);
        }
        oIFrame.style.height = frmHeight + height;
    }
    catch (e)
    {
        window.status = "IFrame Size Plus Error";
    }
}


function resizeWindow()
{
	//if ( !IE4 )
	//{
		window.resizeTo(0,0);
	//}
	
	var iscrollWidth = document.body.scrollWidth;
	var iscrollHeight = document.body.scrollHeight;
	window.resizeTo(iscrollWidth, iscrollHeight);
	
	window.resizeBy(iscrollWidth - document.body.clientWidth, 
					iscrollHeight - document.body.clientHeight);
					
	window.resizeBy(iscrollWidth - document.body.clientWidth, 
					iscrollHeight - document.body.clientHeight);
}

function resizepopup()     
{
// var winW = 356, winH = 200;
    winW = document.body.scrollWidth;
    winH = document.body.scrollHeight;
/*
    if(winH > 550)
        winH = 550;
*/
    window.resizeTo(winW + 25,winH + 40);
}

function resizepopup2(wid)     
{
    var winW = wid, winH = 200;
    winH = document.body.scrollHeight;

    if(winH > 550)
        winH = 550;

    window.resizeTo(winW,winH+40);
}

/* iframeObj : »çÀÌÁî Á¶ÀýÀÌ ÇÊ¿äÇÑ iframeÀÇ °´Ã¼
 * ÀåÁ¡ : ÄÚµå°¡ ´Ü¼øÇÏ´Ù.
 * ´Ü´ý : ÇÁ·¹ÀÓ »çÀÌÁî Á¶ÀýÀ» À§ÇØ¼± °´Ã¼¸¦ ³Ñ°ÜÁà¾ß ÇÑ´Ù.
 *        iframe onload½Ã¿¡ this°´Ã¼¸¦ ³Ñ°ÜÁÖ´øÁö, ¾Æ´Ï¸é °´Ã¼¸¦ get¸Þ¼Òµå¸¦ ÅëÇØ ±¸ÇØ¼­ ³Ñ°ÜÁà¾ß ÇÑ´Ù.
 *        ÇÁ·¹ÀÓ »çÀÌÁî¸¦ »ðÀÔµÈ ÆäÀÌÁöÀÇ »çÀÌÁî·Î ¹Û¿¡ ÀúÀýÀÌ ¾ÊµÈ´Ù.
 * 
 */
function resizeFrame(iframeObj)
{
	var innerBody = iframeObj.contentWindow.document.body;

	if(innerBody.scrollHeight > innerBody.offsetHeight)
	{	//FF
		iframeObj.style.height = innerBody.offsetHeight;
	}

	var innerHeight = innerBody.scrollHeight;
	var innerWidth = innerBody.scrollWidth;
	
	iframeObj.style.height = innerHeight;
	iframeObj.style.width = innerWidth;
}

function showMenuSwf()
{
  document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"249\" height=\"37\" id=\"open_c\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"http://play.naver.com/js/flash/open_play.swf\" /><param name=\"menu\" value=\"false\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#000000\" /><embed src=\"http://play.naver.com/js/flash/open_play1.swf\" menu=\"false\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#000000\" width=\"249\" height=\"37\" name=\"open_c\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>");
}