$(document).ready(function(){
  var ua = navigator.userAgent ;
  if (!(ua.indexOf("iPhone") > 0 || ua.indexOf("iPad") > 0 || ua.indexOf("iPod") > 0)) {      
    $('#video_playlist li').mouseover(function(){
      $(this).addClass('show_deets');
    });

    $('#video_playlist li').mouseout(function(){
      $(this).removeClass('show_deets');
    });
  }
});

function videoLoad(elm, vid_path, vid_image) {
  try {
    jwplayer().load({file: vid_path, image: vid_image});
    jwplayer().play();
    var elm_client = $(elm).find('h3').html();
    var elm_title = $(elm).find('h4').html();
    var vid_title = "";
    if (elm_client != "" && elm_client != null) vid_title += elm_client;
    if (elm_title != "" && elm_title != null) {
      if (vid_title != "") vid_title += " - ";
      vid_title += elm_title;
    }
    $('#video_title').html(vid_title);
  } catch(e) {}
}

function videoWindowLoad(elm, vid_path, vid_image, vid_title) {
  $('#overlay_mask').height($(document).height());
  $('#overlay_mask').width($(document).width());
  $('#overlay_mask').click(function() {videoWindowClose();});
  $('#overlay_mask').show();
  $('#video_overlay').css('left', ($(window).width() - 850)/2+'px');
  $('#video_overlay').css('top', ($(window).height() - $('#video_overlay').height())/2+'px');
  $('#video_overlay').show();
  try {
    setTimeout(function() {
      jwplayer().load({file: vid_path, image: vid_image});
      jwplayer().play();
    }, 300);
    $('#video_overlay_title').html(vid_title);
  } catch(e) {}
}

function videoWindowClose() {
  try {
    jwplayer().pause();
  } catch(e) {}
  $('#overlay_mask').hide();
  $('#video_overlay').hide();
}
