/*
Extension developed by David G. Miles (www.z3roadster.net/dreamweaver)
Original Scrollable Area code developed by Thomas Brattli 
To add more shock to your site, visit www.DHTML Shock.com

Cambios realizados por Ariel Esquivel
12/Septiembre/2002
*/

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 
} 

var bw=new verifyCompatibleBrowser() 
 
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.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    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) 
	} 
}
 
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) 
	} 
} 
 
// end absolutely positioned scrollable area object scripts 

var counter = 0;

function ScrollableArea(width, height, imgUp, imgDown, overlap) {
	this.id = counter;
	counter++;
	this.width = width;
	this.height = height;
	this.imgUp = imgUp;
	this.imgDown = imgDown;
	this.speed = 50;
	this.loop = false;
	this.timer = 0;
	this.initialised = false;
	if (!window.scrollableAreas) {
		window.scrollableAreas = new Array();
	}
	window.scrollableAreas[this.id] = this;
	this.overlap = overlap;
}

ScrollableArea.prototype.initialize = 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.objUp = new ConstructObject('divUp' + this.id) 
	this.objDown = new ConstructObject('divDown' + this.id) 
	var height = this.objScroller.scrollHeight - this.objContainer.scrollHeight;
	if (height <= 0) {
		this.objUp.css.visibility = 'hidden'
		this.objDown.css.visibility = 'hidden'
	}
	this.objScroller.MoveArea(0,0) 
	this.objContainer.css.visibility='visible'
	this.initialised=true; 
}

ScrollableArea.prototype.performScroll = function(speed){ 
	if (this.initialised){ 
		this.loop=true; 
		if (speed > 0) {
			this.objScroller.down(speed);
		} else {
			this.objScroller.up(speed);
		}
	} 
} 
 
ScrollableArea.prototype.ceaseScroll = function() { 
	this.loop=false 
	if (this.timer) clearTimeout(this.timer) 
}

ScrollableArea.prototype.beginDrawing = function() {

	document.write("<div style='position: relative'>");
	document.write("<div id='divUp" + this.id + "' style='position:absolute; width:16; height:16; left:" + (this.width - 16) + "; top:0; z-index:1'>");
	document.write("<a href='javascript:;' onMouseOver='window.scrollableAreas[" + this.id + "].performScroll(-7)' onMouseOut='window.scrollableAreas[" + this.id + "].ceaseScroll()'><img src='" + this.imgUp + "' border='0'></a>");
	document.write("</div>");
	document.write("<div id='divDown" + this.id + "' style='position:absolute; width:16; height:16; left:" + (this.width - 16) + "; top:" + (this.height - 16) + "; z-index:1'>");
	document.write("<a href='javascript:;' onMouseOver='window.scrollableAreas[" + this.id + "].performScroll(7)' onMouseOut='window.scrollableAreas[" + this.id + "].ceaseScroll()'><img src='" + this.imgDown + "' border='0'></a>");
	document.write("</div>");
	if (! this.overlap) {
		document.write("<div id='divContainer" + this.id + "' style='position:absolute; width:" + (this.width - 26) + "; height:" + (this.height) + "; overflow:hidden; top:0; left:0; clip:rect(0," + (this.width - 26) + "," + (this.height) + ",0); visibility:hidden'> ");
	} else {
		document.write("<div id='divContainer" + this.id + "' style='position:absolute; width:" + this.width + "; height:" + this.height + "; overflow:hidden; top:0; left:0; clip:rect(0," + this.width + "," + this.height + ",0); visibility:hidden'> ");
	}
	document.write("<div id='divContent" + this.id + "' style='position:absolute; top:0; left:0'>");
}

ScrollableArea.prototype.endDrawing = function() {
	document.write("</div>");
	document.write("</div>");
	document.write("</div>");
}
