/*
 * 	Easy Slider 1.5 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {										
			speed: 			600,	
			pause:			2000
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w + 100);					
			$("li", obj).css('float','left');
			
			$("#teenused").click(function(){		
				animate(0,true);
				return true;
			});
			$("#firmast").click(function(){		
				animate(1,true);				
				return false;
			});	
			$("#portfolio").click(function(){		
				animate(2,true);
				return false;
			});		
			$("#about").click(function(){		
				animate(3,true);
				return false;
			});	
			$("#hinnaparing").click(function(){		
				animate(4,true);				
				return false;
			});	
			$("#kontakt").click(function(){		
				animate(5,true);
				return false;
			});	
  
			function animate(dir,clicked){
				var ot = t;				
		
				t = dir;
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;									
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						speed
					);								
				return false;
			};			
			
		});
	  
	};

})(jQuery);



