(function($)
{
	
	
	$.fn.t4mview2 = function(options)
	{
		// Die Optionen die der Benutzer des Plugins angeben kann
		options = $.extend({			// Wie viel Prozent das Elemente rausfahren soll
			speed: 25,
			width:0
		
		}, options);	
		$(this).each(function()
		{
			var links 		=	$(this).find('.buttonlinks');
			var rechts 		=	$(this).find('.buttonrechts');
			var streifen	=	$(this).find('.streifen');
			var root		=	$(this);
			
			options.width	=	streifen.width();
			
			links.bind(
					{
						// Wenn die Maus rŸber geht
						mousedown: function(evt)
						{
							var width	=	parseInt(streifen.width())-root.width();
							AnimationRechts(root.width(),streifen, options.speed);
						},
						mouseup : function(evt)
						{
							streifen.stop();	
						},
						mouseout : function(evt)
						{
							streifen.stop();
						}
					}
			);
			rechts.bind(
					{
						mousedown:function()
						{	
							AnimationLeft(root.width(),streifen, options.speed);
						},
						mouseup:function()
						{
							streifen.stop();
						},
						mouseout : function(evt)
						{
							streifen.stop();
						}
					}
			);
		});
		function AnimationLeft(width,object,speed)
		{
			
			var end 		= 	(-options.width+width);
			var speedend 	= 	-end;
			speedend		+=	parseInt(object.css('left').slice(0,-2));
			speedend		=	speedend/speed*100;
			$(object).animate
			(
				{ 	
					left: end+'px'
				}, 
				speedend,
				function()
				{
					  //$(this).css('height',height+'px'); 		
				}
			);
		}
		function AnimationRechts(width,object, speed)
		{
			var end = 0;
			
			var speedend = -parseInt(object.css('left').slice(0,-2));
			
			speedend = speedend/speed*100;
			
			//alert(speedend);
			
			
			$(object).animate
			(
				{ 	
					left: end+'px'
				}, 
				speedend,
				function()
				{
					  //$(this).css('height',height+'px'); 		
				}
			);
		}		
	}
	
}
)(jQuery);
