function supports_video() {
  return !!document.createElement('video').canPlayType;
}

function playVideo(element,video,firstFrame,width,height) {
  var videoPlayer = '/videoPlayer.swf';
  var videoFile = video;
  var videoFileNoExt = video.replace('.flv', '');
  var firstFrame = firstFrame;
  var videoWidth = width;
  var videoHeight = height;

  if ( !jQuery.browser.msie && supports_video() ) {
    $(element).html('<video autobuffer id="videoElement" poster="'+firstFrame+'" width="'+videoWidth+'" height="'+videoHeight+'" controls><source src="'+videoFileNoExt+'.mp4?v=3" /><source src="'+videoFileNoExt+'.ogv?v=3" type="video/ogg" /><source src="'+videoFileNoExt+'.webm?v=3" type="video/webm" /></video>');
    var video = document.getElementById('videoElement');
    if (navigator.userAgent.toLowerCase().indexOf("android")>-1) {
      video.addEventListener('click',function(){
        video.play();
      },false);
    }
  } else {
    // No HTML5 / is IE
    // use Flowplayer
    $(element).html('<a href="'+video+'" style="display:block; width:'+width+'px; height:'+height+'px;" id="'+element.replace('#','')+'-a"></a>');
    flowplayer(element.replace('#','')+'-a', "/flowplayer-3.2.7.swf", {
      clip:{
        autoPlay: false,
        autoBuffering: true
      },
      playlist:[
        {url:firstFrame, scaling:"orig"},
        {url:video, autoPlay:true}
      ]
    });
  }
}
