(function ($) {
	
	$(document).ready(function () {
		$('a.mail').each(function () {
			var $this = $(this), href = $this.attr('href');
			$this.attr('href', href.replace(/ \(at\) /, '@').replace(/ \(dot\) /g, '.'));
		});
		
		$('a.myself img, a.portfolio img, a#twitter img').swap();
	});


	function swap(options) {
		var $this = $(this), $that = $(new Image());
		
		$that.attr('src', $this.attr('src').replace(/(\.[a-z]{3})$/, '_h$1'));
		$that.css({ position: 'absolute', top: 0, left: 0, opacity: 0 });
		
		$.each(['enter', 'leave'], function () {
			$that.bind('mouse' + this, function (event) {
				$that.stop();
				$that.animate({ opacity: (event.type === 'mouseenter') }, 'slow');				
			});
		});
		
		$this.parent().append($that);
	}
	
	$.fn.swap = function (options) {
		return this.each(function () {
			swap.apply(this, [options]);
		});
	};
	
})(jQuery);























