$(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: 'easeslide'
	});
	
	$('#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);
		});

	// 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(".gif","-rollover.gif#hover");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-rollover.gif#hover") != -1) {
				var oldSrc = $(this).attr("src").replace("-rollover.gif#hover",".gif");
				$(this).attr("src",oldSrc);
			}
		}
	);
});
