
function _QuickMenu ()
{
    /* »ç¿ë ¹æ¹ý */
    // ¾Æ·¡¿Í °°Àº ÇüÅÂ·Î½ºÅ¸ÀÏÀ» Àû¿ëÇÑ
    //     #quickMenu { }
    //    #quickT{ }
    //
    // NxQuickMenu ¿ÀºêÁ§Æ®¸¦ »ç¿ë
    //
    // addItem(itemName, eventHandler) : ¸Þ´º ¾ÆÀÌÅÛ°ú ÀÌº¥Æ® ÇÚµé·¯¸¦ µî·Ï. Å¬¸¯ ÀÌº¥Æ® ¹ß»ý½Ã ÇØ´ç ÀÌº¥Æ® ÇÚµé·¯ ¼öÇàÇÏ¸ç Äü¸Þ´º¸¦ ¼û±è
    //     itemName - ¸Þ´º ¾ÆÀÌÅÛ ÀÌ¸§
    //     eventHander - ¼öÇàÇÒ ÀÌº¥Æ® ÇÚµé·¯
    //
    // addText(strText)                : ¸Þ´º¿¡ Æ÷ÇÔµÉ ÅØ½ºÆ® µî·Ï.  Å¬¸¯ ÀÌº¥Æ® ¼öÇà ¾ÈÇÏ¸ç, Äü¸Þ´º¸¦ ¼û±âÁö ¾ÊÀ½
    //     str - Äü¸Þ´º¿¡ Ç¥½ÃÇÒ ÅØ½ºÆ® ³»¿ë
    //
    // Execute(myEvent, property)      : NxQuickMenu¸¦ º¸¿©ÁÖ±â À§ÇÑ ¸Þ¼Òµå. ¸Þ¼Òµå ½ÇÇà ÈÄ µî·ÏµÇ¾ú´ø ¾ÆÀÌÅÛ ¸®½ºÆ®´Â ¸®¼ÂµÊ.
    //     myEvent - IE¿¡¼­´Â event¸¦ ±Û·Î¹úÇÏ°Ô »ç¿ëÇÒ ¼ö ÀÖÁö¸¸, Firefoxµî¿¡¼­ Å¬¸¯ ÀÌº¥Æ®¸¦ ¹Þ¾Æ¿À±â À§ÇÑ event ¿ÀºêÁ§Æ®¸¦ ÆÄ¶óºñÅÍ·Î ¹Þ¾Æ¾ß ÇÔ
    //     properties
    //          loc : Äü¸Þ´º°¡ Ç¥½ÃµÉ À§Ä¡ ¼±Á¤ "below"(±âº», ¸¶¿ì½º Å¬¸¯ À§Ä¡ ¾Æ·¡¿¡ Ç¥½Ã) È¤Àº "above" (¸¶¿ì½º Å¬¸¯ À§Ä¡ À§¿¡ Ç¥½Ã)
    //          headerContents : header¿¡ µé¾î°¥ ³»¿ë. ´Ý±â ¹öÆ°¿¡ NxQuickMenu.hide() ÇÔ¼ö¸¦ ¸ÅÇÎ


    /* º¯¼ö */        
    // itemList, eventList ¹× nItems´Â addItem method¸¦ ÅëÇÏ¿© Ãß°¡µÇ¸ç, Execute ½ÇÇà ÈÄ¿¡´Â ±× ³»¿ëÀ» Áö¿î´Ù.
    // nItems´Â ÃÑ ¾ÆÀÌÅÛ °¹¼ö¸¦ ³ªÅ¸³»¸ç, itemList¿¡´Â ¾ÆÀÌÅÛ ÀÌ¸§À», eventList´Â ÇØ´ç ¾ÆÀÌÅÛ¿¡ ´ëÇÑ onClick ÀÌº¥Æ® ÇÚµé¸µ ¸Þ¼Òµå¸¦ ÀúÀåÇÑ´Ù.
    this.itemList = new Array();    
    this.eventList = new Array();
    this.nItems = 0;


    // loc °ªÀº above È¤Àº below¸¦ ÃëÇØ¾ß ÇÏ¸ç, aboveÀÏ °æ¿ì Äü¸Þ´º¸¦ ¸¶¿ì½º Å¬¸¯ À§Ä¡¿¡¼­ À§ÂÊ¿¡, below´Â ¾Æ·¡ÂÊ¿¡ Ç¥½ÃÇÑ´Ù.
    // default value ·Î below°¡ ¼±ÅÃµÇ¸ç, ÀÌ °ªÀº Execute ¸¦ È£ÃâÇÏ¸é¼­ ÁöÁ¤ÇÑ´Ù.
    this.loc = "";
    this.headerContents = "<h4>quick menu</h4><a href='javascript:NxQuickMenu.hide();'><img src='http://s.nx.com/S2/Portal/Nexon/Nexon2007/image/button/bt_close_quick.gif' alt='´Ý±â' /></a>";
    
    this.generateHtml = function()
    {
        var header = "<div id='quickMenu'><div id='quickT'> " + this.headerContents + "</div><ul>";
        var contents = this.getBody();
        var footer = "</ul></div>";
        return  header + contents + footer;
    }            
        
    this.addText = function (strText, strValue)
    {
        this.itemList[this.nItems] = strText;
        
        if(strValue == '')
			this.eventList[this.nItems] = "__nx_text__";
		else
			this.eventList[this.nItems] = strValue;
			
        this.nItems ++;
    }
    this.addItem = function (itemName, eventHandler)
    {
        this.itemList[this.nItems] = itemName;
        this.eventList[this.nItems] = eventHandler;
        this.nItems ++;
    }


    this.open = function(myEvent){
       var curObj = document.getElementById("quickMenu");

       if(myEvent != null){            
            var loc_x = myEvent.clientX + document.body.scrollLeft;
            var loc_y = myEvent.clientY + document.body.scrollTop;
        }       
                
        if(this.loc == "above"){
            var height = 0;
            if(curObj.currentStyle != null){
                height = curObj.currentStyle.height + "";
            }
            else if(curObj.clientHeight != null)
            {
                height = curObj.clientHeight + "";
            }
            if(height != 0){
                if(height.search("px")>0){
                    height = height.substring(0, height.indexOf("px"));
                }

                if(height > 0){    
                    loc_y = loc_y - height;
                }
                if(loc_y < 0){ loc_y = 0;}
            }
        }        
        curObj.style.left= loc_x;
        curObj.style.top = loc_y;
        curObj.style.visibility="visible";        
    }

    this.close = function()
    {
        alert("close function used. but it shouldn't be;");
    }

    this.hide = function()
    {
        document.getElementById("quickMenu").style.visibility='hidden';
    }
    this.getBody = function()
    {
        var str = "";
        var i=0;
        for(i=0; i<this.nItems; i++){
			
			str += "<li ";
			if(this.eventList[i] == "-")
				str += "class='lineQ'>";
			else if(this.eventList[i] == "none")			
				str += "class=\"dimout\">" + this.itemList[i];
			else if(this.eventList[i] == "__nx_text__")
				str += " >" + this.itemList[i];
			else
				str += "style='cursor:hand' onClick = 'NxQuickMenu.hide();" + this.eventList[i] + "'" + " >" + this.itemList[i];
			
			str += "</li>";
        }
        
        return str;            
    }
        
    this.createPH = function()
    {
        if(!document.getElementById('quickMenu'))
        {
            var myPh = document.createElement( 'div' );
            document.body.appendChild(myPh);
            myPh.id = "quickMenu";
            myPh.style.position="absolute";
        }
    }

    // myEvent ÆÄ¶ó¹ÌÅÍ´Â FireFoxµî¿¡¼­ ¸¶¿ì½º Å¬¸¯ ÀÌº¥Æ®¸¦ ¹Þ¾Æ¿À±â À§ÇÔ
    this.Execute = function(myEvent, property)
    {        
        if(typeof(property.loc) != "undefined")
        {
            if(property.loc.toLowerCase() == "above"){
                this.loc = "above";
            }else{
                this.loc = "below";
            }
        }
        else{
            this.loc = "below";
        }
        if(typeof(property.headerContents) != "undefined"){this.headerContents = property.headerContents;}        
        this.createPH();
        // For debugging document.getElementById("quickMenu").style.visibility="hidden";
        //alert( this.generateHtml() );
        document.getElementById("quickMenu").innerHTML = this.generateHtml();
        this.open(myEvent);
        this.nItems=0;
    }
};

var NxQuickMenu = new _QuickMenu();
