$(document).ready(function() {
  
  // Preload Images
  
  jQuery.preloadImages = function()
  {
    for(var i = 0; i<arguments.length; i++)
    {
      jQuery("<img>").attr("src", arguments[i]);
    }
  }
  
  $.preloadImages('/static/img/home.jpg','/static/img/films.jpg','/static/img/about.jpg','/static/img/contact.jpg','/static/img/home_over.jpg','/static/img/films_over.jpg','/static/img/about_over.jpg','/static/img/contact_over.jpg')
  
  $("#menu").mouseover(function(event) {
      var target = $(event.target);
      if(target.hasClass('menu-link')) {
        target.addClass('highlight');
      } else {
        target.find('div').addClass('highlight');
      }
      // $("#menu").animate({ 
      //   height: "80px"
      // }, 100 );
    }
  );
  $("#menu").mouseout(function(event) {
      var target = $(event.target);
      if(target.hasClass('menu-link')) {
        target.removeClass('highlight');
      } else {
        target.find('div').removeClass('highlight');
      }
      // $("#menu").animate({ 
      //   height: "50px"
      // }, 100 );
    }
  );
  
  //render players
  $(".video-player").each(function(id, el) {
      var so = new SWFObject(
        '/static/swf/player.swf',
        'player', 
        512, 
        328,
        '8.0.0',
        '#121212'
      );
      so.addParam('swliveconnect', 'true');
      so.addParam('allowScriptAccess', 'always');
      so.addParam('quality', 'autohigh');
      so.addParam('wmode', 'transparent');
      so.addVariable('video_path', $(el).attr('video'))
      so.write(el);
  });
});


