// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// 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 Constructor

Detect = function() {
	var agent = navigator.userAgent.toLowerCase(); 
	this._mac = agent.indexOf('mac') != -1;
	this._win = !this._mac;
	this._w3c = document.getElementById;
	this._iex = document.all;
	this._ns4 = document.layers;
}
Detect.prototype.getObj = function(name) {
	if(this._w3c){
		return document.getElementById(name);
	}else if(this._iex){
		return document.all[name];
	}else if(this._ns4){
		return this.getObjNS4(document,name);
	}
}
Detect.prototype.getObjNS4 = function(obj, name) {
	var d = obj.layers;
	var result,temp;
	for(var i=0; i<d.length; i++){
		if(d[i].id == name){
		 	result = d[i];
		}else if(d[i].layers.length){
			var temp = this.getObjNS4(d[i],name);
		}
		if(temp){
			result = temp;
		}
	}
	return result;
}
Detect.prototype.getStyle = function(obj) {
//	return (this._ns4) ? obj : obj.style;
return obj;
}
Detect.prototype.getScrollTop = function(){
  height = (document.all) ? document.body.clientHeight : window.innerHeight;
	return this._iex ? document.body.scrollTop + height - 60: window.pageYOffset + height - 60;
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// MenuDiv Constructor

MenuDiv = function(name){
	if(name){
		this._inherit = Detect; this._inherit(name);
		this._id  = name;
		this._el  = this.getObj(this._id);
		this._css = this.getStyle(this._el);
		this._by  = this.getTop();
		return this;
	}
}
MenuDiv.prototype = new Detect();

MenuDiv.prototype.getTop = function(){
	return parseInt(this._css.top || 0);
}
MenuDiv.prototype.scrollMenu = function(){
	var ty = this._by+this.getScrollTop();
	var my = this.getTop();
	
	this._css.visibility = 'hidden'; // fixes redraw problem for nested divs
	this._css.top = my+(ty-my)/4;
	this._css.visibility = 'visible'; // fixes redraw problem for nested divs
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

API = new Detect();

function createObjects(){
	API.menu = new MenuDiv('menu');
	menuInterval = setInterval('API.menu.scrollMenu()',50);
}

onload = createObjects;

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

