function  sleep(milliSeconds){
    var startTime = new Date().getTime(); // get the current time
    while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}

var slide_pages = 0;
var active_slidepage = 0;

function hide_slidebuttons()
{
	$("#slide_navi").fadeOut("fast");
}

function show_slidebuttons()
{
	$("#slide_navi").fadeIn("slow");
}

function slideto(taget)
{
	$('#slide_container').animate({left: taget}, 1250);
	$('.slide_page').fadeTo("slow",0.1);
	$('.slide_page').eq(active_slidepage).fadeTo("slow",1);
	$("#content").fadeIn("slow");
}

function slide_next()
{
	var taget = -(active_slidepage * 930 + 930);
	active_slidepage++;
	
	if (active_slidepage > slide_pages){
	taget = 0;
	active_slidepage=0;
	}
	slideto(taget);
}

function slide_prev()
{
	active_slidepage--;
	if (active_slidepage < 0){
		active_slidepage = slide_pages;
		}
	var taget = -(active_slidepage * 930);

	slideto(taget);

}

function reset_left_menu()
{
	$(".navi_left_sub").slideUp("fast");
	$(".left_navi_li").css("background-color","#ffffff");
}

function getparentpage(parent_id)
{
	reset_left_menu();
	$.ajax({
		type: "GET",url: "lib/ajax/getparentpages.php",data: "id="+parent_id,
		beforeSend: function(){
		$("#content").fadeOut("fast");
		sleep(200);
	},
	success: function(html){
		$("#content").html(html);
		$("#navi_left_sub_id_"+parent_id).slideDown("fast");
		$("#navi_left_li_id_"+parent_id).css("background-color","#e0e0e0");
		slide_pages = $(".slide_page").size();
		active_slidepage = 0;
		if(slide_pages > 1)
		{
			$("#slide_container").css("width",slide_pages*950);
			slide_pages = slide_pages - 1;
			slideto(active_slidepage);
			show_slidebuttons();
		}
		else
		{
			hide_slidebuttons();
			$("#content").fadeIn("slow");
		}
	}
	});
}

function getparentpagefromsub(parent_id)
{
	$(".left_navi_li").css("background-color","#ffffff");
	$.ajax({
		type: "GET",url: "lib/ajax/getparentpages.php",data: "id="+parent_id,
		beforeSend: function(){
		$("#content").fadeOut("fast");
		sleep(200);
	},
	success: function(html){
		$("#content").html(html);
		$("#navi_left_sub_id_"+parent_id).slideDown("fast");
		$("#navi_left_li_id_"+parent_id).css("background-color","#e0e0e0");
		slide_pages = $(".slide_page").size();
		active_slidepage = 0;
		if(slide_pages > 1)
		{
			$("#slide_container").css("width",slide_pages*950);
			slide_pages = slide_pages - 1;
			slideto(active_slidepage);
			show_slidebuttons();
		}
		else
		{
			$("#content").fadeIn("slow");
			hide_slidebuttons();
		}
	}
	});
}

function getpage(id)
{
	reset_left_menu();
	hide_slidebuttons();
	$.ajax({
		type: "GET",url: "lib/ajax/getcontentpage.php",data: "id="+id,
		beforeSend: function(){
		$("#content").fadeOut("fast");
		sleep(200);
	},
	success: function(html){
		$("#content").html(html);
		$("#content").fadeIn("slow");
	}
	});

}

function geteventpage(id)
{
	reset_left_menu();
	hide_slidebuttons();
	$.ajax({
		type: "GET",url: "lib/ajax/geteventpage.php",data: "id="+id,
		beforeSend: function(){
		$("#content").fadeOut("fast");
		sleep(200);
	},
	success: function(html){
		$("#content").html(html);
		$("#content").fadeIn("slow");
	}
	});
}

function getgallery(id)
{
	reset_left_menu();
	hide_slidebuttons();
	$.ajax({
		type: "GET",url: "lib/ajax/getgallery.php",data: "id="+id,
		beforeSend: function(){
		$("#content").fadeOut("fast");
		sleep(200);
	},
	success: function(html){
		$("#content").html(html);
		$("#content").fadeIn("slow");
	}
	});
}

$(document).ready(function(){
	if($.browser.name == "msie" && $.browser.versionX == 6){
		$('#wrapper').html = "<h1 class='gross'><br /><br /><br /><br />Diese Seite kann mit ihrem Broswer nicht richtig angezeigt werden! <span class='mittel'>Bitte installieren Sie eine aktuelle Version.</span></h1>";
	}
	
	$(".navi_left_sub").slideUp("fast");
	$(".search_link").fadeTo(0,0);
	hide_slidebuttons();
	getpage(6);
	
});
