// PAGE INITIALISATION /////////////////////////////////////////////////

function destinationsInfoInitialise(){
	makeMediaDisplayInteractive();
	// cache the tab panels so that they're quicker to display
	tabPanelsCacheAll( "destinationSection" );
	tabPanelsDisplayFirst( "destinationSection" );
	
	if( $( "DestinationInfoIntroSlideshow" ) != null ){
	
		// start the "At a glance" tab slideshow running
		atAGlanceSlideshowStart();
	
	}
}


function destinationsSubsectionThrob( section ){
	var section = $( section );

	if( section == null ){ return; }
	
	var duration = 500;
	var steps = 10;
	var timeDelta = duration / (steps - 1);
//	var colourSteps = colourCreateFade( {r:247,g:146,b:30}, {r:255,g:255,b:255}, steps );
	var colourSteps = colourCreateFade( {r:251,g:196,b:143}, {r:255,g:255,b:255}, steps );

	for( var i = 0; i < steps; ++i ){
		setTimeout( "$('" + section.id + "').style.background = '" + colourSteps[i] + "';", i * timeDelta );
	}
}

// "AT A GLANCE" PHOTO SLIDESHOW FUNCTIONS //////////////////////////////////////////////

// the slideshow on the "At a glance" page is a lot simpler than the main one -
// it doesn't need to start or stop, just keeps cycling through the list of photos
function atAGlanceSlideshowStart(){
	// only start the slideshow if there is more than one photo
	if(window.photos){
		if( window.photos.length > 1 ){
			setInterval( atAGlanceSlideshowNext, window.slideshowTimeBetweenChange );
			window.atAGlancePhotoIndex = 0;
		}
	}
}

function atAGlanceSlideshowNext(){
	window.atAGlancePhotoIndex = (window.atAGlancePhotoIndex + 1) % window.photos.length;
	var nextPhoto = window.photos[window.atAGlancePhotoIndex];
	$( "DestinationAtAGlancePhoto" ).src = nextPhoto.filename;
	$( "DestinationAtAGlancePhoto" ).alt = nextPhoto.caption + " (photo)";
	Element.update( "DestinationAtAGlancePhotoCaption", nextPhoto.caption );
}