 
 
function renderFlickr() {
var imgTag = "";
var thumbs = $(".psthumb");
var delay = 125;
for(i = 0; i < 75; i++) {
	$('#pstream'+i).delay(delay).fadeIn("slow");
	delay = delay + 50;
  };
 }  


function slideTab(id,action) {
   if(action == "open") {
      $(id).animate({left: "+=635px"}, 500 );
    } else {
      $(id).animate({left: "-=635px"}, 300 );
    }
}

function slideWalk(id,action) {
   if(action == "open") {
      $(id).animate({left: "+=635px"}, 500 );
    } else {
      $(id).animate({left: "-=466px"}, 300 );
    }
}


/* Parklezer slider callback functions, text in two languages */
function parklezerCallback(id,language) {

   $("#paging a").removeClass('active');
   

   switch (id) {
   
      case "1":
      if(language == 'nl') {
        instructies="Op de Westergasfabriek hangen QR borden met een karakteristiek verhaal over de plek of het gebouw.";
      } else {
        instructies="At the Westergasfabriek you find QR codes on signs with typical stories about the place and the building.";
      }
      break;
      
      
      case "2":
      if(language == 'nl') {
        instructies="Met een speciale QR code lezer op je mobiel kan je de QR code scannen.";
      } else {
        instructies="With a special QR code reader on your mobile phone you can scan the QR code";
      }
      break;
      
      
      case "3":
      if(language == 'nl') {
        instructies="Geef toestemming om naar de internetpagina te gaan.";
      } else {
        instructies="Give permission to go to the webpage.";
      }
      break;
      
      
      case "4":
      if(language == 'nl') {
        instructies="Lees over de geschiedenis van dit gebouw of plek.";
      } else {
        instructies="Read about the history of this building.";
      }
      break;
   }
   
   $('#parkinstructie').html(instructies);
   Cufon.replace('#parkinstructie');
   
  }
  

function showAllLayers(){
	 $('#plattegrond img:not("kaart")').show();
}

function showLayers(id){
	var id = id.replace('legenda','layer');
	$('#plattegrond img:not(.kaart)').hide();
	$('#plattegrond .'+id+'').show();
}
  
function streamer() {
  $("#streamer").delay('500').animate({left: "+=620px", opacity: 1}, 1500 );
  $("#streamer").delay('3000').fadeOut('slow');
  }
  
  
  
/* Westerwandelingen bg rotate */
function bgWalkRandom() {

  var randNo = Math.floor(Math.ceil(Math.random()*4));
  var img = 'bg-wandelingen-'+randNo+'.jpg';
  $('#bgvideo').css('background-image','url(images/'+img+')');
  $('#bgvideo').delay(400).fadeIn(600);

  function rotateDelay(i) {
    rotate(i);
  }
  
  function rotate(j) {
	  var randNo = parseInt(j);
	  randNo++;
	  if(randNo == 5) randNo = 1;
	  var img = 'bg-wandelingen-'+randNo+'.jpg';
	  
	  $('#bgvideo').fadeOut(400, function() {
	   $('#bgvideo').css('background-image','url(images/'+img+')')
	   });

	  $('#bgvideo').fadeIn(400);
  
	  setTimeout(function() {
        rotateDelay(randNo)
    }, 10000); 
    
  }
  
  setTimeout(function() {
        rotate(randNo)
    }, 10000); 
  
  }
  
  
/* function to toggle the Audioplayer */
function toggleAudioPlayer(id) {

    var soundId  = id.replace('file-','');
    var holderId = "audioholder-"+soundId;
    var playerId = "audioplayer-"+soundId;
      
    if ($('#'+playerId).hasClass('audioplayer')) {
      $('#'+holderId).show();
      
      /* embed flashplayer */
      var flashvars = { id: soundId };  
      swfobject.embedSWF("flash/sound_player.swf", playerId, "330", "55", "9", "flash/expressInstall.swf",flashvars);

    } else {
      $('#'+playerId).hide();
      $('#'+holderId).html('<div id="audioplayer-'+soundId+'" class="audioplayer"></div>');
    }
    
  }

  
/* Document ready functions */  
$(document).ready(function() {

  /* vars */ 
  var ulLanguage = $('#language').val();

  /* Cufon */
  Cufon.replace('#parkinstructie');
  Cufon.replace('.walkcontent h2');
  Cufon.replace('#fluisterthema h1,#fluisterthema .quote');
  Cufon.replace('#hulptabs h2');
  Cufon.replace('#over-left h1,#over-left h2, #over-right h2');
  Cufon.replace('.close-lightbox');
  Cufon.replace('#hulptabs h3');
  Cufon.replace('#streamer', {textShadow: '1px 1px 1 #333333'});
  Cufon.replace('#nav_over a', {hover:'true'});
  
 

  
  /* Westerwandelingen slider */
  $(".button-wandeling").click(function() {
  
    var sliderid = "#"+$(this).parent().attr("id");
    if ($(this).attr('class') == 'button-wandeling open') {
      $(sliderid).animate({left: "+=425px"}, 500 );
      $(this).removeClass('open');
    } else {
      $(sliderid).animate({left: "-=425px"}, 500 );
      $(this).addClass('open');
    }
    return false;
  
  });
  
  
  /* Tab slide control*/
  $('.controls').click(function() {
  
    var id = $(this).parent().attr("id");
    
    if (id == "hulptabs") { 
      var id = "tab1";
      var thisId = '#tab1-button';
    } else {
      var thisId = "#"+$(this).attr('id'); 
    }

    if ($(thisId).attr('class') == 'controls hoe close' || $(thisId).attr('class') == 'controls close') {
        slideTab('#'+id,'open');
        $(thisId).removeClass('close');
        $(thisId).addClass('open');
     } else {
        slideTab('#'+id,'close');
        $(thisId).removeClass('open');
        $(thisId).addClass('close');
     }
    return false;
    });
    

  /* because tab1 button is behind we have to make a ghost layer and duplicate routines */
  $('#ghosttab1').mouseover(function() {
    $("#tab1 a.close").css('background-position','-100px');
    $("#tab1 a.open").css('background-position','-150px') 
    })
   .mouseout(function() {
    $("#tab1 a.close").css('background-position','0px') 
    $("#tab1 a.open").css('background-position','0px') 
    });
    
   $('#ghosttab1').click(function() {
     $("#tab1 a.open").css('background-position','0px');
     
     if ($("#ghosttab1").css('left') != "0px") {
       $("#ghosttab1").css('left','0px');
     } else {
       $("#ghosttab1").css('left','635px');
     }
     return false;
   });
   
   
   
   /* Parklezer slider controls */
   $('.pl-page-01').click(function(){
     $('#parkslider').animate({left:'0px'},700);
      parklezerCallback("1",ulLanguage);
      $(".pl-page-01").addClass('active');
     return false;
     })
     
   $('.pl-page-02').click(function(){
     $('#parkslider').animate({left:"-590px"},700);
     parklezerCallback("2",ulLanguage);
     $(".pl-page-02").addClass('active');
     return false;
     })
     
   $('.pl-page-03').click(function(){
     $('#parkslider').animate({left:"-1185px"},700);
      parklezerCallback("3",ulLanguage);
     $(".pl-page-03").addClass('active');
     return false;
     })
     
   $('.pl-page-04').click(function(){
     $('#parkslider').animate({left:"-1780px"},700);
     parklezerCallback("4",ulLanguage);
     $(".pl-page-04").addClass('active');
     return false;
     })



  /* Plattegrond toggle */
   $(".kaartknop").click(function(){
    $("#overlay_bg_container").fadeIn();
    $("#overlay_details").fadeIn();
    
    if($(this).attr('class') == 'kaartknop fluisterbank'){
    	$('#legenda-fluisterbank').mouseover();
    }else if($(this).attr('class') == 'kaartknop qr'){
    	$('#legenda-qr').mouseover();
    }else if($(this).attr('class') == 'kaartknop tijdkijker'){
    	$('#legenda-tijdkijker').mouseover();
    }else if($(this).attr('class') == 'kaartknop tours'){
    	$('#legenda-tours').mouseover();
    }
    
    return false;
   });
   
  $(".close-lightbox").click(function(){
    $("#overlay_bg_container").fadeOut();
    $("#overlay_details").fadeOut();
    return false;
   });
   
   $(".close-lightbox-main").click(function(){
    history.back();
    return false;
   });
  
  /* plattegrond legenda */
  
  $('#legenda li a').mouseover(function(){
	  $('#legenda li a').removeClass('active');
	  $(this).addClass('active');
	  showLayers($(this).attr('id'));
  }).mouseout(function(){
	  $(this).removeClass('active');
	  showAllLayers();
  })
    
    
   /* Streamer fade in */
   $("#streamer").delay('2000').fadeIn('slow');



   /* Audioplayer fluisterbank */
   $(".listenknop").click(function(){
    objId = $(this).attr('id');
    toggleAudioPlayer(objId);
    return false;
   });



});


