$(function() {
	$(".slideshow").scrollable({ vertical: false, size: 1,
		onBeforeSeek: function() {  
		   this.getItems().fadeTo(75, 0.1);          
		}, 
		onSeek: function() {  
		   this.getItems().fadeTo(150, 1);  
		} 
	}).autoscroll({autoplay: true, interval: 5000}).circular(); 
	
	$('.bio').hide();
	$('.image').overlay({
		onBeforeLoad: function() {
			$("#overlayContent").html(this.getTrigger().parent().html());
			$("#overlayContent .bio").show();
			
		},
		onLoad: function() {
			aHeight = $("#overlayContent .bio").height()+20;
			if (aHeight < 200) { aHeight = 200; } 
			$("#overlay1").height(aHeight);
		}
	});
	
	$('.mailingList').overlay({
		onLoad: function() {
			aHeight = $("#overlayContent .bio").height()+20;
			if (aHeight < 200) { aHeight = 200; } 
			$("#overlay1").height(aHeight);
			$("#mailingFname").focus();
		}
	});
	
	$("#mailingListSignup").submit(function() {
		$.post('/home/subscribe_mailchimp', { 'fname': $("#mailingFname").val(), 'lname': $("#mailingLname").val(), 'email': $("#mailingEmail").val() }, 		function(data) {
			if (data.success == 1) {
				$("#mailingMessage").fadeOut(500).html("Congratulations! Please check your email to confirm.").fadeIn(3000);
				$("#mailingFname").val("");
				$("#mailingLname").val("");
				$("#mailingEmail").val("");
			} else {
				$("#mailingMessage").fadeOut(500).html("Uh oh! "+data.error).fadeIn(3000);
			}
		}, "json");
		return false;
  });
	
	positionFooter(); 
	function positionFooter(){
		$("#footer").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#footer").height())+"px"})	
	}
	$(window)
		.scroll(positionFooter)
		.resize(positionFooter)
		
	$('.pane').hide();
	$('.pane:first').show();
	$('#navigation a').click(function() {
		var id = $(this).attr('id');
		$('.pane:visible').hide();
		$('#'+id+'Pane').show();
	});
	$('#navigation ul li').click(function() {
		var id = $(this).attr('id');
		$('.pane:visible').hide();
		$('#'+id+'Pane').show();
	});
	$('.internal').click(function() {
		var id = $(this).attr('theid');
		$('.pane:visible').hide();
		$('#'+id+'Pane').show();
	});
	
	
});