function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 

var counter = 0;
function ScrollableArea(width, height, sense, speed) {
	this.id = counter;
	counter++;
	this.width = width;
	this.height = height;
	this.speed = speed;
	this.sense = sense;
	this.loop = false;
	this.timer = 0;
	this.initialised = false;
	if (!window.scrollableAreas) {
		window.scrollableAreas = new Array();
	}
	window.scrollableAreas[this.id] = this;
}
 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight;
    this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth;
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight ;
    this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth;
    this.up=MoveAreaUp;
	this.down=MoveAreaDown; 
    this.right=MoveAreaRight;
    this.left=MoveAreaLeft;
    this.MoveArea=MoveArea; 
		this.x; 
		this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 

function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
 
function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+this.parent.objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(this.parent.loop) setTimeout(this.obj+".down("+move+")",this.parent.speed) 
	} 
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(this.parent.loop) setTimeout(this.obj+".up("+move+")",this.parent.speed) 
	} 
} 
 
function MoveAreaRight(move){ 
	if(this.x>-this.scrollWidth+this.parent.objContainer.clipWidth){ 
		this.MoveArea(this.x-move,0) 
		if(this.parent.loop) setTimeout(this.obj+".right("+move+")", this.parent.speed) 
	} 
	//else {
		//this.parent.sense = 1 * this.parent.sense;
		//this.MoveArea(0,0) 
		//if(this.parent.loop) setTimeout(this.obj+".left("+(-1 * move)+")", this.parent.speed) 
	//}
}
 
function MoveAreaLeft(move){ 
	if(this.x<0){ 
		this.MoveArea(this.x-move,0) 
		if(this.parent.loop) setTimeout(this.obj+".left("+move+")", this.parent.speed) 
	} //else {
		///this.parent.sense = 1 * this.parent.sense;
		//if(this.parent.loop) setTimeout(this.obj+".right("+(-1 * move)+")",this.parent.speed) 
	//} 
} 

ScrollableArea.prototype.PerformAutoScroll = function(vel){ 
	if (this.initialised){ 
		this.loop=true; 
		if(vel>0) this.objScroller.right(vel) 
		else this.objScroller.left(vel) 
	} 
} 

ScrollableArea.prototype.PerformScroll = function(vel){ 
	if(this.initialised){ 
		this.loop=true; 
		if(vel>0) this.objScroller.down(vel) 
		else this.objScroller.up(vel) 
	} 
} 
 
ScrollableArea.prototype.CeaseScroll = function (){
    this.loop=false 
    if(this.timer) clearTimeout(this.timer) 
} 

ScrollableArea.prototype.Show = function (){
	this.objContainer.css.visibility='visible'
} 

ScrollableArea.prototype.Hide = function (){
	this.objContainer.css.visibility='hidden'
}


ScrollableArea.prototype.InitialiseScrollableArea = function(){ 
    this.objContainer=new ConstructObject('divContainer' + this.id) 
		this.objContainer.parent = this
    this.objScroller=new ConstructObject('divContent' + this.id,'divContainer' + this.id) 
		this.objScroller.parent = this
	  this.objScroller.MoveArea(0,0) 
    this.objContainer.css.visibility='visible' 
    this.initialised=true; 
} 

ScrollableArea.prototype.beginDrawing = function() {
	document.write("<div id='divContainer" + this.id + "' style=' width:" + this.width + "; height:" + this.height + "; overflow:hidden; top:0; left:0; clip:rect(0," + this.width + "," + this.height + ",0); visibility:show'> ");
	document.write("<div id='divContent" + this.id + "' style='position:relative; '>");
}

ScrollableArea.prototype.endDrawing = function() {
	document.write("</div>");
	document.write("</div>");
}