$(function(){
	$("ul.updates-tabs").tabs("div.updates-panes > div", {
		onBeforeClick: function(i) {
			var pane = this.getPanes().eq(i);
			if(pane.is(":empty") || pane.html().indexOf("wait-loading")) {
				var url = "/updates_ajax.html?type=" + this.getTabs().eq(i).attr("href").substring(1);
				pane.load(url);
			}
		}
	}).history();

	$("div.updates-more a").live("click", function(){
        var offset = $(this).attr("id");
        var type = $(this).attr("title");
        if(type == "latest") {
        	var pane = 0;
		} else if(type == "recent-movies") {
			var pane = 1;
		}
        $("div.updates-more").html("<p class=\"wait-loading\">&nbsp;</p>");
        $.get("/updates_ajax.html", { type: type, offset: offset }, function(data) {
			$("div.updates-more").hide();
			$("div.updates-panes div.pane:eq("+pane+")").append(data);
		}, "html");
		return false;
	});

	$("div.new-sash").live("click", function(){
		var url = $("> a", this).attr("href");
		location.href = url;
	});

});