
if(!$chk(slvr))
{
	var slvr = {};
}

/**
 * slvr.ScrollView
 *
 * @classDescription slvr.ScrollView provides horizontal scroll functionality 
 */
slvr.ScrollView = new Class({

	/**
	 * Options
	 * 
	 * @type {Object}
	 */
	options: {
		nextButtonImage: '/silverstore/images/listpage/next_product.png',
		previousButtonImage: '/silverstore/images/listpage/previous_product.png',
		nextButtonArrowImage: '/silverstore/images/listpage/next_arrow.png',
		previousButtonImage: '/silverstore/images/listpage/previous_product.png',
		previousButtonArrowImage: '/silverstore/images/listpage/previous_arrow.png',
		maxScrollSpeed: 25
	},
	
	/**
	 * @type {Element}
	 */
	scrollTarget: null,
	
	/**
	 * @type {Element}
	 */
	scrollContainer: null,
	
	/**
	 * @type {Element}
	 */
	scrollBarTarget: null,
	
	/**
	 * @type {slvr.scrollBar}
	 */
	scrollBar: null,
	
	/**
	 * @type {Number}
	 */
	contentWidth: 0,
	
	/**
	 * @type {Number}
	 */
	scrollTargetX: 0,
	
	/**
	 * @type {Number}
	 */
	scrollTargetXAnimator: null,
	
	/**
	 * @type {Boolean}
	 */
	isAnimationScroll: false,
	
	/**
	 * @type {Element} Image
	 */
	nextProductImage: null,
	
	/**
	 * @type {Element} Image
	 */
	previousProductImage: null,	
	
	dimenstionController: null, 
	
	/**
	 * slvr.ScrollView Constructor
	 * 
	 * @param {Object} target
	 * @param {Object} options
	 */
	initialize: function(viewTarget, scrollBarTarget, options) {
		
		this.setOptions(options);		
		this.scrollTarget = $(viewTarget);
		this.scrollContainer = this.scrollTarget.getParent();
		this.scrollBarTarget = $(scrollBarTarget);

		this.setup();
	},
	
	/**
	 * @private
	 */
	setup: function() {
		
	
		
		this.scrollContainer.setStyles({
										'overflow':'hidden',
										'height': '100%'
										});
										
		// if(Browser.Engine.trident) {
		// 	this.scrollContainer.setStyles({
		// 										'width': (window.getSize().x - (2 * 25))
		// 									});
		// }
		
		// get full width of the content
		var items = this.scrollTarget.getChildren();
		var fullWidth = 0;
		for(var i=0;i<items.length;i++) {
			fullWidth += (items[i].getSize().x + items[i].getStyle('margin-right').toInt() + items[i].getStyle('margin-left').toInt());
		}
		this.contentWidth = fullWidth;

		this.scrollTarget.setStyles({'display':'block', 'width':this.contentWidth});
		
		if($chk(this.scrollBarTarget)) {			
			this.scrollBar = new slvr.ScrollBar(this.scrollBarTarget, {onDrag: this.onDragHandler.bindWithEvent(this)});
			this.scrollBar.setDraggerWidth(this.scrollBarWidth());
		}
		
		// Pageing controllers
		this.nextProductImage = new Asset.image(this.options.nextButtonImage, {
																		id: 'NextProductButtonImage', 
																		title: 'Next Product', 
																		onload: this.nextProductImageLoadedHandler.bindWithEvent(this)
																		});
		this.previousProductImage = new Asset.image(this.options.previousButtonImage, {
																		id: 'PrevProductButtonImage', 
																		title: 'Previous Product', 
																		onload: this.previousProductImageLoadedHandler.bindWithEvent(this)
																		});
				
		this.dimenstionController = new slvr.PageDimensionController(this.scrollContainer);
																		
		slvr.SharedNotificationCenter().addObserver(this, 'PageDimensionDidResize', this.windowResizeHandler.bindWithEvent(this));
		// Listen for window resize events
		window.addEvent('resize', this.windowResizeHandler.bindWithEvent(this));
		
		this.scrollTarget.setStyle('visibility', 'visible');
		this.scrollContainer.setStyle('background-image', 'none');

		
	},
	
	/**
	 * @return {Number}
	 */
	itemWidth: function() {
		var item = this.scrollTarget.getFirst();
		return (item.getSize().x + item.getStyle('margin-right').toInt() + item.getStyle('margin-left').toInt());
	},
	
	/**
	 * @return {Number}
	 */
	scrollBarWidth: function() {
		var scrollBarWidth = (this.scrollContainer.getSize().x / this.fullContentWidth()) * this.scrollContainer.getSize().x;
		return scrollBarWidth;
	},
	
	/**
	 * @return {Number}
	 */
	fullContentWidth: function() {
		return this.contentWidth;
	},
	
	/**
	 * @return {Number}
	 */
	scrollRange: function() {
		return this.scrollTarget.getSize().x - this.scrollContainer.getSize().x;
	},
	
	/**
	 * @return {Number}
	 */
	numberOfDisplayGroups: function() {
		return Math.ceil(this.scrollTarget.getSize().x / this.scrollContainer.getSize().x);
	},
	
	/**
	 * @return {Number}
	 */
	currentDisplayGroupZero: function() {
		
		var currentScroll = this.scrollContainer.getScroll().x;
		var currentGroup = Math.ceil(currentScroll / this.scrollContainer.getSize().x);
		
		return currentGroup;
	},
	
	scrollToNextProduct: function() {		
		
		var fullPostion = this.scrollContainer.getScroll().x + this.scrollContainer.getSize().x;
		var newTarget = Math.min(this.scrollRange(), fullPostion);
		
		this.scrollToPosition(newTarget, true);
	},
	
	
	scrollToPreviousProduct: function() {		

		var fullPostion = this.scrollContainer.getScroll().x - this.scrollContainer.getSize().x;
		var newTarget = Math.max(0, fullPostion);
		
		this.scrollToPosition(newTarget, true);
	},	
	
	/**
	 * @param {Number} targetPercentage
	 */
	scrollToPercentage: function(targetPercentage, syncBar) {
		var newTarget = (this.scrollRange() * (($chk(targetPercentage) && $type(targetPercentage) == 'number') ? targetPercentage : 0));	
		this.scrollToPosition(newTarget, syncBar);
	},
	
	scrollToPosition: function(target, syncBar) {
		syncBar = $chk(syncBar) ? syncBar : false;
		this.scrollTargetX = target;
		$clear(this.scrollTargetXAnimator);
		this.scrollTargetXAnimator = this.scrollFx.periodical(5, this, [syncBar]);
		this.isAnimationScroll = true;	
	},

	scrollTo: function(target, syncBar) {
		syncBar = $chk(syncBar) ? syncBar : false;
		$clear(this.scrollTargetXAnimator);
		//this.scrollTargetX = target;
		this.scrollContainer.scrollTo((target*this.scrollRange()), 0);

		// Set buttons
		if(target <= 0 || !$chk(target) || !$defined(target) || $type(target) != 'number') {
			this.hidePreviousButton();
		} else {
			this.showPreviousButton();
		}
		if(target == 1) {
			this.hideNextButton();
		} else {
			this.showNextButton();
		}		
	},
	
	scrollFx: function(syncBack) {
	
		var calcutatedDistance = ((this.scrollTargetX - this.scrollContainer.getScroll().x) * 0.1);
		var moveDistance;
		
		if(Math.min(this.options.maxScrollSpeed, Math.abs(calcutatedDistance)) == Math.abs(calcutatedDistance)) {
			moveDistance = calcutatedDistance;
		} else {
			moveDistance = this.options.maxScrollSpeed * (calcutatedDistance < 0 ? -1 : 1); // Correct directon of max speed
			// // TODO: Change back to scrolling
			// 			moveDistance = (this.scrollTargetX - this.scrollContainer.getScroll().x);// - this.maxScrollSpeed;
		}
		
		var newScroll = Math.round((this.scrollContainer.getScroll().x + moveDistance)/10)*10;
		
		this.scrollContainer.scrollTo(newScroll, 0);
		
		// Set buttons
		if(this.scrollTargetX == 0) {
			this.hidePreviousButton();
		} else {
			this.showPreviousButton();
		}
		if(this.scrollTargetX == this.scrollRange()) {
			this.hideNextButton();
		} else {
			this.showNextButton();
		}

		if(Math.abs(Math.abs(this.scrollTargetX) - Math.abs(this.scrollContainer.getScroll().x)) < 9) {
			this.scrollContainer.scrollTo(this.scrollTargetX, 0);
			this.isAnimationScroll = false;
			$clear(this.scrollTargetXAnimator);
		}
		
		if(syncBack) {
			this.scrollBar.setScrollPercetage((newScroll/(this.scrollContainer.getScrollSize().x-this.scrollContainer.getSize().x)));
		}
	},
	
	/**
	 * Triggered by window.onresize
	 * @param {Event} e
	 */
	windowResizeHandler: function(e) {

		// if(Browser.Engine.trident) {
		// 	this.scrollContainer.setStyles({
		// 										'width': (window.getSize().x - (2 * 25))
		// 									});
		// }


		this.scrollBar.setDraggerWidth(this.scrollBarWidth());
		if($chk(this.nextProductButton)) {
			var newRight = ((window.getSize().x - this.scrollContainer.getSize().x) / 2) + this.scrollContainer.getSize().x - this.nextProductButton.getSize().x;
			this.nextProductButton.setStyles({
												// 'left': (this.scrollContainer.getSize().x - this.nextProductButton.getSize().x + this.scrollContainer.getStyle('margin-left').toInt()),
												// 'left': this.scrollContainer.getPosition($(document.body)).toInt(),
												'left': newRight,
												'opacity': (this.scrollRange() > 0 ? 1 : 0 ),
												'height': this.scrollContainer.getSize().y
											});
		}

		if($chk(this.previousProductButton)) {
			var newLeft = ((window.getSize().x - this.scrollContainer.getSize().x) / 2) -2;
			this.previousProductButton.setStyles({
												'height': this.scrollContainer.getSize().y,
												'left': newLeft
											});
		}
		
		if(this.scrollRange() > 0) {
			this.scrollBar.showScrollBar();
		} else {
			this.scrollBar.hideScrollBar();
		}
		
		var products = this.scrollTarget.getChildren();
		var height = this.scrollContainer.getSize().y;
		
		for(var i=0;i<products.length;i++) {
			products[i].getElement('.productImage').setStyle('top', (height/2) - (products[i].getFirst().getSize().y/2));
		}
		
		if(Browser.Engine.trident && $chk(this.nextArrawButton) && $chk(this.previousArrawButton)) {
			this.nextArrawButton.setStyle('margin-top', (this.nextProductButton.getStyle('height').toInt()/2)-(this.nextArrawButton.getStyle('height').toInt()/2));
			this.previousArrawButton.setStyle('margin-top', (this.previousProductButton.getStyle('height').toInt()/2)-(this.previousArrawButton.getStyle('height').toInt()/2));
		}
		this.scrollBar.resizeHandler();
		
	},
	
	onDragHandler: function(percentage, syncBack) {
		//this.scrollToPercentage(percentage, syncBack);
		this.scrollTo(percentage, syncBack);
		
	},
	
	/**
	 * @type {Element}
	 */
	nextProductButton: null,
	
	nextArrawButton: null,
	
	nextProductImageLoadedHandler: function() {
		
		var nextProductButtonLeft = ((window.getSize().x - this.scrollContainer.getSize().x) / 2) + this.scrollContainer.getSize().x - this.nextProductImage.getAttribute('width').toInt();
		
		this.nextProductButton = new Element('div');		
		this.nextProductButton.setStyles({
											'display': 'block',
											'height': this.scrollContainer.getSize().y,
											'width': this.nextProductImage.getAttribute('width').toInt(),
											'z-index': 999,
											'cursor': 'pointer',
											'position': 'absolute',
											'top': this.scrollContainer.getPosition().y,
											// 'left': (this.scrollContainer.getSize().x - this.nextProductImage.getAttribute('width').toInt() + this.scrollContainer.getStyle('margin-left').toInt()),
											'left': nextProductButtonLeft,
											'opacity': (this.scrollRange() > 0 ? 1 : 0 ),
											'backgroundImage': 'url(/silverstore/images/listpage/background.gif)',
											'background-repeat': 'repeat'
										});

		this.nextProductButton.addEvent('click', this.nextButtonClickedHandler.bindWithEvent(this));
		
		
		var nextButtonInner = new Element('div');
		nextButtonInner.setStyles({
									'display': 'block',
									'width': '100%',
									'height': '100%',
									'background-repeat': 'repeat-y'
									});
		
		if(Browser.Engine.trident) {
			nextButtonInner.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.options.nextButtonImage+"', sizingMethod='scale')");
		} else {
			nextButtonInner.setStyle('background-image', 'url('+this.options.nextButtonImage+')');
		}
		
		this.nextArrawButton = new Element('div');
		
		if(Browser.Engine.trident) {
			this.nextArrawButton.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.options.nextButtonArrowImage+"', sizingMethod='crop')");
			this.nextArrawButton.setStyles({
											'height': '24px',
											'width': '31px',
											'marginLeft': 35
											});
		} else {
			this.nextArrawButton.setStyle('background-image', 'url('+this.options.nextButtonArrowImage+')');
			this.nextArrawButton.setStyles({
											'height': '100%',
											'width': '100%'
											})			
		}
		
		this.nextArrawButton.setStyles({
										'display': 'block',
										'backgroundPosition': 'right center',
										'backgroundRepeat': 'no-repeat'
										});
	
		this.nextArrawButton.injectInside(nextButtonInner);
		nextButtonInner.injectInside(this.nextProductButton);
		this.nextProductButton.injectInside(window.document.body);
		
		if(Browser.Engine.trident) {
			this.nextArrawButton.setStyle('margin-top', (this.nextProductButton.getStyle('height').toInt()/2)-(this.nextArrawButton.getStyle('height').toInt()/2));
		}
	},
	
	nextButtonClickedHandler: function(e) {
		var evt = new Event(e);
		evt.stop();
		
		this.scrollToNextProduct();	
		
	},
	
	
	/**
	 * @type {Element}
	 */
	previousProductButton: null,
	
	previousArrawButton: null,

	
	previousProductImageLoadedHandler: function() {

		var newLeft = ((window.getSize().x - this.scrollContainer.getSize().x) / 2) - 2;
		this.previousProductButton = new Element('div');
		this.previousProductButton.setStyles({
											'display': 'block',
											'height': this.scrollContainer.getSize().y,
											'width': this.nextProductImage.getAttribute('width').toInt(),
											'z-index': 999,
											'cursor': 'pointer',
											'position': 'absolute',
											'top': this.scrollContainer.getPosition().y,
											// 'left': (this.scrollContainer.getPosition().x),
											'left': newLeft,
											'opacity': 0,
											'backgroundImage': 'url(/silverstore/images/listpage/background.gif)',
											'background-repeat': 'repeat'
										});
										
		this.previousProductButton.addEvent('click', this.previousButtonClickedHandler.bindWithEvent(this));
		
		var previousButtonInner = new Element('div');
		previousButtonInner.setStyles({
										'display': 'block',
										'width': '100%',
										'height': '100%',
										'background-repeat': 'repeat-y'
										})
		
		if(Browser.Engine.trident) {
			previousButtonInner.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.options.previousButtonImage+"', sizingMethod='scale')");
		} else {
			previousButtonInner.setStyle('background-image', 'url('+this.options.previousButtonImage+')');
		}
		
		this.previousArrawButton = new Element('div');
		this.previousArrawButton.setStyles({
											'display': 'block',
											'backgroundPosition': 'left center',
											'backgroundRepeat': 'no-repeat'
											});
//							previousButtonArrowImage		
		
		if(Browser.Engine.trident) {
			this.previousArrawButton.setStyle('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.options.previousButtonArrowImage+"', sizingMethod='image')");
			this.previousArrawButton.setStyles({
											'height': '24px',
											'width': '31px'
											})
			
		} else {
			this.previousArrawButton.setStyle('background-image', 'url('+this.options.previousButtonArrowImage+')');
			this.previousArrawButton.setStyles({
												'height': '100%',
												'width': '100%'
												});
		}
		
		this.previousArrawButton.injectInside(previousButtonInner);
		previousButtonInner.injectInside(this.previousProductButton);
		this.previousProductButton.injectInside(window.document.body);
		
		if(Browser.Engine.trident) {
			this.previousArrawButton.setStyle('margin-top', (this.previousProductButton.getStyle('height').toInt()/2)-(this.previousArrawButton.getStyle('height').toInt()/2));
		}
	},
	
	previousButtonClickedHandler: function(e) {
		var evt = new Event(e);
		evt.stop();
		this.scrollToPreviousProduct();
	},
	
	previousButtonShowFx: null,
	previousButtonHideFx: null,	
	
	hidePreviousButton: function() {
		if($chk(this.previousButtonShowFx)) {
			this.previousButtonShowFx.cancel();
			this.previousButtonShowFx = null;
		}

		if(!$chk(this.previousButtonHideFx)) {
			this.previousButtonHideFx = new Fx.Tween(this.previousProductButton, {onCancel: this.prevDone.bind(this),  
																				  onComplete: this.prevDone.bind(this)});
			this.previousButtonHideFx.start('opacity', 0);			
		}
	},
	
	showPreviousButton: function() {
		
		if($chk(this.previousButtonHideFx)) {
			this.previousButtonHideFx.cancel();
			this.previousButtonHideFx = null;
		}
		// this.previousProductButton.setStyle('left', this.scrollContainer.getStyle('margin-left').toInt());
		var newLeft = ((window.getSize().x - this.scrollContainer.getSize().x) / 2) - 2;
		this.previousProductButton.setStyle('left', newLeft);
		if(!$chk(this.previousButtonShowFx)) {
			this.previousButtonShowFx = new Fx.Tween(this.previousProductButton, {onCancel: this.prevDone.bind(this),
																				  onComplete: this.prevDone.bind(this)});
			this.previousButtonShowFx.start('opacity', 1);			
		}

	},
	
	prevDone: function() {
		this.previousButtonShowFx = null;
	},
	
	nextButtonShowFx: null,
	nextButtonHideFx: null,	
	
	hideNextButton: function() {
		if($chk(this.nextButtonShowFx)) {
			this.nextButtonShowFx.cancel();
			this.nextButtonShowFx = null;
		}
		if(!$chk(this.nextButtonHideFx)) {
			this.nextButtonHideFx = new Fx.Morph(this.nextProductButton, {onCancel: this.nextDone.bind(this),  
																		  onComplete: this.nextDone.bind(this)});
			this.nextButtonHideFx.start({
										'opacity':0
										});			
		}
	},
	
	showNextButton: function() {	
		if($chk(this.nextButtonHideFx)) {
			this.nextButtonHideFx.cancel();
			this.nextButtonHideFx = null;
		}
		if(!$chk(this.nextButtonShowFx)) {
			this.nextButtonShowFx = new Fx.Morph(this.nextProductButton, {onCancel: this.nextDone.bind(this),  
																		  onComplete: this.nextDone.bind(this)});
			this.nextButtonShowFx.start({
										'opacity':1
										});		
		}	
	},
	
	nextDone: function() {
		this.nextButtonShowFx = null;
	}

});
slvr.ScrollView.implement(new Options);
slvr.ScrollView.implement(new Events);


/**
 * slvr.ScrollBar
 *
 * @classDescription slvr.ScrollBar provides functionality for a scrollBar
 */
slvr.ScrollBar = new Class({

	/**
	 * Options
	 * 
	 * @type {Object}
	 */
	options: {
		onDrag: Class.empty
	},
	
	/**
	 * @type {Element}
	 */
	scrollBarTarget: null,
	
	/**
	 * @type {Element}
	 */
	scrollDraggerTarget: null,
	
	/**
	 * @type {Drag}
	 */
	dragAction: null,
	
	/**
	 * slvr.ScrollBar Constructor
	 * 
	 * @param {Object} scrollBar
	 * @param {Object} options
	 */
	initialize: function(scrollBarTarget, options) {
		this.setOptions(options);
		this.scrollBarTarget = $(scrollBarTarget);
		//window.addEvent('resize', this.resizeHandler.bindWithEvent(this));
		this.setup();
	},
	
	/**
	 * @private
	 */
	setup: function() {
		// Setup scroll dragger
		this.scrollDraggerTarget = this.scrollBarTarget.getFirst();
		this.dragAction = new Drag.Move(this.scrollDraggerTarget, {
																	container: this.scrollBarTarget,
																	onStart: this.onDragStartHandler.bindWithEvent(this),
																	onDrag: this.onDragHandler.bindWithEvent(this),
																	onComplete: this.onDragCompleteHandler.bindWithEvent(this)
																	});
																	
		this.scrollDraggerTarget.setStyle('left', this.scrollBarTarget.getPosition().x);
		this.scrollDraggerTarget.setStyle('height', 4);
	},
	
	/**
	 * @param {Number} newWidth
	 */
	setDraggerWidth: function(newWidth) {
		this.scrollDraggerTarget.setStyle('width', Math.min(this.scrollBarTarget.getSize().x, newWidth));
	},
	
	dragging: false,
	
	setScrollPercetage: function(targetPercentage) {
		if(!this.dragging) {
			
			var nextPos = (this.absoluteMaxScrollX() * targetPercentage) + this.scrollBarTarget.getPosition().x;
			this.scrollDraggerTarget.setStyle('left', nextPos);
			
		}
	},
	
	/**
	 * @return {Number}
	 */
	absoluteScrollX: function() {
		return (this.scrollDraggerTarget.getPosition().x - this.scrollBarTarget.getPosition().x);
	},
	
	/**
	 * @return {Number}
	 */
	absoluteMaxScrollX: function() {
		return (this.scrollBarTarget.getSize().x - this.scrollDraggerTarget.getSize().x);
	},
	
	/**
	 * @return {Number}
	 */
	scrollPercentage: function() {
		return (this.absoluteScrollX() > 0 && this.absoluteMaxScrollX() > 0) ? (this.absoluteScrollX() / this.absoluteMaxScrollX()) : 0;
	},
	
	/**
	 * @param {Element} dragger
	 */
	onDragHandler: function(dragger) {
		this.fireEvent('onDrag', [this.scrollPercentage(), true]);
		this.dragging = true;
	},
	
	/**
	 * @param {Element} dragger
	 */
	onDragStartHandler: function(dragger) {
		this.fireEvent('onDrag', [this.scrollPercentage(), true]);
	},
	
	/**
	 * @param {Element} dragger
	 */
	onDragCompleteHandler: function(dragger) {
		this.fireEvent('onDrag', [this.scrollPercentage(), false]);
		this.dragging = false;
	},
	
	scrollBarFx: null,
	scrollDraggerBarFx: null,
	
	hideScrollBar: function() {
		if($chk(this.scrollBarFx)) {
			this.scrollBarFx.cancel();
			this.scrollBarFx = null;
		}
		if($chk(this.scrollDraggerBarFx)) {
			this.scrollDraggerBarFx.cancel();
			this.scrollDraggerBarFx = null;
		}
		
		this.scrollBarFx = new Fx.Tween(this.scrollBarTarget, {onCancel: this.scrollFxDone.bind(this),
															   onComplete: this.scrollFxDone.bind(this)});
		this.scrollBarFx.start('opacity', 0);			
		this.scrollBarFx = new Fx.Tween(this.scrollDraggerTarget, {onCancel: this.scrollFxDone.bind(this),
																   onComplete: this.scrollFxDone.bind(this)});
		this.scrollBarFx.start('opacity', 0);			

	},

	showScrollBar: function() {	
		if($chk(this.scrollBarFx)) {
			this.scrollBarFx.cancel();
			this.scrollBarFx = null;
		}
		if($chk(this.scrollDraggerBarFx)) {
			this.scrollDraggerBarFx.cancel();
			this.scrollDraggerBarFx = null;
		}
		
		this.scrollBarFx = new Fx.Tween(this.scrollBarTarget, {onCancel: this.scrollFxDone.bind(this),
															   onComplete: this.scrollFxDone.bind(this)});
		this.scrollBarFx.start('opacity', 1);			
		this.scrollBarFx = new Fx.Tween(this.scrollDraggerTarget, {onCancel: this.scrollFxDone.bind(this),
																   onComplete: this.scrollFxDone.bind(this)});
		this.scrollBarFx.start('opacity', 1);
	},
	
	scrollFxDone: function() {
		this.scrollBarFx = null;
		this.scrollDraggerBarFx = null;
	},
	
	resizeHandler: function() {
		this.scrollDraggerTarget.setStyle('top', this.scrollBarTarget.getPosition().y);
	}

});
slvr.ScrollBar.implement(new Options);
slvr.ScrollBar.implement(new Events);


/**
 * Will setup a scroll area and will add it to the window.slvr.scrollViews array.
 * Should be called on domReady for each scroll istance
 *
 * @param {Mixed} scrollView An Element or id string
 * @param {Mixed} scrollBar An Element or id string
 */
slvr.setUpScrollView = function(scrollView, scrollBar) {

	if(!$chk(scrollView)) {
		return;
	}
	
	if(!$chk(window.slvr.scrollViews)) {
		window.slvr.scrollViews = [];
	}
	
	var newScrollView = new slvr.ScrollView(scrollView, scrollBar);
	window.slvr.scrollViews.push(newScrollView);

}
