$(document).ready(
	function() {
	
	// Droppy Settings
		$('#page-nav').droppy({
			speed: 250,
			hideSpeed: 500
		});
	
	// Homepage slideshow
		if ($('#slideshow-home .slides').length) {
			$('#slideshow-home .slides').cycle({ 
				fx: 'fade',
				random: 1,
				pause: 1,
				timeout: 4000
			});
		};

	// Entry slideshows
		if ($('.entry .slides').length) {
			$('.slides').each(function(){
				var parent = this.parentNode;
				var $pager = $('<ul class="pager"></ul>').insertAfter(this);
				$(this).before('<div class="photo-credits credits"></div>').cycle({
					fx: 'fade',
					speed: 'normal',
					timeout: 0,
					before: onBefore,
					after: onAfter,
					pager: $pager,
					//pagerEvent: 'mouseover', // click event returns true if this is set
					pagerAnchorBuilder: function(idx, slide) { 
						var src = $('img',slide).attr('src'); 
						var alt = $('img',slide).attr('alt');
						return '<li><a href="#" title="' + alt + '"><img src="' + src + '" alt="' + alt + '" height="50" /></a></li>';
					}
				});
				// Center slides in container
				function onBefore(curr,next,opts) {
					var $slide = $(next);
					var w = $slide.outerWidth();
					var h = $slide.outerHeight();
					$slide.css({ // use height and width from CSS
						marginTop: (320 - h) / 2,
						marginLeft: (375 - w) / 2
					});
				};
				function onAfter(idx,slide) {
					var byline = $('.byline',slide).html();
					if ($('.byline',parent).length) {
						$('.photo-credits',parent).html('<span>' + byline + '</span>');
					};
				};
			});
		};

	// Project Portfolio selector top menu
		if ($('#project-slider').length) {
			$('#project-slider').tabs({ fx: { opacity: 'toggle', duration: 'normal' } });
			$('#project-slider').bind('tabsshow', function(event, ui) { location.hash = ui.tab.hash; });
			$("#project-slider").jCarouselLite({
				btnNext: ".next",
				btnPrev: ".prev",
				circular: false,
				mouseWheel: true,
				visible: 5
			});
		};
		
	// Company History selector top menu
		if ($('#history-slider').length) {
			$('#history-slider').tabs({ fx: { opacity: 'toggle', duration: 'normal' } });
			$('#history-slider').bind('tabsshow', function(event, ui) { window.location.hash = ui.tab.hash; window.scroll(0,0); });
		};
		
	// Print Link
		if ($('.print-button').length) {
			$('.print-button').click(function() {
				window.open(this.href,'printable','height=440,width=700,scrollbars=yes,menubar=yes');
				return false;
			});
			
		};

	// jScrollPane
	//	if ($('.scrollbar').length) {
	//		$('.scrollbar').jScrollPane({showArrows:true});
	//	};

	});