/*
		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
if (navigator.userAgent.indexOf("Gecko")>-1){
   isDom = true
   window.onresize = rePosGecko;
}
else{
   isDom = false
}

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
  if (isDom) wndo[num].maxY+=200
} 

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

//----------------------- Added from external pages in package

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

function initScrLyr(holdName,wnName,lyrName) {
	pgLoaded = true;
	if (document.all && !document.all(holdName)) return
	else if (document.getElementById && !document.getElementById(holdName)) return
	
  var wSTR = '<table border="0" cellpadding="0" cellspacing="0" height="'+scroll_params.sHeight+'" width=12>'+
     '<tr><td align=right valign="top" style="padding:0px 0px 0px 0px"><a href="javascript: //" onmouseover="inchUp(0,4); window.status=\'Hover here to scroll up.\'; return true" onmouseout="stopScroll(0); window.status=\'\'; return true"><img src="'+scroll_params.imgDir+'/tri-up.gif" width="13" height="13" alt="" border="0"></a></td></tr>'+
     '<tr><td align=right style="padding:0px 0px 0px 0px"><table cellpadding=0 cellspacing=0 width=13 border=0><tr><td></td></tr></table></td></tr>'+
     '<tr><td align=right style="padding:0px 0px 0px 0px" valign="bottom"><a href="javascript: //" onmouseover="inchDown(0,4); window.status=\'Hover here to scroll down.\'; return true" onmouseout="stopScroll(0); window.status=\'\'"><img src="'+scroll_params.imgDir+'/tri-dn.gif" width="13" height="13" alt="" border="0"></a></td>'+
     '</tr></table>'
	
	if (document.all && document.all("scrolllyr").offsetHeight <= scroll_params.sHeight){
	   document.all("scrolltd").removeNode(true)
	}
	else if (document.all){
	   document.all("scrolltd").innerHTML = wSTR
	}
	else if (isDom && document.getElementById("scrolllyr").offsetHeight <= scroll_params.sHeight){
	   document.getElementById("scrolltd").parentNode.removeChild(document.getElementById("scrolltd"))
	}
	else if (isDom){
	   document.getElementById("scrolltd").innerHTML = wSTR
	}

  // creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[wndo.length] = new dynObj(wnName);
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(wndo.length-1,lyrName);

	// 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(holdName)!=-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);
  }
}

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


function setScrollHead(sWidth,sHeight,imgDir){
 var wSTR = '<style type="text/css">\n'+
  '<!--\n'+
  '#scrollhold{ position:relative; overflow:hidden; width:'+sWidth+'px; height:'+sHeight+'px; z-index:100; }\n'+
  '#scrollwn{ position:absolute; left:0px; top:0px; width:'+sWidth+'px; height:'+sHeight+'px; '+
  'clip:rect(0px, '+sWidth+'px, '+sHeight+'px, 0px); overflow:hidden;	z-index:1; }\n'+
  '#scrolllyr{ position:absolute; visibility:hidden; left:0px; top:0px; z-index:1; }\n'+
  '.scrollcontent	{ font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; }\n'+
  '-->\n'+
  '</style>\n'+
  '<table width="'+(sWidth+12)+' "height="'+sHeight+'" cellspacing="0" cellpadding="0" border="0">'+
	'<tr>'+
	'<td valign="top" width="100%" style="padding:10px 5px 10px 0px">'+
	'<div id="scrollhold">'+
	'<div id="scrollwn">'+
	'<div id="scrolllyr" class="content">'
  
 document.write(wSTR)
 scroll_params = {sWidth:sWidth,sHeight:sHeight,imgDir:imgDir}
}

function setScrollFoot(){
    document.write('</div></div></div></td><td align=right style="padding:0px 0px 0px 0px" id=scrolltd>'+
                  '</td></tr></table>')

}

//OtherOnLoad = (window.onload) ? window.onload :  new Function
//window.onload = function(){ alert("START");  OtherOnLoad(); initScrLyr("scrollhold","scrollwn","scrolllyr"); }

