var newWindow;
var controller = 1;
var autoplay = true;

function openWMPVideoWindow(filename, loop, width, height) {

  //make the text to write to the new window
  //all variables not passed to the function must be assigned here

  //if controller is to be shown add 16 for Quicktime, 32 for Windows Media Player to the height
  var controller_height = 16 //may need to calc based upon browser, etc
  if(controller == 1) {
    //add controller height
    //height = parseInt(height) + parseInt(controller_height);
  }

  text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
  text += "<html>\n<head>\n<title>PegasusTrainer.com</title></head>\n<body align=\"left\" leftmargin=\"0\" topmargin=\"0\" bgcolor=\"#000000\">\n";
  text += "<OBJECT ID=\"MediaPlayer\"\n"; 
  text += "WIDTH=\"" + width + "\"\n"; 
  text += "HEIGHT=\"" + height + "\"\n";
  text += "CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\"\n";
  text += "TYPE=\"application/x-oleobject\">\n";
  text += "<PARAM NAME=\"FileName\" VALUE=\"" + filename + "\">\n";
  text += "<PARAM name=\"autostart\" VALUE=\"true\">\n";
  text += "<PARAM name=\"ShowControls\" VALUE=\"true\">\n";
  text += "<param name=\"ShowStatusBar\" value=\"true\">\n";
  text += "<PARAM name=\"ShowDisplay\" VALUE=\"false\">\n";
  text += "<EMBED TYPE=\"application/x-mplayer2\"\n"; 
  text += "SRC=\"" + filename + "\"\n";
  text += "NAME=\"MediaPlayer\"\n";
  text += "WIDTH=\"" + width + "\"\n";
  text += "HEIGHT=\"" + height + "\"\n";
  text += "ShowControls=\"1\"\n";
  text += "ShowStatusBar=\"0\"\n";
  text += "ShowDisplay=\"0\"\n"; 
  text += "autostart=\"1\">\n"; 
  text += "</EMBED></OBJECT>\n";  


/*
  text += "<OBJECT id=\"VIDEO\"\n";
  text += "width=\"" + width + "\"\n";
  text += "height=\"" + height + "\"\n"; 
  text += "style=\"position:absolute; left:0;top:0;\"\n";
  text += "CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"\n";
  text += "type=\"application/x-oleobject\">\n";	
  text += "<PARAM NAME=\"URL\" VALUE=\"" + filename + "\">\n";
  text += "<PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"True\">\n";
  text += "<PARAM NAME=\"AutoStart\" VALUE=\"" + autoplay + "\">\n";
  text += "<PARAM name=\"uiMode\" value=\"none\">\n";
  text += "<PARAM name=\"PlayCount\" value=\"9999\">\n";
  text += "</OBJECT>\n";
*/

  text += "\n</body>\n</html>\n"; 

  //text is written so now open a new window, write the text and focus the window
  newWindow=window.open('','VideoPlayer','width=' + width + ',height=' + height + ',resizable') ;
  newWindow.document.write(text);
  newWindow.focus();
  newWindow.document.close();
}