function theRotator() {
	$('#bakgrund_rotation ul li').css({opacity: 0.0});
	
	$('#bakgrund_rotation ul li:first').css({opacity: 1.0});
		
	// intervall för rotation
	setInterval('rotate()',6000);
	
}

function rotate() {	
	var current = ($('#bakgrund_rotation ul li.show')?  $('#bakgrund_rotation ul li.show') : $('#bakgrund_rotation ul li:first'));

    if ( current.length == 0 ) current = $('#bakgrund_rotationul li:first');

	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#bakgrund_rotation ul li:first') :current.next()) : $('#bakgrund_rotation ul li:first'));
	
	//ta bort kommentar för slumpning
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};



$(document).ready(function() {		
	theRotator();
	$('#bakgrund_rotation').fadeIn(1000);
    $('#bakgrund_rotation ul li').fadeIn(1000); // för IEs skull

	$('.portal_navi img').hover( function () {
			$(this).attr("src", $(this).attr('src').replace(/0.png/, '1.png'));
	},
	
	function () {
			$(this).attr("src", $(this).attr('src').replace(/1.png/, '0.png'));
	}
	);

		
	
	
	(function ($) {
	if (!$) return;
	$.fn.extend({
	    fixPNG: function(sizingMethod, forceBG) {
	            if (!($.browser.msie)) return this;
	            var emptyimg = "blank.gif"; 
	            sizingMethod = sizingMethod || "scale";
	            this.each(function() {
	                    var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"),
	                            imgname = (isImg) ? this.src : this.currentStyle.backgroundImage,
	                            src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
	                    this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
	                    if (isImg) this.src = emptyimg;
	                    else this.style.backgroundImage = "url(" + emptyimg + ")";
	            });
	            return this;
	    }
	});
	})(jQuery);
});
