String.prototype.capitalize = function() {
    return this.charAt(0).toUpperCase() + this.slice(1);
}

$(document).ready(function() {

	$("#navigation a").click(function() {
		anchor = $(this).attr("href");
		$("title").html("Shilf | " + anchor.replace("#","").capitalize());
	}).anchorAnimate({speed : 600});

	$('.slideshow .pictures').each(function() {
		canvasHeight = 386;
		buttonHeight = 138;
		$(this).parent().find(".prev, .next")
			.css("margin-top", (canvasHeight/2)-(buttonHeight/2));		
	}).cycle({ 
		fx:     'scrollHorz', 
		prev:   '.prev', 
		next:   '.next',
		speed:	'500', 
		timeout: 0 
	});
	
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1000
	}, settings);	
	
	return this.each(function() {
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}


