﻿var PeabActiveSlide = 'Images'; //Flash, Images or Map
var PeabActiveSlideBefore = '';

function SetSlideFlash() {
	setPeabActiveSlide('Flash');
}
function setSlideImages() {
	setPeabActiveSlide('Images');
}
function setSlideMap() {
	setPeabActiveSlide('Map');
}

function setPeabActiveSlide(slide) {
	PeabActiveSlideBefore = PeabActiveSlide;
	PeabActiveSlide = slide;
}

function selectPresentationControls(selectFlashButton, selectImagesButton, selectMapButton) {
	if (selectFlashButton) {
		jQuery('.ContentToolBar .flashLink').hide();
		jQuery('.ContentToolBar .flashLinkSelected').show();
	} else {
		jQuery('.ContentToolBar .flashLink').show();
		jQuery('.ContentToolBar .flashLinkSelected').hide();
	}
	if (selectImagesButton) {
		jQuery('.ContentToolBar .slideShowLink').hide();
		jQuery('.ContentToolBar .slideShowLinkSelected').show();
	} else {
		jQuery('.ContentToolBar .slideShowLink').show();
		jQuery('.ContentToolBar .slideShowLinkSelected').hide();
	}
	if (selectMapButton) {
		jQuery('.ContentToolBar .mapLink').hide();
		jQuery('.ContentToolBar .mapLinkSelected').show();
	} else {
		jQuery('.ContentToolBar .mapLink').show();
		jQuery('.ContentToolBar .mapLinkSelected').hide();
	}
}

function spankIE() {
	if (jQuery.browser.msie && parseInt(jQuery.browser.version)<8) jQuery('#RegionContent,#PageBottom,#ImageSlideshow').css({ "zoom": "1" }).css({ "zoom": "100%" });
}

function showProjectMap() {
	setSlideMap();

	jQuery('#ImageSlideshow .controls .stopButton').click();

	showSlideshow();

	hideImageGallery();
	hideFlash();

	jQuery('#ProjectMap').slideDown(spankIE);

	jQuery('#ImageSlideshow .controls').hide();

	selectPresentationControls(false, false, true)

	PEAB.Base.MapInstance.checkResize();
	PEAB.Base.MapInstance.loadurl2();
}
function hideProjectMap() {
	if (PeabActiveSlideBefore == 'Map') {
		jQuery('#ProjectMap').slideUp(spankIE);
	}
	else {
		jQuery('#ProjectMap').hide();
	}
}
function showImageGallery() {
	setSlideImages();

	showSlideshow();

	hideProjectMap();
	hideFlash();

	jQuery('#ImageSlideshow').slideDown(spankIE);

	jQuery('#ImageSlideshow .controls .startButton').click();
	jQuery('#ImageSlideshow .controls').show(400);

	selectPresentationControls(false, true, false);
	
	PEAB.Base.MapInstance.checkResize();

}

function hideImageGallery() {
	if (PeabActiveSlideBefore == 'Images') {
		jQuery('#ImageSlideshow').slideUp(spankIE);
	}
	else {
		jQuery('#ImageSlideshow').hide();
	}
}

function showFlash() {
	SetSlideFlash();

	showSlideshow();

	hideImageGallery();
	hideProjectMap();

	jQuery('#ImageSlideshow .controls .stopButton').click();

	jQuery('#SiteFlash').slideDown(spankIE);

	jQuery('#ImageSlideshow .controls').hide();

	selectPresentationControls(true, false, false);

	PEAB.Base.MapInstance.checkResize();
}

function hideFlash() {
	if (PeabActiveSlideBefore == 'Flash') {
		jQuery('#SiteFlash').slideUp(spankIE);
	}
	else {
		jQuery('#SiteFlash').hide();
	}
}

function hideSlideshow() {
	jQuery('#ImageSlideshow .controls .stopButton').click();
	jQuery('#ImageSlideshow .controls').hide();
	
	jQuery('#PageContent .Slideshow').slideUp(spankIE);

	jQuery('#PageContent .ContentToolBar .hideButton').hide();
	jQuery('#PageContent .ContentToolBar .showButton').show();

	selectPresentationControls(false, false, false);
}

function showSlideshow() {
	jQuery("#PageContent .Slideshow").hide();
	jQuery("#PageContent .Slideshow").css({ "position": "static" });

	jQuery('#PageContent .Slideshow').slideDown(spankIE);
	
	jQuery('#PageContent .ContentToolBar .hideButton').show();
	jQuery('#PageContent .ContentToolBar .showButton').hide();

	if (PeabActiveSlide == 'Images') {
		jQuery('#ImageSlideshow .controls').show(400);
		jQuery("#PageContent #ImageSlideshow").css({ "position": "relative" });
		jQuery("#PageContent #ImageSlideshow").css({ "top": "0" });
		selectPresentationControls(false, true, false);
	} else	if (PeabActiveSlide == 'Map') {
		selectPresentationControls(false, false, true);
	} else if (PeabActiveSlide == 'Flash') {
		selectPresentationControls(true, false, false);
	}
}

