/*
		dw_core.js
		version date: July 2002
				
		This code is from Dynamic Web Coding 
    at http://www.dyn-web.com/
    Copyright 2002 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.
*/

/////////////////////////////////////////////////////////////////////
//  dynObj constructor
//		arguments: id (required): id of positioned div.
//		left,top,width,height optional arguments.
/////////////////////////////////////////////////////////////////////
function dynObj(id,x,y,w,h) {
	this.el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (!this.el) return null;
	this.doc = (document.layers)? this.el.document: this.el;
	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 = w? w: (this.el.offsetWidth)? this.el.offsetWidth: (this.css.clip.width)? this.css.clip.width: 0;
	this.height = h? h: (this.el.offsetHeight)? this.el.offsetHeight: (this.css.clip.height)? this.css.clip.height: 0;
	// if w/h passed, set style width/height
	if (w){ (document.layers)? this.css.clip.width=w+px: this.css.width=w+px;}
	if (h){ (document.layers)? this.css.clip.height=h+px: this.css.height=h+px;}
	this.obj = id + "dynObj"; 	eval(this.obj + "=this");
}

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

function dw_shiftTo(x,y) {
	if (x!=null) this.x=x; if (y!=null) this.y=y;	
	// rounded below (this.x/y can hold decimals)
	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_writeLyr(cntnt) {
	if (typeof this.doc.innerHTML!="undefined") {
      this.doc.innerHTML = cntnt;
  } else if (document.layers) {
			this.doc.write(cntnt);
			this.doc.close();
  }
}

function dw_setBgClr(bg) {
	if (document.layers) this.doc.bgColor=bg;
	else this.css.backgroundColor=bg;
}

// assign methods 
dynObj.prototype.show = dw_show;
dynObj.prototype.hide = dw_hide;
dynObj.prototype.shiftTo = dw_shiftTo;
dynObj.prototype.shiftBy = dw_shiftBy;
dynObj.prototype.writeLyr = dw_writeLyr;
dynObj.prototype.setBgClr=dw_setBgClr;


// 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;
  }
}

/*
		dw_scroll.js
		requires dw_core.js
		last revised: March 2003 
		Contains functions for "scrolling layer content"
		i.e., for onmouseover and onclick scrolling
    
    Functions now included for glide-scroll onclick
    which requires dw_slide.js
    
		This code is from Dynamic Web Coding 
    at http://www.dyn-web.com/
    Copyright 2001-3 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.		
*/

///////////////////////////////////////////////////////////////////////////////
//  NOTE: dynObj in dw_core.js now used for wndo and scrolling 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)
///////////////////////////////////////////////////////////////////////////////

var scrTimer = 20; // interval between calls to scroll onmouseover

function stopScroll(num) {
  if (pgLoaded && wndo[num]) {
  	clearTimeout(wndo[num].scrTmId);
  	wndo[num].scrTmId = 0;
  }
}

/////////////////////////////////////////////////////////////////////
// loadScrLyr function: loads scrollable content div(s)
//	arg's: wndo array number, id of scrollable div,
//	and id of table or other html element that contains div content. 
//	NOTE: Ns6+/Mozilla need 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.
/////////////////////////////////////////////////////////////////////
function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
  wndo[num].scrTmId = 0;
	wndo[num].cnt = new dynObj(lyr);
  // mainly for ns6+/mozilla when scrolling horizontally
  if (id && document.getElementById) 
    wndo[num].cnt.width = document.getElementById(id).offsetWidth;
	wndo[num].cnt.show();
	wndo[num].cnt.shiftTo(0,0);	// restore top/left to 0 
	wndo[num].maxX = wndo[num].cnt.width - wndo[num].width;
	wndo[num].maxY = wndo[num].cnt.height - wndo[num].height
} 

// These functions are for onmouseover scrolling
function inchDown(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>-wndo[num].maxY) { 
    if ((y-inc)>(-wndo[num].maxY)) wndo[num].cnt.shiftBy(0,-inc);
		else wndo[num].cnt.shiftBy(0,-(wndo[num].maxY-Math.abs(y)));
		wndo[num].scrTmId = setTimeout("inchDown("+num+","+inc+")",scrTimer);	
	}
}

function inchUp(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
    if ((y+inc)<=0) wndo[num].cnt.shiftBy(0,inc); 
		else wndo[num].cnt.shiftBy(0,-y);
		wndo[num].scrTmId = setTimeout("inchUp("+num+","+inc+")",scrTimer);	
  }
}

function inchRight(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var x = parseInt(wndo[num].cnt.css.left);	
	if (x>-wndo[num].maxX) { 
    if ((x-inc)>(-wndo[num].maxX)) wndo[num].cnt.shiftBy(-inc,0);
		else wndo[num].cnt.shiftBy(-(wndo[num].maxX-Math.abs(x)),0);
		wndo[num].scrTmId = setTimeout("inchRight("+num+","+inc+")",scrTimer);	
	}
}

function inchLeft(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var x = parseInt(wndo[num].cnt.css.left);
	if (x<0) { 
    if ((x+inc)<=0) wndo[num].cnt.shiftBy(inc,0); 
		else wndo[num].cnt.shiftBy(-x,0); 
		wndo[num].scrTmId = setTimeout("inchLeft("+num+","+inc+")",scrTimer);	
  }
}


// These functions are for onclick scrolling
function jumpDown(num,jump) {
	if (!pgLoaded||!wndo[num]) return;
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>(-wndo[num].maxY)) { 
		if ((y-jump)>(-wndo[num].maxY)) wndo[num].cnt.shiftBy(0,-jump);
		else wndo[num].cnt.shiftBy(0,-(wndo[num].maxY-Math.abs(y)));	
  }
}

function jumpUp(num,jump) {
	if (!pgLoaded||!wndo[num]) return;
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		if ((y+jump)<=0) wndo[num].cnt.shiftBy(0,jump); 
		else wndo[num].cnt.shiftBy(0,-y); 
	}
}

function jumpRight(num,jump) {
	if (!pgLoaded||!wndo[num]) return;
	var x = parseInt(wndo[num].cnt.css.left);
	if (x>(-wndo[num].maxX)) {
		if ((x-jump)>(-wndo[num].maxX)) wndo[num].cnt.shiftBy(-jump,0);
		else wndo[num].cnt.shiftBy(-(wndo[num].maxX-Math.abs(x)),0);	
  }
}

function jumpLeft(num,jump) {
	if (!pgLoaded||!wndo[num]) return;
	var x = parseInt(wndo[num].cnt.css.left);
	if (x<0) { 
		if ((x+jump)<=0) wndo[num].cnt.shiftBy(jump,0); 
		else wndo[num].cnt.shiftBy(-x,0); 
	}
}

// Functions for glide-scrolling onclick  
// NOTE: dw_slide.js needed for glide-scroll
function glideRight(num,dist) {
	if (!pgLoaded||!wndo[num]) return;
	var x = parseInt(wndo[num].cnt.css.left);
	if (x>(-wndo[num].maxX)) {
		if ((x-dist)>(-wndo[num].maxX)) wndo[num].cnt.slideBy(-dist,0,500);
		else wndo[num].cnt.slideBy(-(wndo[num].maxX-Math.abs(x)),0,500);	
  }
}

function glideLeft(num,dist) {
	if (!pgLoaded||!wndo[num]) return;
	var x = parseInt(wndo[num].cnt.css.left);
	if (x<0) { 
		if ((x+dist)<=0) wndo[num].cnt.slideBy(dist,0,500); 
		else wndo[num].cnt.slideBy(-x,0,500); 
	}
}

function glideDown(num,dist) {
	if (!pgLoaded||!wndo[num]) return;
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>(-wndo[num].maxY)) { 
		if ((y-dist)>(-wndo[num].maxY)) wndo[num].cnt.slideBy(0,-dist,500);
		else wndo[num].cnt.slideBy(0,-(wndo[num].maxY-Math.abs(y)),500);	
  }
}

function glideUp(num,dist) {
	if (!pgLoaded||!wndo[num]) return;
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		if ((y+dist)<=0) wndo[num].cnt.slideBy(0,dist,500); 
		else wndo[num].cnt.slideBy(0,-y,500); 
	}
}

/* 
		dw_slide.js 
		requires dw_core.js
		version date: July 2002

		This code is from Dynamic Web Coding - www.dyn-web.com 
    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.
		
		This code was developed while studying code from: 
		dynduo by Dan Steinman at www.dansteinman.com/dynduo,
		www.cross-browser.com by Mike Foster,
		and www.youngpup.net by Aaron Boodman.
		Code is adapted from those sources.
		
		The slide methods are modified from cbe_slide.js from
		www.cross-browser.com by Mike Foster, where the following
		notice is included:
		
		* Copyright (c) 2002 Michael Foster (mike@cross-browser.com)
 		* This library is distributed under the terms of the 
		* GNU Lesser General Public License (gnu.org).
	  * Time-based, parametric equation animation derived from 
	  * algorithms by Aaron Boodman (youngpup.net), 
	  * and Sebastien Chevrel (sebchevrel.com).
		
*/

dynObj.prototype.slideTo = function(destX,destY,slideTime,fn,container) {
	this.slideTime = slideTime||.0001; this.fn=fn||null;
	// ok to slide along one axis only
	if (destX==null) destX=this.x;
	if (destY==null) destY=this.y;
	if (isNaN(parseInt(destX))) {	// if relative to container (string)
		this.posRel(destX,destY,container);
		this.destX=this.leftPos; this.destY=this.topPos;
	} else {
		this.destX=destX; this.destY=destY;
	}
	this.distX=this.destX-this.x; this.startX=this.x;
	this.distY=this.destY-this.y; this.startY=this.y;
	this.slideStart = (new Date()).getTime();
	if (this.slideProp=="steady") this.per = 1/this.slideTime;
	else this.per = Math.PI/(2*this.slideTime);
	if (this.slideProp=="acc") {
		this.distX=-this.distX; this.distY=-this.distY;
		this.startX=this.destX; this.startY=this.destY;
	}
	this.sliding=true;
	this.doSlide();
}

dynObj.prototype.slideBy = function(dx,dy,slideTime,fn,container) {
	var destX=this.x+dx; var destY=this.y+dy;
	this.slideTo(destX,destY,slideTime,fn,container);
}

dynObj.prototype.doSlide = function() {
	if (!this.sliding) return;	// slide can be interrupted
	var elapsed = (new Date()).getTime()-this.slideStart;
	if (elapsed<this.slideTime) {
		if (this.slideProp=="dec") {
			var x = Math.round((this.distX)*Math.sin(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*Math.sin(this.per*elapsed)+this.startY);
		} else if (this.slideProp=="acc") {
			var x = Math.round((this.distX)*Math.cos(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*Math.cos(this.per*elapsed)+this.startY);
		} else {
			var x = Math.round((this.distX)*(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*(this.per*elapsed)+this.startY);
		}
		this.shiftTo(x,y);
		this.onSlide();
		setTimeout(this.obj+".doSlide()",35);
	} else {	// if time's up
		this.shiftTo(this.destX,this.destY);
		this.onSlide();
		this.sliding=false;
		this.onSlideEnd();
		if (this.fn) eval(this.fn);
	}
}

// do you want your slides to be steady, accelerate or decelerate?
dynObj.prototype.slideProp="dec";	// can be "steady", "acc", or "dec"

dynObj.prototype.onSlide=function() {}
dynObj.prototype.onSlideEnd=function() {}

/* scroll layer script */

var pgLoaded = false;
var wndo = new Array();	// "window(s)" for scrollable content
function initScrLyr() {
 pgLoaded=true;	
 // creat scrollable content area
 // arg: id of div containing scrollable div(s)
 wndo[0] = new dynObj('wn');	
 // load scrolling content
 // arg's: array number of wndo, id of scroll div
 loadScrLyr(0,'lyr1');	

 // remove layers from table for ns6+/mozilla (overflow/clip 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;
    wndo[i].holder = document.getElementById(holderId);
    var scrWn = wndo[i].holder.removeChild(wndo[i].el);
    document.body.appendChild(wndo[i].el);
    wndo[i].css.zIndex = 1000;
    var y = wndo[i].holder.offsetTop;
    var x = wndo[i].holder.offsetLeft;
    wndo[i].shiftTo(x,y);
   }
  }
 }
}

// ns6+/mozilla need to reposition layers onresize
function rePosGecko() {
 for (var i=0; i<wndo.length; i++) {
  var y = wndo[i].holder.offsetTop;
  var x = wndo[i].holder.offsetLeft;
  wndo[i].shiftTo(x,y);
 }
}

window.onload = initScrLyr;
if (navigator.userAgent.indexOf("Gecko")>-1) window.onresize = rePosGecko;