function opacityFader(obj, initial) {
	
	var callback = this;
	this.cur = initial;
	this.tar = initial;
	this.obj = obj;
	this.inter = null;
	this.speed = 10;
	
	this.doFade = function() {
			if (this.cur > this.tar) { /* Fade out */
				rm =  (this.cur-this.speed >= this.tar)?(this.speed):(this.cur - this.tar);
				this.cur -= rm;
			}
			if (this.cur < this.tar) { /* Fade in */
				rm =  (this.cur+this.speed <= this.tar)?(this.speed):(this.tar - this.cur);
				this.cur += rm;
			}
			
			this.updateObj(); /* Set Opacity */
			
			if (this.cur == this.tar) { clearInterval(this.inter); } /* All Done */
			
	}
	
	this.fadeTo = function(n,s) {
		if (s) { this.speed = s; }
		this.tar = n;
		if (this.inter) { clearInterval(this.inter); } /* No Multiple Intervals */
		this.inter = setInterval(function () { callback.doFade() }, 50);
	}
	
	this.updateObj = function() {
		this.obj.style.opacity = this.cur / 100;
		if (this.obj.filters) { this.obj.filters.alpha.opacity = this.cur; } /* Because IE has to be "Special" */
		if (this.cur == 0) { this.obj.style.visibility = "hidden"; }
		if (this.cur > 0) { this.obj.style.visibility = "visible"; } 
	}
	
	this.obj.style.filter = "alpha(opacity=" + this.cur + ")";  /* Again, IE needs the "special needs" treatment */
	this.updateObj();
	
}
function animFrame() {
	
	switch (curframe++) {
		
		case 0:
			topSouth.fadeTo(100,15);
			topCentral.fadeTo(0,15);
			topNorth.fadeTo(0,15);
			break;
			
		case 1:
			topSouth.fadeTo(0,15);
			topCentral.fadeTo(100,15);
			topNorth.fadeTo(0,15);
			break;
			
		case 2:
			topSouth.fadeTo(0,15);
			topCentral.fadeTo(0,15);
			topNorth.fadeTo(100,15);
			curframe = 0;
			break;
			
	}
	
}

function clickLoc(i) {
	
	clearInterval(animation);
	curframe = i;
	animFrame();
	
}

topSouth = new opacityFader(document.getElementById("topsouth"), 100);
topCentral = new opacityFader(document.getElementById("topcentral"), 0);
topNorth = new opacityFader(document.getElementById("topnorth"), 0);

curframe = 1;
animation = setInterval(function () { animFrame() }, 5000);
