$(document).ready(function() {
	
	$('#thumbnails a').not('#thumbnails a.current').addClass('no-hover');// remove the non-jscript hover behavior
	
	$('div.site').not(':first').children().hide(); // hide all the content of each box so they're pre-hidden for when divs are shown.
	$('div.site').not(':first').hide(); // hide all the site divs except the first one

	$('div#siteWindow').css('overflow-y','hidden'); // stop the scrollbars showing
	
	$('#thumbnails a').click( function(e){ // for each of the thumbnails
		
			e.preventDefault(); // stop default behavior

		//	$('div.site').stop(); // stop any site divs that are in transition
			
			if (!$(this).hasClass('current')){ // if this ISN'T the thumbnail for the current site div
				$('#thumbnails a').removeClass('current'); // remove any others that are current
				$(this).addClass('current');// add current class to this one, as it's now the current one

				var thisID = $(this).attr('id'); // get the id of the thumbnail so we can use it to select the site div
		

				$('div.site:visible').fadeOut( 'slow',function() { // fade out any visible site divs then callback
						
					$('div#' + thisID +'_box').fadeIn(400, function(){ // fade up the box then callback
								$('div#' + thisID +'_box').children().fadeIn(400);// Fade up the contents

					});
				})
		
			} // end of if to only run if not current
	}); // end of click function

		// Thumbnail hover
	$("#thumbnails a").hover( function(e){  
		if (!$(this).hasClass('current')){ // if not the current thumbnail
				$('#thumbnails a').stop();
				$(this).fadeTo(400,0.5, function(){ // fade it a bit to look cool
					$(this).removeClass('no-hover'); // then on callback, add the class to make hover behavior
				});

				$(this).fadeTo(500,1); // then fade up
				
		};// end of if test
		}, // end of hover over
		 function(){	// on mouseout
		 		if (!$(this).hasClass('current')){ // if not the current thumbnail

		 			$(this).addClass('no-hover'); // remove the jhover class to return to normal state.
				};
		 }
		
		); // end of hover function
	
	
});
