	
	var clickPos = 0;

	scrollbox = function(targetId, duration, scrollevent) {
		this.init( targetId, duration, scrollevent );
	}

	scrollbox.prototype = {

		init: function( targetId, duration, scrollevent ) {

			this.targetId = targetId;

			this.duration = duration / 1000;

			if ( scrollevent == null ) {
				scrollevent = 'mousedown';
			}

			this.scrollevent = scrollevent;

			this.runningLeft = false;
			this.runningRight = false;

			this.createAnim();

			if ( clickPos > 0 ) {
				this.anim.attributes = {
					scroll: { to: [clickPos, 0] }
				};
				this.anim.animate();
			}
			
		},

		createAnim: function() {

			this.el = document.getElementById( this.targetId );
			this.elWidth = this.el.scrollWidth;

			this.anim = new YAHOO.util.Scroll( this.targetId, {}, this.duration );
			this.anim.onComplete.subscribe( ( function( scrollbox ) {
				return function() {
					if ( scrollbox.runningLeft ) {
						scrollbox.anim.attributes = {
							scroll: { to: [parseInt( scrollbox.el.scrollLeft ) - 10, 0] }
						};
						scrollbox.runningLeft = true;
						scrollbox.anim.animate();
					} else if ( scrollbox.runningRight ) {
						scrollbox.anim.attributes = {
							scroll: { to: [parseInt( scrollbox.el.scrollLeft ) + 10, 0] }
						};
						scrollbox.runningRight = true;
						scrollbox.anim.animate();
					}

				}
			} ) (this) );


			this.bindEvents();

		},

		bindEvents: function() {

			//shorthand
			var rightEl = document.getElementById( this.targetId + '_right');
			var leftEl = document.getElementById( this.targetId + '_left');

			switch( this.scrollevent ) {

				case 'mousedown':

					rightEl.onmousedown = ( function( scrollbox ) {
						return function() {
							scrollbox.anim.attributes = {
								scroll: { to: [parseInt( scrollbox.el.scrollLeft ) + 10, 0] }
							};
							scrollbox.runningRight = true;
							scrollbox.anim.animate();
						}
					} ) (this);

					rightEl.onmouseup = ( function( scrollbox ) {
						return function() {
							scrollbox.runningRight = false;
							clickPos = scrollbox.el.scrollLeft;
						}
					} ) (this);

					leftEl.onmousedown = ( function( scrollbox ) {
						return function() {
							scrollbox.anim.attributes = {
								scroll: { to: [parseInt( scrollbox.el.scrollLeft ) - 10, 0] }
							};
							scrollbox.runningLeft = true;
							scrollbox.anim.animate();
						}
					} ) (this);

					leftEl.onmouseup = ( function( scrollbox ) {
						return function() {
							scrollbox.runningLeft = false;
							clickPos = scrollbox.el.scrollLeft;
						}
					} ) (this);

					break;

			}

		}

	}