/*******************************************************************************
 * subject       : [www.chubbkorea.co.kr/home] °øÅë JavaScript
 * filename    : /home/common/js/common.js
 * description : JavaScript ÇÔ¼ö¸ðÀ½
 *******************************************************************************
 * date            /    made by(modified by)        /    work description
 *******************************************************************************
 * 2005-09-06   /    ¹ÚÁöÈÆ(kokun99@hanmail.net)    /    initial
 ******************************************************************************/


/*******************************************************************************
 * Index
 *******************************************************************************
 * ¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ° ºñÈ°¼ºÈ­ - jsDisableMouse
 * ÆäÀÌÁö ·Îµù½Ã Æ÷Ä¿½º ÀÌµ¿   - jsSetFocus
 * ¿£ÅÍÃ¼Å©                    - jsChkEnter
 * ÀÌ¹ÌÁö Å©±â Á¶Á¤            - jsResizeImage
 ******************************************************************************/


    /**********************************************************************
    * ÁÖ¿ä±â´É : ¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ° ºñÈ°¼ºÈ­
    * ÀÛ ¼º ÀÏ : 2005-07-18
    * ÀÛ ¼º ÀÚ : ¹ÚÁöÈÆ (kokun99@hanmail.net)
    * »ç¿ë¹æ¹ý : ¾Æ·¡ ÀÌº¥Æ® µÎ°³¿¡ ´ëÇØ jsDisableMouse ÇÔ¼ö¸¦ ½ÇÇàÇÑ´Ù.
    *            document.onmouseup=jsDisableMouse
    *            document.onmousedown=jsDisableMouse
    * °á °ú °ª : 
    * ÁÖÀÇ»çÇ× : <body> Å×±× ¾È¿¡  <body onContextMenu="return false">¸¦
    *            »ç¿ëÇÏ´Â °ÍÀÌ ´õ È¿°úÀûÀÌ´Ù.
    ***********************************************************************/
    function jsDisableMouse()
    {
        if (event.button==2 || event.button==1+2 || event.button==2+1)
        { alert("¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°Àº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù."); }
    }
    //document.onmouseup=jsDisableMouse
    //document.onmousedown=jsDisableMouse


    /**********************************************************************
    * ÁÖ¿ä±â´É : ÆäÀÌÁö ·Îµù½Ã Æ÷Ä¿½º ÀÌµ¿
    * ÀÛ ¼º ÀÏ : 2005-07-18
    * ÀÛ ¼º ÀÚ : ¹ÚÁöÈÆ (kokun99@hanmail.net)
    * »ç¿ë¹æ¹ý : <body> Å×±× ¾È¿¡ ¾Æ·¡¿Í °°ÀÌ ³Ö¾î¼­ »ç¿ëÇÑ´Ù.
    *            <body onLoad="jsSetFocus('[Æ÷Ä¿½º ÀÌµ¿ÇÒ °³Ã¼ÀÌ¸§')">
    *            <body onLoad="jsSetFocus('<%=objOnLoadFocus%>')">
    *            À§¿Í °°ÀÌ ÆÄ¶ó¹ÌÅÍ [°³Ã¼ÀÌ¸§]À» ASP/PHP º¯¼ö¸¦ »ç¿ëÇØ¼­
    *            ÁöÁ¤ÇÏ¸é Æí¸®ÇÏ´Ù.
    * °á °ú °ª : 
    * ÁÖÀÇ»çÇ× : °³Ã¼ÀÌ¸§À» µû¿ÈÇ¥ ¾È¿¡ ³Ö¾î¼­ ¹®ÀÚ¿­·Î Àü´ÞÇØ¾ß ÇÑ´Ù.
    ***********************************************************************/
    function jsSetFocus(objFocus)
    {
        try
        {
            var form = eval(objFocus);
            form.select();
            form.focus();
        }
        catch (e)
        {}
    }
    
    
    /**********************************************************************
    * ÁÖ¿ä±â´É : ¿£ÅÍÃ¼Å©
    * ÀÛ ¼º ÀÏ : 2005-07-18
    * ÀÛ ¼º ÀÚ : ¹ÚÁöÈÆ (kokun99@hanmail.net)
    * »ç¿ë¹æ¹ý : jsChkEnter([½ÇÇàÇÒ ÇÔ¼ö¸í])
    *          : jsChkEnter('document.all.form[0].user_name.focus()')
    * °á °ú °ª : ÀÎÀÚ·Î Àü´ÞµÈ ÇÔ¼ö/½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÑ´Ù.
    * ÁÖÀÇ»çÇ× : ÇÔ¼öÀÌ¸§À» µû¿ÈÇ¥ ¾È¿¡ ³Ö¾î¼­ ¹®ÀÚ¿­·Î Àü´ÞÇØ¾ß ÇÑ´Ù.
    ***********************************************************************/
    function jsChkEnter(functionCall)
    {
        if(event.keyCode == 13)
        { eval(functionCall); }
    }


    /**********************************************************************
    * ÁÖ¿ä±â´É : ÀÌ¹ÌÁö Å©±â Á¶Á¤
    * ÀÛ ¼º ÀÏ : 2005-04-19
    * ÀÛ ¼º ÀÚ : ¹ÚÁöÈÆ (kokun99@hanmail.net)
    * »ç¿ë¹æ¹ý : jsResizeImage([ÀÌ¹ÌÁö°³Ã¼], [ÃÖ´ë³Êºñ], [ÃÖ´ë±æÀÌ])
    *          : jsChkEnter(document.all.img_preview, window.document.body.offsetWidth, window.document.body.offsetHeight)
    * °á °ú °ª : ÀÎÀÚ·Î Àü´ÞµÈ ÀÌ¹ÌÁö°³Ã¼ÀÇ Å©±â°¡ ÃÖ´ë³Êºñ/±æÀÌ¸¦ ³ÑÁö ¾Êµµ·Ï Á¶Á¤µÈ´Ù.
    *            [ÃÖ´ë³Êºñ]°¡ 0ÀÌ¸é ÀÌ¹ÌÁö °¡·ÎÅ©±â´Â ¹«Á¦ÇÑÀÌ°í,
    *            [ÃÖ´ë±æÀÌ]°¡ 0ÀÌ¸é ÀÌ¹ÌÁö ³ôÀÌ´Â ¹«Á¦ÇÑÀÌ´Ù.
    * ÁÖÀÇ»çÇ× : 
    ***********************************************************************/
    function jsResizeImage (obj, max_width, max_height)
    {
        var temp_img = new Image();
        temp_img.src = obj.src;
        
        if (temp_img.width >= temp_img.height && temp_img.width > max_width && max_width > 0) {
            obj.width  = max_width;
            obj.height = temp_img.height * (max_width / temp_img.width);
        } else if (temp_img.width <= temp_img.height && temp_img.height > max_height && max_height > 0) {
            obj.width = temp_img.width * (max_height / temp_img.height);
            obj.height = max_height;
        }
    }