/*
		dw_scroll.js
		version date: July 2002
		constructor and basic methods for scrollers
				
		This code is from Dynamic Web Coding 
    at http://www.dyn-web.com/
    Copyright 2001-2 by Sharon Paine 
    See Terms of Use at http://www.dyn-web.com/bus/terms.html
    Permission granted to use this code 
    as long as this entire notice is included.
*/


////////////////////////////////////////////////////////////////////
//  Constructor function used for creating scrollable content areas.
//	Used to create both wndo and content objects.
//  Argument for creating wndo objects:	id of wndo div.
//	Arguments for creating content (done in loadScrLyr function):
//	id of content div, id of html element that contains content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
//	You can set left/top in style sheet or pass it to constructor.
//	Width/height (and clip) need to be set in style sheet
//	(opera and ns4 can't reflow content)
////////////////////////////////////////////////////////////////////
function dw_scrollObj(obj,id,x,y) {
	this.el = (document.getElementById)? document.getElementById(obj): (document.all)? document.all[obj]: (document.layers)? getLyrRef(obj,document): null;
	if (!this.el) return null;
	this.css = (this.el.style)? this.el.style: this.el;
	var px = (document.layers||window.opera)? "": "px";
	this.x = x || 0;	if (x) this.css.left = this.x+px;
	this.y = y || 0;	if (y) this.css.top = this.y+px;
	this.width = (this.el.clientWidth)? this.el.clientWidth: (id && document.getElementById && document.getElementById(id).offsetWidth)? document.getElementById(id).offsetWidth: (this.el.offsetWidth)? this.el.offsetWidth: (this.css.clip.width)? this.css.clip.width: 0;
	this.height = (this.el.offsetHeight)? this.el.offsetHeight: (this.css.clip.height)? this.css.clip.height: 0;
	this.obj = obj + "Obj"; eval(this.obj+"=this");
}


function dw_shiftTo(x,y) {
	if (x!=null) this.x=x; if (y!=null) this.y=y;	
	if (this.css.moveTo) { 
		this.css.moveTo(Math.round(this.x),Math.round(this.y)); 
	} else { 
		this.css.left=Math.round(this.x)+"px"; 
		this.css.top=Math.round(this.y)+"px"; 
	}
}

function dw_shiftBy(x,y) {
	this.shiftTo(this.x+x,this.y+y);
}

function dw_show() {	this.css.visibility = "visible"; }
function dw_hide() { this.css.visibility = "hidden"; }


dw_scrollObj.prototype.shiftBy=dw_shiftBy;
dw_scrollObj.prototype.shiftTo=dw_shiftTo;
dw_scrollObj.prototype.show=dw_show; 
dw_scrollObj.prototype.hide=dw_hide;

// get reference to nested layer for ns4
// from dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}