/*
 * Script to manage HTML5 video player
 *
 * a is a css selector
 * j is a video url
 * f is the poster url (image to display before the video is played)
 **/
function renderVideo(a,j,f){
  
  $(document).ready(function()
  {
    $(a).children(".playButton").parent().children("video").attr("poster",f);
    $(a).children(".playButton").parent().children("video").append($("<source/>").attr("src",j));
    
    var h=["iphone","ipod","ipad"];
    var e=false;
    
    for(var g=0;g<h.length;g++)
    {
      if(navigator.userAgent.toLowerCase().indexOf(h[g])>-1)
      {
        e=true;
        break
      }
    }
    
    if(e)
    {
      $(".playButton").click(c)
    }
    else
    {
      $(a).children(".playButton").hide();
      $(a).children(".playButton").parent().children("video").attr("controls","true");
      $(a).children(".playButton").parent().children("video").attr("autoplay","false")}
    }
  );
    
  function c(f)
  {
    $(this).parent().children("video").attr("controls","true");
    $(this).parent().children("video").trigger("load");
    $(this).parent().children("video").trigger("play");
    $(this).hide()
  }  
  
};
