// JavaScript Document
function doSectGallery(){
			
	//image rollover 	
	$('#gallery img').each(function(i) {
		var imgFile = $(this).attr('src');
		
		var preloadImage = new Image();
  		var imgExt = /(\.\w{3,4}$)/;
 	 	preloadImage.src = imgFile.replace(imgExt,'_h$1');
		
		$(this).hover(
			function() {
				//$(this).attr('src', preloadImage.src);  disable swap images!
			},
			function () {
				var currentSource=$(this).attr('src');
				$(this).attr('src', imgFile);
		});
	});
	
	//get starting caption
	var capCurr = $('#gallery a').attr('name');
	//display starting caption
	$('#photoCap').html('<p>' + capCurr + '</p>');
	
	/* image click	*/	
	$('#gallery a').click(function(evt) {
		//don't follow link
		 evt.preventDefault();
		
		 //get path to new image
	  	 var imgPath = $(this).attr('href');		 
		 //get reference to old image
		 var oldImage = $('#photo img');	
				 
		 //check to see if they're the same image		 
		 if (imgPath == oldImage.attr('src')) { 
		 	//if they are then you're done
		 	return;
		 } else {
			 //remove highglight from previously clicked thumbnail
       		$('.selected').removeClass('selected');		
			 //add highlight to this thumbnail
			 $(this).addClass('selected');
			 //create HTML for new image
			 var newImage = $('<a href="' + imgPath + '" target="_blank"><img src="' + imgPath +'" title="groter: klik op foto"></a>');
			 //get new caption
			 var capNew = $(this).attr('name');
			
	 		 //$('#photoCap').html('<p>imgCap New: ' + capNew + '</p>');
			 //make new image invisible
			 newImage.hide();			 
			 //add to the #photo div
			 $('#photo').prepend(newImage);			
			 //fade out old image and remove from DOM
			 oldImage.fadeOut(1000,function(){
		     		$(this).remove();
				});
			 //fade in new image
			 newImage.fadeIn(1000);
			 //display new caption
			 $('#photoCap').html('<p><i>' + capNew + '</i></p>');
		 }
	});
		
	$('#gallery a:eq(0)').click();
}

function arcToggle(){
	$('.arcItems').hide();
	$('#archive h3').toggle(
		function() {
	   		$(this).next('.arcItems').fadeIn();
		 	$(this).addClass('close');
		 },
		function() {
		  $(this).next('.arcItems').fadeOut();
			$(this).removeClass('close');
	  	}
	); // end select h3 toggle			
}
