
$(document).ready(function(){
  
  // Init slideshows and marquees
  $(".slideshow").slideshow( { transition: 'fade', animateSpeed: 1200, delay: 1000, loadDelay: 1000, pauseOnMouseover: true });  
  
  // Lightbox
  $("a.lightbox").each(function(e){
    var a = this;
    var setup = false;
    
    var height = $(a).attr("data-height") || 400;
    var width = $(a).attr("data-width") || 800;
     
    // Vimeo video
    if( $(a).hasClass("vimeo") ){
      var video = a.href;
      var id = video.match(/vimeo\.com\/([0-9]*)/);
      
      if( id && id[1] != ""){
        a.href = 'http://player.vimeo.com/video/'+ id[1] +'?title=0&amp;byline=0&amp;portrait=0';
        $(a).colorbox({iframe:true, innerWidth:width, innerHeight:height});
      }
    }
    
    // Other
    else {
      a.href += ((a.href.indexOf("?") < 0) ? "?lightbox" : "&lightbox");
      $(a).colorbox({iframe:true, innerWidth:width, innerHeight:height });
    }
  });
});
