$(document).ready(function(){
		
	$("#home_slider").kwerk_slider();

});

jQuery.extend( jQuery.easing,{
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	}
});

jQuery.fn.kwerk_slider = function() {
	return this.each( function() {

		var $el 	 = $(this),
			el_width = $(window).width();
		
		$el
			.css({'width': el_width, 'margin-right': -(el_width-960)/2 })
		.find("li")
			.css({'width': el_width})
		.find("img")
			.css({'margin-right': (el_width-960)/2 });

   		//Get size of images, how many there are, then determin the size of the image reel.
		var imageSum 		= $("img", $el).size(),
			imageReelWidth 	= el_width * imageSum,
			$imageReel 		= $("ul", $el),
			active 			= 1;
		
		//Adjust the image reel to its new size
		$imageReel.css({'width' : imageReelWidth, 'height': '298px'});

		setInterval(function() {
			var position = active * el_width;

			if (active > imageSum-1) {
				active = 0; 
				var position = active * el_width;
			};

			$imageReel.fadeOut().animate({ 
				left: -position
			}, 100, "easeOutCubic").fadeIn();

			active++;
		}, 5000);
		
   });
};


function MM_openBrWindow(theURL,winName,features) { //v2.0
  newWindow = window.open(theURL,winName,features);
  newWindow.focus();
}

function popWin(theURL) {
 MM_openBrWindow(theURL,'popWindow','status=yes,scrollbars=yes,width=520,height=575');
 }

