// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
// If you do remove this, I will hunt you down :)
//
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

// **********************************************************************
// Detect Browser

agent = navigator.userAgent.toLowerCase(); 
mac = (agent.indexOf("mac")!=-1);
win = (!this.mac) ?true:false;
w3c = (document.getElementById) ?true:false;
iex = (document.all) ?true:false;
ns4 = (document.layers) ?true:false;

// **********************************************************************
// Global Utility Functions

function getObj(name){
	if(w3c){
		return document.getElementById(name);
	}else if(iex){
		return document.all[name];
	}
}
function getYpos(name){
	var obj = getObj(name);
	var curtop = 0;
	while(obj.offsetParent){
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	return curtop;
}

// **********************************************************************
// Scroll Window


_looper = false;
_scroll = null;

function scrollWin(x,y){
	if(_looper){
		var left = (iex) ? document.body.scrollLeft : window.pageXOffset;
		var top  = (iex) ? document.body.scrollTop : window.pageYOffset;
		if(Math.abs(left-x)<=1 && Math.abs(top-y)<=1){
			scrollTo(x,y);
			clearInterval(_scroll);
			_looper = false;
			_scroll = null;
		}else{
			scrollTo(left+(x-left)/2, top+(y-top)/2);
		}
	}else{
		_scroll = setInterval('scrollWin('+x+','+y+')',100);
		_looper = true;
	}
}
function navigate(n){
	if(!w3c){
		location.href = '#a'+n;
		return;
	}
	if(_looper){
		clearInterval(_scroll);
		_looper = false;
		_scroll = null;
	}
	for(var i=1; i<=5; i++){
		var d = getObj('d'+i);
		if(i==parseInt(n)){
			d.className = 'on';
		}else{
			d.className = 'off';
		}
	}
	// using the following line, IE/PC returns an incorrect number when getting the document height.
	// var dh = (iex) ? document.body.offsetHeight : window.document.height;
	// the following line is used to detemine the document height.
	var dh = getObj('container').offsetHeight; 
	var wh = (iex) ? document.body.clientHeight : window.innerHeight;
	var y = getYpos('d'+n);
	if(y>dh-wh){y = dh-wh;}
	scrollWin(0,y);
}

// **********************************************************************