// Location: Chapters5
$().ready(function(){
	
	// Home Page slide show
	// Append controls and initialize Cycle plugin
	$("#home-slider").cycle({ 
			timeout: 8000,
			pager:  '#slider-nav', 
			pagerAnchorBuilder: function(idx, slide) { 
			    // return selector string for existing anchor 
				return '#slider-nav li:eq(' + idx + ') a'; 
			}
		});
		// Stop when a slide is clicked	
		$('#slider-nav a').click(function(){
			$("#home-slider").cycle('stop');
		});	
		
	// Redirects for select "jump" lists
	$("select.jumplist").change(function(){
		if($(this).val() != '') {
			window.location = $(this).val();
		}
	});
	
	// Video overlays
	$(".video-link").fancybox();
	
	$(".video-slider").cycle({
		fx:'scrollHorz', 
		timeout:0,
		next: '.video-next',
		prev: '.video-prev'
	});
	
	
	// Open external links in a new window
	$("a[href^=http]").each(function() {
		if(this.href.indexOf(location.hostname.replace(/www./gi, "")) == -1) {
			$(this).click(function() { window.open(this.href, "_blank"); return false; });
		}
	});
	
	// Form field titles as prompts
	// Display prompts as values using Labelify plugin 
	$('input[type="text"]').labelify();
	
});
