////////////////////////////////////////////////////////////////////
//  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 initScrLyr() {
	pgLoaded=true;	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_scrollObj('wn');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'lyr1','t2');	
	
	// remove layers from table for ns6/mozilla (overflow bug)
	if (navigator.userAgent.indexOf("Gecko")>-1) {

		for (var i=0; i<wndo.length; i++) {
			if (wndo[i].el.parentNode.id.indexOf("hold")!=-1) {
				var holderId = wndo[i].el.parentNode.id;
				var holder = document.getElementById(holderId);
				var scrWn = holder.removeChild(wndo[i].el);
				document.body.appendChild(wndo[i].el);
				wndo[i].css.zIndex = 1000;
				var y = holder.offsetTop;
				var x = holder.offsetLeft;
				wndo[i].shiftTo(x,y);
			}
		}
	}
}

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;


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;
  }
}
