// theMovie has the following comma-delimited information:
//
//   file name
//   movie dimension index (low-res)
//   movie dimension index (high-res)
//   file size (low-res)
//   file size (high res)

var theMovie = new Array();
var theTitle = new Array();
var sizeRes = new Array();
var thisSizeRes;
var thisMovieSize;
var emailAdd = 'chemistry@chemistry.alanearhart.org';
var dateMod = '7\/25\/06';

sizeRes[0] = 'Low';
sizeRes[1] = 'High';

// Movie(s) added 8/01/02

theMovie[0] = 'rxn-zncu-gas,2,1,192kB,464kB';
theTitle[0] = 'Zinc and Acidified Copper(II) Nitrate Reaction';

theMovie[1] = 'rxn-cuag,2,1,256kB,892kB';
theTitle[1] = 'Copper and Silver Nitrate Reaction';

theMovie[2] = 'rxn-zncu,2,1,420kB,1.2MB';
theTitle[2] = 'Zinc and Acidified Copper(II) Nitrate Reaction';

theMovie[3] = 'electrolysis,4,3,281kB,972kB';
theTitle[3] = 'Electrolysis of Water';

theMovie[4] = 'electrolysis-ph,6,5,588kB,980kB';
theTitle[4] = 'Electrolysis of Water (Gas and pH Indicator)';

theMovie[5] = 'peroxide,4,3,360kB,1.0MB';
theTitle[5] = 'Catalyzed Decomposition of 30% Hydrogen Peroxide';

theMovie[6] = 'sugar,2,0,2.4MB,0';
theTitle[6] = 'Decomposition of Sugar Using Concentrated Sulfuric Acid';

theMovie[7] = 'oscillate-slice,2,0,1.3MB,0';
theTitle[7] = 'Briggs-Rauscher Oscillating Reaction';

theMovie[8] = 'blue-slice,2,0,1.4MB,0';
theTitle[8] = 'Disruption of Methylene Blue Equilibrium';

theMovie[9] = 'plechatelier,4,3,136kB,440kB';
theTitle[9] = 'Le Ch&acirc;telier\'s Principle and Pressure Change';

theMovie[10] = 'pballoon,4,3,308kB,1.0MB';
theTitle[10] = 'Balloon Inflation by Decreasing Pressure';

theMovie[11] = 'carbonic-slice,2,1,1.0MB,1.6MB';
theTitle[11] = 'Aqueous Reaction Between Sodium Carbonate and Citric Acid';

theMovie[12] = 'grain,2,0,1.7MB,0';
theTitle[12] = 'Simulated Grain Elevator Explosion';

theMovie[13] = 'grain-expand,0,7,0,692kB';
theTitle[13] = 'Flame Pictures From the Simulated Grain Elevator Explosion';

theMovie[14] = 'magnesium,2,1,1.0MB,1.8MB';
theTitle[14] = 'Combustion of Magnesium Ribbon';

theMovie[15] = 'sodium-slice,2,0,2.2MB,0';
theTitle[15] = 'Sodium Metal in Water with Phenolpthalein Indicator';

theMovie[16] = 'zns,2,0,2.2MB,0';
theTitle[16] = 'Exothermic Reaction Between Solid Zinc and Solid Sulfur';

function popUpQTWindow(whichMovie,whichRes,whichLoop,whichPlay) {
  //
  //   whichMovie - movie index
  //   whichRes   - 0 = low resolution
  //                1 = high resolution
  //   whichLoop  - 0 = no looping
  //                1 = palindrome (back-and-forth)
  //                2 = loop
  //   whichPlay  - 0 = no auto play
  //                1 = auto play

  var whichMovie;
  var whichRes;
  var whichLoop;
  var whichPlay;
  var movieWidth;
  var movieHeight;
  var quizWidth;
  var quizHeight;
  var movieFile;
  var movieTitle;
  var userScale;
  var userLoop;
  var userPlay;
  var prePath;
  var theLoop = new Array();
  var autoPlay = new Array();
  var theScale = new Array();
  var movieDim = new Array();
  var movieDimTemp = new Array();
  var movieInfo = new Array();

  prePath = '..\/..\/Movies\/';

  theLoop[0] = 'false';
  theLoop[1] = 'palindrome';
  theLoop[2] = 'true';

  autoPlay[0] = 'false';
  autoPlay[1] = 'true';

  theScale[0] = '1.0';
  theScale[1] = '2.0';

  // width, height
  // The first one is set to null

  movieDim[0] = '';
  movieDim[1] = '320,240';
  movieDim[2] = '160,120';
  movieDim[3] = '240,320';
  movieDim[4] = '120,160';
  movieDim[5] = '320,130';
  movieDim[6] = '160,65';
  movieDim[7] = '300,240';

  quizWidth = '400';
  quizHeight = '450';

  movieInfo = theMovie[whichMovie].split(',');
  movieTitle = theTitle[whichMovie];
  movieFile = movieInfo[0];
  movieDimTemp = movieDim[movieInfo[whichRes + 1]].split(',');
  if (!whichRes) {
    userScale = theScale[1];
    movieFile = movieFile + '-s';
    movieWidth = Math.round((movieDimTemp[0] - 0) * 2) + '';
    movieHeight = Math.round((movieDimTemp[1] - 0) * 2);
  }
  else {
    userScale = theScale[0];
    movieWidth = movieDimTemp[0];
    movieHeight = movieDimTemp[1] - 0;
  }
  movieHeight = (movieHeight + 16) + '';
  userLoop = theLoop[whichLoop];
  userPlay = autoPlay[whichPlay];

  qtWindow = window.open('','qtWindowName','resizable=1,scrollbars=1,status=1,width=' + quizWidth + ',height=' + quizHeight);
  qtWindow.document.write('<HTML>\n<HEAD>\n<TITLE>' +
    theTitle[whichMovie] +
    '<\/TITLE>\n<\/HEAD>\n<SCR' + 'IPT LANGUAGE=\"javascript\">\n');

  qtWindow.document.write('function mOver(whichForm,whichElement) {\n' +
    'var whichForm;\nvar whichElement;\n\n' +
    'document.forms[whichForm].elements[whichElement].style.backgroundColor = \'#000000\';\n' +
    'document.forms[whichForm].elements[whichElement].style.color = \'#FFFFFF\';\n' +
    '}\n\n' +
    'function mOut(whichForm,whichElement) {\n' +
    'var whichForm;\nvar whichElement;\n\n' +
    'document.forms[whichForm].elements[whichElement].style.backgroundColor = \'\';\n' +
    'document.forms[whichForm].elements[whichElement].style.color = \'\';\n}\n\n');

  qtWindow.document.write('<\/SCR' + 'IPT>\n\n');
  qtWindow.document.write('<BODY STYLE=\"background-color: #FFFFFF\">\n' +
    '<DIV ALIGN=\"center\">\n' +
    '<TABLE BORDER=\"0\" CELLSPACING=\"5\">\n<TR><TD ALIGN=\"center\">\n' +
    '<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\"' +
    ' WIDTH=\"' + movieWidth +
    '\" HEIGHT=\"' + movieHeight + '\" ' +
    'CODEBASE=\"http:\/\/www.apple.com\/qtactivex\/qtplugin.cab\">\n' +
    '<PARAM name=\"SRC\" VALUE=\"' + prePath + movieFile + '.mov\">\n' +
    '<PARAM name=\"AUTOPLAY\" VALUE=\"' + userPlay + '\">\n' +
    '<PARAM name=\"LOOP\" VALUE=\"' + userLoop + '\">\n' +
    '<PARAM name=\"SCALE\" VALUE=\"' + userScale + '\">\n' +
    '<PARAM name=\"bgcolor\" VALUE=\"000000\">\n' +
    '<PARAM name=\"CONTROLLER\" VALUE=\"true\">\n' +
    '<EMBED SRC=\"' + prePath + movieFile + '.mov\" ' +
    'ALT=\"chemical reaction\" WIDTH=\"' + movieWidth +
    '\" HEIGHT=\"' + movieHeight + '\" ' +
    'AUTOPLAY=\"' + userPlay + '\" LOOP=\"' + userLoop + 
    '\" SCALE=\"' + userScale + '\"BGCOLOR=\"000000\" ' +
    '\" CONTROLLER=\"true\" ' +
    'PLUGINSPAGE=\"http:\/\/www.apple.com\/quicktime\/download\/">' +
    '<\/EMBED>\n<\/OBJECT>\n' +
    '<\/TD><\/TR><TR><TD ALIGN=\"center\">\n' +
    '<FORM>\n<INPUT TYPE=\"button\" ' +
    'onClick=\"window.close()\"\n ' +
    'onMouseOver=\"mOver(0,0); self.status=\'Close this window\';return true\"\n ' +
    'onMouseOut=\"mOut(0,0); self.status=\'\';return true\"\n ' +
    'VALUE=\"Close Window\">\n<\/FORM>\n' +
    '<\/TD><\/TR>\n<\/TABLE>\n' +
    '<\/DIV>\n');
  qtWindow.document.write('<HR>\n<DIV>\nScript last modified: ' +
    dateMod + '<BR><A HREF=\"mailto:' + emailAdd + '\">' + emailAdd +
    '<\/A>\n<\/DIV>\n');
  qtWindow.document.write('<\/BODY>\n<\/HTML>');
  qtWindow.document.close();
  qtWindow.focus();

  qtWindowOpened = 1;
}

function parseMovieSize(whichMovie,whichIndex) {
  var whichMovie;
  var whichIndex;
  var movieInfo = new Array();

  movieInfo = theMovie[whichMovie].split(',');
  thisMovieSize = movieInfo[3 + whichIndex];

  thisSizeRes = sizeRes[whichIndex];
}
