/*-------------------------------------
½ºÅ©·Ñ ¹è³Ê
-------------------------------------*/
var bodyHeight = scrollobjHeight = 0;
function scrollBanner()
{
 if ( document.all ) window.attachEvent("onload", initSlide); // IE °æ¿ì
 else window.addEventListener("load", initSlide, false); // FF(¸ðÁú¶ó) °æ¿ì
}
function initSlide()
{
 var scroll = document.getElementById('scroll');
 var scrollTop = get_objectTop(document.getElementById('pos_scroll'));
 scroll.style.top = document.body.scrollTop + scrollTop;
 bodyHeight = document.body.scrollHeight;
 scrollobjHeight = scroll.clientHeight;
 movingSlide();
}
function movingSlide()
{
 var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
 var scroll = document.getElementById('scroll');
 var scrollTop = get_objectTop(document.getElementById('pos_scroll'));
 yMenuFrom  = parseInt (scroll.style.top, 10);
 yMenuTo    = document.body.scrollTop + 10;
 if(yMenuTo<scrollTop) yMenuTo = scrollTop;
 timeoutNextCheck = 500;
 if (yMenuFrom != yMenuTo) {
  yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 10);
  if (yMenuTo < yMenuFrom) yOffset = -yOffset;
  scroll.style.top = parseInt (scroll.style.top, 10) + yOffset;
  timeoutNextCheck = 10;
 }
 if (scroll.style.pixelTop > bodyHeight - scrollobjHeight) scroll.style.top = bodyHeight - scrollobjHeight;
 setTimeout ("movingSlide()", timeoutNextCheck);
}
function gdscroll(gap)
{
 var gdscroll = document.getElementById('gdscroll');
 gdscroll.scrollTop += gap;
}
function eScroll()
{ 
 var thisObj = this;
 this.timeObj = null;
 
 /*** ¼³Á¤º¯¼ö ***/
 this.mode = "top";    // ½ºÅ©·Ñ ¹æÇâ (top|left)
 this.width = "80%";   // ¶óÀÎ´ç °¡·Î°ª (pixel)
 this.height = 20;    // ¶óÀÎ´ç ³ôÀÌ°ª (pixel)
 this.line = 1;     // Ãâ·Â ¶óÀÎ¼ö
 this.delay = 200;    // ½ºÅ©·ÑÈÄ µô·¹ÀÌ ½Ã°£
 this.speed = 1;     // ½ºÅ©·Ñ ¼Óµµ (ÀÛÀ»¼ö·Ï ºü¸§)
 this.id = 'obj_eScroll';  // °´Ã¼ id (Å¬·¡½º ´ÙÁß »ç¿ë½Ã id ´Ù¸£°Ô ÁöÁ¤ ¿ä¸Á)
 this.contents = new Array(); // Ãâ·Â ³»¿ë (¹è¿­·Î ³»¿ë ÁöÁ¤ ¿ä¸Á)
 this.align = "left";   // ³»¿ë aligne
 this.valign = "middle";   // ³»¿ë valigne
 /*** ³»Àåº¯¼ö ***/
 this.gap = 0;
 this.direction = 1;
 this.add = add;
 this.exec = exec;
 this.start = start;
 this.stop = stop;
 this.scroll = scroll;
 this.direct = direct;
 this.go = go;
 function add(str)
 {
  this.contents[this.contents.length] = str;
 }
 
 function exec()
 {
  this.basis = (this.mode == "left") ? this.width : this.height;
  var outWidth = this.width * ((this.mode == "left") ? this.line : 1);
  var outHeight = this.height * ((this.mode == "top") ? this.line : 1);
  
  var outline = "<div id=" + this.id + " style='overflow:hidden;width:" + outWidth + ";height:" + outHeight + "'><table></table></div>";
  document.write(outline);
  this.obj = document.getElementById(this.id);
  
  var tb = this.obj.appendChild(document.createElement("table"));
  var tbody = tb.appendChild(document.createElement("tbody"));
  tb.cellPadding = 0 ;
  tb.cellSpacing = 0 ;
  tb.onmouseover = function(){thisObj.stop()};
  tb.onmouseout = function(){thisObj.start()};
  
  if (this.mode=="left") var tr = tbody.appendChild(document.createElement("tr"));
  for (k in this.contents){
   if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
   var td = tr.appendChild(document.createElement("td"));
   td.noWrap = true;
   td.style.width = this.width;
   td.style.height = this.height;
   td.style.textAlign = this.align;
   td.style.verticalAlign = this.valign;
   td.innerHTML = this.contents[k];
  }
  
  var len = (this.contents.length<this.line) ? this.contents.length : this.line;
  for (i=0;i<len;i++){
   if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
   td = tr.appendChild(document.createElement("td"));
   td.noWrap = true;
   td.style.width = this.width;
   td.style.height = this.height;
   td.style.textAlign = this.align;
   td.style.verticalAlign = this.valign;
   td.innerHTML = this.contents[i];
  }
  this.obj.parent = this;
  this.tpoint = this.basis * this.contents.length;
  this.start();
 }
 function scroll()
 {
  var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
  if (out%this.basis==0){
   this.gap++;
   if (this.gap>=this.delay) this.gap = 0;
  }
  if (!this.gap){
   var ret = (out==this.tpoint) ? this.direction : out + this.direction;
   if (ret<0) ret = this.tpoint + ret;
   if (this.mode=="left") this.obj.scrollLeft = ret;
   else this.obj.scrollTop = ret;
  }
 }
 function start()
 {
//  this.timeObj = window.setInterval("(document.getElementById('" + this.id + "')).parent.scroll()",this.speed);
 }
 function stop()
 {
  clearTimeout(this.timeObj);
 }
 function direct(d)
 {
  this.direction = d;
 }
 function go()
 {
  this.stop();
  var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
  var ret = (parseInt(out / this.basis) + this.direction) * this.basis;
  if (ret<0) ret = this.tpoint + ret;
  if (ret>this.tpoint) ret = this.basis;
  if (this.mode=="left") this.obj.scrollLeft = ret;
  else this.obj.scrollTop = ret;

 }
}

