(function( $ ){
	var width = 0;
	var child_width = 0;
	var children = 0;
	var max_width = 598;
	var rest_width = 0;
	
	var methods = {
		     init : function( options ) {
				width = parseInt(this.css('width'));
				children = this.children();
				child_width = Math.floor(width/children.length);
				children.each(function(index){
					$(this).css('left',child_width*index);
					$(this).mouseenter(methods.move);
				});
				rest_width = Math.floor((width - max_width)/(children.length-1)) - 1;
				this.mouseleave(methods.reset);
		     },
		     move : function(e)
		     {
		    	var target = $(e.currentTarget);
		    	var pos = 0;
		    	children.each(function(index){
		    		elem = $(this);
		    		elem.stop();
		    				    		
		    		if(elem.attr('class') == target.attr('class'))
		    		{
		    			
		    			elem.animate({left: pos,width: max_width},1000);
		    			pos += max_width;
		    			//elem.css('width',max_width);
		    		}
		    		else
		    		{
		    			
		    			elem.animate({left: pos,width: rest_width},1000);
		    			pos += rest_width;
		    			//elem.css('width',rest_width);
		    		}
		    		
		    		/*if(elem.attr('class') == target.attr('class'))
		    		{
		    			elem.animate({width: max_width},1000);
		    		}
		    		else
		    		{
		    			elem.animate({width: rest_width},1000);
		    		}
		    		*/
		    	});
		    	
		    	
		     },
		     reset : function()
		     {
		    	
		    	 var pos = 0;
		    	 children.each(function(index){
			    	elem = $(this);
			    	elem.stop();
			    	elem.animate({left: pos,width: child_width},1000);
			    	pos += child_width;
		    	 });
		     }
		  };
	
	$.fn.my = function(method) {
		
	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.my' );
	    }   
  };
})( jQuery );

