$(document).ready(function()
{
	 // Open external links in a new window.
	 $("a").filter(".link").click(function(){
	   return !window.open(this.href);
	 });
 	
 	// Defuscate email addresses.
 	$('a').defuscate();

	// Get the accordion working.
	$('#navigation').Accordion({
		active: false,
		header: '.head',
		navigation: true,
		event: 'mouseover',
		autoheight: true,
		animated: 'bounceslide'
	});
	
	$('#switch select').change(function() {
			jQuery('#navigation').activate( this.selectedIndex-1 );
		});
	$('#close').click(function() {
			jQuery('#navigation').activate(-1);
		});
	$('#switch2').change(function() {
			jQuery('#navigation').activate(this.value);
		});
		
	// Cycle images on the Gallery page.
	$('#slideshow').innerfade({ 
    	speed: 1500,
    	timeout: 3000,
    	runningclass: 'gallery',
    	containerheight: '400px'
 	});

	// Add a rollover to images with the "rollover" class.
	$(".rollover").hover(
		function(){
			if($(this).attr("src").indexOf("-rollover") == -1) {
				var newSrc = $(this).attr("src").replace(".png","-rollover.png#hover");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-rollover.png#hover") != -1) {
				var oldSrc = $(this).attr("src").replace("-rollover.png#hover",".png");
				$(this).attr("src",oldSrc);
			}
		}
	);
});
