



$(document).ready(function(){
	


	/* Fancybox
	********************************************/
	$('a.thickbox').fancybox();
	


	/* VideoPlayer
	********************************************/

	$('#menuePlayer ul li a').bind('click', function(e){
		e.preventDefault();

		var videoFile = $(this).attr('href');
    	embedVideoPlayer('menuePlayer', videoFile);
	});


	/*******************************************/
	/*Sprechblasen ein und ausblenden im Formular*/
	$('p.errorBlaseP').each(function(){
		var contentSpace = $(this).html().length;
		if(contentSpace == '') {
			$(this).remove();
		}
	});

	$('input#name').click(function(){
		$('li#BlaseA').fadeOut('slow');
	});
	$('input#mail').click(function(){
		$('li#BlaseB').fadeOut('slow');
	});
	$('textarea#message').click(function(){
		$('li#BlaseC').fadeOut('slow');
	});
	$('input#captcha').click(function(){
		$('li#BlaseD').fadeOut('slow');
	});

	/*******************************************/
	/* Subnavi */
/*
	$('ul#mainNavi li div a').mouseover(function() {
		$(this).next('ul.submenu').slideDown('fast');
	});
	$('#mainNavi div ul.submenu').mouseout(function() {
		$('ul.submenu').slideUp('fast');
	});
*/

	$('ul.sf-menu').superfish({
		delay:       1000,                            // one second delay on mouseout
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
		speed:       'fast',                          // faster animation speed
		autoArrows:  false,                           // disable generation of arrow mark-up
		dropShadows: false                            // disable drop shadows
	});




	/*******************************************/

	/* Styles */
	$('div.box h3:first-child').addClass('noMarginTop');
	$('div.textboxNowrapLeft div.textboxText h2:first-child').addClass('noMarginTop');
	$('ul.newsList:first h2').addClass('noMarginTop');

	/* Tabellen formatieren */
	$('tr:nth-child(odd)').addClass('alt');

	/* Leere Errorwarnungen entfernen */
	$('ul.error li, ol.error li').each(function(){
		var conentLength = $(this).html().length;
		if(conentLength == "0") {
			$(this).remove();
		}
	});

	$('p.error').each(function(){
		var conentLength = $(this).html().length;
		if(conentLength == "0") {
			$(this).remove();
		}
	});

	/********************************************
	********************************************/

	/* Einbinden von swf-Dateien mit swfObject
	Schema: <div id="ad2"><a href="/pub/swf/countdownHoch.swf" rel="ad2|120|560" class="adBanner">Banner</a></div> */
/*
	$('a.adBanner').each(function(){
		var file   = $(this).attr('href');
		var rel    = $(this).attr('rel');
		var rel    = rel.split("|");
		var id     = rel[0];
		var width  = rel[1];
		var height = rel[2];

		var flashvars = { image: '/images/menu.jpg' };
		var params    = {
			'wmode': 'transparent'
		};
		var attributes = {};

		swfobject.embedSWF(file, id, width, height, '9.0.0', 'expressInstall.swf', flashvars, params, attributes);
	});

	/********************************************
	********************************************/
	/*Videoplayer einbinden*/


    /* PodcastPlayer */
    $('a.embedVideo').each(function(){
    	var e = $(this);
    	embedVideoPlayer(e.attr('rel'), e.attr('href'));
    });

    // Tabellenslide
	$('table.tableslide').each(function(){
		$(this).css('display', 'none');
	});

	$('a.tableslide').click().toggle(function(){
		$(this).next().animate({
			height: 'show',
			opacity: 'show'
		}, 'slow');
	}, function(){
		$(this).next().animate({
			height: 'hide',
			opacity: 'hide'
		}, 'slow'
		);
	});

	//Browserhinweis einblenden
	jQuery.each(jQuery.browser, function(i, val){
  		if ($.browser.msie && $.browser.version==6){
  		//if($.browser.mozilla){
  			$('div#browser').slideDown('slow');
  		}

	});
	//Browserhinweis ausblenden
	$('a.warnung').click(function() {
		$('div#browser').slideUp('slow').css('display', 'none');
	});
});

function embedVideoPlayer(htmlElementId, videoFile) {
	var preParams = {}

	var params = {
		allowscriptaccess: 'always',
		allowfullscreen: 'true'
	};

	var flashvars = {
		height: '300',
		width: '500',
		image: 'pub/images/menu_bg.jpg',
		file: videoFile,
		start: '90',
		//transition: 'bubbles',
		bufferlength: '5',
		backcolor: '0xeeeeee',
		frontcolor: '0x666666',
		lightcolor: '0xffffff',
		screencolor: '0x000000',
		overstretch: 'auto',
		shownavigation: 'true',
		showicons: 'true',
		showeq: 'false',
		showstop: 'true',
		showdigits: 'true',
		usefullscreen: 'true'
	};

	swfobject.embedSWF('pub/player/mediaplayer.swf', htmlElementId, '500', '300', '10.0.0', preParams, flashvars, params);

}

