$(document).ready(function() {
	// check to see if we are finishing a transition or not?
	if($('#transition').css('display') == 'block') {
		// complete the transition with a fade out - remember that the css 'block' property is set by PHP in the BODY section below if $_GET['fade'] == 'in'
		$('#transition').fadeOut('fast');
	}
	
	// page transitions
	$('#wrapper a[class!=thickbox]').click(function() {
		if($(this).attr('class') != 'noFade') {
			// leave thickbox links alone
			// store the current URL target for later
			var url = $(this).attr('href');
			// set the HREF of this A tag a nowhere click to stop the HTML tag working
			$(this).attr('href','javascript:;');
			// fade out
			$('#transition').fadeIn('fast', function() {
				// redirect to new url (taken from the a tag originally)
				location.href = url+'?fade=out';
			});
		}
	});
	
	// add title tags to each image matching the alt tags
	$('#wrapper img').each(function() {
		$(this).attr('title', $(this).attr('alt'));
	});
});

function popup(url,w,h) {
 var width  = (w == undefined) ? 350 : w;
 var height = (h == undefined) ? 365 : h;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'newWindow', params);
 if (window.focus) {
	newwin.focus()
}
 return false;
}