$(document).ready(function() {
	$("a.anchorLink").anchorAnimate();
	
    //Close button:
	
	$(".close").click(
		function () {
			$(this).parent().fadeTo(400, 0, function () { // Links with the class "close" will close parent
				$(this).slideUp(400);
			});
			return false;
		}
	);
	
});

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;
		})
	})
}

function move(id){
	if($('#'+id).length){
		var speed = 100;
		var destination = $('#'+id).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, speed);
	}
	
  	return false;
}

function moveTo(position){
	//var scrollTop = $(window).scrollTop();
	var speed = 100;
	var destination = position;
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, speed);
  	return false;
}
