// This is a callback from the Unicast ad. Expects two global objects to be
// created - gWinVideo and gFlashVideo.
function playVideo() {
  // Do we have version 8 player?
  useFlash = true;
  UFO.getFlashVersion();
  var flashVersion = new String(UFO.fv);
  var tempSplit = flashVersion.split(",");
  version = tempSplit[0];

  if (version < 8) { useFlash = false; }

  // If we have the Flash player, and there was a Flash url provided.
  if (useFlash && !(gFlashVideo.url == undefined || gFlashVideo.url == '') ) {
    writeFlash(gFlashVideo.url, gFlashVideo.width, gFlashVideo.height);
  // No Flash installed, check if we can use Windows Media.
  } else if (useWMP && !(gWinVideo.url == undefined || gWinVideo.url == '') ) {
       writePlayer(gWinVideo.url, gWinVideo.width, gWinVideo.height);
  // Use Real as the last resort.
  } else {
    playerchoice = "realmedia";
    writePlayer(gRealVideo.url, gRealVideo.width, gRealVideo.height);
  }
}

// Writes out the Flash player.
function writeFlash(file, width, height) {
    var dart = new Object(); // Used for backward compatibility with old ad refresh code. Not used.
    var FO = { movie:"/images/flash/video.swf", width:width, height:height,
    majorversion:"8", build:"0", id:"videoFlash", name:"videoFlash", wmode:"transparent", swliveconnect:"true",
flashvars:"file="+file+"&skin_url=/images/flash/SteelExternalAll.swf&autoStart=true&dartSZ=" + dart["sz"] +
"&dart_site=" + dart["site"] + "&dart_zone=" + dart["zone"] +
"&dart_target=" + dart["target"] + "&dart_dcopt=" + dart["dcopt"] +
"&dart_url=" + escape(dart["url"]) };
    UFO.create(FO, "playerholder");
}

// FS Command used to refresh ads.
function videoFlash_DoFSCommand(command, args) {
  var tileNum = parseInt(args), div, script;
  if (command == "updateAd") {
    //document.getElementById("dartLayer" + tileNum).innerHTML = args.substr(args.indexOf("|") + 1);
  }
}


// Video class
function Video(url, height, width) {
  this.url=url;
  this.height=height;
  this.width=width;
}


var playerchoice;
var UnicPR = false;
var useFlash = useReal;

if(useFlash) playerchoice = "flashmedia";
else playerchoice = "windowsmedia";

// Windows Media
var gWinVideo = new Video();
gWinVideo.width = 400;
gWinVideo.height = 350;

// Flash Video
var gFlashVideo = new Video();
gFlashVideo.width = 400;
gFlashVideo.height = 350;

// Real Video
var gRealVideo = new Video();
gRealVideo.width = 400;
gRealVideo.height = 350;
