var clipTop;
var clipWidth;
var clipBottom;
var topper;
var lyrheight;
var menuObj;
var time,amount,theTime,theHeight,DHTML;

function init(nMenuObj)
{
	menuObj = nMenuObj;
  
  DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj(menuObj);

	if (document.layers)
	{
		lyrheight = x.style.clip.bottom + 20;
		clipTop = x.style.clip.top;
		clipWidth = x.style.clip.right;
		clipBottom = x.style.clip.bottom;
		topper = x.style.top;
	}
	else if (document.getElementById || document.all)
	{
		var clipv = x.style.clip.split("rect(")[1].split(")")[0].split("px");
		
		for(i=0;i<4;i++) {
      if (clipv[i][0] == ',') clipv[i] = clipv[i].split(",")[1];
      clipv[i] = parseInt(clipv[i]);
    }

    lyrheight = x.obj.offsetHeight;
		clipTop = clipv[0];
		clipWidth = clipv[1];
		clipBottom = clipv[2];
		topper = x.obj.offsetTop;
		
		var clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		x.style.clip = clipstring;
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	  this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	  this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
