var molNum = new Array();
var molFile = new Array();
var molFormula = new Array();
var molValence = new Array();
var molPath;
var totalMolecules;
var possMolecules;
var quizType;
var defaultValue;
var textLength = 35;
var rulesWindowOpened;
var quizWindowOpened;
var helpWindowOpened;
var emailAdd = 'chemistry@chemistry.alanearhart.org';
var dateMod = '8\/07\/06';  

// antimony 0-7

molFile[0] = 'sb1h3';
molFormula[0] = 'SbH<SUB>3</SUB>';
molValence[0] = '1*(5) + 3*(1) = 8';
molFile[1] = 'sb1br3';
molFormula[1] = 'SbBr<SUB>3</SUB>';
molValence[1] = '1*(5) + 3*(7) = 26';
molFile[2] = 'sb1cl3';
molFormula[2] = 'SbCl<SUB>3</SUB>';
molValence[2] = '1*(5) + 3*(7) = 26';
molFile[3] = 'sb1f3';
molFormula[3] = 'SbF<SUB>3</SUB>';
molValence[3] = '1*(5) + 3*(7) = 26';
molFile[4] = 'sb1i3';
molFormula[4] = 'SbI<SUB>3</SUB>';
molValence[4] = '1*(5) + 3*(7) = 26';
molFile[5] = 'sb1cl5';
molFormula[5] = 'SbCl<SUB>5</SUB>';
molValence[5] = '1*(5) + 5*(7) = 40';
molFile[6] = 'sb1f5';
molFormula[6] = 'SbF<SUB>5</SUB>';
molValence[6] = '1*(5) + 5*(7) = 40';
molFile[7] = 'sb1i5';
molFormula[7] = 'SbI<SUB>5</SUB>';
molValence[7] = '1*(5) + 5*(7) = 40';

// arsenic 8-14

molFile[8] = 'as1h3';
molFormula[8] = 'AsH<SUB>3</SUB>';
molValence[8] = '1*(5) + 3*(1) = 8';
molFile[9] = 'as1cl3';
molFormula[9] = 'AsCl<SUB>3</SUB>';
molValence[9] = '1*(5) + 3*(7) = 26';
molFile[10] = 'as1f3';
molFormula[10] = 'AsF<SUB>3</SUB>';
molValence[10] = '1*(5) + 3*(7) = 26';
molFile[11] = 'as1i3';
molFormula[11] = 'AsI<SUB>3</SUB>';
molValence[11] = '1*(5) + 3*(7) = 26';
molFile[12] = 'as1br3';
molFormula[12] = 'AsBr<SUB>3</SUB>';
molValence[12] = '1*(5) + 3*(7) = 26';
molFile[13] = 'as1f5';
molFormula[13] = 'AsF<SUB>5</SUB>';
molValence[13] = '1*(5) + 5*(7) = 40';
molFile[14] = 'as1i5';
molFormula[14] = 'AsI<SUB>5</SUB>';
molValence[14] = '1*(5) + 5*(7) = 40';

// beryllium 15-17

molFile[15] = 'be1h2';
molFormula[15] = 'BeH<SUB>2</SUB>';
molValence[15] = '1*(2) + 2*(1) = 4';
molFile[16] = 'be1f2';
molFormula[16] = 'BeF<SUB>2</SUB>';
molValence[16] = '1*(2) + 2*(7) = 16';
molFile[17] = 'be1cl2';
molFormula[17] = 'BeCl<SUB>2</SUB>';
molValence[17] = '1*(2) + 2*(7) = 16';

// boron 18-22

molFile[18] = 'b1h3';
molFormula[18] = 'BH<SUB>3</SUB>';
molValence[18] = '1*(3) + 3*(1) = 6';
molFile[19] = 'b1f3';
molFormula[19] = 'BF<SUB>3</SUB>';
molValence[19] = '1*(3) + 3*(7) = 24';
molFile[20] = 'b1cl3';
molFormula[20] = 'BCl<SUB>3</SUB>';
molValence[20] = '1*(3) + 3*(7) = 24';
molFile[21] = 'b1br3';
molFormula[21] = 'BBr<SUB>3</SUB>';
molValence[21] = '1*(3) + 3*(7) = 24';
molFile[22] = 'b1i3';
molFormula[22] = 'BI<SUB>3</SUB>';
molValence[22] = '1*(3) + 3*(7) = 24';

  // bromine 23-27

  molFile[23] = 'br1f1';
  molFormula[23] = 'BrF';
  molValence[23] = '1*(7) + 1*(7) = 14';
  molFile[24] = 'br1cl1';
  molFormula[24] = 'BrCl';
  molValence[24] = '1*(7) + 1*(7) = 14';
  molFile[25] = 'br1f3';
  molFormula[25] = 'BrF<SUB>3</SUB>';
  molValence[25] = '1*(7) + 3*(7) = 28';
  molFile[26] = 'br1f5';
  molFormula[26] = 'BrF<SUB>5</SUB>';
  molValence[26] = '1*(7) + 5*(7) = 42';
  molFile[27] = 'br2';
  molFormula[27] = 'Br<SUB>2</SUB>';
  molValence[27] = '2*(7) = 14';

  // carbon 28-51

  molFile[28] = 'c1h4';
  molFormula[28] = 'CH<SUB>4</SUB>';
  molValence[28] = '1*(4) + 4*(1) = 8';
  molFile[29] = 'c1f4';
  molFormula[29] = 'CF<SUB>4</SUB>';
  molValence[29] = '1*(4) + 4*(7) = 32';
  molFile[30] = 'c1cl4';
  molFormula[30] = 'CCl<SUB>4</SUB>';
  molValence[30] = '1*(4) + 4*(7) = 32';
  molFile[31] = 'c1br4';
  molFormula[31] = 'CBr<SUB>4</SUB>';
  molValence[31] = '1*(4) + 4*(7) = 32';
  molFile[32] = 'c1i4';
  molFormula[32] = 'CI<SUB>4</SUB>';
  molValence[32] = '1*(4) + 4*(7) = 32';
  molFile[33] = 'c1h1f3';
  molFormula[33] = 'CHF<SUB>3</SUB>';
  molValence[33] = '1*(4) + 1*(1) + 3*(7) = 26';
  molFile[34] = 'c1h1cl3';
  molFormula[34] = 'CHCl<SUB>3</SUB>';
  molValence[34] = '1*(4) + 1*(1) + 3*(7) = 26';
  molFile[35] = 'c1h1br3';
  molFormula[35] = 'CHBr<SUB>3</SUB>';
  molValence[35] = '1*(4) + 1*(1) + 3*(7) = 26';
  molFile[36] = 'c1h1i3';
  molFormula[36] = 'CHI<SUB>3</SUB>';
  molValence[36] = '1*(4) + 1*(1) + 3*(7) = 26';
  molFile[37] = 'c1cl1f3';
  molFormula[37] = 'CClF<SUB>3</SUB>';
  molValence[37] = '1*(4) + 1*(7) + 3*(7) = 32';
  molFile[38] = 'c1h2cl2';
  molFormula[38] = 'CH<SUB>2</SUB>Cl<SUB>2</SUB>';
  molValence[38] = '1*(4) + 2*(1) + 2*(7) = 20';
  molFile[39] = 'c1h2cl1f1';
  molFormula[39] = 'CH<SUB>2</SUB>ClF';
  molValence[39] = '1*(4) + 2*(1) + 2*(7) = 20';
  molFile[40] = 'c1h2br2';
  molFormula[40] = 'CH<SUB>2</SUB>Br<SUB>2</SUB>';
  molValence[40] = '1*(4) + 2*(1) + 2*(7) = 20';
  molFile[41] = 'c1h3cl1';
  molFormula[41] = 'CH<SUB>3</SUB>Cl';
  molValence[41] = '1*(4) + 3*(1) + 1*(7) = 14';
  molFile[42] = 'c1h3br1';
  molFormula[42] = 'CH<SUB>3</SUB>Br';
  molValence[42] = '1*(4) + 3*(1) + 1*(7) = 14';
  molFile[43] = 'c1f2cl2';
  molFormula[43] = 'CF<SUB>2</SUB>Cl<SUB>2</SUB>';
  molValence[43] = '1*(4) + 2*(7) + 2*(7) = 32';
  molFile[44] = 'c1f3i1';
  molFormula[44] = 'CF<SUB>3</SUB>I';
  molValence[44] = '1*(4) + 3*(7) + 1*(7) = 32';
  molFile[45] = 'c1cl3f1';
  molFormula[45] = 'CCl<SUB>3</SUB>F';
  molValence[45] = '1*(4) + 3*(7) + 1*(7) = 32';
  molFile[46] = 'c1o1';
  molFormula[46] = 'CO';
  molValence[46] = '1*(4) + 1*(6) = 10';
  molFile[47] = 'c1o2';
  molFormula[47] = 'CO<SUB>2</SUB>';
  molValence[47] = '1*(4) + 2*(6) = 16';
  molFile[48] = 'c1o1cl2';
  molFormula[48] = 'COCl<SUB>2</SUB>';
  molValence[48] = '1*(4) + 1*(6) + 2*(7) = 24';
  molFile[49] = 'c1s1';
  molFormula[49] = 'CS';
  molValence[49] = '1*(4) + 1*(6) = 10';
  molFile[50] = 'c1s2';
  molFormula[50] = 'CS<SUB>2</SUB>';
  molValence[50] = '1*(4) + 2*(6) = 16';
  molFile[51] = 'c1se2';
  molFormula[51] = 'CSe<SUB>2</SUB>';
  molValence[51] = '1*(4) + 2*(6) = 16';

  // chlorine 52-55

  molFile[52] = 'cl1f1';
  molFormula[52] = 'ClF';
  molValence[52] = '1*(7) + 1*(7) = 14';
  molFile[53] = 'cl2';
  molFormula[53] = 'Cl<SUB>2</SUB>';
  molValence[53] = '2*(7) = 14';
  molFile[54] = 'cl1f3';
  molFormula[54] = 'ClF<SUB>3</SUB>';
  molValence[54] = '1*(7) + 3*(7) = 28';
  molFile[55] = 'cl1f5';
  molFormula[55] = 'ClF<SUB>5</SUB>';
  molValence[55] = '1*(7) + 5*(7) = 42';

  // fluorine 56

  molFile[56] = 'f2';
  molFormula[56] = 'F<SUB>2</SUB>';
  molValence[56] = '2*(7) = 14';

  // germanium 57-66

  molFile[57] = 'ge1h4';
  molFormula[57] = 'GeH<SUB>4</SUB>';
  molValence[57] = '1*(4) + 4*(1) = 8';
  molFile[58] = 'ge1f4';
  molFormula[58] = 'GeF<SUB>4</SUB>';
  molValence[58] = '1*(4) + 4*(7) = 32';
  molFile[59] = 'ge1cl4';
  molFormula[59] = 'GeCl<SUB>4</SUB>';
  molValence[59] = '1*(4) + 4*(7) = 32';
  molFile[60] = 'ge1br4';
  molFormula[60] = 'GeBr<SUB>4</SUB>';
  molValence[60] = '1*(4) + 4*(7) = 32';
  molFile[61] = 'ge1o1';
  molFormula[61] = 'GeO';
  molValence[61] = '1*(4) + 1*(6) = 10';
  molFile[62] = 'ge1s1';
  molFormula[62] = 'GeS';
  molValence[62] = '1*(4) + 1*(6) = 10';
  molFile[63] = 'ge1se1';
  molFormula[63] = 'GeSe';
  molValence[63] = '1*(4) + 1*(6) = 10';
  molFile[64] = 'ge1te1';
  molFormula[64] = 'GeTe';
  molValence[64] = '1*(4) + 1*(6) = 10';
  molFile[65] = 'ge1o2';
  molFormula[65] = 'GeO<SUB>2</SUB>';
  molValence[65] = '1*(4) + 2*(6) = 16';
  molFile[66] = 'ge1s2';
  molFormula[66] = 'GeS<SUB>2</SUB>';
  molValence[66] = '1*(4) + 2*(6) = 16';


  // hydrogen (binary compounds) 67-75

  molFile[67] = 'h1f1';
  molFormula[67] = 'HF';
  molValence[67] = '1*(1) + 1*(7) = 8';
  molFile[68] = 'h1cl1';
  molFormula[68] = 'HCl';
  molValence[68] = '1*(1) + 1*(7) = 8';
  molFile[69] = 'h1br1';
  molFormula[69] = 'HBr';
  molValence[69] = '1*(1) + 1*(7) = 8';
  molFile[70] = 'h1i1';
  molFormula[70] = 'HI';
  molValence[70] = '1*(1) + 1*(7) = 8';
  molFile[71] = 'h2';
  molFormula[71] = 'H<SUB>2</SUB>';
  molValence[71] = '2*(1) = 2';
  molFile[72] = 'h2o1';
  molFormula[72] = 'H<SUB>2</SUB>O';
  molValence[72] = '2*(1) + 1*(6) = 8';
  molFile[73] = 'h2s1';
  molFormula[73] = 'H<SUB>2</SUB>S';
  molValence[73] = '2*(1) + 1*(6) = 8';
  molFile[74] = 'h2se1';
  molFormula[74] = 'H<SUB>2</SUB>Se';
  molValence[74] = '2*(1) + 1*(6) = 8';
  molFile[75] = 'h2te1';
  molFormula[75] = 'H<SUB>2</SUB>Te';
  molValence[75] = '2*(1) + 1*(6) = 8';

  // iodine 76-83

  molFile[76] = 'i1cl1';
  molFormula[76] = 'ICl';
  molValence[76] = '1*(7) + 1*(7) = 14';
  molFile[77] = 'i1f1';
  molFormula[77] = 'IF';
  molValence[77] = '1*(7) + 1*(7) = 14';
  molFile[78] = 'i1br1';
  molFormula[78] = 'IBr';
  molValence[78] = '1*(7) + 1*(7) = 14';
  molFile[79] = 'i1f3';
  molFormula[79] = 'IF<SUB>3</SUB>';
  molValence[79] = '1*(7) + 3*(7) = 28';
  molFile[80] = 'i1cl3';
  molFormula[80] = 'ICl<SUB>3</SUB>';
  molValence[80] = '1*(7) + 3*(7) = 28';
  molFile[81] = 'i1f5';
  molFormula[81] = 'IF<SUB>5</SUB>';
  molValence[81] = '1*(7) + 5*(7) = 42';
  molFile[82] = 'i1cl5';
  molFormula[82] = 'ICl<SUB>5</SUB>';
  molValence[82] = '1*(7) + 5*(7) = 42';
  molFile[83] = 'i2';
  molFormula[83] = 'I<SUB>2</SUB>';
  molValence[83] = '2*(7) = 14';

  // krypton 84-85

  molFile[84] = 'kr1f2';
  molFormula[84] = 'KrF<SUB>2</SUB>';
  molValence[84] = '1*(8) + 2*(7) = 22';
  molFile[85] = 'kr1f4';
  molFormula[85] = 'KrF<SUB>4</SUB>';
  molValence[85] = '1*(8) + 4*(7) = 36';

  // nitrogen 86-92

  molFile[86] = 'n1h3';
  molFormula[86] = 'NH<SUB>3</SUB>';
  molValence[86] = '1*(5) + 3*(1) = 8';
  molFile[87] = 'n1f3';
  molFormula[87] = 'NF<SUB>3</SUB>';
  molValence[87] = '1*(5) + 3*(7) = 26';
  molFile[88] = 'n1cl3';
  molFormula[88] = 'NCl<SUB>3</SUB>';
  molValence[88] = '1*(5) + 3*(7) = 26';
  molFile[89] = 'n1br3';
  molFormula[89] = 'NBr<SUB>3</SUB>';
  molValence[89] = '1*(5) + 3*(7) = 26';
  molFile[90] = 'n1i3';
  molFormula[90] = 'NI<SUB>3</SUB>';
  molValence[90] = '1*(5) + 3*(7) = 26';
  molFile[91] = 'n2';
  molFormula[91] = 'N<SUB>2</SUB>';
  molValence[91] = '2*(5) = 10';
  molFile[92] = 'n2o1';
  molFormula[92] = 'N<SUB>2</SUB>O';
  molValence[92] = '2*(5) + 1*(6) = 16';

  // oxygen 93-95

  molFile[93] = 'o1f2';
  molValence[93] = '1*(6) + 2*(7) = 20';
  molFormula[93] = 'OF<SUB>2</SUB>';
  molFile[94] = 'o2';
  molFormula[94] = 'O<SUB>2</SUB>';
  molValence[94] = '2*(6) = 12';
  molFile[95] = 'o3';
  molFormula[95] = 'O<SUB>3</SUB>';
  molValence[95] = '3*(6) = 18';

  // phosphorus 96-104

  molFile[96] = 'p1h3';
  molFormula[96] = 'PH<SUB>3</SUB>';
  molValence[96] = '1*(5) + 3*(1) = 8';
  molFile[97] = 'p1f3';
  molFormula[97] = 'PF<SUB>3</SUB>';
  molValence[97] = '1*(5) + 3*(7) = 26';
  molFile[98] = 'p1cl3';
  molFormula[98] = 'PCl<SUB>3</SUB>';
  molValence[98] = '1*(5) + 3*(7) = 26';
  molFile[99] = 'p1br3';
  molFormula[99] = 'PBr<SUB>3</SUB>';
  molValence[99] = '1*(5) + 3*(7) = 26';
  molFile[100] = 'p1i3';
  molFormula[100] = 'PI<SUB>3</SUB>';
  molValence[100] = '1*(5) + 3*(7) = 26';
  molFile[101] = 'p1f5';
  molFormula[101] = 'PF<SUB>5</SUB>';
  molValence[101] = '1*(5) + 5*(7) = 40';
  molFile[102] = 'p1cl5';
  molFormula[102] = 'PCl<SUB>5</SUB>';
  molValence[102] = '1*(5) + 5*(7) = 40';
  molFile[103] = 'p1br5';
  molFormula[103] = 'PBr<SUB>5</SUB>';
  molValence[103] = '1*(5) + 5*(7) = 40';
  molFile[104] = 'p1o1cl3';
  molFormula[104] = 'POCl<SUB>3</SUB>';
  molValence[104] = '1*(5) + 1*(6) + 3*(7) = 32';

  // selenium 105-113

  molFile[105] = 'se1cl2';
  molFormula[105] = 'SeCl<SUB>2</SUB>';
  molValence[105] = '1*(6) + 2*(7) = 20';
  molFile[106] = 'se1f4';
  molFormula[106] = 'SeF<SUB>4</SUB>';
  molValence[106] = '1*(6) + 4*(7) = 34';
  molFile[107] = 'se1cl4';
  molFormula[107] = 'SeCl<SUB>4</SUB>';
  molValence[107] = '1*(6) + 4*(7) = 34';
  molFile[108] = 'se1br4';
  molFormula[108] = 'SeBr<SUB>4</SUB>';
  molValence[108] = '1*(6) + 4*(7) = 34';
  molFile[109] = 'se1f6';
  molFormula[109] = 'SeF<SUB>6</SUB>';
  molValence[109] = '1*(6) + 6*(7) = 48';
  molFile[110] = 'se1cl6';
  molFormula[110] = 'SeCl<SUB>6</SUB>';
  molValence[110] = '1*(6) + 6*(7) = 48';
  molFile[111] = 'se1o1';
  molFormula[111] = 'SeO';
  molValence[111] = '1*(6) + 1*(6) = 12';
  molFile[112] = 'se1o2';
  molFormula[112] = 'SeO<SUB>2</SUB>';
  molValence[112] = '1*(6) + 2*(6) = 18';
  molFile[113] = 'se1o3';
  molFormula[113] = 'SeO<SUB>3</SUB>';
  molValence[113] = '1*(6) + 3*(6) = 24';

  // silicon 114-126

  molFile[114] = 'si1f1h3';
  molFormula[114] = 'SiFH<SUB>3</SUB>';
  molValence[114] = '1*(4) + 1*(7) + 3*(1) = 14';
  molFile[115] = 'si1br1h3';
  molFormula[115] = 'SiBrH<SUB>3</SUB>';
  molValence[115] = '1*(4) + 1*(7) + 3*(1) = 14';
  molFile[116] = 'si1br1f3';
  molFormula[116] = 'SiBrF<SUB>3</SUB>';
  molValence[116] = '1*(4) + 1*(7) + 3*(7) = 32';
  molFile[117] = 'si1f4';
  molFormula[117] = 'SiF<SUB>4</SUB>';
  molValence[117] = '1*(4) + 4*(7) = 32';
  molFile[118] = 'si1cl4';
  molFormula[118] = 'SiCl<SUB>4</SUB>';
  molValence[118] = '1*(4) + 4*(7) = 32';
  molFile[119] = 'si1br4';
  molFormula[119] = 'SiBr<SUB>4</SUB>';
  molValence[119] = '1*(4) + 4*(7) = 32';
  molFile[120] = 'si1i4';
  molFormula[120] = 'SiI<SUB>4</SUB>';
  molValence[120] = '1*(4) + 4*(7) = 32';
  molFile[121] = 'si1h4';
  molFormula[121] = 'SiH<SUB>4</SUB>';
  molValence[121] = '1*(4) + 4*(1) = 8';
  molFile[122] = 'si1h1f3';
  molFormula[122] = 'SiHF<SUB>3</SUB>';
  molValence[122] = '1*(4) + 1*(1) + 3*(7) = 26';
  molFile[123] = 'si1o1';
  molFormula[123] = 'SiO';
  molValence[123] = '1*(4) + 1*(6) = 10';
  molFile[124] = 'si1s1';
  molFormula[124] = 'SiS';
  molValence[124] = '1*(4) + 1*(6) = 10';
  molFile[125] = 'si1se1';
  molFormula[125] = 'SiSe';
  molValence[125] = '1*(4) + 1*(6) = 10';
  molFile[126] = 'si1o2';
  molFormula[126] = 'SiO<SUB>2</SUB>';
  molValence[126] = '1*(4) + 2*(6) = 16';

  // sulfur 127-136

  molFile[127] = 's1o1';
  molFormula[127] = 'SO';
  molValence[127] = '1*(6) + 1*(6) = 12';
  molFile[128] = 's1o2';
  molFormula[128] = 'SO<SUB>2</SUB>';
  molValence[128] = '1*(6) + 2*(6) = 18';
  molFile[129] = 's1o3';
  molFormula[129] = 'SO<SUB>3</SUB>';
  molValence[129] = '1*(6) + 3*(6) = 24';
  molFile[130] = 's1o2f2';
  molFormula[130] = 'SO<SUB>2</SUB>F<SUB>2</SUB>';
  molValence[130] = '1*(6) + 2*(6) + 2*(7) = 32';
  molFile[131] = 's1o2cl2';
  molFormula[131] = 'SO<SUB>2</SUB>Cl<SUB>2</SUB>';
  molValence[131] = '1*(6) + 2*(6) + 2*(7) = 32';
  molFile[132] = 's1f2';
  molFormula[132] = 'SF<SUB>2</SUB>';
  molValence[132] = '1*(6) + 2*(7) = 20';
  molFile[133] = 's1cl2';
  molFormula[133] = 'SCl<SUB>2</SUB>';
  molValence[133] = '1*(6) + 2*(7) = 20';
  molFile[134] = 's1f4';
  molFormula[134] = 'SF<SUB>4</SUB>';
  molValence[134] = '1*(6) + 4*(7) = 34';
  molFile[135] = 's1cl4';
  molFormula[135] = 'SCl<SUB>4</SUB>';
  molValence[135] = '1*(6) + 4*(7) = 34';
  molFile[136] = 's1f6';
  molFormula[136] = 'SF<SUB>6</SUB>';
  molValence[136] = '1*(6) + 6*(7) = 48';

  // tellurium 137-147

  molFile[137] = 'te1o1';
  molFormula[137] = 'TeO';
  molValence[137] = '1*(6) + 1*(6) = 12';
  molFile[138] = 'te1o2';
  molFormula[138] = 'TeO<SUB>2</SUB>';
  molValence[138] = '1*(6) + 2*(6) = 18';
  molFile[139] =  'te1s2';
  molFormula[139] = 'TeS<SUB>2</SUB>';
  molValence[139] = '1*(6) + 2*(6) = 18';
  molFile[140] = 'te1o3';
  molFormula[140] = 'TeO<SUB>3</SUB>';
  molValence[140] = '1*(6) + 3*(6) = 24';
  molFile[141] = 'te1cl2';
  molFormula[141] = 'TeCl<SUB>2</SUB>';
  molValence[141] = '1*(6) + 2*(7) = 20';
  molFile[142] = 'te1br2';
  molFormula[142] = 'TeBr<SUB>2</SUB>';
  molValence[142] = '1*(6) + 2*(7) = 20';
  molFile[143] = 'te1i2';
  molFormula[143] = 'TeI<SUB>2</SUB>';
  molValence[143] = '1*(6) + 2*(7) = 20';
  molFile[144] = 'te1f4';
  molFormula[144] = 'TeF<SUB>4</SUB>';
  molValence[144] = '1*(6) + 4*(7) = 34';
  molFile[145] = 'te1cl4';
  molFormula[145] = 'TeCl<SUB>4</SUB>';
  molValence[145] = '1*(6) + 4*(7) = 34';
  molFile[146] = 'te1br4';
  molFormula[146] = 'TeBr<SUB>4</SUB>';
  molValence[146] = '1*(6) + 4*(7) = 34';
  molFile[147] = 'te1i4';
  molFormula[147] = 'TeI<SUB>4</SUB>';
  molValence[147] = '1*(6) + 4*(7) = 34';

  // xenon 148-152

  molFile[148] = 'xe1f2';
  molFormula[148] = 'XeF<SUB>2</SUB>';
  molValence[148] = '1*(8) + 2*(7) = 22';
  molFile[149] = 'xe1f4';
  molFormula[149] = 'XeF<SUB>4</SUB>';
  molValence[149] = '1*(8) + 4*(7) = 36';
  molFile[150] = 'xe1cl4';
  molFormula[150] = 'XeCl<SUB>4</SUB>';
  molValence[150] = '1*(8) + 4*(7) = 36';
  molFile[151] = 'xe1o3';
  molFormula[151] = 'XeO<SUB>3</SUB>';
  molValence[151] = '1*(8) + 3*(6) = 26';
  molFile[152] = 'xe1o4';
  molFormula[152] = 'XeO<SUB>4</SUB>';
  molValence[152] = '1*(8) + 4*(6) = 32';

  // polyatomic ions 153-180

  molFile[153] = 'as1o4m3';
  molFormula[153] = 'AsO<SUB>4</SUB><SUP>3-</SUP>';
  molValence[153] = '1*(5) + 4*(6) + 3 = 32';
  molFile[154] = 'br1o2m1';
  molFormula[154] = 'BrO<SUB>2</SUB><SUP>1-</SUP>';
  molValence[154] = '1*(7) + 2*(6) + 1 = 20';
  molFile[155] = 'br3m1';
  molFormula[155] = 'Br<SUB>3</SUB><SUP>1-</SUP>';
  molValence[155] = '3*(7) + 1 = 22';
  molFile[156] = 'c1n1m1';
  molFormula[156] = 'CN<SUP>1-</SUP>';
  molValence[156] = '1*(4) + 1*(5) + 1 = 10';
  molFile[157] = 'c1o3m2';
  molFormula[157] = 'CO<SUB>3</SUB><SUP>2-</SUP>';
  molValence[157] = '1*(4) + 3*(6) + 2 = 24';
  molFile[158] = 'cl1o1m1';
  molFormula[158] = 'ClO<SUP>1-</SUP>';
  molValence[158] = '1*(7) + 1*(6) + 1 = 14';
  molFile[159] = 'cl1o4m1';
  molFormula[159] = 'ClO<SUB>4</SUB><SUP>1-</SUP>';
  molValence[159] = '1*(7) + 4*(6) + 1 = 32';
  molFile[160] = 'ge1f3m1';
  molFormula[160] = 'GeF<SUB>3</SUB><SUP>1-</SUP>';
  molValence[160] = '1*(4) + 3*(7) + 1 = 26';
  molFile[161] = 'ge1cl3m1';
  molFormula[161] = 'GeCl<SUB>3</SUB><SUP>1-</SUP>';
  molValence[161] = '1*(4) + 3*(7) + 1 = 26';
  molFile[162] = 'h2f1p1';
  molFormula[162] = 'H<SUB>2</SUB>F<SUP>1+</SUP>';
  molValence[162] = '2*(1) + 1*(7) - 1 = 8';
  molFile[163] = 'h3o1p1';
  molFormula[163] = 'H<SUB>3</SUB>O<SUP>1+</SUP>';
  molValence[163] = '3*(1) + 1*(6) - 1 = 8';
  molFile[164] = 'i1cl2m1';
  molFormula[164] = 'ICl<SUB>2</SUB><SUP>1-</SUP>';
  molValence[164] = '1*(7) + 2*(7) + 1 = 22';
  molFile[165] = 'i1cl4m1';
  molFormula[165] = 'ICl<SUB>4</SUB><SUP>1-</SUP>';
  molValence[165] = '1*(7) + 4*(7) + 1 = 36';
  molFile[166] = 'i1f4m1';
  molFormula[166] = 'IF<SUB>4</SUB><SUP>1-</SUP>';
  molValence[166] = '1*(7) + 4*(7) + 1 = 36';
  molFile[167] = 'i3m1';
  molFormula[167] = 'I<SUB>3</SUB><SUP>1-</SUP>';
  molValence[167] = '3*(7) + 1 = 22';
  molFile[168] = 'n1h4p1';
  molFormula[168] = 'NH<SUB>4</SUB><SUP>1+</SUP>';
  molValence[168] = '1*(5) + 4*(1) - 1 = 8';
  molFile[169] = 'n1o1p1';
  molFormula[169] = 'NO<SUP>1+</SUP>';
  molValence[169] = '1*(5) + 1*(6) - 1 = 10';
  molFile[170] = 'n1o2m1';
  molFormula[170] = 'NO<SUB>2</SUB><SUP>1-</SUP>';
  molValence[170] = '1*(5) + 2*(6) + 1 = 18';
  molFile[171] = 'n1o3m1';
  molFormula[171] = 'NO<SUB>3</SUB><SUP>1-</SUP>';
  molValence[171] = '1*(5) + 3*(6) + 1 = 24';
  molFile[172] = 'n3m1';
  molFormula[172] = 'N<SUB>3</SUB><SUP>1-</SUP>';
  molValence[172] = '3*(5) + 1 = 16';
  molFile[173] = 'p1cl4p1';
  molFormula[173] = 'PCl<SUB>4</SUB><SUP>1+</SUP>';
  molValence[173] = '1*(5) + 4*(7) - 1 = 32';
  molFile[174] = 'p1f6m1';
  molFormula[174] = 'PF<SUB>6</SUB><SUP>1-</SUP>';
  molValence[174] = '1*(5) + 6*(7) + 1 = 48';
  molFile[175] = 'p1o4m3';
  molFormula[175] = 'PO<SUB>4</SUB><SUP>3-</SUP>';
  molValence[175] = '1*(5) + 4*(6) + 3 = 32';
  molFile[176] = 's1o3m2';
  molFormula[176] = 'SO<SUB>3</SUB><SUP>2-</SUP>';
  molValence[176] = '1*(6) + 3*(6) + 2 = 26';
  molFile[177] = 's1o4m2';
  molFormula[177] = 'SO<SUB>4</SUB><SUP>2-</SUP>';
  molValence[177] = '1*(6) + 4*(6) + 2 = 32';
  molFile[178] = 'sb1f6m1';
  molFormula[178] = 'SbF<SUB>6</SUB><SUP>1-</SUP>';
  molValence[178] = '1*(5) + 6*(7) + 1 = 48';
  molFile[179] = 'se1o4m2';
  molFormula[179] = 'SeO<SUB>4</SUB><SUP>2-</SUP>';
  molValence[179] = '1*(6) + 4*(6) + 2 = 32';
  molFile[180] = 'si1f6m2';
  molFormula[180] = 'SiF<SUB>6</SUB><SUP>2-</SUP>';
  molValence[180] = '1*(4) + 6*(7) + 2 = 48';

  // oxyacids 181-197

  molFile[181] = 'h1br1o1';
  molFormula[181] = 'HBrO';
  molValence[181] = '1*(1) + 1*(7) + 1*(6) = 14';
  molFile[182] = 'h1br1o2';
  molFormula[182] = 'HBrO<SUB>2</SUB>';
  molValence[182] = '1*(1) + 1*(7) + 2*(6) = 20';
  molFile[183] = 'h1br1o3';
  molFormula[183] = 'HBrO<SUB>3</SUB>';
  molValence[183] = '1*(1) + 1*(7) + 3*(6) = 26';
  molFile[184] = 'h1br1o4';
  molFormula[184] = 'HBrO<SUB>4</SUB>';
  molValence[184] = '1*(1) + 1*(7) + 4*(6) = 32';
  molFile[185] = 'h1cl1o1';
  molFormula[185] = 'HClO';
  molValence[185] = '1*(1) + 1*(7) + 1*(6) = 14';
  molFile[186] = 'h1cl1o2';
  molFormula[186] = 'HClO<SUB>2</SUB>';
  molValence[186] = '1*(1) + 1*(7) + 2*(6) = 20';
  molFile[187] = 'h1cl1o3';
  molFormula[187] = 'HClO<SUB>3</SUB>';
  molValence[187] = '1*(1) + 1*(7) + 3*(6) = 26';
  molFile[188] = 'h1cl1o4';
  molFormula[188] = 'HClO<SUB>4</SUB>';
  molValence[188] = '1*(1) + 1*(7) + 4*(6) = 32';
  molFile[189] = 'h1n1o2';
  molFormula[189] = 'HNO<SUB>2</SUB>';
  molValence[189] = '1*(1) + 1*(5) + 2*(6) = 18';
  molFile[190] = 'h1n1o3';
  molFormula[190] = 'HNO<SUB>3</SUB>';
  molValence[190] = '1*(1) + 1*(5) + 3*(6) = 24';
  molFile[191] = 'h2c1o3';
  molFormula[191] = 'H<SUB>2</SUB>CO<SUB>3</SUB>';
  molValence[191] = '2*(1) + 1*(4) + 3*(6) = 24';
  molFile[192] = 'h2s1o3';
  molFormula[192] = 'H<SUB>2</SUB>SO<SUB>3</SUB>';
  molValence[192] = '2*(1) + 1*(6) + 3*(6) = 26';
  molFile[193] = 'h2s1o4';
  molFormula[193] = 'H<SUB>2</SUB>SO<SUB>4</SUB>';
  molValence[193] = '2*(1) + 1*(6) + 4*(6) = 32';
  molFile[194] = 'h2se1o4';
  molFormula[194] = 'H<SUB>2</SUB>SeO<SUB>4</SUB>';
  molValence[194] = '2*(1) + 1*(6) + 4*(6) = 32';
  molFile[195] = 'h3as1o4';
  molFormula[195] = 'H<SUB>3</SUB>AsO<SUB>4</SUB>';
  molValence[195] = '3*(1) + 1*(5) + 4*(6) = 32';
  molFile[196] = 'h3p1o4';
  molFormula[196] = 'H<SUB>3</SUB>PO<SUB>4</SUB>';
  molValence[196] = '3*(1) + 1*(5) + 4*(6) = 32';
  
function chooseRandomMolecule() {
  var count = 0;
  var check;
  var match;
  var offset;
  if (quizType == 0) {

  // molecules

    offset = 0;
    possMolecules = 153;
  }
  else if (quizType == 1) {

  // ions
 
    offset = 153;
    possMolecules = 28;
  }
  else if (quizType == 2) {

  // oxyacids

    offset = 181;
    possMolecules = 16;
  }
  else {

  // random selection from molecules, ions, and oxyacids

    offset = 0;
    possMolecules = 197;
  }
  while (count < totalMolecules) {
    molNum[count] = Math.round((possMolecules - 1)*Math.random());
    molNum[count] = molNum[count] + offset;
    if (totalMolecules > 1) {
      check = 0;
      match = false;
      checkloop:
        while (check < count) {
          if (molNum[count] == molNum[check]) {
            match = true;
            break checkloop;
          }
          check++;
        }
      if (!(match)) {
        count++;
      }
    }
    else {
      count++;
    }
  }
}

function popUpRules() {
  rulesWindowOpened = 1;
  rulesWindow = window.open('lewis-rules8.html','rulesWindowName','resizable=1,scrollbars=1,width=500,height=400');
  rulesWindow.focus();
}

function popUpTable() {
  tableWindowOpened = 1;
  tableWindow = window.open('../Nomen/period-basic.html','tableWindowName','resizable=1,scrollbars=1,width=600,height=500');
  tableWindow.focus();
}

function closeChildWindows() {
  if (rulesWindowOpened) {
    if (!rulesWindow.closed) {
      rulesWindow.close();
    }
  }
  if (quizWindowOpened) {
    if (!quizWindow.closed) {
      quizWindow.close();
    }
  }
  if (tableWindowOpened) {
    if (!tableWindow.closed) {
      tableWindow.close();
    }
  }
  if (helpWindowOpened) {
    if (!helpWindow.closed) {
      helpWindow.close();
    }
  }
}

function initValues(isAdmin) {
  var isAdmin;
    
  if (isAdmin == 1) {
    window.document.adminlewis.password.value = '';
  }
  else {
    totalMolecules = 1;
  }
  defaultValue = 'Don\'t peek!';
  rulesWindowOpened = 0;
  quizWindowOpened = 0;
  tableWindowOpened = 0;
  helpWindowOpened = 0;
}

function popUpLewisQuiz(tempValue) {
  var tempValue;

//  quizType = tempValue.substr(-1,1) - 0;
  quizType = tempValue.substr(tempValue.length - 1,1) - 0;
  quizType = quizType - 1;
  lewisQuiz(0);
}

function anotherLewisQuiz(tempValue) {
  var tempValue;

  quizType = tempValue;
  lewisQuiz(0);
}

function openHelpWindow() {
  helpWindowOpened = 1;
  helpWindow = window.open('lewis-help.html','helpWindowName','resizable=1,scrollbars=1,status=1,width=650,height=425');
  helpWindow.focus();
}

function addressPrint() {
  quizWindow.document.write('<HR>\n<DIV>\n' +
    '<A HREF=\"javascript: opener.openHelpWindow()\"><IMG ALT=\"help!\" ' +
    'BORDER=\"0\" ALIGN=\"right\" SRC=\"..\/..\/Images\/help-button.gif\" ' +
    'HEIGHT=\"37\" WIDTH=\"62\"><\/A>\nScript last modified: ' + dateMod + 
    '<BR><A HREF=\"mailto:' + emailAdd + '\">' + emailAdd +
    '<\/A>\n<\/DIV>\n');
}

function lewisQuiz(isAdmin) {
  var isAdmin;
  var count;
  var TempNum;
  var tempVal;

  if (isAdmin == 0) {
    chooseRandomMolecule();
  }
  quizWindowOpened = 1;
  quizWindow = window.open('','quizWindowName','resizable=1,scrollbars=1,status=1,width=550,height=600');
  quizWindow.document.write('<HTML>\n<HEAD>\n<TITLE>Lewis Structure Quiz' +
    '<\/TITLE>\n<SCR' + 'IPT TYPE=\"text/Javascript\" LANGUAGE=\"javascript\">\n' +
    'var totalMolecules = ' + totalMolecules + ';\n' +
    'var defaultValue;\n');
  quizWindow.document.write('if (document.images) {\n' +
    'spacerMol = new Image();\n' +
    'spacerMol.src = \"Images\/lewis-spacer.gif\";\n');
  count = 0;
  while (count < totalMolecules) {
    quizWindow.document.write(molFile[molNum[count]] + 
      ' = new Image();\n' + molFile[molNum[count]] +
      '.src = \"Images\/Random\/' + molFile[molNum[count]] + '.gif\";\n')
    count++;
  }
  quizWindow.document.write('}\n');
  count = 0;
  while (count < totalMolecules) {
    if (molValence[molNum[count]].substr(molValence[molNum[count]].length-2,1) == ' ') {
      tempVal = molValence[molNum[count]].substr(molValence[molNum[count]].length-1,1);
    }
    else {
      tempVal = molValence[molNum[count]].substr(molValence[molNum[count]].length-2);
    }
    quizWindow.document.write('function revealValence' + 
      molFile[molNum[count]] + '() {\nvar tagLine;\n' +
      'tagLine = \'Yes!     \';\n' +
      'if (window.document.formulaName' + molFile[molNum[count]] +
      '.guess.value != ' + tempVal + ') {\ntagLine = \'No!      \';\n' +
      'if (!window.document.formulaName' + molFile[molNum[count]] +
      '.guess.value) {\ndocument.formulaName' + molFile[molNum[count]] +
      '.guess.value = \'???\';\n}\n}\n' +
      'window.document.formulaName' + molFile[molNum[count]] +
      '.molFormulaName.value = tagLine + \'' + molValence[molNum[count]] + '\';\n' +
      'return false;\n}\n');
    count++;
  }
  count = 0;
  quizWindow.document.write('function initValues() {\n');
  quizWindow.document.write('defaultValue = \'# of electrons will appear here\';\n');
  while (count < totalMolecules) {
    quizWindow.document.write('window.document.formulaName' + 
      molFile[molNum[count]] +
      '.guess.value = \'\';\n');
    quizWindow.document.write('window.document.formulaName' + 
      molFile[molNum[count]] +
      '.molFormulaName.value = defaultValue;\n');
    count++;
  }
  quizWindow.document.write('}\n');
  quizWindow.document.write('function quizReset() {\n' +
    '  count = 0;\n  while (count < totalMolecules) {\n' +
    '    tempName = count + \'mol\';\n' +
    '    changeImage(tempName,\'spacerMol\');\n' +
    '    count++;\n  }\n  initValues();\n}\n');
  quizWindow.document.write('function changeImage(formName,newImage) {\n' +
    'if (document.images) {\n' +
    '  document[formName].src = eval(newImage + \".src\");\n' +
    '}\n');
  quizWindow.document.write('}\n');
  printButtonChanges();
  quizWindow.document.write('<\/SCR' + 'IPT>\n' +
    '<\/HEAD>\n<BODY STYLE=\"background: #FFFFFF\"');
  quizWindow.document.write(' onLoad=\"initValues()\"');
  quizWindow.document.write('>\n<H1 STYLE=\"text-align: center\">' +
    'Lewis Structures<\/H1>\n');
  if (isAdmin == 0) {
    quizWindow.document.write('<H2 STYLE=\"text-align: center\">Quiz ' + 
      (quizType + 1) + '- ');
    if (quizType == 0) {
      quizWindow.document.write('Molecules');
    }
    else if (quizType == 1) {
      quizWindow.document.write('Polyatomic Ions');
    }
    else if (quizType == 2) {
      quizWindow.document.write('Oxyacids');
    }
    else {
    quizWindow.document.write('Random Selection- Molecules, ' +
        'Polyatomic Ions, and Oxyacids');
    }
    quizWindow.document.write(' <\/H2>\n');
  }
  count = 0;
  quizWindow.document.write('<TABLE ALIGN=\"center\" BORDER=\"0\">\n<TR>\n' +
    '<TD><HR><\/TD>\n<\/TR>');
  while (count < totalMolecules) {
    tempNum = count + 1;
    quizWindow.document.write('<TR>\n<TD ALIGN=\"center\">\n' +
      '<H3>' + molFormula[molNum[count]] + '<\/H3>\n<\/TD>\n<\/TR>\n' +
      '<TR><TD><HR><\/TD><\/TR>\n');
    quizWindow.document.write('<TR>\n' +
      '<TD ALIGN=\"center\"><BR>\n<FORM NAME=\"formulaName' + 
      molFile[molNum[count]] + '\" onSubmit=\"return revealValence' +
      molFile[molNum[count]] + '();\">\n' + 
      'Total number of valence electrons: \n' +
      '<INPUT TYPE=\"text\" NAME=\"guess\" SIZE=\"5\" VALUE=\"\">\n' +
      '<INPUT TYPE=\"submit\" VALUE=\"Verify\" ' +
      'onMouseOver=\"mOver(0,1)\" onMouseOut=\"mOut(0,1)\">\n<BR><BR>' +
      '<INPUT TYPE=\"text\" NAME=\"molFormulaName\" SIZE=\"' + textLength +
      '\" VALUE=\"\">\n' +
      '<\/FORM><\/TD>\n<\/TR>\n');
    quizWindow.document.write('<TR>\n<TD ALIGN=\"center\">');
    quizWindow.document.write('<IMG NAME=\"' + count + 'mol\" ' +
      'BORDER=\"1\" SRC=\"Images\/lewis-spacer.gif\" WIDTH=\"150\" '+
      'HEIGHT=\"150\" alt=\"lewis structure will be here\">');
    quizWindow.document.write('<\/TD>\n<\/TR>\n');
    quizWindow.document.write('<TR>\n<TD ALIGN=\"center\">\n<FORM NAME=\"' + 
      count + 'molSwap\">\n<INPUT TYPE=\"button\" ' +
      'onMouseOver=\"mOver(1,0)\" onMouseOut=\"mOut(1,0)\" ' +
      'onClick=\"changeImage(\''+ count + 'mol\',\'');
    quizWindow.document.write(molFile[molNum[count]]);
    quizWindow.document.write('\')\" VALUE=\"Reveal Structure!\">\n' +
      '<\/FORM><\/TD>\n<\/TR>\n');
    quizWindow.document.write('<TR>\n<TD><HR><\/TD>\n<\/TR>\n');
    count++;
  }
  quizWindow.document.write('<TR>\n<TD ALIGN=\"center\">\n' +
    '<FORM>\n<INPUT TYPE=\"button\" ');
  quizWindow.document.write('onClick=\"quizReset()\"\n');
  quizWindow.document.write('onMouseOver=\"mOver(document.forms.length-3,0); self.status=\'Reset Quiz ' +
    'Answer(s)\';return true\"\n' +
    'onMouseOut=\"mOut(document.forms.length-3,0); self.status=\'\';return true\"\n' +
    'VALUE=\"Reset Answer(s)\">\n<INPUT TYPE=\"button\" ' +
    'onMouseOver=\"mOver(document.forms.length-3,1); self.status=\'Another quiz\';return true\"\n' +
    'onMouseOut=\"mOut(document.forms.length-3,1); self.status=\'\';return true\"\n' +
    'onClick=\"opener.anotherLewisQuiz(' + quizType + ');\" ' +
    'VALUE=\"Gimme\' Another One\">\n<\/FORM>\n' +
    '<\/TD>\n<\/TR>\n');
  quizWindow.document.write('<\/TABLE>\n');
  quizWindow.document.write('<TABLE ALIGN=\"center\">\n<TR>\n<TD>\n' +
    '<FORM>\n<INPUT TYPE="button\" onClick=\"window.close()\"\n' +
    'onMouseOver=\"mOver(document.forms.length-2,0); self.status=\'Close this window\';return true\"\n' +
    'onMouseOut=\"mOut(document.forms.length-2,0); self.status=\'\';return true\"\n' +
    'VALUE=\"Close Window\">\n<\/FORM>\n<\/TD>\n<TD>\n<FORM>\n' +
    '<INPUT TYPE=\"button\" onClick=\"opener.focus()\"\n' +
    'onMouseOver=\"mOver(document.forms.length-1,0); self.status=\'Switch back to the tutorial\';return true\"\n' +
    'onMouseOut=\"mOut(document.forms.length-1,0); self.status=\'\';return true\"\n' +
    'VALUE=\"Switch Windows\">\n<\/FORM>\n<\/TD>\n<\/TR>\n<\/TABLE>\n');
  addressPrint();
  quizWindow.document.write('<\/BODY><\/HTML>');
  quizWindow.document.close();
  quizWindow.focus();
}

function printButtonChanges() {
  quizWindow.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');
}
