/*
 * simplyScroll 1.0.1 - a scroll-tastic jQuery plugin
 *
 * http://logicbox.net/jquery/simplyscroll
 * http://logicbox.net/blog/simplyscroll-jquery-plugin
 * http://plugins.jquery.com/project/simplyScroll
 *
 * Copyright (c) 2009 Will Kelly - http://logicbox.net
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Last revised: 18/02/2009 21:46
 *
 */

(function($) {

$.fn.simplyScroll = function(o) {
	return this.each(function() {
		new $.simplyScroll(this,o);
	});
};

var defaults = {
	className: 'simply-scroll'
};
	
$.simplyScroll = function(el,o) {
	
	var self = this;
	this.o = $.extend({}, defaults, o || {});
	
	//called on ul/ol/div etc
	this.$list = $(el);	
	//generate extra markup
	this.$list.addClass('simply-scroll-list')
		.wrap('<div class="simply-scroll-clip"></div>')
		.parent().wrap('<div class="' + this.o.className + ' simply-scroll-container"></div>');
	
	

		//wait for load before completing setup
		//webkit issue on sizing - how do I test for webkit?!
//		$(window).load(function() { self.init(); });
self.init();
		
};
	
$.simplyScroll.fn = $.simplyScroll.prototype = {};

$.simplyScroll.fn.extend = $.simplyScroll.extend = $.extend;

$.simplyScroll.fn.extend({
	init: function() {
		//shortcuts
		this.$items = this.$list.children();
		this.$clip = this.$list.parent();
		this.$container = this.$clip.parent();
		this.itemMax = 210; //this.$items.eq(0).width();
		this.clipMax = this.$clip.width();			
		this.posMin = 0;
		this.posMax = this.$items.length * this.itemMax;
		this.$list.css('width',this.posMax +'px');

	},
	goTo: function(x) {
	  this.$clip[0].scrollLeft= x;
	},
	getMax: function() {
	    return this.posMax - this.clipMax;
	}
});
		  
})(jQuery);

