//	$Id: scripts.js 89 2010-07-17 10:26:25Z Yannick $

var banner_timer = null;

$(document).ready(function(){
	$("a.photo").click(function(){
		var photo_big = $("#photo-big");
		var r = new RegExp(/^(.*?)#([0-9]+)_([0-9]+)$/);
		var m = r.exec(this.href);
		var w = Number(m[2])+20;
		var h = Number(m[3])+20;
		var t,pos;
		cphoto = $(this);
		photo_big.html("<img src=\""+m[1]+"\" width=\""+m[2]+"\" height=\""+m[3]+"\" alt=\"\" />");
		if (fixed_dialogs)
		{
			pos = "fixed";
			t = ($(window).height()-h)/2;
		}
		else
		{
			pos = "absolute";
			t = $(document).scrollTop()+($(window).height()-h)/2;
		}
		photo_big.css({
			left: ($(document).width()-w)/2,
			top: t,
			position: pos
		});
		photo_big.fadeIn(250);
		$("body").click(function(e){
			$("body").unbind("click");
			var clicked = $(e.target);
			if ((clicked.is("#photo-big")) || (clicked.closest("#photo-big").length==1))
			{
				var nphoto = cphoto.next("a.photo");
				if (nphoto.length==1) nphoto.click();
				else photo_big.fadeOut(500);
			}
			else
			{
				photo_big.fadeOut(500);
			}
			return false;
		});
		return false;
	});

	banner_timer = window.setTimeout("change_image()",10000);
});

function change_image()
{
	$(".banner_trans").fadeIn(2500,function(){
		var trans = $(".banner_trans").get(0);
		var img2 = img;
		var i = 0;

		$(".banner").get(0).src = trans.src;
		$(".banner_trans").hide();
		while ((img2==img) || (img2==pimg))
		{
			img2 = Math.floor(Math.random()*nimg);
			if (++i==10) break;
		}
		pimg = img;
		img = img2;
		trans.src = banners[img];
		banner_timer = window.setTimeout("change_image()",10000);
	});
}

