$(function() {
  initJSVideoPlayer();
});

function initJSVideoPlayer() {
  /*if(typeof document.body.style.maxHeight === "undefined") {
    return;
  }*/
  
  if($("#news-video-player-no-js").length != 0) {
    $("#news-video-player-no-js").css("visibility", "hidden");
    
    var $base_href = $("#news-video-player-no-js > param[name=_loadbase]").attr("value");
    var $splash = $("#news-video-player-no-js > param[name=_loadimg]").attr("value");
    var $vid = $("#news-video-player-no-js > param[name=_loadvid]").attr("value");
    
    $("#news-video-player-no-js").replaceWith('<div id="news-video-player" name="news-video-player"></div>');
    $("#news-video-player").after("<div class=\"video-player-controls-hold\" id=\"news-video-player-controls\" name=\"news-video-player-controls\"></div>")
  
    $f("news-video-player", {
        src: "flash/flowplayer/flowplayer.commercial-3.1.5.swf"
      },
      {
				clip: {
          baseUrl: $base_href
        },
        playlist: [
          {
            url: $splash,
            scaling: 'orig'
          },
          {
            url: $vid,
            autoPlay: false,
            autoBuffering: true
          }
        ],
        key: '#$fecf33cb71866d3aec5',
				contextMenu: [ 

            // 1. "About Flowplayer...";  selecting this item goes to our homepage 
            {'About Wonder Associates ...' : function() { 
                location.href = "http://www.wonderassociates.com"; 
            }}, 

            // 2. menu separator. 
            '-', 

            // 3. version information. 
            'Wonder Media Player v3.1.5' 
        ],
        plugins: {
          controls: null
        }
      }
    ).controls("news-video-player-controls");
		
		$("#news-video-player-controls").append("<br class=\"clearall\" />");
  } else {
    return;
  }
}