(function($) {
	//public functions
	var methods = {
		init : function(options) {
			var defaults = {
				originalHeight	: 17,
				originalWidth	: 75,
				maxHeight		: 25,
				maxWidth		: 125,
				period			: 150
			},
			opts = $.extend(defaults, options),  t;
			
			$.extend(this, opts);
			this.over = false;
			
			var t = this;
			t.closed = true;
			t.animating=false;
			
			t.$listItems = $(t).children("li");
			t.$listLinks = t.$listItems.children("a");
			t.mouseOutTimer = 0;
				
			$(document).mousemove(function(e){
				methods.updateSizes.apply(t, []);
			});
			$(this).mouseover(function(e){
				clearTimeout(t.mouseOutTimer);
				
				methods.updateSizes.apply(t, []);
			}).mouseout(function(e){
				t.mouseOutTimer = setTimeout(function(){
					methods.resetSizes.apply(t, []);
				}, 100);
			});
			
			t.$listLinks.click(function(){
				// var $parent = $(this).parent();
				// //remove current from other items
				// t.$listItems.not($parent).removeClass("current");
				// //toggle on this one
				// $parent.toggleClass("current");
				return false;
			}).mouseover(function(){
				t.over = true;
			}).mouseout(function(){
				t.over = false;
			});
			
			return this;
		}, 
		updateSizes : function(){
			if(this.over){
				var i, diffY, position, scale, newHeight, newWidth, newOpacity, $currItem;
				
				for(i=0; i<this.$listItems.length; i++){			
					$currItem = $(this.$listItems[i]);

					position = $currItem.offset();
					diffY = Math.abs(position.top-$(document).scrollTop()+$currItem.height()/2 - mouseY);
					
					if(diffY > this.period/2){
						$currItem.css({
							height: this.originalHeight,
							width: this.originalWidth
						}).children("div").hide();
						continue;
					}
					
					//calculate changes
					scale = Math.cos(Math.PI*diffY/this.period);
					newHeight = this.originalHeight + (this.maxHeight - this.originalHeight)*scale;
					newWidth = this.originalWidth + (this.maxWidth - this.originalWidth)*scale;			
					
					$currItem.css({
						height: newHeight,
						width: newWidth
					});
					
					if(scale > 0.96){
						$currItem.children("div").show();
					}else{
						$currItem.children("div").hide();
					}
				}
			}
		},
		resetSizes	: function(){
			var t = this;
			t.$listItems.not(".current").animate({
				height	: t.originalHeight,
				width	: t.originalWidth
			}, 250, function(){
				t.closed = true;
			}).children("div").hide();
		}
	};
	
	/*
		private vars
	*/
	var mouseX, mouseY;
	
	/*
		private functions
	*/
	//track mouse position
	$(document).mousemove(function(e){
		mouseX = e.clientX;
		mouseY = e.clientY;
	});
	
	$.fn.timeline = function(method) {
		//Method Calling Login
		if (methods[method]) {
			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
		} else if (typeof method === 'object' || !method) {
			return methods.init.apply(this, arguments);
		} else {
			$.error('Method ' + method + ' does not exist on jQuery.');
		}
	};
})(jQuery);
