$(document).ready(function(){
	if ($("div").index($('#sectionContent3961828')) < $("div").index($('#sectionContent3954840'))) {
		$('#sectionContent3961828').appendTo('#content'); // Blog widget
		$('#sectionContent3954840').appendTo('#content'); // News widget
	} else {
		$('#sectionContent3954840').appendTo('#content'); // News widget
		$('#sectionContent3961828').appendTo('#content'); // Blog widget
	}
	
	function browserEvaluation() {
		if ($.browser.msie && (parseInt($.browser.version, 10) == "6" || parseInt($.browser.version, 10) == "7" || parseInt($.browser.version, 10) == "8")) {
			return "crap";
		} else {
			return "gold";
		}
	}
	function fadeSpriteHover(e, bgPosOut, bgPosOver, opacityFrom, opacityTo, ms, hoverState, overrideIgnoreIE) {
		// Sample usage: fadeSpriteHover("h1#mainTitle a", "0 0", "0 -70px", 0.8, 1.0, 75, "brighter", false);
		if (browserEvaluation() == "crap" && overrideIgnoreIE === false) return; // IE's early support for opaque, transparent PNGs is too weak
		if (hoverState == "brighter") {
			$(e).hover(
				function () {
					$(e).stop().css({"background-position":bgPosOver,"opacity":opacityFrom}).fadeTo(ms*2, opacityTo);
				},
				function () {
					$(e).stop().css({"background-position":bgPosOver,"opacity":opacityTo}).fadeTo(ms, opacityFrom, function() { $(e).css({"background-position":bgPosOut,"opacity":opacityTo}); });
				}
			);
		}
		if (hoverState == "darker") {
			$(e).hover(
				function () {
					$(e).stop().css({"background-position":bgPosOut,"opacity":opacityFrom}).fadeTo(ms, opacityTo, function() { $(e).css({"background-position":bgPosOver,"opacity":opacityTo}); });
				},
				function () {
					$(e).stop().css({"background-position":bgPosOut,"opacity":opacityTo}).fadeTo(ms, opacityFrom, function() { $(e).css({"background-position":bgPosOut,"opacity":opacityFrom}); });
				}
			);
		}
	}
	fadeSpriteHover("h1#siteTitle a", "0 0", "0 -180px", 1.0, 0.9, 100, "darker", false);
	
	fadeSpriteHover("a#navigationBottom-moduleLink9259337", "0 10px", "0 -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink9247327", "-94px 10px", "-94px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink9247328", "-204px 10px", "-204px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink10299042", "-358px 10px", "-358px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink9349556", "-529px 10px", "-529px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink9361556", "-649px 10px", "-649px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink9361563", "-748px 10px", "-748px -51px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("a#navigationBottom-moduleLink10930694", "-883px 10px", "-883px -51px", 0.4, 1.0, 100, "brighter", false);
	
	fadeSpriteHover("#sectionContent3883043 a#moduleLink9391266", "7px -39px", "-157px -39px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3883043 a#moduleLink9391276", "7px -88px", "-157px -88px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3883043 a#moduleLink9391278", "7px -132px", "-157px -132px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3883043 a#moduleLink9391286", "7px -179px", "-157px -179px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3936689 a#moduleLink3936689a", "-156px -291px", "-320px -291px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3936689 a#moduleLink3936689b", "7px -340px", "-157px -340px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent3936689 a#moduleLink3936689c", "7px -386px", "-317px -386px", 0.8, 1.0, 100, "brighter", false);
	fadeSpriteHover("#sectionContent4304289 a#moduleLink4304289", "1px -505px", "-163px -505px", 0.8, 1.0, 100, "brighter", false);
	
	fadeSpriteHover("#sectionContent4022051 #moduleContent11122675 img.albumPromoThumb, #sectionContent4617673 #moduleContent11129030 img.albumPromoThumb", "", "", 1.0, 0.8, 150, "darker", true);
	fadeSpriteHover("#sectionContent4022051 #moduleContent11122675 img.affiliateBadge, #sectionContent4617673 #moduleContent11129030 img.affiliateBadge", "", "", 1.0, 0.8, 150, "darker", false);
	
	fadeSpriteHover("#footerTopLink", "-137px -31px", "-227px -31px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavHome", "0 7px", "0 -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavNews", "-60px 7px", "-60px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavReviews", "-131px 7px", "-131px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavCalendar", "-235px 7px", "-235px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavSongs", "-344px 7px", "-344px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavBlog", "-425px 7px", "-425px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavPhotos", "-495px 7px", "-495px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerNavStore", "-583px 7px", "-583px -34px", 0.4, 1.0, 100, "brighter", false);
	fadeSpriteHover("#footerAlleycatLink", "-704px 5px", "-1005px 4px", 0.4, 1.0, 150, "brighter", false);
		
	function fadePartnerSpriteHover(iconElement, linkElement, iconBgPosOver, iconBgPosOut, linkBgPosOver, linkBgPosOut, fromOpacity, toOpacity, ms) {
		// Sample usage: fadePartnerSpriteHover("#footerFacebookIcon", "#footerFacebookLink", "-300px -93px", "0 -93px", "-338px -93px", "-38px -93px", 0.4, 1.0, 100);
		if (browserEvaluation() == "crap") return; // IE's early support for opaque, transparent PNGs is too weak
		$(iconElement).hover(
			function () {			
				$(this).data("state", "on");
				clearTimeout($(this).data('partnerElementStatusCheck'));
				if ($(linkElement).data("state") !== "on") {
					$(iconElement).css({"background-position":iconBgPosOver});
					$(linkElement).stop().css({"background-position":linkBgPosOver,"opacity":fromOpacity}).fadeTo(ms*2, toOpacity);
				}
				$(linkElement).data("state", "off");
			},
			function () {
				var partnerElementStatusId = setTimeout(function(){
					if ($(linkElement).data("state") !== "on") {
						$(iconElement).css({"background-position":iconBgPosOut});
						$(linkElement).stop().css({"background-position":linkBgPosOver,"opacity":toOpacity}).fadeTo(ms, fromOpacity, function() { $(linkElement).css({"background-position":linkBgPosOut,"opacity":toOpacity}); });
						$(iconElement).data("state", "off");
					}
				}, 5);
				$(this).data('partnerElementStatusCheck', partnerElementStatusId);
			}
		);
		$(linkElement).hover(
			function () {
				$(this).data("state", "on");
				clearTimeout($(this).data('partnerElementStatusCheck'));
				if ($(iconElement).data("state") !== "on") {
					$(this).stop().css({"background-position":linkBgPosOver,"opacity":fromOpacity}).fadeTo(ms*2, toOpacity);
					$(iconElement).css({"background-position":iconBgPosOver});
				}
				$(iconElement).data("state", "off");			
			},
			function () {
				var partnerElementStatusId = setTimeout(function(){
					if ($(iconElement).data("state") !== "on") {
						$(linkElement).stop().css({"background-position":linkBgPosOver,"opacity":toOpacity}).fadeTo(ms, fromOpacity, function() { $(linkElement).css({"background-position":linkBgPosOut,"opacity":toOpacity}); });
						$(iconElement).css({"background-position":iconBgPosOut});
						$(linkElement).data("state", "off");
					}
				}, 5);
				$(this).data('partnerElementStatusCheck', partnerElementStatusId);
			}
		);
	}
	
	fadePartnerSpriteHover("#footerFacebookIcon", "#footerFacebookLink", "-300px -93px", "0 -93px", "-338px -93px", "-38px -93px", 0.4, 1.0, 100);
	fadePartnerSpriteHover("#footerTwitterIcon", "#footerTwitterLink", "-300px -130px", "0 -130px", "-338px -130px", "-38px -130px", 0.4, 1.0, 100);
	fadePartnerSpriteHover("#footerFeedbackIcon", "#footerFeedbackLink", "-300px -169px", "0 -169px", "-338px -169px", "-38px -169px", 0.4, 1.0, 100);

	fadeSpriteHover(".sectionThumb a img", "", "", 1.0, 0.8, 150, "darker", true);
	fadeSpriteHover(".sectionThumb2 a img", "", "", 1.0, 0.8, 150, "darker", true);
	fadeSpriteHover(".sectionThumbNoBorder a img", "", "", 1.0, 0.8, 150, "darker", true);
	
	
	// Left nav, second version
	
	function animateLeftNavItem(navItem, expandedItem, startWidth, endWidth) {
		// Sample usage: animateLeftNavItem('#sectionContent5197962 #moduleContent12522307', '#sectionContent5197962 ul li a#moduleLink12522307', '32px', '144px');
		$(expandedItem).click(function() { this.blur(); });
		$(navItem).mouseenter(function() {
			$(expandedItem).animate({ width: endWidth }, { duration: 200, queue: false });
		});
		$(navItem).mouseleave(function() {
			$(expandedItem).animate({ width: startWidth }, { duration: 200, queue: false });
		});
	}
	
	function animateiTunesLogo() {
		var navItem = '#sectionContent5207284 #moduleContent12543370';
		var expandedItem = '#sectionContent5207284 ul li a#moduleLink12543370';
		$(expandedItem).click(function() { this.blur(); });
		$(navItem).mouseenter(function() {
			$(expandedItem).css({ 'background-position': '-320px -293px' });
			$(expandedItem).animate({ width: '110px' }, { duration: 200, queue: false, complete: function() {
				$(expandedItem).css({ 'background-position': '-320px -293px' });
				}
			});
		});
		$(navItem).mouseleave(function() {
			$(expandedItem).animate({ width: '32px' }, { duration: 200, queue: false, complete: function() {
				$(expandedItem).css({ 'background-position': '5px -293px' });
				}
			});
		});
	}
	
	function initLeftNavAnimation() {
		animateLeftNavItem('#sectionContent5197962 #moduleContent12522307', '#sectionContent5197962 ul li a#moduleLink12522307', '32px', '144px');
		animateLeftNavItem('#sectionContent5197962 #moduleContent12522308', '#sectionContent5197962 ul li a#moduleLink12522308', '32px', '144px');
		animateLeftNavItem('#sectionContent5197962 #moduleContent12522345', '#sectionContent5197962 ul li a#moduleLink12522345', '32px', '144px');
		animateLeftNavItem('#sectionContent5197962 #moduleContent12522357', '#sectionContent5197962 ul li a#moduleLink12522357', '32px', '144px');
		animateLeftNavItem('#sectionContent5207284 #moduleContent12543368', '#sectionContent5207284 ul li a#moduleLink12543368', '32px', '110px');
		animateLeftNavItem('#sectionContent5207284 #moduleContent12543369', '#sectionContent5207284 ul li a#moduleLink12543369', '32px', '110px');
		animateiTunesLogo();
		animateLeftNavItem('#sectionContent5215821 #moduleContent12562938', '#sectionContent5215821 ul li a#moduleLink12562938', '32px', '144px');
	}
	
	initLeftNavAnimation();
	
	
	// Left nav, first version
	
	/*if (browserEvaluation() == "crap") {
		// IE early versions seem to slow down with too many hoverIntent functions
		
		// Clearer elements prevent jumpy slide movements
		$('#sectionContent3883043').append('<div class="clearer">&nbsp;</div>');
		$('#sectionContent3936689').append('<div class="clearer">&nbsp;</div>');
		$('#sectionContent4304289').append('<div class="clearer">&nbsp;</div>');
		
		$('#sectionContent3883043 .section').mouseenter(function() {
			$('#sectionContent3883043 ul.content-navigation').slideDown(400, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		});
		
		$('#sectionContent3936689 .section').mouseenter(function() {
			$('#sectionContent3936689 ul').slideDown(300, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		});
		
		$('#sectionContent4304289 .section').mouseenter(function() {
			$('#sectionContent4304289 ul').slideDown(300, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		});
		
		$('#sidebar1').mouseleave(function() {
			$('#sectionContent3883043 ul.content-navigation').slideUp(200, 'easeInOutQuart');
			$('#sectionContent3936689 ul').slideUp(300, 'easeInOutQuart');
			$('#sectionContent4304289 ul').slideUp(300, 'easeInOutQuart');
			var sidebarBgFadeBack = window.setTimeout(function() {
				$('#sidebarBg').css({'opacity':1.0});
			}, 200);
		});
	} else {
		// Clearer elements prevent jumpy slide movements
		$('#sectionContent3883043').append('<div class="clearer">&nbsp;</div>');
		$('#sectionContent3936689').append('<div class="clearer">&nbsp;</div>');
		$('#sectionContent4304289').append('<div class="clearer">&nbsp;</div>');
	
		$('#sectionContent3883043 .section').hoverIntent(function() {
			$('#sectionContent3883043 ul.content-navigation').slideDown(400, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		}, function() {
			//$('#sectionContent3883043 ul.content-navigation').slideUp(400, 'easeInOutQuart');
		});
		
		$('#sectionContent3936689 .section').hoverIntent(function() {
			$('#sectionContent3936689 ul').slideDown(300, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		}, function() {
			//$('#sectionContent3936689 ul').slideUp(300, 'easeInOutQuart');
		});
		
		$('#sectionContent4304289 .section').hoverIntent(function() {
			$('#sectionContent4304289 ul').slideDown(300, 'easeInOutQuart');
			$('#sidebarBg').css({'opacity':0.75});
		}, function() {
			//$('#sectionContent4304289 ul').slideUp(300, 'easeInOutQuart');
		});
		
		$('#sidebar1').hoverIntent(function() {
			//$('#sectionContent4304289 ul').slideDown(300, 'easeInOutQuart');
		}, function() {
			$('#sectionContent3883043 ul.content-navigation').slideUp(400, 'easeInOutQuart');
			$('#sectionContent3936689 ul').slideUp(400, 'easeInOutQuart');
			$('#sectionContent4304289 ul').slideUp(400, 'easeInOutQuart');
			var sidebarBgFadeBack = window.setTimeout(function() {
				$('#sidebarBg').css({'opacity':1.0});
			}, 200);
		});
	}*/
	
	$('#footerTopLink').click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 800);
		return false;
	});
	
	$('<div class="posted-by-author"></div>').insertBefore('.journal-entry-wrapper .journal-entry-tag-post-title span.posted-by');
	$('.journal-read-more-tag a').html('Read more &raquo;');
	$('#comments .caption').html('Comments');
	$('#comments .text').html('There are no comments for this entry.');
	$('<div id="postCommentsFromFB"><div class="vertSpacer1">&nbsp;</div></div>').insertAfter('#comments .caption');
	$('.journal-entry-tag .post-snippet-3').appendTo($('#postCommentsFromFB'));
	$('<div class="footnoteToFB"><p>Prefer not to comment via Facebook? Use the blog comment form below.</p></div>').appendTo($('#postCommentsFromFB'));
	$('#add-comment-area .caption').html('<img title="Post" alt="Post" class="inline-icon" src="/universal/images/core-resources/icons/light/comment.png"/>Post a comment');
	$('#authorName_title').html('Name:');
	$('#authorEmail_title').html('Email address (optional):');
	$('#authorUrl_title').html('Website (optional):');
	$('#body_title').html('Comment:');
	$('<div class="vertSpacer1">&nbsp;</div>').insertAfter('#body_title');
	$('#add-comment-area div:contains("Some HTML allowed:")').show().html('');
	$('#add-comment-area div:contains(" | ")').show().html('');
	$('#postform .footer p span').text('Notify me of follow-up comments via email');
	$('#createPostButton').val('Post comment');
	$('#previewPostButton').val('Preview comment');
	$('#login-form h2.document-title').html('Log in');
	$('#login-form .body').html('<p>All log-in attempts are recorded.</p>Repeated failed attempts will result in account lockout.');
	$('#login-form #submitButton').val('Log in');
	
	if ($('body').attr('id') == undefined) $('#content').addClass('contentGeneral');

});

function mapAuthorIcon(authorDisplayName) {
	var authorAccountName;
	switch(authorDisplayName) {
		case 'Alexander':
			authorAccountName = 'eddie';
			break;
		case 'Jocke':
			authorAccountName = 'jocke';
			break;
		case 'Lars':
			authorAccountName = 'lars';
			break;
		case 'Pen Expers':
			authorAccountName = 'peneditor';
			break;
		default:
			authorAccountName = 'peneditor';
	}
	return authorAccountName;
}

var showAuthorIntervalNews;
var showAuthorIntervalBlog;
var showAuthorCounterNews = 0;
var showAuthorCounterBlog = 0;
var showAuthorMaxAttempts = 6;

function showAuthorIconNews() {
	var authorDivElement = document.getElementById('rss-author-9456892-1');
	var authorIconElement = document.getElementById('rss-date-9456892-1');
	var showAuthorIntervalId = showAuthorIntervalNews;
	var theNewsTimeout;
	function delayThenShow() {
		$(authorIconElement).prepend('<div class="rss-icon-' + mapAuthorIcon(theAuthor) + '"></div>By ' + theAuthor + '<br />');
		$('.rss-icon-' + mapAuthorIcon(theAuthor)).animate({opacity: 1}, 400);
		clearTimeout(theNewsTimeout);
	}
	if (showAuthorCounterNews > showAuthorMaxAttempts) {
		clearInterval(showAuthorIntervalId);
	}
	else if ($(authorDivElement).is(':not(:empty)') && $(authorIconElement).is(':not(:empty)')) {
		var theAuthor = $(authorDivElement).html();
		theNewsTimeout = setTimeout(delayThenShow, 250);
		clearInterval(showAuthorIntervalId);
	}
	showAuthorCounterNews++;
}

function showAuthorIconBlog() {
	var authorDivElement = document.getElementById('rss-author-9456968-1');
	var authorIconElement = document.getElementById('rss-date-9456968-1');
	var showAuthorIntervalId = showAuthorIntervalBlog;
	var theBlogTimeout;
	function delayThenShow() {
		$(authorIconElement).prepend('<div class="rss-icon-' + mapAuthorIcon(theAuthor) + '"></div>By ' + theAuthor + '<br />');
		$('.rss-icon-' + mapAuthorIcon(theAuthor)).animate({opacity: 1}, 400);
		clearTimeout(theBlogTimeout);
	}
	if (showAuthorCounterBlog > showAuthorMaxAttempts) {
		clearInterval(showAuthorIntervalId);
	}
	else if ($(authorDivElement).is(':not(:empty)') && $(authorIconElement).is(':not(:empty)')) {
		var theAuthor = $(authorDivElement).html();
		theBlogTimeout = setTimeout(delayThenShow, 350);
		clearInterval(showAuthorIntervalId);
	}
	showAuthorCounterBlog++;
}

function selectArea(theArea, activeFlag, justLoaded) {
	switch(theArea) {
		case 'Sweden':
			$('div.orderEurope').fadeOut('fast').slideUp('fast');
			$('div.orderUS').fadeOut('fast').slideUp('fast');
			$('div.orderWorld').fadeOut('fast').slideUp('fast');
			if (justLoaded) $('div.orderSweden').slideDown('slow');
			break;
		case 'Europe':
			$('div.orderSweden').fadeOut('fast').slideUp('fast');
			$('div.orderUS').fadeOut('fast').slideUp('fast');
			$('div.orderWorld').fadeOut('fast').slideUp('fast');
			if (justLoaded) $('div.orderEurope').slideDown('slow');
			break;
		case 'US':
			$('div.orderSweden').fadeOut('fast').slideUp('fast');
			$('div.orderEurope').fadeOut('fast').slideUp('fast');
			$('div.orderWorld').fadeOut('fast').slideUp('fast');
			if (justLoaded) $('div.orderUS').slideDown('slow');
			break;
		case 'World':
			$('div.orderSweden').fadeOut('fast').slideUp('fast');
			$('div.orderEurope').fadeOut('fast').slideUp('fast');
			$('div.orderUS').fadeOut('fast').slideUp('fast');
			if (justLoaded) $('div.orderWorld').slideDown('slow');
			break;
		default:
			return false;
	}
	$('a.overFlag').removeClass('overFlag').addClass('outFlag');
	$(activeFlag).removeClass('outFlag').addClass('overFlag');
	$(activeFlag).blur();
	addUrlParam('orderArea', theArea);
}

function addUrlParam(key, val){
	var search = document.location.search;
	var newParam = key + '=' + val, params = '?' + newParam;
	if (search) {
		params = search.replace(new RegExp('[\?&]' + key + '[^&]*'), '?' + newParam);
		if (params === search) {
			params += '&' + newParam;
		} else {
			document.location = document.location.pathname + params;
			return;
		}
	} else {
		document.location = document.location.pathname + params;
		return;
	}
}

// hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

