$(document).ready(function() {
	//alert('jQuery Ready!');
	
	//animate content on ready...
	$('#rightContent').css({width:'0',overflow:'hidden'}).animate({width:'654px'},500);
	
	var headerImgs = $.makeArray($('.h'));
	var x=Math.floor(Math.random()*headerImgs.length);
	var headerAlt = $('.h').eq(x).attr('title');

	// Change src on <img id='rotateImg'/>
	$('#rotateImg').attr({src:headerImgs[x],alt:headerAlt}).queue(function(){
		$('#header img').load(function(){
			var imgHeight=$('#header img').height();
			if(imgHeight<274){
				$('#header').css({'height':imgHeight});}
			if(imgHeight>400){
				$('#rotateImg').css({'margin-top':'-90px'});}
		});
	});
	
	// Change caption in caption area and animate.
	$('#cap').text(headerAlt);
	$('#aboutThisImageCaption').css({height:'0'});
	
	// Hover state for main <img />	
	$('#rotateImg').hover(
	function(){
		$('#aboutThisImageCaption').stop().animate({height:'40px'});
	}, 
	function () {
		$('#aboutThisImageCaption').stop().animate({height:'0'});
	}
	);
	
	//add gallery functionality
	$(function(){
	$('.gallery a').lightBox({fixedNavigation:true,
		imageLoading: 'images/loading.gif',
		imageBtnClose:'images/lightbox-btn-close.gif',
		imageBtnPrev: 'images/lightbox-btn-prev.gif',
		imageBtnNext: 'images/lightbox-btn-next.gif'
	});
});

 });
