// ==Name UI Handling ==

var NS4;
var IE4;
if (document.all)
{
    IE4 = true;
    NS4 = false;
}
else
{
    IE4 = false;
    NS4 = true;
}

if (IE4) 
{
    document.onclick = MouseDown;
}
else if (NS4) 
{
    document.captureEvents(Event.CLICK)
    document.onclick = MouseDown;
} 

var memberid = "";
var selCode = "";
var nickname = "";

function ui(p_memberid, p_mbcode,p_selCode) {
    memberid = p_memberid;
	mbcode = p_mbcode;
	selCode = p_selCode;
	if(selCode=="") selCode = '1'
}

function execMenuItem(opType) 
{
    switch(opType) 
    {
        case "EVENT1" :
            viewBoard(memberid,selCode);
            break;
        case "EVENT2" :
            memoSend(mbcode, memberid);
            break;
        case "EVENT3" :
            viewReview(mbcode, memberid);
            break;
        case "EVENT4" :
            GiveAvatar(mbcode, memberid)
            break;
    }
    hideAll();
}

function getTop(){
    return (screen.height - 500) / 2;
}
function getLeft(){
    return (screen.width - 330) / 2;
}
function viewBoard(memberid) {
	if(selCode=="poll"){
	    document.location.href = "/poll/poll.asp?chk1=&chk3=&chk4=on&txtser=" + escape(memberid);
	}else if(selCode=="knowledge"){
	document.location.href = "/knowledge/total.asp?name=all&txtser=" + escape(memberid);	
	}else if(selCode=="club"){
	document.location.href = "/club/inform.asp?name=all&txtser=" + escape(memberid);
	}else if(selCode.substring(0,9) =="musician_"){
	document.location.href = "/musician/list.asp?sel_code=" + selCode.substring(9, 10) + "&chk1=&chk3=&chk4=on&txtser=" + escape(memberid);
	}else if(selCode==5){
	document.location.href = "/community/photo/list.asp?sel_code=" + selCode + "&chk1=&chk3=&chk4=on&txtser=" + escape(memberid);
	}else{
	document.location.href = "/community/board/list.asp?sel_code=" + selCode + "&chk1=&chk3=&chk4=on&txtser=" + escape(memberid);
	}
	
}
function viewReview(mbcode,memberid){
    document.location.href = "/information/review.asp?writer=" + escape(memberid);
}
function GiveAvatar(mbcode,memberid){
    document.location.href = "/avatar/giveSave.asp?code=" + mbcode + "&name=" + escape(memberid);
}
var mouse_top;
var mouse_left;
var status_over = false;    
var parent_menu_name = "menu_parent";
var column_height = 18;
var mainmenu_top_indent = 0;    
var menuover_bgcolor = "#DCE2F5";
var default_menuover_bgcolor = "#ffffff";

function MouseDown(e) 
{
    if (!e) e = window.event;
    event_target = (NS4) ? e.target : e.srcElement;
    event_target = event_target.toString();
    event_check = event_target.indexOf("javascript:ui(");        
    
    if (!status_over) hideAll();
    if (!event_check) 
        viewMenu(e,  parent_menu_name);
    else 
    {
        if (!status_over) hideAll();
        return;
    }
}    
function hideAll() 
{
    eval("document.getElementById('" + parent_menu_name + "').style.display = \"none\"");
}
function viewMenu(e, ar_id) 
{
    if (ar_id == "none") return;
    menuLocBod = window.document.body;
    xPos = menuLocBod.scrollLeft + e.clientX;
    yPos = e.clientY + menuLocBod.scrollTop;
    screen_height = window.document.body.offsetHeight;
    screen_width = window.document.body.offsetWidth;
    mouse_top = e.y;
    mouse_left = e.x;
    mainmenu_top_indent = eval("document.getElementById('" + parent_menu_name + "').childNodes[0].childNodes[0].childNodes.length");
    mainmenu_top_indent = mainmenu_top_indent * column_height;
    if (screen_height > mouse_top + mainmenu_top_indent) 
        yPos = e.clientY + menuLocBod.scrollTop;
    else
        yPos = (e.clientY + menuLocBod.scrollTop) - mainmenu_top_indent;

    if (mouse_top - mainmenu_top_indent < 0) 
        yPos = e.clientY + menuLocBod.scrollTop;

    var objMenu = eval("document.getElementById('" + ar_id + "')");
    objMenu.style.top = yPos;
    objMenu.style.left = xPos;
    objMenu.style.display = "";
}
function menuOver(obj) 
{
    status_over = true;
    changeOnColor(obj);
}
function menuOut(obj) 
{
    status_over = false;
    changeOutColor(obj);
}

function changeOnColor(obj)
{
    obj.style.backgroundColor = menuover_bgcolor;
}
function changeOutColor(obj)
{
    obj.style.backgroundColor = default_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: 2 0 0 10\" height=\"22\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this);\" onclick=\"execMenuItem('EVENT2');\" style=\"cursor:hand\"><font color=#404040>ÂÊÁöº¸³»±â</font></td></tr>");
document.write("<tr><td height='1' bgcolor='#eeeeee'></td></tr>");
document.write("<tr><td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this);\" onclick=\"execMenuItem('EVENT1');\" 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);\" onclick=\"execMenuItem('EVENT3');\" style=\"cursor:hand\"><font color=#404040>¸®ºä±Ûº¸±â</font></td></tr>");
document.write("<tr><td height='1' bgcolor='#eeeeee'></td></tr>");
document.write("<tr><td style=\"padding: 3 0 0 10\" height=\"23\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this);\" onclick=\"execMenuItem('EVENT4');\" style=\"cursor:hand\"><font color=#404040>¼±¹°º¸³»±â</font></td></tr>");
document.write("</table>");
document.write("</td></tr></table>");
document.write("</div>");
