(function($){
    $.slider = function(el, options){
        var base = this;
        var Dimensions = new Array();
        base.$el = $(el);
        base.el = el;
        base.$el.data("slider", base);
        
        base.init = function(){
            base.options = $.extend({},$.slider.defaultOptions, options);
            base.options.width =  base.$el.width();
            var lastLi =  base.$el.find('li:last-child');
			
           
            base.$el.mousemove(function(e){
            	//+75 is to help with the offset
				var ulWidth = (lastLi[0].offsetLeft + 75) + lastLi.outerWidth() + base.options.padding;
				var left = ((e.pageX - base.$el.offset().left) * (ulWidth-base.options.width) / base.options.width) - 75;
				base.$el.scrollLeft(left);
			});
			
			$("li a img", base.el).each(function(){
				Dimensions.push({height : $(this).height(), width : $(this).width()});
			})
			
			$("li", base.el).each(function() {
										   
				if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
					
					$(this).bind('touchstart', function() {
						//+75 is to help with the offset
						var ulWidth = (lastLi[0].offsetLeft + 75) + lastLi.outerWidth() + base.options.padding;
						var left = ((e.pageX - base.$el.offset().left) * (ulWidth-base.options.width) / base.options.width) - 75;
						base.$el.scrollLeft(left);
				});
				}
					
				$(this).hover(
					function() {
						$("img",this).stop().animate({"height" : "+=45px", "width" : "+=45px"}, 250);
					},
					function() {
						$("img",this).stop().animate({"height" : Dimensions[$(this).index()].height, "width" : Dimensions[$(this).index()].width}, 250);

				});
			});

		
        };
        
        base.init();
    };
    
    $.slider.defaultOptions = {
    	padding : 0
    };
    
    $.fn.slider = function(options){
        return this.each(function(){
            (new $.slider(this, options));
        });
    };
    
    $.fn.getslider = function(){
        this.data("slider");
    };
    
})(jQuery)

function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}
