/* ------------------------------------ */
// scroller class		
/* ------------------------------------ */

function scroller(frameWidth,numFrames,windowName) {
	
	// private:member items
	this.window = windowName;
	this.width = frameWidth;
	this.frames = numFrames;
	this.currentFrame = 1;
	this.onClass = "scrollerLinkOn";
	this.offClass = "scrollerLinkOff";
	
	// private:setNavClass
	this.setNavClass = function() {
		var id
		for(var i=1; i<=this.frames; i++)
		{
			itemId = "scrollerNav"+i;
			id = document.getElementById(itemId);
			if(i==this.currentFrame)
				id.className = this.onClass;
			else
				id.className = this.offClass;
		}
	}
	
	// private:getScrollPosition method
	this.getScrollPosition = function() {
		var xPos,isIE = document.all?true:false;
		if(isIE) {
			xPos = eval("window."+this.window+".document.body.scrollLeft")
		}
		else {
			xPos = eval("window."+this.window+".pageXOffset")
		}
		return xPos;
	}
	
	// public:goToFrame method
	this.goToFrame = function (frameNum) {
		var xPos = (frameNum - 1) * this.width;
		eval("window."+this.window+".scrollTo("+xPos+",0)");
		this.currentFrame = frameNum;
		this.setNavClass();
	}
	
	// public:goBack method
	this.goBack = function() {
		
		//get scroll position
		var xScroll = this.getScrollPosition();
		
		if(this.currentFrame>1) {
			var xPos = (this.width*this.currentFrame)-(this.width*2);
			eval("window."+this.window+".scrollTo("+xPos+",0)");
			this.currentFrame = parseInt(this.currentFrame,10)-1;
		} 
		else if(this.currentFrame ==1 && xScroll>0) {
			eval("window."+this.window+".scrollTo(0,0)");
		}
		this.setNavClass();
	}
	
	// public:goForward method
	this.goForward = function() {
	
		//get scroll position
		var xScroll = this.getScrollPosition();
		var maxScroll = (this.frames-1)*this.width;
		
		if(this.currentFrame<this.frames)
		{
			var xPos = (this.width*this.currentFrame);
			eval("window."+this.window+".scrollTo("+xPos+",0)");
			this.currentFrame = parseInt(this.currentFrame,10)+1;
		}
		else if (this.currentFrame==this.frames && xScroll < maxScroll) {
			eval("window."+this.window+".scrollTo("+maxScroll+",0)");
			this.currentFrame = this.frames;
		}
		this.setNavClass();
	}
	
	this.init = function(scroll,page) {
	
		eval("window."+this.window+".scrollTo("+scroll+",0)");
		this.currentFrame = page;
		this.setNavClass();
	}
	
}



