function RefreshTestimonial($id) {
	var a = $("#testimonial span");
	var b = $id.attr("alt").split("|");
	var c = "";
	for (var i = 0; i < b.length; i++) c += (i < 1 ? "\"" + b[i] + "\"<br />" : "<em>" + b[i] + "</em>");

	if (arguments.length == 1) {
		a.animate({ "opacity" : 0	}, 1000, function() {
			a.html(c);
			a.animate({ "opacity" : 1 }, 1000);
		});
	} else {
		a.css({ "opacity" : 0 });
		a.html(c);
		a.animate({ "opacity" : 1 }, 1000);
	}
}

function SwitchTestimonial() {
	var $activeImage = $("#testimonial img.active");
	var $nextImage = $activeImage.next().length ? $activeImage.next() : $("#testimonial img:first");

	RefreshTestimonial($nextImage);

	$activeImage.animate({
		"opacity" : 0,
		"z-index" : 8
	}, 2000, function() {
		$activeImage.hide();
	});

	$nextImage.show();
	$nextImage.animate({
		"opacity" : 1,
		"z-index" : 9
	}, 2000, function() {
		$activeImage.removeClass();
		$nextImage.addClass("active");
	});
}

function IETestimonial($id) {
	var a = $("#testimonial span");
	var b = $id.attr("alt").split("|");
	var c = "";
	for (var i = 0; i < b.length; i++) c += (i < 1 ? "\"" + b[i] + "\"<br />" : "<em>" + b[i] + "</em>");
	a.html(c);
	$id.css({
		"opacity" : 1,
		"z-index" : 9
	});
}

function InitTestimonial() {
	if ($.browser.msie && $.browser.version < 9) {
		IETestimonial($("#testimonial img.active"));
	} else {
		RefreshTestimonial($("#testimonial img.active"), "init");
		$("#testimonial img.active").animate({ "opacity" : 1 }, 2000);
		setInterval("SwitchTestimonial()", 12000);
	}
}

$(function() {
	InitTestimonial();

	var content = "";
	$.getJSON("http://blog.eadministration.dk/?feed=json&jsonp=?", function(data) {
		$.each(data, function(i) {
			if (i < 3) {
				content += "<a href=\"" + data[i].permalink + "\" target=\"_blank\"><h3>" + data[i].title + "<br /><em>" + data[i].date + "</em></h3></a>";
			}
		});
		content += "<center>Besøg bloggen på <a href=\"http://blog.eadministration.dk/\" class=\"special\" target=\"blank\">blog.eadministration.dk</a></center>";
		$("#blog div").removeClass("loader");
		$("#blog div").html(content);
	});
});
