// #### 퀵메뉴 스크롤 관련 자바스크립트 ######################################################################### //

var stmnGAP1 = 70;          // 페이지 위쪽 여백
var stmnGAP2 = 0;           // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 조정하세요
var stmnBASE = 70;          // 스크롤메뉴 초기 시작위치
var stmnActivateSpeed = 200; // 움직임을 감지하는 속도 (숫자가 클수록 느리다)
var stmnScrollSpeed = 10;    // 스크롤되는 속도 (클수록 느림)
var stmnTimer;
    function RefreshStaticMenu()
    {
        var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;
            stmnStartPoint = parseInt(document.getElementById("quick_menu_section").style.top, 10);
            stmnEndPoint = document.body.scrollTop + stmnGAP2;

            if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;
                stmnRefreshTimer = stmnActivateSpeed;
            if (stmnStartPoint != stmnEndPoint) {
                stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
                document.getElementById("quick_menu_section").style.top = parseInt(document.getElementById("quick_menu_section").style.top, 10) + ((stmnEndPoint<stmnStartPoint)?-stmnScrollAmount : stmnScrollAmount);
                stmnRefreshTimer = stmnScrollSpeed;
            }
            stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
    }
    function InitializeStaticMenu()
    {
        document.getElementById("quick_menu_section").style.top = document.body.scrollTop + stmnBASE;
        RefreshStaticMenu();
    }

/*----- image button ------*/
function url(link) {
    location.href= link; 
}

/*----- image rollover ------*/
function menu(obj,mode) {
 var reg = /(menu.+)_(on|off)/;
 var find = obj.src.match(reg)[0];
 var name = obj.src.match(reg)[1];
     obj.src = obj.src.replace(find,name+'_'+mode);
}

function showButton(value,link,type,size) {
    var width = "0";
    var btn = "";
        width = (value.length * 12)+4;

        if (!type) type = "button";
        if (size == "big") {
            btn += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"table-layout: fixed;\">";
            btn += "<colgroup>";
            btn += "<col width=\"6\">";
            btn += "<col width=\""+ width + "\">";
            btn += "<col width=\"6\">";
            btn += "<tr height=\"60\">";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_left_big.gif') no-repeat; width: 6px;\"></td>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_bg_big.gif') repeat-x;\">";
            btn += "        <button style=\"width: "+ width + "px;\" type=\""+type+"\" onclick=\""+link+"\" onfocus=\"this.blur();\">";
            btn += "            <span style=\"font-size: 9pt; color: #000000; cursor: pointer;\">"+value+"</span>";
            btn += "        </button>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_right_big.gif') no-repeat; width: 6px;\"></td>";
            btn += "</tr>";
            btn += "</table>";
        } else if (size == "mid") {
            btn += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"table-layout: fixed;\">";
            btn += "<colgroup>";
            btn += "<col width=\"6\">";
            btn += "<col width=\""+ width + "\">";
            btn += "<col width=\"6\">";
            btn += "<tr height=\"29\">";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_left_mid.gif') no-repeat; width: 6px;\"></td>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_bg_mid.gif') repeat-x;\">";
            btn += "        <button style=\"width: "+ width + "px;\" type=\""+type+"\" onclick=\""+link+"\" onfocus=\"this.blur();\">";
            btn += "            <span style=\"font-size: 9pt; color: #000000; cursor: pointer;\">"+value+"</span>";
            btn += "        </button>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_right_mid.gif') no-repeat; width: 6px;\"></td>";
            btn += "</tr>";
            btn += "</table>";
        } else {
            btn += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"table-layout: fixed; cursor: pointer;\">";
            btn += "<colgroup>";
            btn += "<col width=\"6\">";
            btn += "<col width=\""+ width + "\">";
            btn += "<col width=\"6\">";
            btn += "<tr height=\"21\">";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_left.gif') no-repeat; width: 6px;\"></td>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_bg.gif') repeat-x;\">";
            btn += "        <button style=\"width: "+ width + "px;\" type=\""+type+"\" onclick=\""+link+"\" onfocus=\"this.blur();\">";
            btn += "            <span style=\"font-size: 9pt; color: #000000; cursor: pointer;\">"+value+"</span>";
            btn += "        </button>";
            btn += "    <td style=\"background: url('/board/images/btn/btn_button_right.gif') no-repeat; width: 6px;\"></td>";
            btn += "</tr>";
            btn += "</table>";
        }
        document.write(btn);
}

/*----- windows open ------*/
function win_open(url, name, option) {
    var popup = window.open(url, name, option);
        popup.focus();
}

/*----- flash ------*/
function setFlash(src, w, h) {
	var Flash_html = "";
	Flash_html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="param" width="'+w+'" height="'+h+'">';
	Flash_html += '<param name="movie" value="'+src+'">';
	Flash_html += '<param name="quality" value="high">';
	Flash_html += '<param name="wmode" value="transparent">';
	Flash_html += '<param name="swliveconnect" value="true">';
	Flash_html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	Flash_html += '</object>';
	document.write(Flash_html);
}

/*----- comma ------*/
function addComma(obj,fLen) { 
    if(event.keyCode == 37 || event.keyCode == 39 ) {
        return;
    }

    var fLen = fLen || 2;
    var strValue = obj.value.replace(/,|\s+/g,'');
    var strBeforeValue = (strValue.indexOf('.') != -1)? strValue.substring(0,strValue.indexOf('.')) :strValue ;
    var strAfterValue  = (strValue.indexOf('.') != -1)? strValue.substr(strValue.indexOf('.'),fLen+1) : '' ;

    if(isNaN(strValue)) {
        alert(strValue.concat(' -> 숫자가 아닙니다.'));
        return false;
    }
    var intLast =  strBeforeValue.length-1;
    var arrValue = new Array;
    var strComma = '';

    for(var i=intLast,j=0; i >= 0; i--,j++) { 
        if( j !=0 && j%3 == 0) {
            strComma = ',';
        } else {
            strComma = '';
        }
        arrValue[arrValue.length] = strBeforeValue.charAt(i) + strComma  ;
    }
    obj.value=  arrValue.reverse().join('') +  strAfterValue; 
}
