var counter = Math.floor(Math.random()*19);
  var state = 0;
  var trailermode = false;
  window.onload = function(){
  	  $('title').appear();
	  slideshow();
  }	
  window.setInterval("count()", 9000);
  function count(){
	  counter++;
	  if(counter > 19){
		  counter = 0;
	  }
	  slideshow();
  }
  
  function slideshow(){
	  if(state == 0){
		  Effect.Fade('bild1', {duration: 0.5});
		  $('bild2').style.backgroundImage = "url(pics/pic" + counter + ".jpg)";
		  state = 1;
		 
	  }else{
		  Effect.Appear('bild1', {duration: 0.5});
		  $('bild1').style.backgroundImage = "url(pics/pic" + counter + ".jpg)";
		  state = 0;
		
	  } 
  }
  
  function switchOn(){
	if(trailermode == false){
		
		
		$('content').style.zIndex = 100;
		$('header').style.zIndex = 1000;
		$('container').style.zIndex = 0;
		
		
	}
  }
  function switchBack(){
	  if(trailermode == false){
		
		$('content').style.zIndex = 1000;
		$('header').style.zIndex = 100;
		$('container').style.zIndex = 0;
		
		
		
	  }
  }
  function lastImage(){
	  counter--;
	  if(counter < 0){
		 counter = 19;
	 }
	 slideshow();
  }
  function nextImage(){
	 counter++;
	 if(counter > 19){
		 counter = 0;
	 }
	 slideshow();
  }
  
  function showTrailer(){
	  trailermode = true;
	  Effect.Appear('trailer');
	  $('trailer').style.zIndex = 10000;
	  $('diashow').style.zIndex = 1000;
	  $('header').style.zIndex = 100;
	  $('content').style.zIndex = 1;
	  
  }
  function hideTrailer(){
	  trailermode = false;
	  Effect.Fade('trailer');
	  $('trailer').style.zIndex = 1;
	  $('diashow').style.zIndex = 100;
	  $('header').style.zIndex = 10;
  }
