$(document).ready(function(){
						   
		// hide the next button at the last slide...
		$("#DetailSlides div:last .nextButton").hide();
		
		// hide the next button at the "Staying the night" (slide 14) since there is a custom one in the content
		$("#DetailSlides_14 .nextButton").hide();
		
		// hide the next button at the "Playrooms" (slide 16) since there is a custom one in the content
		$("#DetailSlides_16 .nextButton").hide();
		
		AddCallouts();
		
});



//****************************************************************
// GoTo - custom button in the content text
//****************************************************************
function GoTo(slide) {
	try {
		
		if (slide==15 || slide==16) {
			// Next button on "Playrooms" skips to the end, so the end "Back" button must go back to Playrooms in this case...
			ChangePreviousButtonFlow(19,16);
			}
		
		if (slide==16) {
			// if the "Next" button clicked on the "Staying the night" (slide 14), add a new "back" button on slide 16 to skip the PICU slide...
			ChangePreviousButtonFlow(16,14);
			}
			
		// if the "Go home" option is picked (slide 17), add a new "back" button on slide 17 to skip the night slides...
		if (slide==17) {
			ChangePreviousButtonFlow(17,13);
			}
			
		$("#DetailSlides").cycle(slide);
		
		}
	catch (error) {
		alert( "GoTo: " + error.description );
		}
}


//****************************************************************
// ChangePreviousButtonFlow
//****************************************************************
function ChangePreviousButtonFlow( slideToChage, slideToGo ) {
	try {
	/*
		$(".slide_"+slideToChage+" .previousButton").addClass("previousButtonOriginal").hide();
		var spanish = $(".slide_content").hasClass("slide_content_spanish") ? "_spanish" : "";
		$('<span class="button previousButton"><img border="0" alt="back" src="img/button_back' + spanish + '.gif"/></span>').insertAfter(".slide_"+slideToChage+" .previousButton").click(function(){
			// set new slide target
			$('#DetailSlides').cycle(slideToGo);
			// return everything to normal after the clcik
			$(this).remove();
			$(".slide_"+slideToChage+" .previousButtonOriginal").show();
			});	
		*/
		$(".slide_"+slideToChage+" .previousButtonTemp").remove();
	
		$(".slide_"+slideToChage+" .previousButton").removeClass("previousButton").addClass("previousButtonOriginal").hide();
		var spanish = $(".slide_content").hasClass("slide_content_spanish") ? "_spanish" : "";
		$('<span class="button previousButtonTemp"><img border="0" alt="back" src="img/button_back' + spanish + '.gif"/></span>').insertAfter(".slide_"+slideToChage+" .previousButtonOriginal").click(function(){
			// set new slide target
			$('#DetailSlides').cycle(slideToGo);
			// return everything to normal after the click
			$(this).remove();
			$(".slide_"+slideToChage+" .previousButtonOriginal").removeClass("previousButtonOriginal").addClass("previousButton").show();
			});	
	
	
		
		}
	catch (error) {
		alert( "ChangePreviousButtonFlow: " + error.description );
		}
}		



//****************************************************************
// AddCallouts
//****************************************************************
function AddCallouts() {
	try {
		
		$(".slide_content .callout").each(function(){
									
			// CREATE A CALLOUT INSIDE EACH .callout span
			$(this).prepend( "<div class='callout_popup'><div class='callout_popup_content'>" + $(this).attr("title") + "</div></div>" ).removeAttr("title");
			//$( "<div class='callout_popup'><div class='callout_popup_content'>" + $(this).attr("title") + "</div></div>" ).insertBefore(this);
			
			// MOUSE CALLOUTS BY DEFAULT
			$(this).children(".callout_popup").hide();
			
			// MOUSE OVER
			$(this).hover(
				function () {
					if ($.browser.msie) {
						// IE (even v8!?! can't handle fadein/out animation when there is png with transparency
						$(this).children(".callout_popup").show().css({"margin-left":"-275px"});
						}
					else {
						$(this).children(".callout_popup").show().animate({ opacity: 1, marginLeft: "-275px" }, 200 );
						}
					}, 
				function () {
					$(this).children(".callout_popup").css({"margin-left":"-265px"}).hide();
					}
				);
		
			});
		
		}
	catch (error) {
		alert( "AddCallouts: " + error.description );
		}
}


