var timer = null;
var actTeaser = 0;

function pageInit(){
	//$('#videos a').lightbox();
	
	// Teaser starten
	
	timer = window.setInterval('showTeaser()', 8000);
	showTeaser();
}

function showTeaser(){
	
	var cTeasers = $('#teaser > div').size();
	
	if(actTeaser != 0)
		$('#teaser .divNeuheit:nth-child(' + actTeaser + ')').fadeOut('slow');
	
	actTeaser++;
	
	if(actTeaser > cTeasers)
		actTeaser = 1;
	
	//$('#teaser div:nth-child(' + actTeaser + ')').css('display','block');
	$('#teaser div:nth-child(' + actTeaser + ')').fadeIn('slow');
	
	//timer = window.setTimeout('showTeaser()', 5000);
}

function show_videos(which){
	
	// Show the lightbox
	
	$('#lightbox-overlay').css('opacity', 0.85);
	
	$('#lightbox-overlay').fadeIn(400, function(){
		
		// Resize the boxes appropriatly
		$.Lightbox.resizeBoxes('general');

		// Reposition the Boxes
		$.Lightbox.repositionBoxes({'speed':0});

		// Hide things
		$('#lightbox-infoFooter').hide(); // we hide this here because it makes the display smoother
		$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox').hide();
		// Show the lightbox
		
		$('#lightbox').css('opacity',$.Lightbox.opacity).fadeIn(300, function(){
			var loc = window.location.href;
			$('#lightbox-imageBox').css({'height': '332px', 'width': '453px'});
			loc.indexOf("2010") != -1 ? path = "/2010" : path = "";
		
			var so = new SWFObject('js/flowplayer/player.swf','mpl','450','330','8');	// 720/400 ist die Grösse des Videos
			so.addParam('allowfullscreen','true');
			so.addParam('allowscriptaccess','always');
			so.addParam('wmode','window');
			so.addVariable('file', path + '/pics_layout/videos/Vinoversum-' + which + '.flv');		// Hier den Pfad zum Video einbinden!
			//so.addVariable('image',path + '/pics_layout/videos/startbild_laden.jpg');	// Auskommentieren, falls ein Starbild gezeigt werden soll
			so.addVariable('icons','true'); 
			so.addVariable('dock','true');
			so.addVariable('autostart','true');
			so.addVariable('controlbar','over');
			so.write('lightbox-imageContainer');
			
			$('#lightbox-imageContainer').bind('click', function(){
				return false;
				
			});
		});

	});
	
	return false;
}
