$(function() {
	$("form.ajax").submit(function() {
		$(this).ajaxSubmit();
		$(this).parent(".addform").hide();
		return false;
	});
	
	$("#center.slideshow img").each(function() {
		var img = $(this);
		img.get(0).onload = function() {
			var w = (img.width() == 710) ? 20: ((750 - img.width())/2);
			var h = (img.height() == 560) ? 20: ((600 - img.height())/2);
			img.css({left: w+"px", top: h+"px"});
		}
	}).not(":first").hide();
	setInterval("changeSlide()", 4500);
	
	$("a.up").click(function() {
		$("#right > div").scrollTo({top:"-=250px"}, "fast");
		return false;
	});
	
	$("a.down").click(function() {
		$("#right > div").scrollTo({top:"+=250px"}, "fast");
		return false;
	});
	
	$.bindAjaxLinks();
});

$.extend({
	bindAjaxLinks: function() {
		$("a.ajax").unbind('click').click(function() {
			$("#"+$(this).attr('rel')).load($(this).attr('href'), function() {
				$.bindAjaxLinks();
			});
			return false;
		});
	}
});

function changeSlide() {
	var vis = $("#center.slideshow img:visible");
	var next = (vis.next("img").size() != 0) ? vis.next("img") : $("#center.slideshow img:first");
	vis.fadeOut("slow");
	next.fadeIn("slow");
}