Shadowbox.init({
	handleOversize: "drag",
	overlayOpacity: 0.9,
	players: ["img", "flv"],
	flv: ["flv", "mp4"] 
});

$(function() {
	$(".scrollable").scrollable({circular: true, mousewheel: true});

	$("ul.tabs").tabs("div.panes > div.pane", { history: true, effect: "fade"});
	$("ul.tabs").bind("onBeforeClick onClick", function() {
		vAlignScroller();
	});
	
	vAlignScroller();
	
	var loc = document.location.href.split("/");
	loc = loc[loc.length - 2];
	loc = loc.split("#")[0];
	$("a[href='/" + loc + "']").addClass("current");
	
	if($("#index").length > 0) {
		$("#banner div.items").cycle({
			fx: "fade",
			timeout: 7000,
			pager:  "#banner nav ul",
			pagerAnchorBuilder: function(idx, slide) {
				return '<li><a href="#">' + slide.rel + '</a></li>'; 
			},
			pagerClick: function(idx, slide) {
				document.location.href = slide.href;
			}
		});
	}
	
	if($("#sludge-video").length > 0) {
		flashembed("sludge-video", "/scripts/shadowbox-3.0.3/libraries/mediaplayer/player.swf", {
			file: "/video/sludge-768k.mp4",
			controlbar: "over",
			image: "/images/sludge-poster.jpg"
		});
	}
});

function vAlign() {
	var t = (($(this).parent().height() - $(this).height()) / 2) + "px";
	$(this).css("margin-top", t);
}

function vAlignScroller() {
	$(".scrollable .items div p").each(vAlign);
	$(".scrollable .items div img").each(vAlign);
}