(function($) {
         $.fn.hw_img_scrollbox = function() { 
		var width_inner = 0;
		var width_outer = 0;
		var offset = $(this).offset();				
         	 get_width();                	 
         	 $('#hw_img_scrollbox_inner').css('width',width_inner+5);//+5 is little trick for ie 6 so the last img is visible
         	 $('a.hw_img_scrollbox_left').css({'left':offset.left,'top':offset.top});
         	 $('a.hw_img_scrollbox_right').css({'left':offset.left + width_outer - 50, 'top' : offset.top });
         	 $('a.hw_img_scrollbox_right').click(function(){
         	 		 $( "#hw_img_scrollbox_inner" ).animate({'margin-left':'-=100'}, { duration: 500, step: function( now, fx ){
         	 		 	 	 if(width_outer - now > width_inner){
         	 		 	 	 	 $(this).stop();
         	 		 	 	 }
         	 		 	 }
         	 		 }); 
         	 });
         	 $('a.hw_img_scrollbox_left').click(function(){
         	 		 $( "#hw_img_scrollbox_inner" ).animate({'margin-left':'+=100'}, { duration: 500, step: function( now, fx ){
         	 		 	 	 if(now > 0){
         	 		 	 	 	 $(this).stop();
         	 		 	 	 }
         	 		 	 }
         	 		 }); 
         	 });
         	 function get_width(){
         	 	 width_outer = $('#hw_img_scrollbox_outer').css('width');
         	 	 width_outer = parseInt(width_outer.substr(0,width_outer.length-2));
         	 	 $('#hw_img_scrollbox_inner > a').each(function(){
         	 	 	help = $(this).css('width');
         	 	 	width_inner += parseInt(help.substr(0,help.length-2));
         	 	 });         	 	 
         	 }
         };
})(jQuery);
