$(document).ready( function(){ 
	initJQuery();
	table_style();
});

function initJQuery(){
	
	$('.pic_list ul li a').hover(function() {
		$('.left_list ul li a.'+this.className).addClass('hovi');
		$(this).find('img').addClass('hovi');
	},
		function(){
		$('.left_list ul li a.'+this.className).removeClass('hovi');
		$(this).find('img').removeClass('hovi');
		}
	);
	
	$('.left_list ul li a').hover(function() {
		$('.pic_list ul li a.'+this.className).addClass('hovi');
	},
		function(){
		$('.pic_list ul li a.'+this.className).removeClass('hovi');
		}
	);
	
	$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$('#content .vid_div_text a').each(function(intIndex) {
		$(this).after('<div class="strich nr"'+intIndex+'></div>');
	});
	
	$(".screenlist:last").addClass('last');
	
	$(".screenlist:first").addClass('first');
	
	$('#content .suche ul li:first').addClass('first');
	$('#content .news ul li:first').addClass('first');
	
	$('#content .suche ul li').each(function(intIndex) {
		//alert($(this).height());
		$(this).find('a').height($(this).height()-2);
	});	
	
	$('a.link').click(function() {
		$('a.link').removeClass('akt');
		$(this).addClass('akt');
		var myvar = this.className;
		var arr = myvar.split(' ');
		$('.qt').hide();
		$('.qt.'+arr[1]).show();
		
		$('.wmv').hide();
		$('.wmv.'+arr[1]).show();
		
		$('.flv').hide();
		$('.flv.'+arr[1]).show();
	});
	
}


function table_style(){
	$('#content table').each(function(){
	var $table = $(this);
		first = 0;
		$('tr', $table).each(function(row) {
			var $row = $(this);
				//erste td breite
				td=0;
				$('td', $row).each(function(td) {
					if(td==0)$(this).addClass('breite_fest');
					td = 1;					
				});
			//erste tr
			if (row == 0) $row.addClass('topper');
			
			if(first==1){
				var counting = row % 2;
				if (counting === 1) $row.addClass('first');
				else $row.addClass('second');
			}
			
			/*
			$row.hover(function() {
					$row.addClass('row_hover');
				},
					function(){
					$row.removeClass('row_hover');
					}
			);
			*/
			
			//erster Durchlauf beendet
			first = 1;
		});
	});
}

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) { 
	swfobject.removeSWF(thePlayerId);
    var tmp=document.getElementById(theWrapper);
    if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; }
	
}


function createPlayer(thePlaceholder, thePlayerId, theFile, title) {

    var flashvars = {
            file:theFile,
            autostart:"false"
    }
    var params = {
            allowfullscreen:"true", 
            allowscriptaccess:"always"
    }
    var attributes = {
            id:thePlayerId,  
            name:thePlayerId
    }
    if(title) $('#video_title').html(title);
    swfobject.embedSWF("player.swf", thePlaceholder, "682", "400", "9.0.115", false, flashvars, params, attributes);
}


function initPlayer(theFile, title) {
    deletePlayer('wrapper', 'placeholder1', 'player1');
    createPlayer('placeholder1', 'player1', theFile, title);
}
