$(document).ready(function(){
$("#bloglink").click(function () {
	$("#projekte").hide();
	$("#image").hide();
	$("#text").hide();
	$("#links").hide();
	$("#blog").fadeIn(1000);
	$("#book").hide();
	show_blog_content();
});

$("#projektelink").click(function () {
	$("#blog").hide();
	$("#projekte").fadeIn(1000);
	$("#links").hide();
	$("#image").show(1000);
	$("#text").show(1000);
	$("#book").hide();
});

$("#linkslink").click(function () {
	$("#blog").hide();
	$("#projekte").hide();
	$("#links").fadeIn(1000);
	$("#image").hide();
	$("#text").hide();
	$("#book").hide();
});

$("#booklink").click(function () {
	$("#blog").hide();
	$("#projekte").hide();
	$("#links").hide();
	$("#image").hide();
	$("#text").hide();
	$("#book").fadeIn(1000);
	show_content('book');
});

/* Create ImageFlow instances when the DOM structure has been loaded */
var instanceOne = new ImageFlow();
instanceOne.init({
	ImageFlowID:'myImageFlow',
	reflections: false,
	reflectionP: 0.1,
	slider: true,
	captions: true,
	opacity: true,
	xStep: 200,
	imageFocusM: 1.5,
	imageFocusMax: 1,
	startAnimation: true,
	startID: 2,
	onClick: function(){
		show_text(this.url);
	}
});

/**
 * initial wird Schule Neugraben gezeigt
 */
show_text('schule-neugraben');

});

/*
* ajax request, der den content zum jeweiligen Bild holt
*/
function show_text(url) {
	var pic = url.replace(/\/img\//, '');
	pic = pic.replace(/.jpg/, '');

	var uri = "/_includes/ajax.php?class=AxSubcontent&__get__=getText&page_content=" + pic;

	$.get(uri, function(data){
		$("#text").show("slow").html(data);
	});
}

/*
* ajax request, der den content für die Blog Einträge holt
*/
function show_blog_content() {
	var html = '';
	var url = "/_includes/ajax.php?class=XMLRead&__get__=parseContent&count=2&url=http://blog.netzmeister-st-pauli.de/index.php?tempskin=_rss2";
	$("#blogContent").html('');

	$.get(url, function(data){
		var obj = JSON.parse(data);

		$.each(obj.items, function(i, val) {
			html = '<h3>' + val.title +  ' - ' + dateFormat(val.date, "dd.mm.yyyy") + '</h3>';
			html += '<p class="blog_teaser">' + val.content.replace(/\s?p\s/g,'') + '<a href="' +val.link + '">[ more ]</a></p>';

			$("#blogContent").append(html);
		});
	});
}

function show_content(area) {
	var uri = "/_includes/ajax.php?class=AxSubcontent&__get__=getText&page_content=" + area;

	$.get(uri, function(data){
		$("#" + area).show("slow").html(data);
	});
}