

// =========================================================================
// JS Scroller V3.0, modified version by Richard Shea (see additions below)
// Original coding & sources as stated below:
// Modified from Aaron Boodman http://webapp.youngpup.net/?request=/components/ypSimpleScroll.xml
// mixed ypSimpleScroll with dom-drag script and allowed multiple scrollers through array instances
// (c)2004 Sergi Meseguer (http://zigotica.com/), 04/2004:

// Additional coding by Richard Shea (http://shea.co.uk), September-Nov 2006
// Added mousewheel interactivity for Firefox, Opera and IE.
// Added keyboard interactivity (most nav keys), page up/dn areas
// Added thumb-bar auto size script.
// Added fading top & bottom to text area.
// =========================================================================
var theHandle = []; var theRoot = []; var theThumb = []; var theScroll = []; var thumbTravel = []; var ratio = [];

function instantiateScroller(count, id, left, top, width, height, speed){
	if(document.getElementById) {
		theScroll[count] = new ypSimpleScroll(id, left, top, width, height, speed);
	}
}

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY){
		var BarOuter = '<div class="scrollarea" id="area'+count+'" onmousedown="PageDn();">';
		var buttons = '<div class="up" id="up'+count+'"><a href="#" onmousedown="theScroll['+count+'].scrollNorth(\''+count+'\',0)" onmouseup="theScroll['+count+'].endScroll();this.blur();" onmouseover="return false;"><img src="js/up.gif" width="15" height="15" border="0"></a></div><div class="dn"  id="dn'+count+'""><a href="#" onmousedown="theScroll['+count+'].scrollSouth(\''+count+'\',0)" onmouseup="theScroll['+count+'].endScroll();this.blur();" onmouseover="return false;"><img src="js/dn.gif" width="15" height="15" border="0"></a></div><div class="thumb" id="'+thumb+'" style="left: 135px; top: 15px; cursor:hand;"><img src="js/thumb.gif" width="13" height="15" id="thumbimg"></div>';
		BarOuter = BarOuter + '</div><div class="scrollarea" id="areaup'+count+'" onmousedown="PageUp();"></div>'
		document.getElementById(root).innerHTML = buttons + document.getElementById(root).innerHTML + BarOuter;

		theRoot[count]   = document.getElementById(root);
		theThumb[count]  = document.getElementById(thumb);
		var thisup = document.getElementById("up"+count);
		var thisdn = document.getElementById("dn"+count);
		var thisarea = document.getElementById("area"+count);
		var thisareaup = document.getElementById("areaup"+count);
		theThumb[count].style.left = parseInt(minX+15) + "px";
		thisup.style.left = parseInt(minX+15) + "px";
		thisdn.style.left = parseInt(minX+15) + "px";
		thisarea.style.left = parseInt(minX+15) + "px";
		thisarea.style.left = parseInt(minX+15) + "px";	
thisarea.style.top = 15 + "px";	
		thisareaup.style.left = parseInt(minX+15) + "px";
//		theThumb[count].style.borderTop='1px solid #FFFFFF';
//		theThumb[count].style.borderLeft='1px solid #FFFFFF';
//		theThumb[count].style.borderRight='1px solid #AAAAAA';
//		theThumb[count].style.borderBottom='1px solid #AAAAAA';
		
		theThumb[count].style.top = parseInt(minY) + "px";
		thisup.style.top = 0 + "px";
		thisdn.style.top = parseInt(minY+maxY) + "px";
		thisarea.style.height = parseInt(minY+maxY) + "px";
		// clickable area up, half height.
		thisareaup.style.height = (maxY/2)+ "px";
		//thisdn.style.top = 15 + "px";
		PageSize=parseInt(minY+maxY); // used for PgDn and PgUp key functions

		theScroll[count].load();
		// Resize the thumbwheel on scrollbar
		sBar = parseInt(minY+maxY)-15 - (theScroll[count].scrollH/2)
sBar = 15;		
		// Make sure it's never less than 15px
		if (sBar<15){sBar=15}
		theThumb[count].style.height = sBar + "px";
		// Move thumb image vertically centre within thumbwheel above.
		document.getElementById('thumbimg').style.top= sBar/2-7.5+"px";

		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init(theThumb[count], null, minX+15, maxX+15, minY, maxY-sBar+14);		
		// the number of pixels the thumb can travel vertically (max - min)
		thumbTravel[count] = theThumb[count].maxY - theThumb[count].minY;

		// the ratio between scroller movement and thumbMovement
		ratio[count] = theScroll[count].scrollH / thumbTravel[count];

		theThumb[count].onDrag = function(x, y) {
			theScroll[count].jumpTo(null, Math.round((y - theThumb[count].minY) * ratio[count]));
		}
		if (theScroll[count].scrollH <1){
			hideLayer('thumb0');
			hideLayer('area0');hideLayer('areaup0');
			hideLayer('dn0');hideLayer('up0');
		}
}	

// INITIALIZER:
// ==============================================================
// ala Simon Willison http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function(){
		if(theScroll.length>0) {
		for(var i=0;i<theScroll.length;i++){
			createDragger(i, "handle"+i, "root"+i, "thumb"+i, theScroll[i].clipW, theScroll[i].clipW, 15, theScroll[i].clipH-30);
			
			// Anchor Link Jump addition (By Richard Shea)
			if (self.document.location.hash.substring(1) != ""){
				var Anc = getAnchorPosition(self.document.location.hash.substring(1));
				theScroll[i].jumpTo(Anc.x, Anc.y-theScroll[i].clipH);
				theScroll[i].scrollNull(0,1,1);
			}	
			
		}
		
	}
}) 

function HandleMouseWheel(delta) {
        if (delta < 0){theScroll[0].scrollSouth(0,1,1);}
        else {theScroll[0].scrollNorth(0,1,1);}
}


function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (event.detail) {
		delta = -event.detail/3;
	}
	if (delta)
		HandleMouseWheel(delta);
}

/* Initialization code. */
if (window.addEventListener)
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;


// Keyboard interactivty //
document.onkeydown = KeyCheck;       
function KeyCheck(e){
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   switch(KeyID) {
      case 35: // End key;
	theScroll[0].jumpTo(0,99999);theScroll[0].scrollSouth(0,1,1);break;       
      case 36: // End key;
	theScroll[0].jumpTo(0,0);theScroll[0].scrollNorth(0,1,1);break;       
      case 32: // Space key;
	PageDn();break;       
      case 34: // PgDn key;
	PageDn();break;       
      case 33: // PgUp key;
	PageUp();break;       
      case 38: // Arrow Up;
      	theScroll[0].scrollNorth(0,1,1);break;      
      case 40: // Arrow Down
	theScroll[0].scrollSouth(0,1,1);break;   
      }
}
function PageDn(){
	theScroll[0].jumpTo(0,theScroll[0].scrollTop+(PageSize/1.5))
	theScroll[0].scrollSouth(0,1,1);
}
function PageUp(){
	theScroll[0].jumpTo(0,theScroll[0].scrollTop-(PageSize/1.5))
	theScroll[0].scrollNorth(0,1,1);
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag	= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup	= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


/* =======================================================
* ypSimpleScroll
* 3/11/2001
* 
* http://www.youngpup.net/
* ======================================================= */

// Modified by Sergi Meseguer (www.zigotica.com) 04/2004
// Now it works with dragger and can use multiple instances in a page



ypSimpleScroll.prototype.scrollNorth = function(count,cont) { this.startScroll(90, count,cont) }
ypSimpleScroll.prototype.scrollSouth = function(count,cont) { this.startScroll(270, count,cont) }
ypSimpleScroll.prototype.scrollWest = function(count,cont) { this.startScroll(180, count,cont) }
ypSimpleScroll.prototype.scrollEast = function(count,cont) { this.startScroll(0, count,cont) }
ypSimpleScroll.prototype.scrollNull = function(count,cont) { this.startScroll(-1, count,cont) }

ypSimpleScroll.prototype.startScroll = function(deg, count,cont) {
	if (this.loaded){
		if (this.aniTimer) window.clearTimeout(this.aniTimer)
		if (deg == -1){
			deg=90
			this.speed = 1
		}	
		else {
			this.speed = this.origSpeed
		}
		this.overrideScrollAngle(deg)
		this.lastTime = (new Date()).getTime() - this.y.minRes
		this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"','"+cont+"')", this.y.minRes)
	}
}

ypSimpleScroll.prototype.endScroll = function() {
	if (this.loaded){
		window.clearTimeout(this.aniTimer)
		this.aniTimer = 0;
		this.speed = this.origSpeed
	}
}

ypSimpleScroll.prototype.overrideScrollAngle = function(deg) {
	if (this.loaded){
		deg = deg % 360
		if (deg % 90 == 0) {
			var cos = deg == 0 ? 1 : deg == 180 ? -1 : 0
			var sin = deg == 90 ? -1 : deg == 270 ? 1 : 0
		} 
		else {
			var angle = deg * Math.PI / 180
			var cos = Math.cos(angle)
			var sin = Math.sin(angle)
			sin = -sin
		}
		this.fx = cos / (Math.abs(cos) + Math.abs(sin))
		this.fy = sin / (Math.abs(cos) + Math.abs(sin))
		this.stopH = deg == 90 || deg == 270 ? this.scrollLeft : deg < 90 || deg > 270 ? this.scrollW : 0
		this.stopV = deg == 0 || deg == 180 ? this.scrollTop : deg < 180 ? 0 : this.scrollH
	}
}

ypSimpleScroll.prototype.overrideScrollSpeed = function(speed) {
	if (this.loaded) this.speed = speed
}


ypSimpleScroll.prototype.scrollTo = function(stopH, stopV, aniLen) {
	if (this.loaded){
		if (stopH != this.scrollLeft || stopV != this.scrollTop) {
			if (this.aniTimer) window.clearTimeout(this.aniTimer)
			this.lastTime = (new Date()).getTime()
			var dx = Math.abs(stopH - this.scrollLeft)
			var dy = Math.abs(stopV - this.scrollTop)
			var d = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2))
			this.fx = (stopH - this.scrollLeft) / (dx + dy)
			this.fy = (stopV - this.scrollTop) / (dx + dy)
			this.stopH = stopH
			this.stopV = stopV
			this.speed = d / aniLen * 1000
			window.setTimeout(this.gRef + ".scroll()", this.y.minRes)
		}
	}
}

ypSimpleScroll.prototype.jumpTo = function(nx, ny) { 
	if (this.loaded){
		nx = Math.min(Math.max(nx, 0), this.scrollW)
		ny = Math.min(Math.max(ny, 0), this.scrollH)
		this.scrollLeft = nx
		this.scrollTop = ny
		if (this.y.ns4)this.content.moveTo(-nx, -ny)
		else {
			this.content.style.left = -nx + "px"
			this.content.style.top = -ny + "px"
		}
	}
}

ypSimpleScroll.minRes = 10
ypSimpleScroll.ie = document.all ? 1 : 0
ypSimpleScroll.ns4 = document.layers ? 1 : 0
ypSimpleScroll.dom = document.getElementById ? 1 : 0
ypSimpleScroll.mac = navigator.platform == "MacPPC"
ypSimpleScroll.mo5 = document.getElementById && !document.all ? 1 : 0

ypSimpleScroll.prototype.scroll = function(deg,count,cont) {
	if (cont==0){
		this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"','"+cont+"')", this.y.minRes)
		speedx=this.speed
	}
	else {
		speedx=this.speed*10
	}
	var nt = (new Date()).getTime()
	var d = Math.round((nt - this.lastTime) / 1000 * speedx)
	if (d > 0){
		var nx = d * this.fx + this.scrollLeft
		var ny = d * this.fy + this.scrollTop
		var xOut = (nx >= this.scrollLeft && nx >= this.stopH) || (nx <= this.scrollLeft && nx <= this.stopH)
		var yOut = (ny >= this.scrollTop && ny >= this.stopV) || (ny <= this.scrollTop && ny <= this.stopV)
		if (nt - this.lastTime != 0 && 
			((this.fx == 0 && this.fy == 0) || 
			(this.fy == 0 && xOut) || 
			(this.fx == 0 && yOut) || 
			(this.fx != 0 && this.fy != 0 && 
			xOut && yOut))) {
			this.jumpTo(this.stopH, this.stopV)
			this.endScroll()
		}
		else {
			this.jumpTo(nx, ny)
			this.lastTime = nt
		}

	// (zgtc) now we also update dragger position:
	//theThumb[count]  = document.getElementById('thumb0');
	if(deg=='270'){
		Pos = parseInt(((theThumb[count].maxY-theThumb[count].minY)*this.scrollTop/this.stopV)+theThumb[count].minY);
		if (!isNaN(Pos)){theThumb[count].style.top = Pos + "px"}
		}
	if(deg=='90'){
		Pos = parseInt(((theThumb[count].maxY-theThumb[count].minY)*this.scrollTop/this.scrollH)+theThumb[count].minY);
		if (!isNaN(Pos)){theThumb[count].style.top = Pos + "px"}
		}
	}
}

function ypSimpleScroll(id, left, top, width, height, speed) {
	var y = this.y = ypSimpleScroll
	if (document.layers && !y.ns4) history.go(0)
	if (y.ie || y.ns4 || y.dom) {
		this.loaded = false
		this.id = id
		this.origSpeed = speed
		this.aniTimer = false
		this.op = ""
		this.lastTime = 0
		this.clipH = height
		this.clipW = width+left
		this.scrollTop = 0
		this.scrollLeft = 0
		this.gRef = "ypSimpleScroll_"+id
		eval(this.gRef+"=this")
		var d = document
		d.write('<style type="text/css">')
		d.write('#' + this.id + 'Container { left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px; clip:rect(0 ' + width + ' ' + height + ' 0); overflow:hidden; }')
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; }')
		d.write('#' + this.id + 'Content { left:' + (-this.scrollLeft) + 'px; top:' + (-this.scrollTop) + 'px; width:' + width + 'px; }')
		// (zgtc) fix to overwrite p/div/ul width (would be clipped if wider than scroller in css):
		//d.write('#' + this.id + 'Container p, #' + this.id + 'Container div {width:' + parseInt(width-10) + 'px; }')
		d.write('</style>')
	}
}

ypSimpleScroll.prototype.load = function() {
	var d, lyrId1, lyrId2
	d = document
	lyrId1 = this.id + "Container"
	lyrId2 = this.id + "Content"
	this.container = this.y.dom ? d.getElementById(lyrId1) : this.y.ie ? d.all[lyrId1] : d.layers[lyrId1]
	this.content = obj2 = this.y.ns4 ? this.container.layers[lyrId2] : this.y.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	this.docH = Math.max(this.y.ns4 ? this.content.document.height : this.content.offsetHeight, this.clipH)
	this.docW = Math.max(this.y.ns4 ? this.content.document.width : this.content.offsetWidth, this.clipW)
	this.scrollH = this.docH - this.clipH
	this.scrollW = this.docW - this.clipW
	this.loaded = true
	this.scrollLeft = Math.max(Math.min(this.scrollLeft, this.scrollW),0)
	this.scrollTop = Math.max(Math.min(this.scrollTop, this.scrollH),0)
	this.jumpTo(this.scrollLeft, this.scrollTop)
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function changeOpac(opacity, id,w,h,Fcolor) {
	if (opacity == 100) opacity = 99.99;
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	object.backgroundColor=Fcolor;
	object.width=w+'px';
	object.height=1+'px';
}
function FadeTop(L,T,w,h,Fcolor){
	document.write("<div id='fadertop'>")
	document.getElementById('fadertop').style.top = T + "px";
	document.getElementById('fadertop').style.left = L + "px";
	for (i=20; i>1; i=i-1){
		iHTML="<div id='fadetop"+i+"'><!-- //--></div>"
		document.write(iHTML)
		changeOpac(5*i, 'fadetop'+i,w,h,Fcolor)
	}
	document.write("</div>")
}
function FadeBot(L,T,w,h,Fcolor){
	document.write("<div id='faderbot'>")
	document.getElementById('faderbot').style.top = h-19 + "px";
	document.getElementById('faderbot').style.left = L + "px";
	for (i=1; i<20; i++){
		iHTML="<div id='fadebot"+i+"'><!-- //--></div>"
		document.write(iHTML)
		changeOpac(5*i, 'fadebot'+i,w,h,Fcolor)
	}
	document.write("</div>")
}




/////////////////////////////////////////////////////////////
// Layer functions
/////////////////////////////////////////////////////////////

if (document.getElementById){
   var doc = 'document.', vis = '.style.visibility', pos = '.style.top';;
}
else if (document.all) {
   var doc = 'document.all.', vis = '.style.visibility', pos = '.style.top';;
}
else if (document.layers){
	var doc = 'document.document.', vis = '.visibility', pos = '.top';;
}
function showLayer(object) {
	if (document.getElementById){
		eval(doc + "getElementById('"+object+"')" + vis + ' = "visible"');

	}
	else if (document.layers || document.all){
		eval(doc + object + vis + ' = "visible"');
	}
}

function hideLayer(object) {
	if (document.getElementById){
		eval(doc + "getElementById('"+object+"')" + vis + ' = "hidden"');
	}
	else if (document.layers || document.all){
		eval(doc + object + vis + ' = "hidden"');
	}
}

function WriteToLayer(object,content){
	if (document.getElementById){
		document.getElementById(object).innerHTML = "&nbsp;" + content + "&nbsp;";
	}
	else if (document.all){
		document.all(object).innerHTML = "&nbsp;" + content + "&nbsp;";
	}
	else if (document.layers) {
		document.layers[object].document.open();
		document.layers[object].document.write("&nbsp;"+content+"&nbsp;");
		document.layers[object].document.close();
	}
}



// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}


