dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var scrTimer = 40; // interval between calls to scroll onmouseover
var scrTmId=0;	// for setTimeouts

var pgLoaded;
wndo = new Array();	// "window" for scrollable content

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

function dw_shiftBy(x,y) {
	if (ns4) { this.css.moveBy(x,y); }
	else { 
		this.css.left = parseInt(this.css.left)+x+"px";
		this.css.top = parseInt(this.css.top)+y+"px";
	}
}

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

function jumpDown(num,jump) {
	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 jumpRight(num,jump) {
	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 jumpUp(num,jump) {
	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 jumpLeft(num,jump) {
	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); 
	}
}

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

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

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

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

function stopScroll() {
	clearTimeout(scrTmId);
}

function dw_lyrObj(obj,id) {
	this.el = (ns4)? getLyrRef(obj,document): (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;
	this.css = (ns4)? this.el: (ie4||ie5||ns5)? this.el.style: null;
	this.height = (ns4)? this.el.clip.height: (ie4||ie5)? this.el.clientHeight: (ns5)? this.el.offsetHeight: 0;
	this.width = (ns4)? this.el.clip.width: (ie4||ie5)? this.el.clientWidth: (ns5)? (id)? document.getElementById(id).offsetWidth: this.el.offsetWidth: 0;
}

function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
	wndo[num].cnt = new dw_lyrObj(lyr,id);
	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
} 

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

function getLyrRef(lyr,doc) {
	if (ns4) {
		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;
  }
}

var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; 
	origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

window.onload = initScrLyr; 
function initScrLyr() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('wn');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'whatsnew');	
}

function initScrLyr2() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('giglist');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'jpcssdiv1');	
}

function initScrLyr3() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('bandlist');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'jpcssdiv1');	
}

function initScrLyr4() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('supplist');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'jpcssdiv1');	
}

function initScrLyr5() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('gallery');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'jpcssdiv1');	
}

function initScrLyr6() {
	pgLoaded=true;	
	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('textbox1');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'jpcssdiv1');	
}
