$(function(){
  $('body').removeClass('js-disabled').addClass('js-enabled');
  
  // Feature boxes text hover effect
  $('.feature_box').showFeatureText();  
  
  // Hide the non js version of the homepage movie & show image
  $('body#body_home #movie_object #no_js_object').hide();
    
  // Create the link to launch the homepage movie
  $('body#body_home #film div:first').append(
    '<a href="#" id="view_film" class="replace launch_movie">View the Rokeby film <span></span></a>'
  );
  
  // Setup any links to launch the homepage movie
  $('.launch_movie').initialiseFlash();
  
})

// Use swfobject library to place flash on click
$.fn.initialiseFlash = function() {
  return this.each(function(){
    $(this).click(function(){    
      swfobject.embedSWF("/flash/rokeby_flv.swf", "movie_object", "464", "262", "9.0.0", "");
      return false;
    });    
  });  
}



// Display the feature box text on hover
$.fn.showFeatureText = function() {
  return this.each(function(){    
    var box = $(this);
    var heightOfImage = 188;
    var text = $('p',this);
    var link = $('a',text);
    var textHeight = text.height();
    
    text.css({
      position: 'absolute',
      top: '67px'
    }).hide();
    
    link.css({
      position: 'absolute',
      bottom: 0
    });

    box.hover(function(){
      text.animate({
        height: textHeight+'px'
      },{queue:false,duration:250});
    },function(){
      text.animate({
        height: 0
      },{queue:false,duration:250});
    });  
  });
}