var clipTop = 0;
var clipWidth = 370;
var clipBottom = clipHeight = 255;
var topper = 160;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;


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;
}




function init (targetLayerName, scrollerLayerName)
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;

	if (targetLayerName == undefined)
		targetLayerName = "scrollArea"

	if (scrollerLayerName == undefined)
		scrollerLayerName = "scroller"

	//alert (targetLayer)

	scrollLayer = new getObj(targetLayerName);
	thelayer = new getObj("scrollContent");
	if (!thelayer || !scrollLayer) return;

	clipTop = 0
	clipBottom = clipHeight

	if (document.layers)
	{
		lyrheight = thelayer.style.clip.bottom;
		//lyrheight += 20;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = thelayer.obj.offsetHeight;
	}

//alert ("scrollContent h:" + lyrheight +  " " + "clipHeight " + clipHeight)

	if (lyrheight <= clipHeight)
	{
		//alert (lyrheight + " <= " + clipHeight)
    scrollerLayer = new getObj(scrollerLayerName)
		scrollerLayer.style.display = "none"
	}
	else
	{

		if (document.getElementById || document.all)
		{
			clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
			scrollLayer.style.clip = clipstring;
			//alert (clipstring)
		}
		else if (document.layers)
		{
			scrollLayer.style.clip.top = clipTop;
			scrollLayer.style.clip.bottom = clipBottom;
		}

		scrollPercent(0)
	}
}



function scrollPercent (percent)
{
	if (!DHTML) return;
	thelayer = new getObj("scrollContent");
	if (!thelayer) return;

	topper =  - (percent * (lyrheight-clipHeight));

	if (document.getElementById || document.all)
	{
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.top = topper;
	}

	//window.status = percent + "%";
}



function bbhScroller_DoFSCommand(command, args)                {
  var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var myFlashObj = InternetExplorer ? bbhScroller : document.bbhScroller;

	//alert (command + " " + args)
  this[command](args)
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") 

!= -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub bbhScroller_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call bbhScroller_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
} 