﻿$(document).ready( function() {
	
	
//******************************** jQuery Cycle Initialization for Kentucky's Scrapbook *****************************************
//
//
//Build the control panel and attach the jQuery Cycle plugin to the Kentucky's Scrapbook and Kentucky Spotlight.	
//Create image navigation and control panel
	$('.homeFlickrPhotos ul').after('<div id="controlPanelScrapbook">');
	
//Build the control panel for Scrapbook and Spotlight
	var $prev = "<a href=\"#\" id=\"prevImgScrapbook\"><img src=\"/SiteCollectionImages/homepage/prevbutton.png\" alt=\"Go to previous image\" border=\"0\" /></a>";
	var $play = "<a href=\"#\" id=\"playImgScrapbook\"><img src=\"/SiteCollectionImages/homepage/playbutton.png\" alt=\"Play slideshow\" border=\"0\" /></a>";
	var $pause = "<a href=\"#\" id=\"pauseImgScrapbook\"><img src=\"/SiteCollectionImages/homepage/pausebutton.png\" alt=\"Pause slideshow\" border=\"0\" /></a>";
	var $next = "<a href=\"#\" id=\"nextImgScrapbook\"><img src=\"/SiteCollectionImages/homepage/nextbutton.png\" alt=\"Go to next image\" border=\"0\" /></a>"
	$('#controlPanelScrapbook').append($prev).append($play).append($pause).append($next);
	

//Attach Play and Pause functionality to control buttons
	$('#playImgScrapbook').click( function() {
		$('#playImgScrapbook').hide();
		$('#pauseImgScrapbook').show();
		$('.homeFlickrPhotos ul').cycle('resume');
		return false;
	});
	$('#pauseImgScrapbook').click( function() {
		$('#pauseImgScrapbook').hide();
		$('#playImgScrapbook').show();
		$('.homeFlickrPhotos ul').cycle('pause');
		return false;
	});

 
//Attach opacity to control panel via jQuery for ease and consistency, and set the initial opacity
//DON'T delete this. We may repurpose it.
	/*$('#controlPanel').hover( function() {
			$(this).fadeTo(0,1);
		}, function() {
			$(this).fadeTo(0,0.4);
	});
	$('#controlPanel').fadeTo(0,0.4);*/

			
//Set Cycle customizations
	$('.homeFlickrPhotos ul').cycle({ 
		fx:    'fade', 
		speed: 500,
		timeout: 7000, 
		next: '#nextImgScrapbook',
		prev: '#prevImgScrapbook'
	 });
	 
	// facebox
 	 	jQuery(document).ready(function($) {
  		$('a[rel*=facebox]').facebox()
}) 
	
	//apply accordion plugin
    $(".accordion").accordion();

	//apply tabs plugin
	$("#tabs").tabs({ fx: { opacity: 'toggle' }
	
	
	});

});

// jcarousel auto-scroller  

function mycarousel_initCallback(carousel)
{
 // Disable autoscrolling if the user clicks the prev or next button.
 carousel.buttonNext.bind('click', function() {
 carousel.startAuto(0);
 });

 carousel.buttonPrev.bind('click', function() {
 carousel.startAuto(0);
 });

 // Pause autoscrolling if the user moves with the cursor over the clip.
 carousel.clip.hover(function() {
 carousel.stopAuto();
 }, function() {
 carousel.startAuto();
 });
};

jQuery(document).ready(function() {
 jQuery('#special').jcarousel({
 auto: 0,
 wrap: 'last',
 scroll:1,
 initCallback: mycarousel_initCallback
 });
});


//******************************** jQuery Show/Hide Initialization *****************************************
//
//
$(document).ready(function() {

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='Show';
var hideText='Hide';

// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'</a>');

// hide all of the elements with a class of 'toggle'
$('.toggle').hide();

// capture clicks on the toggle links
$('a.toggleLink').click(function() {

// change the link depending on whether the element is shown or hidden
$(this).html ($(this).html()==hideText ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').toggle('slow');

// return false so any link destination is not followed
return false;

});
});


