hs.graphicsDir = '/highslide/graphics/';
hs.outlineType = 'rounded-white';
hs.blockRightClick = true;
hs.showCredits = false;

var thumbOffset = 0, thumbsPage = 4, numThumbs = 0;
var defstripe = "a-" + currentSection;

$(document).ready(function() {
	$("body").addClass(defstripe);
	$("#stripe1").attr("class", defstripe);
	$("a.nav-item.a-"+currentPage).addClass("current");

	$("div.nav a").mouseenter(function(){
		$("#stripe1").attr("class", $(this).attr("class"));
	});
	
	$("#navnav").mouseleave(function(){
		$("#stripe1").attr("class", defstripe);
	});

	$('td.smallphoto > div').append('<span></span>');

	$('.listtitle a').hover(function() { $("div:first", $(this).closest("td").prev()).addClass("active"); }, function() { $("div:first", $(this).closest("td").prev()).removeClass("active"); });

	$('td.smallphoto img, td.smallphoto span').hover(function() { $("div:first", $(this).closest("td")).addClass("active"); }, function() { $("div:first", $(this).closest("td")).removeClass("active"); });
	$('td.smallphoto img, td.smallphoto span').click(function() { document.location.href=$("a", $(this).closest("td")).attr("href"); });

	$('.mainpic').hover(function() { $(this).parent().addClass("bgbottom"); }, function() { $(this).parent().removeClass("bgbottom"); });

	$('.mainpic').click(function() {
		var u = $(this).parent().css('background-image');
		if (u != "")
		{
			var m = u.match(/url\(\"?([^\"]*)\"?\)/);
			hs.expand(this, {src:m[1].replace('_p.jpg', '_o.jpg')});
		}
	});

	$('.lister img.thumb:gt(' + (thumbsPage-1) + ')').hide();
	$('.lister img.spacer:gt(' + (thumbsPage-1) + ')').hide();
	numThumbs = $('.thumb').size();

	$('.thumb').click(function() {
		var r = $(this).attr('rel');
		if (r != "") {
			$("#mainpicdiv").css('background-image', 'url('+r+')');
			location.hash=$(this).attr('alt');
		}
	});

	$('#leftarr').click(function() {
		if (thumbOffset > 0)
		{
			thumbOffset--;
			$('.lister img.thumb:eq(' + (thumbOffset+thumbsPage) + ')').hide();
			$('.lister img.spacer:eq(' + (thumbOffset+thumbsPage) + ')').hide();
			$('.lister img.thumb:eq(' + thumbOffset + ')').show();
			$('.lister img.spacer:eq(' + thumbOffset + ')').show();
			checkThumbControls();
		}
	});

	$('#rightarr').click(function() {
		if (thumbOffset < numThumbs-thumbsPage)
		{
			$('.lister img.thumb:eq(' + thumbOffset + ')').hide();
			$('.lister img.spacer:eq(' + thumbOffset + ')').hide();
			$('.lister img.thumb:eq(' + (thumbOffset+thumbsPage) + ')').show();
			$('.lister img.spacer:eq(' + (thumbOffset+thumbsPage) + ')').show();
			thumbOffset++;
			checkThumbControls();
		}
	});

	$('#mainpicdiv, div.lister').mousewheel(function(event, delta)
	{
		if (delta > 0) { $("#leftarr").click(); }
		else if (delta < 0) { $("#rightarr").click(); }
		event.stopPropagation();
		event.preventDefault();
	});

	checkThumbControls();
});

$(document).ready(function() {
	$(".teamphoto a, .teamphoto span").hover(
	function(){
		var div1 = $("div:first", $(this).closest("td"));
		div1.addClass("active");
		var img = div1.find("img");
		img.attr("src", img.attr("src").replace("_s.jpg", "_c.jpg"));
	},
	function(){
		var div1 = $("div:first", $(this).closest("td"));
		div1.removeClass("active");
		var img = div1.find("img");
		img.attr("src", img.attr("src").replace("_c.jpg", "_s.jpg"));
	});

	$("div.teamname a").hover(
	function(){
		var div1 = $("div:first", $(this).closest("td").prev());
		div1.addClass("active");
		var img = div1.find("img");
		img.attr("src", img.attr("src").replace("_s.jpg", "_c.jpg"));
	},
	function(){
		var div1 = $("div:first", $(this).closest("td").prev());
		div1.removeClass("active");
		var img = div1.find("img");
		img.attr("src", img.attr("src").replace("_c.jpg", "_s.jpg"));
	});

});

function checkThumbControls()
{
	if (thumbOffset > 0) { $("#leftarr").addClass('active'); }
	else { $("#leftarr").removeClass('active'); }
	if (numThumbs > thumbOffset+thumbsPage) { $("#rightarr").addClass('active'); }
	else { $("#rightarr").removeClass('active'); }
}

