// common values for medium- and large-size composite videos
var popup_win = new Array(null, null, null, null, null, null);
var popup_stub = new Array("VERNIER_DT_Demo-800x600", 
                           "VERNIER_DT_Demo-1024x768", 
                           "VERNIER_DT_Demo-1280x960",
                           "VERNIER_DT_Demo-800x600-no_audio", 
                           "VERNIER_DT_Demo-1024x768-no_audio", 
                           "VERNIER_DT_Demo-1280x960-no_audio");
var popup_width = new Array(800, 1024, 1280, 800, 1024, 1280);
var popup_height = new Array(600, 768, 960, 600, 768, 960);
var file_size = new Array(13.3, 17.3, 23.4, 8.3, 12.3, 18.3);
var controller_height = 20; // add this to height to account for controller to show

function createMovieHTML(moviefile,width,height) {
  return "<OBJECT classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\""+
    "codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\""+
    "width=\""+width+"\" height=\""+height+"\""+
    "id=\"movie\">"+
    "<PARAM name=\"src\" value=\""+moviefile+"\">"+
    "<PARAM NAME=\"autoplay\" VALUE=\"false\">"+
    "<PARAM NAME=\"scale\" VALUE=\"aspect\">"+
    "<PARAM NAME=\"controller\" VALUE=\"true\">"+
    "<PARAM NAME=\"playeveryframe\" VALUE=\"false\">"+
    "<EMBED width=\""+width+"\" height=\""+height+"\""+
    "src=\""+moviefile+"\""+
    "TYPE=\"video/quicktime\""+
    "PLUGINSPAGE=\"www.apple.com/quicktime/download\""+
    "name=\"movie\""+
    "AUTOPLAY=\"false\""+
    "SCALE=\"aspect\""+
    "CONTROLLER=\"true\""+
    "PLAYEVERYFRAME=\"false\""+
    "enablejavascript=\"false\">"+
    "</EMBED>"+
    "</OBJECT>";
}

function OpenPopup(index,add2Title) {
  popup_win[index] = window.open("","popup_win"+index,"location=0,toolbar=no,resizable=no,width="+(popup_width[index]+0)+",height="+(popup_height[index]+controller_height));
  writePopupHTML(popup_win[index].document,
                 "VERNIER Demo @ DARPATech 2007 ("+popup_width[index]+" x "+popup_height[index]+")"+add2Title,
                 popup_stub[index],
                 popup_width[index],
                 popup_height[index]+controller_height);
  // center in middle on top:
  if (window.moveTo) { popup_win[index].moveTo(parseInt((screen.width - popup_width[index])/2),0); }
  if (window.focus) { popup_win[index].focus(); }
}

function writePopupHTML(doc,title,filestub,width,height) {
  doc.write('<html>');
  doc.write('<head>');
  doc.write('<title>'+title+'</title>');
  doc.write('<link href="/css/screen.css" media="screen" rel="stylesheet" type="text/css" />');
  doc.write('<link href="/css/print.css" media="print" rel="stylesheet" type="text/css" />');
  doc.write('</head>');
  doc.write('<body STYLE="background-color: black; text-align: center">');
  doc.write(createMovieHTML(filestub+".mov",width,height));
  doc.write('</body>');
  doc.write('</html>');
  doc.close();
}

function getFileSize(index) {
  return "("+file_sizes[index]+" MB)";
}

function writeCellHTML(index,add2Title) {
  return "<a href=\"javascript:OpenPopup("+index+",'"+add2Title+"');\">Popup Movie</a><br>("+file_size[index]+" MB)";
}
