// Browse Type
// IE Script
var NS4;
var IE4;
NS4 = (document.layers);
IE4 = (document.all);
isWin = (navigator.appVersion.indexOf("Win") != -1)

if (NS4) {
	document.captureEvents(Event.CLICK)
	document.onclick = MouseDown;
} else if (IE4) {
	document.onclick = MouseDown;
}

// ÆË¾÷ °ü·Ã ÇÔ¼ö 
function open_window(url, name, width, height, feature)
{
	var oWnd;

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) { // browser version >= ie 4
		if(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);
		}
		else {
			oWnd = window.open(url, name, feature+",width=" + width +",height=" + height);
		}
	}
	else {
		oWnd = window.open(url, name, feature+",width=" + width +",height=" + height);
	}
	return oWnd;
}

function open_wnd(url, name, width, height)
{
	var oWnd = open_window(url, name, width, height, "toolbar=0,menubar=0,resizable=no,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=no");    
    else
		var oPop = open_window(url, "", width, height, "toolbar=0,menubar=0,scrollbars=no,resizable=no");    
	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://id.naver.com/nidlogin.login?mode=form&url=" + paramURL;
	top.location.href = url;
}
function toLogoutPage()
{
	var url = "/common/LogOut.jsp";
	top.location.href = url;
}

// change admin menu's class
function admin_menu_select(menu_num)
{
	for(i=1; i<=15; i++) {
		if (typeof(eval('parent.document.all.menu' + i)) == 'object') {
			if(i == menu_num) eval('parent.document.all.menu'+menu_num+'.className = "b u";');
			else eval('parent.document.all.menu'+i+'.className = "";');
		}
	}
}


function resizepopup() 	
{
	var winW = 356, winH = 200;
	winW = 356;
  winH = document.body.scrollHeight;

	if(winH > 550){
		winH = 550;
	}
  window.resizeTo(winW,winH+30);

}

function resizepopup2(wid) 	
{
	var winW = wid, winH = 200;
	winW = wid;
	winH = document.body.scrollHeight;

	if(winH > 550)
	{
		winH = 550;
	}
	window.resizeTo(winW,winH+40);
}

// onLoad Handler 
function LH_create()
{
	this.LIST = new Array();
	this.add = LH_add;
	this.exec = LH_exec;
}

function LH_add(strExec)
{
	this.LIST[this.LIST.length] = strExec;
}

function LH_exec()
{
	var list_len = this.LIST.length;
	for (var i = 0; i < list_len; i++)
	{
		eval(this.LIST[i]);
	}
}

// ÇÑ±Û ½ºÆ®¸µ Ã³¸® ÇÔ¼ö 
// string String::cut(int len, string tail)
String.prototype.cut = function(len, tail) 
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) 
	{
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
		if (l > len) return str.substring(0,i) + tail;
	}
	return str;
}

// bool String::bytes(void)
String.prototype.bytes = function() 
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) 
		l += (str.charCodeAt(i) > 128) ? 2 : 1;

	return l;
}

// string String::trim();
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

// == Iframe Handling ==
// iframe resize½Ã ÃÖ¼Ò width, height
var frmMinWidth;
var frmMinHeight;
var applyMinSize = false;
// iframe resize½Ã ÃÖ´ë width, height
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;
}

function resizeIframe(name)
{
	if (name == null || name == "")
	{
		name = "cafe_main";
	}
        
    try
    {
        if (document.all)
		    var oBody   = document.frames(name).document.body;
        else
            var oBody = document.getElementById(name).contentDocument.body;
	    var oIFrame = document.getElementById(name);
        //var frmWidth  = oBody.scrollWidth + (oIFrame.offsetWidth - oIFrame.clientWidth);
        //var frmHeight = oBody.scrollHeight + (oIFrame.offsetHeight - oIFrame.clientHeight);
        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);
        }

        if (oIFrame.src.indexOf("BoardList.do")>0&&frmWidth>600)
        {
            frmWidth = 600;
        }
        oIFrame.style.height = frmHeight;
        oIFrame.style.width = frmWidth;
    }
    catch (e) {}
}

function parentResizeIframe(name)
{
    if (parent && parent != this && parent.resizeIframe != null)
    {
        parent.resizeIframe(name);
    }
}

// F5¸¦ ´­·¶À»¶§ iframe ³»ºÎ¸¸ refresh µÇµµ·Ï Ã³¸® start
if (NS4) 
{
	document.captureEvents(Event.KEYDOWN)
	document.onkeydown = trapRefreshNS;
} 
else if (IE4) 
{
	document.onkeydown = trapRefreshIE;
}

function trapRefreshNS(e)
{
    if (e.keyCode == 116)
    {
        e.keyCode = 0; 
        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();
    }
}
// F5¸¦ ´­·¶À»¶§ iframe ³»ºÎ¸¸ refresh µÇµµ·Ï Ã³¸® end

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
    {
        var oBody   = document.frames(name).document.body;
        var oIFrame = document.all(name);
        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 replaceBackslash(paramStr) {            // µû¿ÈÇ¥¿Í ¿ª½½·¡½¬ Ã³¸®
    var str = paramStr;
    if(str.indexOf("\\") >= 0) str = str.replace(/\\/g, "\\\\");
    if(str.indexOf("\"") >= 0) str = str.replace(/\"/g, "\\\"");
    return str;
}

// ==Name UI Handling ==
var n_id = "";
var n_tid = "";
var open_type = "";
var n_nick = "";

function ui(lv_tid, lv_open_type, nick) {
    n_tid = lv_tid;
    
    if (lv_open_type == null)
        open_type = "3"    
    open_type = lv_open_type.valueOf();
    
    if (nick == null)
        n_nick = "";
    else
        n_nick = nick;
}

function exec_menuitem(key) {

    switch(key) {
        case "EVENT1" :
            blog_view(n_tid);
            break;
        case "EVENT2" :
            sendmemo(n_tid,n_nick);
            break;
        case "EVENT4" :
            PchatInvite(n_tid);
            break;
        case "EVENT5" :
            inviteClub(n_tid);
            break;
        case "EVENT6" :
            buddyAdd(n_tid);
            break;
    }

}

function blog_view(tid) {

    lv_linkUrl = "http://blog.naver.com/" + tid ;
    
    switch (open_type) 
    {
        case "0" :
        case 0 :
            document.location.href = lv_linkUrl;
            break;
        case "1" :
        case 1 :
            parent.location.href = lv_linkUrl;
            break;
        case "2" :
        case 2 :
            top.location.href = lv_linkUrl;
            break;
        case "3" : 
        case 3 :
            popblog(tid);
            break;
        case "4" :
            break;
        case "5" : 
            break;
        default :        
            document.location.href = lv_linkUrl;
            break;
    }
}

function sendmemo(id,nick)
{
    window.open("http://note.naver.com/export/sendNotePopupForm.jsp?mode=B&toNaverId=" + id + "&toNickName=" + nick + "&blockType=N&svcType=2","popWin","width=330,height=200,scrollbars=no,resizable=no,top=" + ((screen.height - 500) / 2) + ", left=" + ((screen.width - 330) / 2));
}

function PchatInvite(id)
{
    window.open("http://blog.naver.com/chat/PrivateChatOn.jsp?blogId=" + id + "&cafe=ok","popChatinvite","width=10,height=10,scrollbars=no,resizable=no,top=" + ((screen.height - 500) / 2) + ", left=" + ((screen.width - 330) / 2));
}

function inviteClub(tid)
{
    window.open("http://cafe.naver.com/CafeInviteCheckPop.do?inviteid=" + tid +"" ,"popWin","width=350,height=390,scrollbars=no,resizable=no,top=" + ((screen.height - 500) / 2) + ", left=" + ((screen.width - 330) / 2));
}

function buddyAdd(tid)
{
    window.open("http://blog.naver.com/buddy/addBuddy.jsp?blogId="+tid,"buddyAdd","width=346,height=250,scrollbars=yes");
}

function popblog(tid)
{
    var wnd = window.open("http://blog.naver.com/" + tid, "popblog");
    wnd.focus();
}

var mouse_top;
var mouse_left;
var scroll_top;
var scroll_left;
var event_id = "none";
var status_over = false;    
var parent_menu_name = "menu_parent";
var child_menu_array = ["menu_child1"];
var submenu_left_indent = 70;
var column_height = 18;
var submenu_top_indent = 0;
var mainmenu_top_indent = 0;    
var menuover_bgcolor = "#e4ff75";
var menuover_fgcolor = "#ffffff";
var default_menuover_bgcolor = "#ffffff";
var default_menuover_fgcolor = "#000000";

    function startIt() {
    }
    
    function menuOver(ar_obj, ar_id) {
        status_over = true;
        changeColor(ar_obj);
        hideChild(event_id);
        viewSubMenu(event, ar_obj, ar_id);
                
    }
    
    function SubmenuOver(ar_obj) {
        status_over = true;
        changeColor(ar_obj);
    }
    
    function MouseDown(e) {
        event_target = event.srcElement;
        event_target = event_target.toString();
        event_check = event_target.indexOf("javascript:ui(");        
        
        
        if (!status_over) hideAll();
        if (!event_check) 
            viewMenu(event,  parent_menu_name);
        else {
            if (!status_over) hideAll();
            return;
        }
    }    
    
    function hideChild(ar_id) {
        if (event_id == "none") return;
        var menu_len = child_menu_array.length;
        for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
    }
    
    function hideAll() {
        eval(parent_menu_name + ".style.display = \"none\"");
        if (event_id == "none") return;
        var menu_len = child_menu_array.length;
        for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
    }

    function viewMenu(e, ar_id) {
        if (ar_id == "none") return;
        menuLocBod = window.document.body;
        xPos = menuLocBod.scrollLeft + event.clientX;
        yPos = event.clientY + menuLocBod.scrollTop;
        screen_height = window.document.body.offsetHeight;
        screen_width = window.document.body.offsetWidth;
        mouse_top = e.y;
        mouse_left = e.x;
        eval("mainmenu_top_indent = " + parent_menu_name + ".children[0].children[0].children.length");
        mainmenu_top_indent = mainmenu_top_indent * column_height;
        if (screen_height > mouse_top + mainmenu_top_indent) 
            yPos = event.clientY + menuLocBod.scrollTop;
        else
            yPos = (event.clientY + menuLocBod.scrollTop) - mainmenu_top_indent;

        if (mouse_top - mainmenu_top_indent < 0) 
            yPos = event.clientY + menuLocBod.scrollTop;
            
        eval(ar_id + ".style.pixelTop =" + yPos);
        eval(ar_id + ".style.pixelLeft =" + xPos);        
        eval(ar_id + ".style.display = \"\"");
    }
    
    function viewSubMenu(e, ar_obj, ar_id) {
        if (ar_id == "none") return;
        event_id = ar_id;
        parent_top = menu_parent.style.pixelTop;
        parent_left = menu_parent.style.pixelLeft;
        child_top = ar_obj.style.pixelTop;
        child_left = ar_obj.style.pixelLeft;
        screen_height = window.document.body.offsetHeight;
        screen_width = window.document.body.offsetWidth;
        mouse_top = e.y;
        mouse_left = e.x;
        menuLocBod = window.document.body;
        xPos = menuLocBod.scrollLeft + parent_left + submenu_left_indent;
        eval("submenu_top_indent = " + ar_id + ".children[0].children[0].children.length");
        submenu_top_indent = submenu_top_indent * column_height;
        if (screen_height > mouse_top + submenu_top_indent) 
            yPos = event.clientY + menuLocBod.scrollTop;
        else
            yPos = (event.clientY + menuLocBod.scrollTop) - submenu_top_indent;
        
        if (mouse_top - submenu_top_indent < 0) 
            yPos = event.clientY + menuLocBod.scrollTop;
            
        eval(ar_id + ".style.pixelTop =" + yPos);
        eval(ar_id + ".style.pixelLeft =" + xPos);        
        eval(ar_id + ".style.display = \"\"");
    }
        
    function menuOut(ar_obj) {
        status_over = false;
        changeColor(ar_obj);
    }
    
    function changeColor(ar_obj) {
        

        if (ar_obj.style.background == menuover_bgcolor) {
            ar_obj.style.background = default_menuover_bgcolor;
        } else {
            ar_obj.style.background = menuover_bgcolor;
        }
        
    }


document.write("<div id=\"menu_parent\" style=\"position:absolute;display:none;top:0;left:0;z-index:9;\">");
/*
document.write("<table width=\"95\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ");
document.write("<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">");
document.write("<tr><td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT1');\" style=\"cursor:hand\"><font color=#404040>ºí·Î±×º¸±â</font></td></tr>");
document.write("<tr><td background=\"http://blogimgs.naver.com/imgs/bg_dot.gif\" height=\"1\"></td></tr>");
document.write("<tr><td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT2');\" style=\"cursor:hand\"><font color=#404040>ÂÊÁöº¸³»±â</font></td></tr>");
document.write("<tr><td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT3');\" style=\"cursor:hand\"><font color=#404040>¸ÞÀÏº¸³»±â</font></td></tr>");
document.write("<tr><td style=\"padding: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT4');\" style=\"cursor:hand\"><font color=#404040>1:1 ´ëÈ­</font></a></td></tr>");
document.write("<tr><td background=\"http://blogimgs.naver.com/imgs/bg_dot.gif\" height=\"1\"></td></tr>");
document.write("<tr><td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT5');\" style=\"cursor:hand\"><font color=#404040>Ä«ÆäÃÊ´ë</font></td></tr>");
document.write("<tr><td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('EVENT6');\" style=\"cursor:hand\"><font color=#404040>ÀÌ¿ôÃß°¡</font></td></tr>");
document.write("</table>");
document.write("</td></tr></table>");
*/
document.write("</div>");


// ¿À¸®Áö³¯ BZBoard¿¡´Â ÇÊ¿ä¾øÁö¸¸ ÀÚ»ý ¿ÏÄ¡È¯ÀÚ »ç·Ê¶§¹®¿¡ »ì·ÁµÐ ÇÔ¼ö
function showOrigSize(filename, HubCode) {
	window.open('/Admin/Include/ShowImg.asp?File=' + filename + '&HubCode=' + HubCode, '_blank', 'width=50,height=50,status=no, menubar=no, scrollbars=no, resizable=no');
}


//pngÆÄÀÏ ¿¡·¯Ã³¸®¿ë 
function setPng24(obj) {   
	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 ''; 
} 