var videoCommand = '';


//VideoPlayer action handler
function onPlayerAction( p_action, p_params, p_playerId ){
  //var logArea = document.getElementById( 'logArea' );
  //logArea.value = createLogString( p_action, p_params, p_playerId )+logArea.value;
}

//Create log line
function createLogString( p_action, p_params, p_playerId ){
  var res = "";
  res += p_playerId;
  res += ": "+p_action;
  if( p_params!=null ){
    res+=": "+inspect( p_params );
  }
  res += "\n";
  return res;
}

//Show members of the object
function inspect( p_object ){
  var res = "";
  for( var it in p_object ){
    if( res!="" ){
      res+=", ";
    }
    res += "it="+p_object[it];
  }
  return res;
}

// Get the video player as an object in javascript
function videoObject(objectName){
  if(navigator.appName.indexOf("Microsoft") != -1){
    return window[objectName];
  } else {
    return document[objectName];
  }
}

// Video controls
function stopVideo(){
  //videoObject('video_display').pause;
  //document.getElementById('video_display').StopPlay();
}

var videoUp = false;

// Swaps the placeholder image HTML out for the actual video player
function showVideo(){
  if(videoUp == false){
    document.getElementById('vid_hide').style.display = 'block';
    videoUp = true;
  }
}

// Renders the video player.  Accepts four parameters; the video title, the base URL and the URLs to the video and the thumbnail image (used for the preview pane).
function renderVideoPlayer(vidTitle, baseURL, videoURL,previewURL){
  var html = '';
  // Create the flash object for displaying video
  html += "<object class=\"video_display\" id=\"video_display_object\" >\n";
  html += "<param name=\"movie\" value=\"" + baseURL + "img/videoplayer.swf\" title=\"Watch '" + vidTitle + "'\" />";
  html += "<param name=\"wmode\" value=\"transparent\" />\n";
  html += "<param name=\"quality\" value=\"high\" />\n";
  html += "<param name=\"allowScriptAccess\" value=\"always\" />\n";
  html += "<param name=\"allowFullScreen\" value=\"true\" />\n";
  html += "<param name=\"FlashVars\" value=\"video=" + videoURL + "&preview=" + previewURL + "\" />\n";
  html += "<embed id=\"video_display_embed\" name=\"video_display\" src=\"" + baseURL + "img/videoplayer.swf\" class=\"video_display\" quality=\"high\" wmode=\"transparent\" title=\"Watch '" + vidTitle + "'\" ";
  html += " allowScriptAccess=\"always\" allowFullScreen=\"true\" ";
  html += " FlashVars=\"video=" + videoURL + "&preview=" + previewURL + "\" ";
  html += " type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" swLiveConnect=\"true\" >\n";
  html += "</embed></object>\n";
  
  document.getElementById('video_player_insert').innerHTML = html;
}