//Remove hover states for iphone
$(document).ready(function() {
	if(navigator.userAgent.match(/iPhone/i) ||
	 navigator.userAgent.match(/iPad/i) ||
	 navigator.userAgent.match(/iPod/i)
	 ){
		
		$('#top-container').css({ 'height' : '15px' });
		
		var all = document.getElementsByTagName("*");
		for (var i=0, max=all.length; i < max; i++) {
			 var ele = all[i];
			delete ele.onmouseover;
			ele.onmouseover = null;
			ele.onmouseover = new Function(); 
		}
	 }
});


// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



 /**
 * Sets a Cookie with the given name and value.
 *
 * name Name of the cookie
 * value Value of the cookie
 * [expires] Expiration date of the cookie (default: end of current session)
 * [path] Path where the cookie is valid (default: path of calling document)
 * [domain] Domain where the cookie is valid
 * (default: domain of calling document)
 * [secure] Boolean value indicating if the cookie transmission requires a
 * secure transmission
 */



 function SetCookie(name, value, expires, path, domain, secure)
 {

 var expires = new Date();
 expires.setYear(3000);

 document.cookie= name + "=" + escape(value) +
 ((true) ? "; expires=" + expires : "") +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 ((secure) ? "; secure" : "");
 }
 //alert(String("25/12/3000").toGMTString()) ;
 /**
 * Gets the value of the specified cookie.
 *
 * name Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 * or null if cookie does not exist.
 */
 function GetCookie(name)
{
 var dc = document.cookie;
 var prefix = name + "=";
 var begin = dc.indexOf("; " + prefix);
if (begin == -1)
 {
 begin = dc.indexOf(prefix);
 if (begin != 0) return null;
 }
 else
 {
 begin += 2;
 }
 var end = document.cookie.indexOf(";", begin);
 if (end == -1)
 {
 end = dc.length;
 }
 return unescape(dc.substring(begin + prefix.length, end));
 }

 /**
 * Deletes the specified cookie.
 *
 * name name of the cookie
 * [path] path of the cookie (must be same as path used to create cookie)
 * [domain] domain of the cookie (must be same as domain used to create cookie)
 */
 function deleteCookie(name, path, domain)
 {
 if (GetCookie(name))
 {
 document.cookie = name + "=" +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
 }

 // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

function e(id) {
	return document.getElementById(id)?document.getElementById(id):false;
}

function onRollOver(obj_img){
	obj_img.src =obj_img.src.split("-off").join("-on");	
}

function onRollOut(obj_img){
	if (places_page_active) {
		var current_emp = obj_img.id;
		active_emp_val = "img_" + active_emp;
		//alert("current: " + current_emp + " active: " + active_emp_val);
		if (current_emp == active_emp_val) {
		}
		else {
			obj_img.src = obj_img.src.split("-on").join("-off");
		}
	}
	else {
		obj_img.src = obj_img.src.split("-on").join("-off");
	}
}

//-------- HOME BUTTONS ------//
function onMapOver(id) {
	e("nav-home-" + id).className = "nav-on";
}

function onMapOut(id) {
	e("nav-home-" + id).className = "nav-off";
}

//----- INTENAL BUTTONS ------//
function onNavOver(id) {
	e(id).className = "nav-visible";
}

function onNavOut(id) {
	e(id).className = "nav-hidden";
}


//----- PEOPLE BUTTONS ----//
function onBtnOver(id) {
	e(id).className = "visible";
}

function onBtnOut(id) {
	e(id).className = "hidden";
}

//----------------- EMPLOYEE SECTION ------------------//

// SET active id to blank on load
var str_active_id = "life";

function rollOver(id) {
	e(id).src = e(id).src.split("-off").join("-on");
}

function rollOut(id) {
	if (str_active_id != id) {
		e(id).src = e(id).src.split("-on").join("-off");
	}
}

function employeeSection(id) {
	str_active_id = id; 
	
	var str_sections = new Array("life","work","play");
	for (i = 0; i < 3; i++) {
		e("employee-" + str_sections[i]).className="employee-hidden";
		e(str_sections[i]).src = e(str_sections[i]).src.split("-on").join("-off");
	}
	e(str_active_id).src = e(str_active_id).src.split("-off").join("-on");
	e("employee-" + id).className="employee-shown";	
	
	return false;
}


//------- SCROLLER ------//
var scroller1Initiated = 0;
var scroller2Initiated = 0;
var scroller3Initiated = 0;

function startScroller(id) {
	if(id == "life") {
		if (scroller1Initiated == 0) {
			Scrollercontent1.init();
			scroller1Initiated++;
			return;
		}
	}
	if(id == "work") {
		if (scroller2Initiated == 0) {
			Scrollercontent2.init();
			scroller2Initiated++;
			return;
		}
	}
	if(id == "play") {
		if (scroller3Initiated == 0) {
			Scrollercontent3.init();
			scroller3Initiated++;
			return;
		}
	}
}


//--------- PLACES PAGE FOR NAVIGATION ITEMS AND LIST ------//

function callFirstEmployee() {
	showEmployee("gladstone");
	//active_emp = "gladstone";
	e("img_gladstone").src = "images/map-gladstone-on.gif"
}


function showEmployee(str_locid){
	
	e("content").innerHTML = "";
	
	if (active_emp != "none") {
		e("img_" + active_emp).src = e("img_" + active_emp).src.split("-on").join("-off");
	}
	e("places-stickit-note").className = "hidden";
	e("places-frame-container").className = "visible";
	
	active_emp = str_locid;
	e("img_" + str_locid).src = e("img_" + str_locid).src.split("-off").join("-on");		
	if(obj_data[str_locid]){	
		var arr =  obj_data[str_locid];
	
		if (arr[0] != null){
			e("emp-link1").href = arr[0]["str_link"];
			e("emp_img_top").src = arr[0]["str_image"];
			e("emp_name_top").innerHTML =  arr[0]["str_name"];
			e("emp_pos_top").innerHTML =  "<span>" + arr[0]["str_position"] + "</span>";
			/*e("emp_location_top").innerHTML =  "<span>" + arr[0]["str_location"] + "</span>";*/
			
			if (e("places-content-container").className = 'hidden') {
				e("places-content-container").className = 'visible';
			}
			e("content").innerHTML = e("content_" + str_locid).innerHTML;
			Scrollercontent.goTop(0);
			Scrollercontent.resetHeight();
			
		} else {
			// hide top
			e("places-frame-container").className = "hidden";
		}
			
		if (arr[1] != null){
			e("emp-link2").href = arr[1]["str_link"];
			e("emp_img_btm").src = arr[1]["str_image"];
			e("emp_name_btm").innerHTML =  arr[1]["str_name"];
			e("emp_pos_btm").innerHTML =  "<span>" + arr[1]["str_position"] + "</span>";
			/*e("emp_location_btm").innerHTML =  "<span>" + arr[1]["str_location"] + "</span>";*/
			
		} else {
			// hide btm
		}
	}
	else {
		e("places-frame-container").className = "hidden";
		return false;
	}
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


var Scrollerthincontent = {
speed			: 100,
aniLen			: 1000,
clipH			: 300,
thumbMax		: 290,
thumbH			: 10,
scrollbarH		: 300,
scrollTop		: 0,
scrollLeft		: 0,
minRes			: 10,
ie4				: navigator.appName == "Microsoft Internet Explorer" && !document.getElementById,
ns4				: document.layers ? 1 : 0,
dom				: document.getElementById ? 1 : 0,
mac				: navigator.platform == "MacPPC",
mo5				: navigator.userAgent.indexOf("Gecko") != -1,
imgElevBack1	: ypImage("Images/x.gif"),
imgElevBack2	: ypImage("Images/x.gif"),
imgElevBack3	: ypImage("Images/x.gif"),
imgThumb1		: ypImage("Images/x.gif"),
imgThumb2		: ypImage("Images/x.gif"),
imgUp1			: ypImage("Images/x.gif"),
imgUp2			: ypImage("Images/x.gif"),
imgUp3			: ypImage("Images/x.gif"),
imgDn1			: ypImage("Images/x.gif"),
imgDn2			: ypImage("Images/x.gif"),
imgDn3			: ypImage("Images/x.gif"),
dir:0,lastTime:0,aniTimer:0,dragActive:0,dragLastY:0,dragStartOffset:0,
startPos:0,startTime:0,accel:0,endPos:0,dist:0
}
var int_scrollloadedtestcount_thincontent = 0;
function goInitScrollerthincontent(){	
Scrollerthincontent.init();
}
Scrollerthincontent.init = function() {
with (this) {
// gather pieces
this.lyrFrame			= getLyr("scrollerthincontent", document)
this.lyrScrollbar		= getLyr("scrollbar", lyrFrame)
this.lyrThumb			= getLyr("thumb", lyrScrollbar)
this.lyrMarker			= getLyr("marker", lyrScrollbar)
this.lyrElevUp			= getLyr("elevUp", lyrScrollbar)
this.lyrElevDn			= getLyr("elevDn", lyrScrollbar)
//this.lyrThumbArrowUp	= getLyr("thumbArrowUp", lyrScrollbar)
//this.lyrThumbArrowDn	= getLyr("thumbArrowDn", lyrScrollbar)
this.lyrContainer		= getLyr("container", lyrFrame)
this.lyrContent			= getLyr("content", lyrContainer)
// calculate some values
this.docH				= Math.max(ns4 ? lyrContent.document.height : lyrContent.offsetHeight, clipH)
this.scrollH			= docH - clipH
if (this.scrollH < 1){
if(e("scrollbar")){
e("scrollbar").style.display = "none";
}
} else {
if(e("scrollbar")){
e("scrollbar").style.display = "block";
}
}
if ((this.docH <= clipH ) && int_scrollloadedtestcount_thincontent < 25) {	
int_scrollloadedtestcount_thincontent++
goInitScrollerthincontent();
setTimeout("goInitScrollerthincontent()",200);
return		
}
if (this.docH > clipH) {
// hook events
lyrElevUp.onmousedown   = slideTo
lyrElevDn.onmousedown	= slideTo
lyrThumb.onmousedown    = startDrag
lyrThumb.onmouseover    = function() { Scrollerthincontent.toggleThumb(true) }
lyrThumb.onmouseout     = function() { Scrollerthincontent.toggleThumb(false) }
lyrThumb.ondragstart	= function() { return false; }
lyrElevUp.onmouseover   = function() { Scrollerthincontent.toggleElev(Scrollerthincontent.lyrElevUp, 2) }
lyrElevUp.onmouseout    = function() { Scrollerthincontent.toggleElev(Scrollerthincontent.lyrElevUp, 1) }
lyrElevDn.onmouseover	= function() { Scrollerthincontent.toggleElev(Scrollerthincontent.lyrElevDn, 2) }
lyrElevDn.onmouseout	= function() { Scrollerthincontent.toggleElev(Scrollerthincontent.lyrElevDn, 1) }
// initialize some settings
lyrThumb.s.top = 0;
this.thumbTop = 0;
this.goTop(0);
/*startPos = 0;
dir = 0;
lastTime = 0;
aniTimer = 0;
dragActive = 0;
dragLastY = 0;
dragStartOffset = 0;
startTime = 0;
accel = 0;
endPos = 0;
dist = 0;*/
// ns4.
if (document.layers) { 
lyrThumb.captureEvents(Event.MOUSEDOWN)
lyrElevDn.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE)
lyrElevUp.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE)
}
// mozilla5.
if (mo5) document.getElementById("scrollerMo5Shim").style.height = docH
this.lyrScrollbar.s.visibility = 'visible';
//alert(scrollTop);
} 
else 
{
this.goTop(0);
this.lyrScrollbar.s.visibility = 'hidden';
}
// all done!
this.loaded = true
}
}
Scrollerthincontent.startScroll = function(dir) {
if (this.aniTimer) window.clearTimeout(this.aniTimer)
this.dir		= dir
this.lastTime	= (new Date()).getTime() - this.minRes
this.startPos	= this.scrollTop
this.aniTimer	= window.setTimeout("Scrollerthincontent.scroll()", this.minRes)
}
Scrollerthincontent.scroll = function() {
this.aniTimer	= window.setTimeout("Scrollerthincontent.scroll()", this.minRes)
var now			= (new Date()).getTime()
var elapsed		= now - this.lastTime
var ny			= eval(this.scrollTop + this.dir + (elapsed * this.speed / 1000))
this.lastTime	= now
if (ny > this.scrollH && this.dir == "+" || ny < 0 && this.dir == "-") {
this.endScroll()
this.jumpTo(this.dir == "+" ? this.scrollH : 0)
}
else this.jumpTo(ny)
}
Scrollerthincontent.endScroll = function() {
if (this.aniTimer) this.aniTimer = window.clearTimeout(this.aniTimer)
}
Scrollerthincontent.startDrag = function(e) {
if (!e) e = window.event
with (Scrollerthincontent) {
if (aniTimer) window.clearTimeout(aniTimer)
var ey = e.pageY ? e.pageY : e.y
dragLastY = ey
dragStartOffset = ey - parseInt(lyrThumb.s.top)
dragActive = true
if (ns4) window.document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP)
window.document.onmousemove = doDrag
window.document.onmouseup = stopDrag
}
return false
}
Scrollerthincontent.doDrag = function(e) {
if (!e) e = window.event
var s  = Scrollerthincontent
var ey = (e.pageY ? e.pageY : e.y)
var dy = ey - s.dragLastY
var ny = parseInt(Scrollerthincontent.lyrThumb.s.top) + dy
// constrain
if (ny >= s.thumbMax) s.dragLastY = s.thumbMax + s.dragStartOffset
else if (ny < 0) s.dragLastY = s.dragStartOffset
else s.dragLastY = ey
ny = Math.min(Math.max(ny, 0), s.thumbMax)
s.jumpTo(ny * s.scrollH / s.thumbMax)
return false;
}
Scrollerthincontent.positionThumbArrows = function(ny) {
//this.lyrThumbArrowUp.s.top = ny - 6
//this.lyrThumbArrowDn.s.top = ny + 15
}
Scrollerthincontent.stopDrag = function() {
Scrollerthincontent.dragActive = false
Scrollerthincontent.toggleThumb(false)
if (Scrollerthincontent.ns4) window.document.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP)
window.document.onmousemove = null
window.document.onmouseup   = null
}
// slideTo gets called in the scope of lyrElevUp or lyrElevDn
Scrollerthincontent.slideTo = function(e) {
if (!e) e = window.event
var ey = e.offsetY ? e.offsetY : e.layerY
if (typeof ey == "undefined") ey = 0
var ny = (this.id == "elevDn") ? ey-14 : ey
ny += this.s.top == "" ? 0 : parseInt(this.s.top)
ny *= Scrollerthincontent.scrollH / Scrollerthincontent.thumbMax
ny = Math.min(ny, Scrollerthincontent.scrollH)
with (Scrollerthincontent) {
startTime = (new Date()).getTime()
startPos = scrollTop
endPos = ny
dist = endPos - startPos
accel = dist / 1000 / 1000
if (aniTimer) aniTimer = window.clearInterval(aniTimer)
aniTimer = window.setInterval("Scrollerthincontent.slide()", 10)
}
}
Scrollerthincontent.slide = function() {
with (this) {
var now = (new Date()).getTime()
var elapsed = now - startTime
if (elapsed > 1000) endScroll()
else {
var t = 1000 - elapsed
var ny = endPos - t * t * accel
jumpTo(ny)
}
}
}
Scrollerthincontent.jumpTo = function(ny) {
var thumbTop = ny * this.thumbMax / this.scrollH
this.lyrElevUp[document.layers ? "clip" : "style"].height = thumbTop
this.lyrElevDn[document.layers ? "clip" : "style"].height = this.scrollbarH - thumbTop
this.lyrElevDn.s.top = thumbTop
this.lyrThumb.s.top = thumbTop
this.lyrContent.s.top = -ny
this.positionThumbArrows(ny * this.thumbMax / this.scrollH)
this.scrollTop = ny  
}
Scrollerthincontent.goTop = function(ny) {
var thumbTop = ny * this.thumbMax / this.scrollH
//this.lyrElevUp[document.layers ? "clip" : "style"].height = thumbTop
//this.lyrElevDn[document.layers ? "clip" : "style"].height = this.scrollbarH - thumbTop
//this.lyrElevDn.s.top = thumbTop
//this.lyrThumb.s.top = thumbTop
this.lyrContent.s.top = -ny
//this.positionThumbArrows(ny * this.thumbMax / this.scrollH)
this.scrollTop = ny  
}
Scrollerthincontent.toggleThumb = function(bOn) {
var img = this.getFirstImage(this.lyrThumb)
//img.src = !bOn && !this.dragActive ? this.imgThumb1.src : this.imgThumb2.src
if (!bOn && !this.dragActive) this.toggleThumbArrows(false)
else {
this.positionThumbArrows(parseInt(this.lyrThumb.s.top))
this.toggleThumbArrows(true)
}
}
Scrollerthincontent.toggleThumbArrows = function(bOn) {
//this.lyrThumbArrowUp.s.visibility = bOn ? "visible" : "hidden"
//this.lyrThumbArrowDn.s.visibility = bOn ? "visible" : "hidden"
}
Scrollerthincontent.toggleElev = function(lyr, iState) {
var img = this["imgElevBack" + iState];
with (this) {
//if (document.layers) lyr.document.images[0].src = img.src;
//else lyr.firstChild.src = img.src;
lyr.onmousemove = iState == 2 ? moveMarker : null
if (iState == 1) lyrMarker.s.visibility = "hidden"
}
}
Scrollerthincontent.moveMarker = function(e) {
with (Scrollerthincontent) {	
if (!lyrThumb.active) {
if (!e) e = window.event
var ey = e.layerY ? e.layerY : e.offsetY
if (isNaN(ey)) ey = 0
var ny = Math.round(ey / 2) * 2
ny += (this.s.top == "" ? 0 : parseInt(this.s.top))
ny -= 1
lyrMarker.s.top = ny
lyrMarker.s.visibility = "visible"
}
}
}
Scrollerthincontent.toggleButton = function(suffix, iState) {
var lyr = eval("Scrollerthincontent.lyrScroll" + suffix)
var img = this.getFirstImage(lyr)
//img.src = "scroll"+suffix+iState+".gif"
}
Scrollerthincontent.getLyr = function(sLyrId, oNestRef) {
var o
if (document.all) o = oNestRef.all[sLyrId]
else if (document.layers) o = oNestRef.layers[sLyrId]
else o = this.recursiveNs6Get(sLyrId, oNestRef)
o.s = document.layers ? o : o.style
return o
}
// this is kinda slow for ns6 -> 
// but best way I could think of w/o totally bloating the code.
Scrollerthincontent.recursiveNs6Get = function(id, p) {
if (p.childNodes) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].id == id) return p.childNodes[i]
else if (p.childNodes[i].childNodes.length > 0) {
var obj = Scrollerthincontent.recursiveNs6Get(id, p.childNodes[i])
if (obj && obj != null) return obj
}
}
}
return false
}
Scrollerthincontent.getFirstImage = function(lyr) {
return document.layers ? lyr.document.images[0] : document.all ? lyr.all.tags("IMG")[0] : lyr.getElementsByTagName("IMG")[0]
}
function ypImage(s) {
var oImg  = new Image();
// oImg.src = "Images/x.gif" ;//s
return oImg
}
function dbg(obj) {
var s = ""
for (prop in obj) s += prop + ":" + obj[prop] + "\n"
alert(s)
}
function e(id){
return document.getElementById(id);
}




// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


var Scrollerwidecontent = {
speed			: 100,
aniLen			: 1000,
clipH			: 300,
thumbMax		: 290,
thumbH			: 10,
scrollbarH		: 300,
scrollTop		: 0,
scrollLeft		: 0,
minRes			: 10,
ie4				: navigator.appName == "Microsoft Internet Explorer" && !document.getElementById,
ns4				: document.layers ? 1 : 0,
dom				: document.getElementById ? 1 : 0,
mac				: navigator.platform == "MacPPC",
mo5				: navigator.userAgent.indexOf("Gecko") != -1,
imgElevBack1	: ypImage("Images/x.gif"),
imgElevBack2	: ypImage("Images/x.gif"),
imgElevBack3	: ypImage("Images/x.gif"),
imgThumb1		: ypImage("Images/x.gif"),
imgThumb2		: ypImage("Images/x.gif"),
imgUp1			: ypImage("Images/x.gif"),
imgUp2			: ypImage("Images/x.gif"),
imgUp3			: ypImage("Images/x.gif"),
imgDn1			: ypImage("Images/x.gif"),
imgDn2			: ypImage("Images/x.gif"),
imgDn3			: ypImage("Images/x.gif"),
dir:0,lastTime:0,aniTimer:0,dragActive:0,dragLastY:0,dragStartOffset:0,
startPos:0,startTime:0,accel:0,endPos:0,dist:0
}
var int_scrollloadedtestcount_widecontent = 0;
function goInitScrollerwidecontent(){	
Scrollerwidecontent.init();
}
Scrollerwidecontent.init = function() {
with (this) {
// gather pieces
this.lyrFrame			= getLyr("scrollerwidecontent", document)
this.lyrScrollbar		= getLyr("scrollbar", lyrFrame)
this.lyrThumb			= getLyr("thumb", lyrScrollbar)
this.lyrMarker			= getLyr("marker", lyrScrollbar)
this.lyrElevUp			= getLyr("elevUp", lyrScrollbar)
this.lyrElevDn			= getLyr("elevDn", lyrScrollbar)
//this.lyrThumbArrowUp	= getLyr("thumbArrowUp", lyrScrollbar)
//this.lyrThumbArrowDn	= getLyr("thumbArrowDn", lyrScrollbar)
this.lyrContainer		= getLyr("container", lyrFrame)
this.lyrContent			= getLyr("content", lyrContainer)
// calculate some values
this.docH				= Math.max(ns4 ? lyrContent.document.height : lyrContent.offsetHeight, clipH)
this.scrollH			= docH - clipH
if (this.scrollH < 1){
if(e("scrollbar")){
e("scrollbar").style.display = "none";
}
} else {
if(e("scrollbar")){
e("scrollbar").style.display = "block";
}
}
if ((this.docH <= clipH ) && int_scrollloadedtestcount_widecontent < 25) {	
int_scrollloadedtestcount_widecontent++
goInitScrollerwidecontent();
setTimeout("goInitScrollerwidecontent()",200);
return		
}
if (this.docH > clipH) {
// hook events
lyrElevUp.onmousedown   = slideTo
lyrElevDn.onmousedown	= slideTo
lyrThumb.onmousedown    = startDrag
lyrThumb.onmouseover    = function() { Scrollerwidecontent.toggleThumb(true) }
lyrThumb.onmouseout     = function() { Scrollerwidecontent.toggleThumb(false) }
lyrThumb.ondragstart	= function() { return false; }
lyrElevUp.onmouseover   = function() { Scrollerwidecontent.toggleElev(Scrollerwidecontent.lyrElevUp, 2) }
lyrElevUp.onmouseout    = function() { Scrollerwidecontent.toggleElev(Scrollerwidecontent.lyrElevUp, 1) }
lyrElevDn.onmouseover	= function() { Scrollerwidecontent.toggleElev(Scrollerwidecontent.lyrElevDn, 2) }
lyrElevDn.onmouseout	= function() { Scrollerwidecontent.toggleElev(Scrollerwidecontent.lyrElevDn, 1) }
// initialize some settings
lyrThumb.s.top = 0;
this.thumbTop = 0;
this.goTop(0);
/*startPos = 0;
dir = 0;
lastTime = 0;
aniTimer = 0;
dragActive = 0;
dragLastY = 0;
dragStartOffset = 0;
startTime = 0;
accel = 0;
endPos = 0;
dist = 0;*/
// ns4.
if (document.layers) { 
lyrThumb.captureEvents(Event.MOUSEDOWN)
lyrElevDn.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE)
lyrElevUp.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE)
}
// mozilla5.
if (mo5) document.getElementById("scrollerMo5Shim").style.height = docH
this.lyrScrollbar.s.visibility = 'visible';
//alert(scrollTop);
} 
else 
{
this.goTop(0);
this.lyrScrollbar.s.visibility = 'hidden';
}
// all done!
this.loaded = true
}
}
Scrollerwidecontent.startScroll = function(dir) {
if (this.aniTimer) window.clearTimeout(this.aniTimer)
this.dir		= dir
this.lastTime	= (new Date()).getTime() - this.minRes
this.startPos	= this.scrollTop
this.aniTimer	= window.setTimeout("Scrollerwidecontent.scroll()", this.minRes)
}
Scrollerwidecontent.scroll = function() {
this.aniTimer	= window.setTimeout("Scrollerwidecontent.scroll()", this.minRes)
var now			= (new Date()).getTime()
var elapsed		= now - this.lastTime
var ny			= eval(this.scrollTop + this.dir + (elapsed * this.speed / 1000))
this.lastTime	= now
if (ny > this.scrollH && this.dir == "+" || ny < 0 && this.dir == "-") {
this.endScroll()
this.jumpTo(this.dir == "+" ? this.scrollH : 0)
}
else this.jumpTo(ny)
}
Scrollerwidecontent.endScroll = function() {
if (this.aniTimer) this.aniTimer = window.clearTimeout(this.aniTimer)
}
Scrollerwidecontent.startDrag = function(e) {
if (!e) e = window.event
with (Scrollerwidecontent) {
if (aniTimer) window.clearTimeout(aniTimer)
var ey = e.pageY ? e.pageY : e.y
dragLastY = ey
dragStartOffset = ey - parseInt(lyrThumb.s.top)
dragActive = true
if (ns4) window.document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP)
window.document.onmousemove = doDrag
window.document.onmouseup = stopDrag
}
return false
}
Scrollerwidecontent.doDrag = function(e) {
if (!e) e = window.event
var s  = Scrollerwidecontent
var ey = (e.pageY ? e.pageY : e.y)
var dy = ey - s.dragLastY
var ny = parseInt(Scrollerwidecontent.lyrThumb.s.top) + dy
// constrain
if (ny >= s.thumbMax) s.dragLastY = s.thumbMax + s.dragStartOffset
else if (ny < 0) s.dragLastY = s.dragStartOffset
else s.dragLastY = ey
ny = Math.min(Math.max(ny, 0), s.thumbMax)
s.jumpTo(ny * s.scrollH / s.thumbMax)
return false;
}
Scrollerwidecontent.positionThumbArrows = function(ny) {
//this.lyrThumbArrowUp.s.top = ny - 6
//this.lyrThumbArrowDn.s.top = ny + 15
}
Scrollerwidecontent.stopDrag = function() {
Scrollerwidecontent.dragActive = false
Scrollerwidecontent.toggleThumb(false)
if (Scrollerwidecontent.ns4) window.document.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP)
window.document.onmousemove = null
window.document.onmouseup   = null
}
// slideTo gets called in the scope of lyrElevUp or lyrElevDn
Scrollerwidecontent.slideTo = function(e) {
if (!e) e = window.event
var ey = e.offsetY ? e.offsetY : e.layerY
if (typeof ey == "undefined") ey = 0
var ny = (this.id == "elevDn") ? ey-14 : ey
ny += this.s.top == "" ? 0 : parseInt(this.s.top)
ny *= Scrollerwidecontent.scrollH / Scrollerwidecontent.thumbMax
ny = Math.min(ny, Scrollerwidecontent.scrollH)
with (Scrollerwidecontent) {
startTime = (new Date()).getTime()
startPos = scrollTop
endPos = ny
dist = endPos - startPos
accel = dist / 1000 / 1000
if (aniTimer) aniTimer = window.clearInterval(aniTimer)
aniTimer = window.setInterval("Scrollerwidecontent.slide()", 10)
}
}
Scrollerwidecontent.slide = function() {
with (this) {
var now = (new Date()).getTime()
var elapsed = now - startTime
if (elapsed > 1000) endScroll()
else {
var t = 1000 - elapsed
var ny = endPos - t * t * accel
jumpTo(ny)
}
}
}
Scrollerwidecontent.jumpTo = function(ny) {
var thumbTop = ny * this.thumbMax / this.scrollH
this.lyrElevUp[document.layers ? "clip" : "style"].height = thumbTop
this.lyrElevDn[document.layers ? "clip" : "style"].height = this.scrollbarH - thumbTop
this.lyrElevDn.s.top = thumbTop
this.lyrThumb.s.top = thumbTop
this.lyrContent.s.top = -ny
this.positionThumbArrows(ny * this.thumbMax / this.scrollH)
this.scrollTop = ny  
}
Scrollerwidecontent.goTop = function(ny) {
var thumbTop = ny * this.thumbMax / this.scrollH
//this.lyrElevUp[document.layers ? "clip" : "style"].height = thumbTop
//this.lyrElevDn[document.layers ? "clip" : "style"].height = this.scrollbarH - thumbTop
//this.lyrElevDn.s.top = thumbTop
//this.lyrThumb.s.top = thumbTop
this.lyrContent.s.top = -ny
//this.positionThumbArrows(ny * this.thumbMax / this.scrollH)
this.scrollTop = ny  
}
Scrollerwidecontent.toggleThumb = function(bOn) {
var img = this.getFirstImage(this.lyrThumb)
//img.src = !bOn && !this.dragActive ? this.imgThumb1.src : this.imgThumb2.src
if (!bOn && !this.dragActive) this.toggleThumbArrows(false)
else {
this.positionThumbArrows(parseInt(this.lyrThumb.s.top))
this.toggleThumbArrows(true)
}
}
Scrollerwidecontent.toggleThumbArrows = function(bOn) {
//this.lyrThumbArrowUp.s.visibility = bOn ? "visible" : "hidden"
//this.lyrThumbArrowDn.s.visibility = bOn ? "visible" : "hidden"
}
Scrollerwidecontent.toggleElev = function(lyr, iState) {
var img = this["imgElevBack" + iState];
with (this) {
//if (document.layers) lyr.document.images[0].src = img.src;
//else lyr.firstChild.src = img.src;
lyr.onmousemove = iState == 2 ? moveMarker : null
if (iState == 1) lyrMarker.s.visibility = "hidden"
}
}
Scrollerwidecontent.moveMarker = function(e) {
with (Scrollerwidecontent) {	
if (!lyrThumb.active) {
if (!e) e = window.event
var ey = e.layerY ? e.layerY : e.offsetY
if (isNaN(ey)) ey = 0
var ny = Math.round(ey / 2) * 2
ny += (this.s.top == "" ? 0 : parseInt(this.s.top))
ny -= 1
lyrMarker.s.top = ny
lyrMarker.s.visibility = "visible"
}
}
}
Scrollerwidecontent.toggleButton = function(suffix, iState) {
var lyr = eval("Scrollerwidecontent.lyrScroll" + suffix)
var img = this.getFirstImage(lyr)
//img.src = "scroll"+suffix+iState+".gif"
}
Scrollerwidecontent.getLyr = function(sLyrId, oNestRef) {
var o
if (document.all) o = oNestRef.all[sLyrId]
else if (document.layers) o = oNestRef.layers[sLyrId]
else o = this.recursiveNs6Get(sLyrId, oNestRef)
o.s = document.layers ? o : o.style
return o
}
// this is kinda slow for ns6 -> 
// but best way I could think of w/o totally bloating the code.
Scrollerwidecontent.recursiveNs6Get = function(id, p) {
if (p.childNodes) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].id == id) return p.childNodes[i]
else if (p.childNodes[i].childNodes.length > 0) {
var obj = Scrollerwidecontent.recursiveNs6Get(id, p.childNodes[i])
if (obj && obj != null) return obj
}
}
}
return false
}
Scrollerwidecontent.getFirstImage = function(lyr) {
return document.layers ? lyr.document.images[0] : document.all ? lyr.all.tags("IMG")[0] : lyr.getElementsByTagName("IMG")[0]
}
function ypImage(s) {
var oImg  = new Image();
// oImg.src = "Images/x.gif" ;//s
return oImg
}
function dbg(obj) {
var s = ""
for (prop in obj) s += prop + ":" + obj[prop] + "\n"
alert(s)
}
