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 swfObject to insert video:
    var flashvars = {
      vidWidth: width,
      vidHeight: height,
      playVid: video,
      img: firstFrame,
      autoStart: "false"
    };
    var params = {
      quality: "High",
      wmode: "transparent",
      play: "false"
    };
    var swfObjElement = element.replace('#',''); // Fix Element from function call.
    swfobject.embedSWF(videoPlayer, swfObjElement, width, height, '9.0.0', '', flashvars, params);
  }
}
