function Scroller(target, speed, width, btnP, btnN, step) {	this.index = 0;	this.disabled = false;	this.el = document.getElementById(target);	this.btnPrevious = document.getElementById(btnP);	this.btnNext = document.getElementById(btnN);	if (!this.el || !this.btnPrevious || !this.btnNext) {		this.disabled = true;		return;	}	  var o = this;	if (this.btnPrevious) this.btnPrevious.onclick = function() { o.previousItem(); this.blur(); return false; }	if (this.btnNext) this.btnNext.onclick = function() { o.nextItem(); this.blur(); return false; }	this.itemWidth = width;	this.continuous = true;	this.items = this.getItems();	this.itemCount = this.items.length;	this.step = (step == null) ? 1 : step;}Scroller.prototype.getItems = function() {	var items = new Array();	var o = this;	var childNodes = child_nodes(this.el);	for (var i=0; i<childNodes.length; i++) {		var child = childNodes[i];		if(child.nodeName == 'A' && child.hasChildNodes()) {			child.onmouseclick = function() { this.blur(); }			child.onmouseover = function() {				var img = this.getElementsByTagName('div');				img.style.marginLeft = "-610px";			}			child.onmouseout = function() {				var img = this.getElementsByTagName('div');				img.style.marginLeft = "0px";			}		}		items.push(child);	}	return items;}Scroller.prototype.setItem = function(i) {	if (this.disabled) {		return;	}	if (this.itemCount <= this.step) {		this.moveItem(0);		this.disableButton(this.btnPrevious);		this.disableButton(this.btnNext);		return;	}	this.index = (this.continuous) ? i+1 : i;	if (!this.continuous && this.index == 0) this.disableButton(this.btnPrevious);	this.moveItem(this.index);}Scroller.prototype.setRandomItem = function() {	this.index = Math.round(Math.random()*(this.itemCount-1));	this.moveItem(this.index);}Scroller.prototype.nextItem = function() {  var newIndex = this.index + this.step;  if (!this.continuous)    {    // there are only 2 items the step is more than the number of items    if ( (this.itemCount < 2) || (newIndex >= this.items.length) )      return;    // enable if we are past the first step    if (newIndex >= this.step)      this.enableButton(this.btnPrevious);    if (newIndex >= (this.items.length-this.step))      this.disableButton(this.btnNext);    }  this.index += this.step;  if (this.index == this.items.length)      {      this.moveItem(0);      this.index = 1;      }  this.displayItem();}Scroller.prototype.previousItem = function() {  var newIndex = this.index - this.step;  if (!this.continuous)    {    if (this.itemCount < 2 || newIndex < 0)      return;    if (newIndex == 0)      this.disableButton(this.btnPrevious);    if (newIndex < (this.items.length - this.step))      this.enableButton(this.btnNext);    }	this.index -= this.step;	if (this.index == -1) {		this.moveItem(this.itemCount-1);		this.index = this.itemCount-2;  	}	this.displayItem();}Scroller.prototype.moveItem = function(i) {	this.el.style.left = -(this.itemWidth*i) + 'px';}Scroller.prototype.displayItem = function() {	this.tweenItem(-this.itemWidth*(this.index));}Scroller.prototype.tweenItem = function(end) {	var elScroll = new fx.ElementScroll(this.el, {duration: 400, transition: fx.cubic});	elScroll.tween(end);}
