// jump menu for changing options
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


if(photos) {
	var image_no = 1;
	var image_end = '.jpg';
	var image_src;
	var button_click = true;
	
	// preload images
	for(var i = 1; i<total_img; i++)
	{
	
		image_src = image_path + image_no + image_end
	$("<img>").attr("src", image_src);
	}
}

$(document).ready(function() {
	
	
	//************* photo slideshow ******************
	
	
	if(photos) {
		$("#hidden_photos").hide();
		
		// set photo numbers
		function set_photo_details () {
			photo_details_text = image_no + '/' + total_img + ' ';
			$("#photo_details").text(photo_details_text);
		
		}
		
		// set the source of the photo
		function set_photo_src () {
			image_src = image_path + image_no + image_end; 
			$("#exhibition_photo img").attr("src", image_src);
		}
		
		
		// set the photo credit and caption
		function set_photo_credit () {
			
			
			
			if (photographer_credit[image_no-1]!='' || photo_caption[image_no-1]!='') {
			
			
				if (photo_caption[image_no-1]!='' && photographer_credit[image_no-1]!='') {
						$("#photo_credit").text(photo_caption[image_no-1] + " Photograph " + photographer_credit[image_no-1] + ".");
				} else if (photo_caption[image_no-1]!='' && photographer_credit[image_no-1]=='') {
						$("#photo_credit").text(photo_caption[image_no-1]);
				} else if (photo_caption[image_no-1]=='' && photographer_credit[image_no-1]!='') {
						$("#photo_credit").text("Photograph " + photographer_credit[image_no-1] + ".");
				}  
			} else {
				$("#photo_credit").text(" ");
			}
					
		}
		
		
		
		// set initial photo details
		set_photo_details();
		set_photo_src();
		set_photo_credit();
		
		$("#next").click(function(){ 
			image_no ++;
			
			if (image_no > total_img) {
				image_no = 1;
			} 
			set_photo_src();
			set_photo_details();
			set_photo_credit();
		});
		
		$("#previous").click(function(){ 

			image_no --;
			
			if (image_no < 1) {
				image_no = total_img;
			} 
			set_photo_src();
			set_photo_details();
			set_photo_credit();
		});
	
	}
	
	// *************************** toggle content ****************************
	// choose text for the show/hide links
	var showText="Show All Dates";
	var hideText="Show Notice";
	var showAll="View All";
	var hideAll="Hide All";
	var showNames="Show Names";
	var hideNames="Hide Names";
	
	
	
	
	
	
	
	// hide CSS border on top toggle
	$(".toggle:first").css({'border-top-style': 'none'});
	
	
	
	
	
	if (notice_status=='off') {
		$("#notice").hide();
		$("#tour_schedule .dynamic_content").hide();
		$("#toggle_text").text(hideText);
		}
	if (notice_status=='on') {
		$(".dynamic_content").hide();
		}
		
	
	
	// rollover for toggle holder
	
	
	$("div.toggle").click(function(){
				
			 if ($(this).next(".dynamic_content").is(":hidden")) {
				$("#tour_schedule .dynamic_content").slideUp("fast");
				$(this).next(".dynamic_content").slideDown("slow");
				
				// check if top toggle with text and image change
       			if ($(this).is(":contains('TOUR SCHEDULE')")) {
					$("#notice").fadeOut("slow");
					//image_src='/images/arrow_up.gif';
					//$("#arrow_image").attr("src", image_src);
					$("#toggle_text").text(hideText);
					
				}
				
			} else {
				$(this).next(".dynamic_content").slideUp("slow");
				
					// check if top toggle with text and image change
       				if ($(this).is(":contains('TOUR SCHEDULE')")) {
					
					//image_src='/images/arrow_down.gif';
					//$("#arrow_image").attr("src", image_src);
					$("#toggle_text").text(showText);
					$("#tour_schedule .dynamic_content").slideUp("fast");
					$("#notice").fadeIn("slow");
					
				}
			}
	});
	
	
		
	$("a.toggleAll").click(function(){
		
		if ($(this).text()==showAll) {
			$(this).text(hideAll);
			$("a.toggle").text(hideText);
			$(".dynamic_content").slideDown("slow");
			}
		else {
			$(this).text(showAll);
			$("a.toggle").text(showText);
			$(".dynamic_content").slideUp("slow");
		}
	});
	
	// toggle names on the 17s photos
	$("#linkPanel").click(function(){
		
		if ($(this).text()==showNames) {
			$(this).text(hideNames);
			$("a.toggle").text(hideNames);
			$("#names").slideDown("slow");
			}
		else {
			$(this).text(showNames);
			$("a.toggle").text(showNames);
			$("#names").slideUp("slow");
		}
	});

});
