(function($) {
	$.fn.homeDock = function(options) {
		// extend and save the default options
		var opts = $.extend({}, $.fn.homeDock.defaults, options);

		var $ul = $(this);
		var $li = $ul.find("li");
		var left = 0;

		$li.each(function(index) {
			index += 1;
			var $li = $(this);
			var leftL = left - 71;
			var leftR = left + 71;
			$li.data("id", index);
			$li.data("left", left + "px");
			$li.data("leftL", leftL + "px");
			$li.data("leftR", leftR + "px");
			$li.css("left", left + "px");
			left = left + 35;
		})
		.addClass("withJs");
			
		$li.mouseover(function(){
			var id = $(this).data("id");
			$(this).parent("ul").parent(".homeDockWrapper").css("zIndex", 11);
			$li.each(function(){
				var difference = $(this).data("id") - id;
				if(difference < 0) {
					$(this).css("zIndex", 1).stop().animate({ width: "30px", height: "30px", top: "0", left: $(this).data("leftL")}, opts.transition, opts.easing);
				}
				else if(difference > 0) {
					$(this).css("zIndex", 1).stop().animate({ width: "30px", height: "30px", top: "0", left: $(this).data("leftR")}, opts.transition, opts.easing);
				}
				else {
					$(this).css("zIndex", 11).stop().animate({ width: "172px", height: "172px", top: "-71px", left: $(this).data("leftL") }, opts.transition, opts.easing);
				}
			});
		});

		$ul.mouseleave(function(){
			$(this).parent(".homeDockWrapper").css("zIndex", 1);
			$li.each(function(){
				$(this).stop().animate({ width: "30px", height: "30px", top: "0", left: $(this).data("left") }, opts.transitionLeave, opts.easing).css("zIndex", 10);
			});
		});
		return this;

	}
	

	/**
	 * Default settings for the jQuery plugin
	 */	
	$.fn.homeDock.defaults = {
		transition: 300,
		transitionLeave: 500,
		easing: "quadEaseOut"
	}; 
}(jQuery));

