// JavaScript Document

$(document).ready(function(){
//center the wrapper
	//centerWrapper();
	
	// functions to show the image of the gallery thumbnail 
	$(".enlarge").click(function(){
			
			var source = $(this).attr("alt");
			var caption = $(this).attr("title");
		
		  	$(this).after($("#popup"));
		  	$("#popup").replaceWith("<div id='popup' class='loading'><a class='close' href='#' title='Close'>"+ caption +"</a><img class='largeImg' src='img/"+ source + "' title='click to close'/></div>");								   
			
			$(".close,#popup").click(function(){
				$("#popup").fadeOut('slow');
				return false;
			});
			//image loader
		  	$('.largeImg').load(function () {
		      $(this).hide();
		      $('#popup').removeClass('loading').append(this);
		      $(this).fadeIn();
		    });// end load
	});
			
		//submenu on hover
		$('#leftNav li').hover(
		function(){
			$(this).addClass('showSub');
		},
		function(){
			$(this).removeClass('showSub');
		});

});

//center the wrapper

function centerWrapper(){
var wrapTopMargin;
var windowHeight = $(window).height();
var wrapperHeight = $('#wrapper').height();

if(wrapperHeight > windowHeight){
	wrapTopMargin = 10;
}else{
	wrapTopMargin = (windowHeight - wrapperHeight)/2;
}
//set the wrapper top margin 
$('#wrapper').css({"margin-top":wrapTopMargin});
}
//end centerWrapper()
	
