$(document).ready(function(){
	$('a[rel=fotoshow]').click(function(){
		img = $(this).attr('href');

		if (img==$("#bigimg").attr('src')) return false;

		blockwidth = $('#imgblockfolder').width();
		imgwidth = $(this).width();
		imgpos = $(this).position();
		pos = blockwidth/2-imgwidth/2-imgpos.left;

		poslast = $('a[rel=fotoshow]:last').position();
		widlast = $('a[rel=fotoshow]:last').width();
		lastpoint = blockwidth-(poslast.left+widlast);

        //alert (lastpoint);
		if (pos<lastpoint) pos=lastpoint;

		if (pos>0) pos=0;

		$("#imgblock").animate({"left": pos}, "slow");

		$(this).parent().find("a").addClass("imgopaq").attr({"style":"filter:alpha(opacity=60)"});
		$(this).animate({"opacity": 1}).removeClass("imgopaq");

		$("#bigimg").fadeOut(
			function(){                $('#fotoload').show();
				$('#bigimg').attr('src', img).load(function() {					 $('#fotoload').hide();
   					 $("#bigimg").fadeIn();
				});

				//$("#bigimg").attr('src',img);

			}
		);

		return false;

	});

	$('a[rel=fotoshow]:first').removeClass('imgopaq');

	/*$('a[rel=fotoshow]').mouseover(function(){		$(this).animate({"opacity": 1});
	});

	$('a[rel=fotoshow]').mouseout(function(){		img = $(this).attr('class');
		if (img!='imgopaq') return false;
		$(this).animate({"opacity": 0.6});
	});*/

	fresize();

	$(window).resize(function(){		fresize()
	});

	jQuery.preloadImages = function() {
	    jQuery.each (arguments,function (e) {
	        jQuery("<img>").attr("src", this);
	    });
	}
	$.preloadImages("/images/fotoload.gif");

});

	function fresize() {
		tdw = $("#fotolinetd").width();
		bod = $("#body").width()-320;
		hgh = $(window).height()-220;
		$('#tdbigfoto').height(hgh);
		$('#divbigfoto').height(hgh-10);
		$('#imgblockfolder').width(bod);
	}

