$(document).ready(function() {
	
	$("img.fade").hide();

	$(window).bind("load", function() {
		$("img.fade").fadeIn(1500);
	});

	//CENTRE THE SCREEN
	$("#globalWrap").centerScreen();

	//SET UP CYCLE
	$("#gallery").cycle({
		fx: 'fade',
		timeout: 0,
		speed: 1200,
		next: '#next', 
		prev: '#prev',
		after: onAfter,
		sync: 1
	});

	//$("#folio").hide();

	// INIT GALLERY NAV BTNS
	var galleryBtns = $("#galleryNav a");
	
	$(galleryBtns).animate( {opacity: '1'}, {duration: 3000});
	$(galleryBtns).animate( {opacity: '0'}, {duration: 500});
	
	$(galleryBtns).hover(
		function() {  
			$(this).stop().animate( {opacity: '1'}, {duration: 1000});  
		}, 
		function() {  
			$(this).stop().animate( {opacity: '0'}, {duration: 1000});  
		});

	// INSERT A DIV OVER THE GALLERY WITH LOADER
	$("#gallery").append("<div id=\"loadOverlay\"><\/div>");
	$("#loadOverlay").css({
		'width':'100%',
		'height':'468px',
		'background': '#E0DED8 url(../img/glo/loader.gif) center center no-repeat',
		'position':'absolute',
		'z-index':'101'
	});

});// END DOC READY


$(window).load(function() {
	
	$("#loadOverlay").fadeOut(2000, function() {
	$(this).remove();
	//$("#folio").fadeIn("slow");
	});
});// END ONLOAD


function onAfter() { 
    $('#folio').html("<h5>" + this.title + "<\/h5><p><strong>Image copyright: <\/strong>" + this.alt + "<\/p>"); 
}
