
// EXTERNAL LINKS

$(document).ready(function()
{
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
});




// SIDEBAR

$(document).ready(function()
{
	$("#sidebar dd").hide();
	var showThis = Math.floor(Math.random()*($("#sidebar dd").size()));
	$("#sidebar dd:eq(" + (showThis) + ")").show();
	$("#sidebar dt").mouseover(function()
	{
		$("#sidebar dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
	$("#sidebar h2:last").mouseover(function()
	{
		$("#sidebar dd").show('slow');
		return false;
	});
});




// GALLERIA

$(document).ready(function()
{
	$('.galleria').addClass('galleria'); // adds new class name to maintain degradability

	$('ul.galleria').galleria({
		history   : false, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#galleria_main', // the containing selector for our main image
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes

		// fade in the image & caption
		image.css('display','none').fadeIn(1000);
		caption.css('display','none').fadeIn(1500);

		// fetch the thumbnail container
		var _li = thumb.parents('li');

		// fade out inactive thumbnail
		_li.siblings().children('img.selected').fadeTo(500,0.3);

		// fade in active thumbnail
		thumb.fadeTo('fast',1).addClass('selected');

		// add a title for the clickable image
		image.attr('title','Next Image >>');
		},

		onThumb : function(thumb) { // thumbnail effects goes here

		// fetch the thumbnail container
		var _li = thumb.parents('li');

		// if thumbnail is active, fade all the way.
		var _fadeTo = _li.is('.active') ? '1' : '0.3';

		// fade in the thumbnail when finnished loading
		thumb.css({display:'none', opacity:_fadeTo}).fadeIn(1500);

		// hover effects
		thumb.hover(
			function() { thumb.fadeTo('fast',1); },
			function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});
});




// ADDRESS

$(document).ready(function()
{
	var calgary = '<address>Knut Neven<br/>#509 - 205 Riverfront Avenue SW<br/>Calgary, Alberta<br/>T2P 5K4<br/>Canada</address><address>403.667.6960<br/><a href="mailto:postmaster@neven.ca">postmaster@neven.ca</a>';
	$("div.address[title='calgary']").html(calgary);
});




// COUNTRY

$(document).ready(function()
{
	var isoCountry = '';
	var imgCountry = '';
	$("p.player, p.place").each(function(j) {
		obj = $(this);
		isoCountry = $(obj).attr("title");
		imgCountry = "url(/images/country/" + isoCountry + ".png)";
		obj.css("background-image", imgCountry);
	});
});




// STRINGBALL

$(document).ready(function()
{
	$("ul#stringball").stringball(
	{
		camd: 1000,
		radi: 150,
		speed: 2
	});
});