// *************************** jQuery Initialisation **************************** //

$(document).ready(function() {

	// mouse over images
	$('#priNav img').imghover();
	$('.moreLeft img').imghover();
	$('.moreRight img').imghover();

	// mailto obsfucation
	// $('a.mailto').mailtoObsfucator();

	// default form value restoration
	$('#searchWords').defaultRestore();

	$('#search').submit(function(){
		if( $('#searchWords').val() == 'Search for...' ){
			alert('Please enter a term to search for');
			return false;
		}
		return true;
	});


	$("#pageImages_thumbs img").hover(function(){
		var imgToShow = getIndex( this );
		imgToShow.show();
	},function(){
		var imgToShow = getIndex( this );
		imgToShow.hide();
	});

	$("#footer #links .collapse").hide(function(){
		$("#footer #links").prepend("<span class=\"toggleCollapsible\">&nbsp;</span>");
		$("span.toggleCollapsible").click(function(){
			$("#footer #links .collapse").toggle();
			$(this).toggleClass("close");
		});
	});


});


// find its position
function getIndex(jqEle){
	var imgIndex = $('#pageImages_thumbs img').index( jqEle );
	var imgToShow = $('#pageImages_large > img:eq('+ imgIndex +')');
	return imgToShow;
}

