jQuery.fn.anchorAnimate = function(settings){

 	settings = jQuery.extend({
		speed : 1100
	}, 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;
		})
	})
}

$(document).ready(function(){
    $("#navigation").each(function(){
		$(this).hover(function(){
			$(this).animate({width: "229px"}, {queue:false, duration:400});
		},function() {
			$(this).animate({width: "57px"}, {queue:false, duration:400});
		});
	});

	setTimeout(function() {
	        $("#navigation").animate({width: "57px"}, {queue:false, duration:800});
	    }, 1000);
	
	$("a.anchorLink").anchorAnimate();
	
	$(function() {

		// select the thumbnails and make them trigger our overlay
		$("#thumbs a").overlay({

			// each trigger uses the same overlay with the id "gallery"
			target: '#gallery',

			// optional exposing effect
			expose: '#b8d63a'

		// let the gallery plugin do its magic!
		}).gallery({

			// the plugin accepts its own set of configuration options
			speed: 800
		});

	});
	
});

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

