(function(jQuery){
	if ( jQuery().jScrollPane ) {
   		jQuery('#content').jScrollPane();
	}

	jQuery.rotate = function() {
		//Get the first image
		var current = (jQuery('div.rotator ul li.show')?  jQuery('div.rotator ul li.show') : jQuery('div.rotator ul li:first'));

	    if ( current.length == 0 ) current = jQuery('div.rotator ul li:first');

		//Get next image, when it reaches the end, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? jQuery('div.rotator ul li:first') :current.next()) : jQuery('div.rotator ul li:first'));

		//Un-comment the 3 lines below to get the images in random order

		//var sibs = current.siblings();
	    //var rndNum = Math.floor(Math.random() * sibs.length );
	    //var next = jQuery( sibs[ rndNum ] );


		//Set the fade in effect for the next image, the show class has higher z-index
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 2000);

		//Hide the current image
		current.animate({opacity: 0.0}, 2000)
		.removeClass('show');

	};

	jQuery.theRotator = function() {
		//Set the opacity of all images to 0
		jQuery('div.rotator ul li').css({opacity: 0.0});

		//Get the first image and display it (gets set to full opacity)
		jQuery('div.rotator ul li:first').css({opacity: 1.0});

		//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
		setInterval(jQuery.rotate,10000);

	}

	jQuery.theRotator();

	jQuery('a[title="Gallery"]').bind('click', function(e){
		e.preventDefault();
		jQuery('#gallery a:first').trigger('click');
	});
	jQuery('a[rel^="gallery"]').prettyPhoto({
		animation_speed: 'fast', /* fast/slow/normal */
					slideshow: 5000, /* false OR interval time in ms */
					autoplay_slideshow: false, /* true/false */
					opacity: 0.80, /* Value between 0 and 1 */
					show_title: true, /* true/false */
					allow_resize: true, /* Resize the photos bigger than viewport. true/false */
					default_width: 500,
					default_height: 344,
					counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
					theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
					horizontal_padding: 20, /* The padding on each side of the picture */
					overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
					keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
					social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' /* html or false to disable */
	});


})(jQuery);

