$(document).ready(function(){
	
	addEventsToMainImage()	
		
	//Upon clicking a non-active image, set it to be the active one
	//alter the main image also
	$('.thumbs img.inactive').click(
		function(){
			$(".thumbs img").removeClass("active").addClass("inactive");
			$(this).removeClass("inactive").addClass("active");
			//hack, argh
			var nonThumb =$(this).attr("src").replace('_thumb','');
			nonThumb = nonThumb.replace('Thumbnails/','');
			$("#mainimg").attr("src", nonThumb);
			
			$("#mainimg").attr("name", $(this).attr("name"));
			$("#mainimg").attr("title", $(this).attr("title"));
			$("#mainimg").attr("src", nonThumb);
			
			$("#mainimgwrapper").attr("href", nonThumb);
			
			//Should probably also add a click event to the main image such that it does funky stuff
			$('#mainimg').unbind('click');
			addEventsToMainImage();
			
			return false;
		}
	);		
});	

function addEventsToMainImage(){
    $('#mainimgwrapper').lightBox();    
}


