
var SI = new Object();
SI.onbeforeload	= function() { for (var module in this) { if (this[module].onbeforeload) { this[module].onbeforeload(); };};};
SI.onload		= function() { for (var module in this) { if (this[module].onload) { this[module].onload(); };};};
SI.onresize		= function() { for (var module in this) { if (this[module].onresize) { this[module].onresize(); };};};

SI.MORE = {
	onbeforeload	: function() {
		if (!document.getElementsByTagName) return;
		// Get navigation
		var navigation = document.getElementById('navigation').innerHTML;
		
		// Find all of our navigation containers
		var navs = new Array();
		var divs = document.getElementsByTagName("div");
		for (var i=0; i<divs.length; i++) {
			var e = divs[i];
			if (e.className=='navigation') {
				e.innerHTML = navigation;
				navs[navs.length] = e;
				};
			};
		
		// Opera doesn't get the scoll feature at the moment
		if (window.opera) { return; }
		
		for (var j=0; j<navs.length; j++) {
			var lnks = navs[j].getElementsByTagName("a");
			
			for (var k=0; k<lnks.length; k++) {
				var a = lnks[k];
				if (k==j) {
					a.className = 'active';
					a.onclick = function() { return false; }
					continue;
					}
				a.onclick = function () {
					SI.MORE.Scroll.to(this.href.replace(/^[^#]*#/,''));
					return false;
					}
				}
			}
		},
	Scroll	: {
		scrollLoop 		: false, 
		scrollInterval	: null,
		getWindowHeight	: function() {
			if (document.all) {  return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight; }
			else { return window.innerHeight; }
			},
		getScrollLeft	: function() {
			if (document.all) { return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft; }
			else { return window.pageXOffset; }
			},
		getScrollTop	: function() {
			if (document.all) { return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; }
			else { return window.pageYOffset; }
			},
		getElementYpos	: function(el) {
			var y = 0;
			while(el.offsetParent){
				y += el.offsetTop
				el = el.offsetParent;
				}
			return y;
			},
		to : function(id){
			if(this.scrollLoop){
				clearInterval(this.scrollInterval);
				this.scrollLoop = false;
				this.scrollInterval = null;
				}
			var container = document.getElementById('container');
			var documentHeight = this.getElementYpos(container) + container.offsetHeight;
			var windowHeight = this.getWindowHeight();
			var ypos = this.getElementYpos(document.getElementById(id));
			if(ypos > documentHeight - windowHeight) ypos = documentHeight - windowHeight;
			this.scrollTo(0,ypos);
			},
		scrollTo : function(x,y) {
			if(this.scrollLoop) {
				var left = this.getScrollLeft();
				var top = this.getScrollTop();
				if(Math.abs(left-x) <= 1 && Math.abs(top-y) <= 1) {
					window.scrollTo(x,y);
					clearInterval(this.scrollInterval);
					this.scrollLoop = false;
					this.scrollInterval = null;
					}
				else {
					window.scrollTo(left+(x-left)/2, top+(y-top)/2);
					}
				}
			else {
				this.scrollInterval = setInterval("SI.MORE.Scroll.scrollTo("+x+","+y+")",100);
				this.scrollLoop = true;
				}
			}
		}
	}





