(function($){
   $.fn.xpicGlow = function(glowInDuration, glowOffDuration){
      var element = $(this);
      element.each(function(){
      	$$ = $(this);
      	// static and glow div class names
      	var glowDiv = $$.prev().css('opacity', 0).attr('class');
      	var staticDiv = $$.prev().prev().attr('class');
      	var staticAndGlowWidth = $(' > span.width', $$.prev()).html();
      	var staticAndGlowHeight = $(' > span.height', $$.prev()).html();
      	var spritePic = $(' > img', $$.prev()).attr('src');
      	var spritePicPosition = $(' > img', $$.prev()).attr('alt');
      	$$.prev().prev().css('width', staticAndGlowWidth).css('height', staticAndGlowHeight).css('background', 'url(' + spritePic + ') no-repeat');
      	$$.prev().css('width', staticAndGlowWidth).css('height', staticAndGlowHeight).css('background', 'url(' + spritePic + ') no-repeat').css('backgroundPosition', '0 ' + spritePicPosition);
     	var elementWidth = $(' > span.width', $$).html();
     	var elementHeight = $(' > span.height', $$).html();
     	var elementPaddingTop = $(' > span.padding-top', $$).html();
     	var elementPaddingleft = $(' > span.padding-left', $$).html();
     	$$.css('width', elementWidth).css('height', elementHeight).css('paddingTop', elementPaddingTop).css('paddingLeft', elementPaddingleft);
      	$$.hover(
      		function(event){
      			current = $(this);
				current.prev().stop().animate({opacity: 1}, {duration:glowInDuration});
      		},
      		function(event){
      			current = $(this);
      			current.prev().stop().animate({opacity: 0}, {duration:glowOffDuration});
      		}
      	)
      });
   }
})(jQuery);