// This requires jQuery...

function setPopups(){
	$("a.popup").click(function(){
		var ftw=window.open(this.href, 'popup', "width=800,height=600");
		return false;

	});
	$("a.popup-square").click(function(){
		var ftw=window.open(this.href, 'popup', "width=800,height=800");
		return false;

	});
	$("a.newwin").click(function(){
		var ftw=window.open(this.href, 'newwin',"");
		return false;

	});
}

$(function(){
	$("a.fastload").click(function(){
		var newhref = this.href+"?contentonly=1";
		var that = this;
		$.ajax({
			url: newhref,
			success: function(html){
				$("#content").replaceWith(html);
				$("#secondary-nav li").css({listStyleImage: "none"});
				$(that).parent().css({listStyleImage: "url(/images/thispage.png)"});
				setPopups();
  			}
		});
		return false;
	});
	
	$("#slideshow-container").addClass("onready");
	var photocount = $(".slide").size();
	$("#photo-container").width(photocount*604+1000);
	
	$("#next-image").click(function(){
		
		var offset = parseInt($("#photo-container").css("left"));
		var currentphoto = -offset/604+1;
		var nextphoto    = 1;
		var left = 0;
		if(currentphoto != photocount){
			left = currentphoto*604;
			nextphoto    = currentphoto+1;
		}
		// Because IE is stupid.
		$("#photo-"+currentphoto).css({"visibility":"hidden"});
		$("#photo-container").css({"left":-left});
		$("#photo-"+nextphoto).css({"visibility":"visible"});
		return false;
	
	});

	setPopups();
});