$(document).ready(function(){
    
	function formatText(index, panel) {
		  return index + "";
	    }
    
        $(function () {
        
            $('.anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "Go",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
            });
            
            $("#slide-jump").click(function(){
                $('.anythingSlider').anythingSlider(6);
            });
            
        });
	
	$("#gallery #secondaryContent .anythingSlider ul li a").click(function (event) {
	 event.preventDefault();

	 var href = $(this).attr("href");
	 href = href.substr( href.length-2,2);
	 update($("#primaryContent"),href);
    });

	function update(j,b) {
	  var strReplace = "http://wamuseum.com.au/sydney/gallery/image" + b + ".html";
	  	j.fadeTo(1500, 0.01, function () {		

				j.load(strReplace);
				j.fadeTo(1500, 1);				  
			}
		);
	 // j.load("http://www.museum.wa.gov.au/sydney/gallery/image07.html");
	 //$("#primaryContent dd p").prepend(b);
	  
    }
	
	$("#reading #primaryContent .reviewContainer ul li p a").click(function (event) {
	 event.preventDefault();

	 var href = $(this).attr("href");
	 href = href.substr( href.length-1,1);
	 updateReview($(".review"),href);
    });

	function updateReview(j,b) {
	  var strReplace = "http://wamuseum.com.au/sydney/reading/review" + b + ".html";
	  	j.fadeTo(1500, 0.01, function () {		

				j.load(strReplace);
				j.fadeTo(1500, 1);				  
			}
		);
	 // j.load("http://www.museum.wa.gov.au/sydney/gallery/image07.html");
	 //$("#primaryContent dd p").prepend(b);
	  
    }
	
	
	
	function externalLinks() {
 	if (!document.getElementsByTagName) return;
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) {
 	  var anchor = anchors[i];
 	  if (anchor.getAttribute("href") &&
 	      anchor.getAttribute("rel") == "external")
     	  anchor.target = "_blank";
 	  }
	}
	window.onload = externalLinks;
	
  });


	AudioPlayer.setup("http://wamuseum.com.au/template/style/flash/audio-player/player.swf", {  
		width: "100%",
		transparentpagebg: "yes", 
		leftbg: "CFD2D7",         // Speaker icon/Volume control background
		lefticon: "333333",       // Speaker icon
		voltrack: "F2F2F2",	      // Volume track
		volslider: "333333", 	  // Volume slider
		rightbg: "CFD2D7", 	      // Play/Pause button background
		rightbghover: "ECECEC",   // Play/Pause button background (hover state)
		righticon: "333333",      // Play/Pause icon
		righticonhover: "990000", // Play/Pause icon (hover state)
		loader: "990000", 	      // Loading bar
		track: "F2F2F2", 	      // Loading/Progress bar track backgrounds
		tracker: "B7C5D2", 	      // Progress track
		border: "CCCCCC", 	      // Progress bar border
		skip: "666666", 	      // Previous/Next skip buttons
		text: "333333"            // Text 	
	});
