var clipLeft = 0;
var clipHeight = 55;
var clipRight = 550;
var topper = 0;
var lyrwidth = 0;
var time1,amount,theTime,theWidth,DHTML;

function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('example');
	if (document.layers)
	{
		//lyrheight = x.style.clip.bottom;
		//lyrheight += 20;
		lyrwidth = x.style.clip.width;
		//lyrwidth += 20;
		x.style.clip.top = 0;
		x.style.clip.left = clipLeft;
		x.style.clip.right = clipRight;
		x.style.clip.bottom = clipHeight;
	}
	else if (document.getElementById || document.all)
	{
		//lyrheight = x.obj.offsetHeight;
		lyrwidth = x.obj.offsetWidth;
		x.style.clip = 'rect(0px,'+clipRight+'px,'+clipHeight+'px,'+clipLeft+'px)';
	}
	//alert(lyrheight+'-'+lyrwidth);	
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	if (!DHTML) return;
	clipLeft += amount;
	clipRight += amount;
	topper -= amount;
	if (clipLeft < 0 || clipRight > (lyrwidth))
	{
		clipLeft -= amount;
		clipRight -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect(0px,'+clipRight+'px,'+clipHeight+'px,'+clipLeft+'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.left = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.left = clipLeft;
		thelayer.style.clip.right = clipRight;
		thelayer.style.left = topper;
	}
	time1 = setTimeout('realscroll()',theTime);
}

function stopScroll()
{
	if (time1) clearTimeout(time1);
}

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 = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}