﻿
//var stmnLEFT = 1 // 스크롤메뉴의 좌측 위치. 필요 없을 경우 삭제
var stmnGAP1 = 0; // 페이지 헤더부분의 여백 (이보다 위로는 올라가지 않음) : 검색바 이전 111 (41증가)
//var stmnGAP2 = 79; // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 세팅
var stmnGAP2 = 42; // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 세팅 - Quick Search 상단과 위치 맞춤.
var stmnBASE = 67; // 스크롤메뉴 초기 시작위치 (아무렇게나 해도 상관은 없지만 stmnGAP1과 약간 차이를 주는게 보기 좋음)
var stmnActivateSpeed = 50; // 움직임을 감지하는 속도 (숫자가 클수록 늦게 알아차림)
var stmnScrollSpeed = 10; // 스크롤되는 속도 (클수록 늦게 움직임)


var stmnTimer;

// 스크롤 메뉴의 위치 갱신
function RefreshStaticMenu() {
    try {
        var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

        stmnStartPoint = parseInt(STATICMENU.style.top, 10);
        stmnEndPoint = document.documentElement.scrollTop + stmnGAP2;
        if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;
        stmnRefreshTimer = stmnActivateSpeed;

        if ( stmnStartPoint != stmnEndPoint ) {
                stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
                //STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
                var newTop3 = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
                var newTop4 = newTop3 + "px";
                STATICMENU.style.top = newTop4;
                stmnRefreshTimer = stmnScrollSpeed;
        }
        
        var halfScreenSize = document.documentElement.clientWidth / 2;
        //STATICMENU.style.left = halfScreenSize + stmnLEFT; // 메뉴 왼쪽 위치 초기화. 필요없을 경우 삭제

        stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
    } 
    catch(e) {
        //alert(e.description);
    }
}

// 메뉴 초기화
function InitializeStaticMenu() {
    try {
        //STATICMENU.style.top = document.documentElement.scrollTop + stmnBASE; // 기본위치로 이동한다.
        var newTop = document.documentElement.scrollTop + stmnBASE;
        var newTop2 = newTop + "px";
        STATICMENU.style.top = newTop2;
        //STATICMENU.style.top = "300px"; // 기본위치로 이동한다.
        RefreshStaticMenu(); // 스크립트 가동
        
        //var halfScreenSize = document.documentElement.clientWidth / 2;
        //alert(halfScreenSize);

        //STATICMENU.style.left = halfScreenSize + stmnLEFT; // 메뉴 왼쪽 위치 초기화. 필요없을 경우 삭제
    } 
    catch(e) {
        //alert(e.description);
    }
}

//InitializeStaticMenu();

