(function($) {
	
	$.fn.rollOver = function() {
		$(this).each(function() {
			var self = $(this);
			var src = self.attr('src');

			if (!src.match(/\_on/)) {
				// Preload
				var over = src.replace(/(\.gif|\.jpg|\.png)/, '_on$1');
				var img = new Image();
				img.src = over;

				self.hover(function() {
					self.attr('src', over);
				}, function() {
					self.attr('src', src);
				});
			}
		});
	};
	
	$.fn.adjustHeight = function() {
		$(this).each(function() {
			var self = $(this);
			var max = 0;
			
			$(this).children().each(function(i, obj) {
				if ($(obj).innerHeight() > max) max = $(obj).innerHeight();
			});
			$(this).children().css('height', max);
		});
	};
	
	$.fn.verticalCenter = function() {
		$(this).each(function() {
			$(this).css('margin-top', (($(this).parent().parent().height() / 2) - ($(this).height() / 2)) + 'px');
		});
	};
	
	$(document).ready(function() {
		$('.rollOver').rollOver();
		$('.adjust').adjustHeight();
		$('.vCenter').verticalCenter();
		
		$('#new_item ul li:nth-child(3n+2)').css('margin', '0 10px 20px');
		$('#ranking ul li:nth-child(3n+2)').css('margin', '0 10px 20px');
	});
})(jQuery);

