// JavaScript Document

var cur = 0;
var next;
image_rotate = new Array();

/*
var cur = 0;
var next, aktiv, len;
var t = 8000;
var w = 960;
function slider() {
	var s = t/5;
	next = (cur+1!=len) ? cur+1 : 0;
	$("#slider_"+cur).fadeOut(s);
	$("#slider_"+next).fadeIn(s);
	cur = next;
}
*/
$(document).ready(function(){
/*						   
	$('.selector').click(function() {
		$(this).next().toggle('slow');
		return false;
	}).next().hide();
*/

	$("#accordion").accordion({ autoHeight: false });


	$(".img").fancybox({
		'titlePosition'	: 'over',
		'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over"><span class="page">Bild '+(currentIndex + 1)+' / '+currentArray.length+'</span>'+title+'&nbsp;</span>';
		},
		'onComplete'	: function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});
	$(".vid").each(function() {
		this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/');
	});
				   
	$(".vid").fancybox({
		'padding'		: 0,
		'autoScale'		: false,
		'title'			: this.title,
		'titleShow'		: false,
		'type'			: 'swf',
		'swf'			: {
		'wmode'				: 'transparent',
		'allowfullscreen'	: 'true'
		}
	});
	
	
	$(".animate").css({"width":$(".animate .div_anim").width()+"px","height":$(".animate .div_anim").height()+"px","position":"relative"});
	$(".animate .div_anim").each( function(i) {
		$(this).css("position","absolute");
		image_rotate[i] = $(this);
	});
	t=setTimeout("animation()",5000);
	
/*
	//Header Slider
	var sel = $(".animate .div_anim");
	len = sel.length;
	if (len>1) {
		w = sel.width();
		$(".animate").css({"position":"relative", "width":w+"px"});
		sel.each(function(index) {
			$(this).attr({id:"slider_"+index}).css({"position":"absolute"});
		});
		aktiv = window.setInterval("slider()",t);
	}
*/
	if (startanzeige!=1) {
		height = $("#content").height();
		if (height<500) {
			$("#content_placeholder").css("height",(515-height)+"px");
		}
	}
	
	$(function() {
		$( "#bdate" ).datepicker({dateFormat: 'dd.mm.yy'});
	});
});


function animation(){
	img_count = image_rotate.length;
	next = (cur<(img_count-1))? cur+1 : 0;
	$(image_rotate[cur]).fadeOut(1000);
	$(image_rotate[next]).fadeIn(1000);
	t=setTimeout("animation()",5000);
	cur = next;
}



