
function move_zommed(e) {
	var minus = 0;
	if( $x + $move.width() + 5 > $max_width ) minus = $x + $move.width() + 15 - $max_width;
	$move.css({'top': ($y + 5) + 'px', 'left': ($x + 5 - minus) + 'px'});
}

$(function(){
	
	$max_width = $('body').width();
	$move = $('#zoomedPic');
	$x = 0;
	$y = 0;
	
	$('#allPics td.pic img').hover(
	function(e) {
		var img = $(this);
		$move.stop(true, true);

		$move.find('div.header').html( $(this).parents('td').find('div.header').html() );
		$move.find('div.zommedPic img').hide().attr('src', img.attr('src').replace(/_middle\./, '_prev300.') );
		$move.fadeIn(300);
		
		$move.find('div.loading').show();
		$move.find('div.zommedPic img').load(function(evt2) {
			$(this).fadeIn(200);
			$move.find('div.loading').hide();
			move_zommed();
		});
		
		//move.find('div.comments span').html( $(this).find('div.comments').html() );
	},
	function() {
		$move.stop(true, true);
		$move.hide();
	})
	.mousemove(function(e) { $x = e.pageX; $y = e.pageY; move_zommed(); });;

});