
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() {
	var offset = $("#sidebar").offset();
	var topPadding = 15;
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset.top) {
			$("#sidebar").stop().animate({
				marginTop: $(window).scrollTop() - offset.top + topPadding
			});
		} else {
			$("#sidebar").stop().animate({
				marginTop: 0
			});
		};
	});
});


//<![CDATA[
$(document).ready(function(){
	$("a.anchorLink").anchorAnimate();
	
	$(".slide-down").hide();
	$(".jquery-slider").click(function() {
		var visible = $(".slide-down:visible").length;
		if(visible == 0) {
			$(".slide-down").show();
		} else {
			$(".slide-down").hide();
		}
	});
					   

	$("#jquery_jplayer_1").jPlayer({
		ready: function () {
			$(this).jPlayer("setMedia", {
				mp3: "filer/semlor-i-advent.mp3"
			}).jPlayer("play");
		},
		ended: function (event) {
			$(this).jPlayer("play");
		},
		swfPath: "js/jplayer",
		supplied: "mp3"
	});
});
//]]>
