//스크롤 따라다니는레이어시작-----------------------------------------------
// 셋팅 시작 
var _scroll_topmargin=115;     // 이동 메뉴의 상단 한계 픽셀 
var _scroll_ing_topmargin=10;    // 움직이는 도중의 상단과의 간격 
var _scroll_activate_speed=300;     // 초기 움직임을 감지하는 시간차이 (1/1000초) 
var _scroll_ing_activate_speed=10;    // 움직이기 시작한 이후에 감지하는 시간차이 (1/1000초) 
var _divMenuID = "divMenu"; // 오른쪽에 div 레이어의 ID명 

// 브라우저 셋팅 
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false); 
var isNS4 = (document.layers ? true : false); 
var isNS = navigator.appName == "Netscape"; 

function getRef(id) { 
   if (isDOM) return document.getElementById(id); 
   if (isIE4) return document.all[id]; 
   if (isNS4) return document.layers[id]; 
} 

// 메인함수 
function moveRightEdge() { 
   var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck; 
   if (isNS4) { 
       yMenuFrom   = divMenu.top; 
       yMenuTo     = windows.pageYOffset+_scroll_ing_topmargin; 
   } else if (isDOM) { 
       yMenuFrom   = parseInt (divMenu.style.top, 10); 
       yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop)+_scroll_ing_topmargin; 
   } 

   if(yMenuTo<_scroll_topmargin) yMenuTo = _scroll_topmargin; 

   timeoutNextCheck = _scroll_activate_speed; 

   if (yMenuFrom != yMenuTo) { 
       yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 10); 
       if (yMenuTo < yMenuFrom) yOffset = -yOffset; 
       if (isNS4) divMenu.top += yOffset; 
       else if (isDOM) divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset; 
       timeoutNextCheck = _scroll_ing_activate_speed; 
   } 
   setTimeout ("moveRightEdge()", timeoutNextCheck); 
} 

// Body 태그의 onLoad 이벤트에 넣어주면 됨.... 
function moveInit() { 
   if (isNS4) { 
       var divMenu = document[_divMenuID]; 
       divMenu.top = top.pageYOffset + _scroll_topmargin; 
       divMenu.visibility = "visible"; 
       moveRightEdge(); 
   } else if (isDOM) { 
       var divMenu = getRef(_divMenuID); 
       divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + _scroll_topmargin; 
       divMenu.style.visibility = "visible"; 
       moveRightEdge(); 
   } 
} 
//스크롤 따라다니는레이어끝---------------------------------

