(function($){ 	
	$.fn.jCubes = function (options){
		var defaults = {
			speed:500,
			easing:"linear",
			direction:"lr"
		};		
		var options = $.extend(defaults, options);
		var animateCSSProp = options.direction == "lr" ? "width" : "height";
		var animateOptionsMin = {},animateOptionsMax = {};
		animateOptionsMin[animateCSSProp] = "0px";
		animateOptionsMax[animateCSSProp] = options.direction == "lr" ? "110px" : "90px";
		var overCSSClass = options.direction + "-" + "over";	
			//console.log(this.length)  
		
		return this.each(function() {
			$(this).each(
				function (){
					var currentSrc = $("img",this).attr("src");
					//console.log(currentSrc)
					var name = currentSrc.split(".")[0];
					var ext = currentSrc.split(".")[1];
					var overSrc = name + "_over." + ext;
					$(this).append("<img src='"+overSrc+"' alt='' class='"+overCSSClass+"'/>");							
				}
			).hover(
				function (){
					$("img",this).eq(0).stop().animate(animateOptionsMin,options.speed,options.easing,function(){$(this).addClass(overCSSClass);}); 
					$("img",this).eq(1).stop().animate(animateOptionsMax,options.speed,options.easing,function(){$(this).removeClass(overCSSClass);});  	
				},
				function (){
					$("img",this).eq(0).stop().animate(animateOptionsMax,options.speed,options.easing,function(){$(this).removeClass(overCSSClass);}); 
					$("img",this).eq(1).stop().animate(animateOptionsMin,options.speed,options.easing,function(){$(this).addClass(overCSSClass);});  	
				}
			);
		}); 
	}; // end $.fn.jCubes
	
})(jQuery); 
