$(document).ready(function(){


	// Scroll
	setTimeout('$("body:not(.aktuelles):not(.termine):not(.band)").scrollTo(600,1500,{easing:"easeOutQuad"})',500);
	// setTimeout('$("body:not(.aktuelles):not(.termine):not(.band)").scrollTo(0,1500,{easing:"easeOutQuint"})',2000)


	
	var BodyClass = $("body").attr("class").split(" ");
	var BodyClass = BodyClass[0];
	var GradientClass = $("div#gradient").attr("class");
	
	// Nav
	$("#nav").find("img").each(function(){

		var i = $(this).attr("src").split(".");
		var j = i[0].split("_");

		// Hover
		if (j[1]!=BodyClass){
			$(this).hover(function(){
				$(this).attr("src", i[0]+"_cur.png");
			},
			function(){
				$(this).attr("src", i[0]+".png");
			});
		};

		// Active
		if (j[1]==BodyClass){
			$(this).attr("src", i[0]+"_cur.png");
		};
		if (j[1]==GradientClass){
			$(this).attr("src", i[0]+"_cur.png");
		};

	});



	// Tweet
	$("#tweet").tweet({
		username: "sinnfluthagen",
		join_text: "",
		avatar_size: 0,
		count: 1,
		auto_join_text_default: "we said,", 
		auto_join_text_ed: "we",
		auto_join_text_ing: "we were",
		auto_join_text_reply: "we replied to",
		auto_join_text_url: "we were checking out",
		loading_text: "loading tweets..."
	});



	// List Zufall-Bullet
	$("#content ul li").each(function(){
		LI = Math.floor(Math.random()*5);
		$(this).css("background-image", "url(/fileadmin/templ/css/li_0"+LI+".png)");
	});



	// Termine Table
	$(".termine h3").each(function(){
		X = Math.floor(Math.random()*250);
		Y = Math.floor(Math.random()*250);
		$(this).css("backgroundPosition", X+"px "+Y+"px");
	});
	$(".termine h3").click(function(){
		$(this).parent("div").toggleClass("panel-open").toggleClass("panel-closed")
	});
	$(".termine td").each(function(){
		$(this).find("p.bodytext:last").css("margin","0");
	});



	// Band
	if (BodyClass=="simon") {
		var ThisNot = "01";
		$("#band_01").css("display","block");
	} else if (BodyClass=="kevin") {
		var ThisNot = "02";
		$("#band_02").css("display","block");
	} else if (BodyClass=="michael") {
		var ThisNot = "03";
		$("#band_03").css("display","block");
	} else if (BodyClass=="thomas") {
		var ThisNot = "04";
		$("#band_04").css("display","block");
	} else if (BodyClass=="benedict") {
		var ThisNot = "05";
		$("#band_05").css("display","block");
	};

	$("#band area").each(function(){
		$(this).not("#band_"+ThisNot+"_trg").hover(function(){
			$("#band_00").css("opacity","0");
			$("#band_"+ThisNot).css("opacity","0");
			i = $(this).attr("id").split("_");
			$("#"+i[0]+"_"+i[1]).stop(true,true).fadeIn();
		},function(){
			$("#"+i[0]+"_"+i[1]).stop(true,true).fadeOut();
			$("#band_00").css("opacity","1");
			$("#band_"+ThisNot).css("opacity","1");
		});
	});

	$(".band tr:odd").addClass("odd");
	$(".band tr:even").addClass("even");

	$(".band #left .csc-textpic-image").each(function(){
		Rotation = Math.floor(Math.random()*15);
		$(this).addClass("rotate-"+Rotation);
		Img = $(this).children("img").attr("src");
		$(this).css("background-image", "url("+Img+")");
		Polaroid = Math.floor(Math.random()*3);
		$(this).children("img").attr("src","fileadmin/templ/img/polaroid_0"+Polaroid+".png");
		$(this).children("img").attr("top","-"+Rotation+"px");
	});



	// Gästebuch
	$(".tx-veguestbook-pi1 h3").each(function(){
		X = Math.floor(Math.random()*250);
		Y = Math.floor(Math.random()*250);
		$(this).css("backgroundPosition", X+"px "+Y+"px");
	});



});

