    $(document).ready(function(){
		//Prayertable
		var PrayerTable = $("#xhanch_my_prayer_time").detach();
		PrayerTable.prependTo("#content");
		
		//menu
		$(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 });

		//featured
        $("#featured").minitabs('slow', 'fade');
		
		//links
		$('#sidebar .widget li a').hover(function() { //mouse in
			$(this).animate({ paddingLeft: '15px' }, 200);
		}, function() { //mouse out
			$(this).animate({ paddingLeft: 3 }, 200);
		});
		
		//rss
		$('#rss').hover(function() { //mouse in
			$(this).animate({ top: 0 }, 200);
		}, function() { //mouse out
			$(this).animate({ top: '-20' }, 200);
		});
		
		/*
		//Sticky sidebar (the categories)
		function sticky_relocate() {
			var window_top = $(window).scrollTop();
			var div_top = $('#sticky-anchor').offset().top;
			
			if (window_top > div_top)
				$('#sticky').addClass('stick')
			else
				$('#sticky').removeClass('stick');
		}
		
		$(function() {
		  $(window).scroll(sticky_relocate);
		  sticky_relocate();
		});
		*/
		
		//Under kategorier
		$('li#categories-3 ul > li.cat-item').has('.children').addClass('CategoryHasChildren').bind('click', function() {
			$( this ).toggleClass('active');
			$( this ).find('.children').slideToggle('slow');
			return false; //stops page loadig
		}).find('.children').hide('slow');
		
		$('.children li a').click( function() {
			$( this ).closest('ul').closest('li').unbind('click');
			return true;
		});

		//Remove the comment box on page "Skicka din fraga"
		if (document.location.href == "http://fatwa.se/?page_id=4541")
			$("#postmeta").remove();
			
		var intervalID = setInterval('rotate()',5500);
			
		$("#featured").hover(function() {
			$("#featured div").addClass('RotatorNotActive');
			clearInterval(intervalID);
		}, function(){
			$("#featured div").removeClass('RotatorNotActive');
			intervalID = setInterval('rotate()',5500);
			rotate();
		});
		
		/*
		$("ul#slide2 li").click(function() {
			var divID = $(this).find('a').attr('href');
			$(divID).css({opacity: 1.0});
		});
		*/
		
    });
	
	function rotate() {
		//Get the first image
		var current = ($('div#featured div.show') ?  $('div#featured div.show') : $('div#featured div:first'));
		
	    if ( current.length == 0 )
			current = $('div#featured div:first');
			
		//Get next image, when it reaches the end, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#featured div:first') : current.next()) : $('div#featured div:first'));
		
		//The right side slider
		$("#slide2 li a").removeClass('current');
		$("ul#slide2 li a[href='#"+next.attr('id')+"']").addClass('current');
		
		//Set the fade in effect for the next image, the show class has higher z-index
		next.css({opacity: 0.0, display: 'block'}).animate({opacity: 1.0}, 1500).addClass('show');
		
		//Hide the current image
		current.animate({opacity: 0.0}, 1500).css({display: 'none'}).removeClass('show');
	}
	
	//kedua
	jQuery.fn.topLink = function(settings) {
		settings = jQuery.extend({
			min: 1,
			fadeSpeed: 200,
			ieOffset: 50
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = $(this);
			el.css('display','none'); //in case the user forgot
			$(window).scroll(function() {
				if(!jQuery.support.hrefNormalized) {
					el.css({
						'position': 'absolute',
						'top': $(window).scrollTop() + $(window).height() - settings.ieOffset
					});
				}
				if($(window).scrollTop() >= settings.min)
				{
					el.fadeIn(settings.fadeSpeed);
				}
				else
				{
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};
	
	$(document).ready(function() {
		$('#top-link').topLink({
			min: 400,
			fadeSpeed: 500
		});
		//smoothscroll
		$('#top-link').click(function(e) {
			e.preventDefault();
			$.scrollTo(0,500);
		});
	});

