var ImageScroller = {
	curImage: 1,
	Images: [],
	Links: [],
	load: function() {
		this.mainImage = document.getElementById("IS_main");
		this.setTimer();		
	},
	goClick: function() {
		document.location = this.Links[this.curImage-1];	
	},
	
	nextImage: function() {		
		this.unsetImage(this.curImage);
		this.curImage++;
		if (this.curImage > this.Images.length) this.curImage = 1;
		this.setImage(this.curImage);		
	},
	prevImage: function() {
		this.unsetImage(this.curImage);
		this.curImage--;
		if (this.curImage < 1) this.curImage = this.Images.length;
		this.setImage(this.curImage);	
			
	},
	goImage: function(i) {
		this.unsetImage(this.curImage);
		this.curImage = i;
		this.setImage(i);
	},
	setImage: function(i) {
		document.getElementById("IS_im"+i).src = "images/feature_"+i+"bg.gif";		
		this.mainImage.src = this.Images[i-1];	
		this.redoTimeout();				
	},
	unsetImage: function(i) {
		document.getElementById("IS_im"+i).src = "images/feature_"+i+".gif";	
	},
	
	timerExpire: function() {
		this.nextImage();
		this.setTimer();
	},
	redoTimeout: function() {
		//window.clearTimeout(this.timeout);
		//this.setTimer();
	},
	setTimer: function() {
		
		this.timeout = 	window.setTimeout("ImageScroller.timerExpire()", 15000);	
	}
}

var ContentControl = {
	scrollTrigger: false,
	triggerId: "",
	
	triggerScroll: function(type, status) {
		this.scrollTrigger = status;
		
		if (this.scrollTrigger == false) {
			this.triggerId = "";
			return;	
		}	
		this.triggerId = type;
		this.runTrigger();
	},
	
	runTrigger: function() {
		if (this.triggerId == "down")
			this.scrollDown();
		else if (this.triggerId == "up")
			this.scrollUp();
		else
			return;				
		setTimeout("ContentControl.runTrigger();", 30);
	},
	
	scrollUp: function() {
		var cd = document.getElementById("contentarea");			
		if (cd.scrollHeight) {
			if (cd.scrollTop-20 < 0)
				cd.scrollTop = 0;
			else
				cd.scrollTop -= 20;
		}	
	},

	scrollDown: function() {
		var cd = document.getElementById("contentarea");	
			
		if (cd.scrollHeight) {
			if (cd.scrollTop+20 > cd.scrollHeight)
				cd.scrollTop = cd.scrollHeight;
			else
				cd.scrollTop += 20;
		}				
	}
}


var ChangeContentImage = function(newSrc) {
	var iob = document.getElementById('ContentImage');
	if (iob) {
		iob.src=newSrc;	
	}
}

