
NewBrowser =
          (((navigator.appName == "Netscape") &&
            (parseInt(navigator.appVersion) >= 3 )) ||
           ((navigator.appName == "Microsoft Internet Explorer") &&
            (parseInt(navigator.appVersion) >= 4 )));

function preload( img )
        {
          var a = new Image();
          a.src = img;
          return a;
        }

if ( NewBrowser )
        {
	    var Notes = new Array(42)
            Notes[0] = preload( "ab1.gif" );
            Notes[1] = preload( "a1.gif" );
            Notes[2] = preload( "as1.gif" );
            Notes[3] = preload( "bb1.gif" );
            Notes[4] = preload( "b1.gif" );
            Notes[5] = preload( "bs1.gif" );
            Notes[6] = preload( "cb2.gif" );
            Notes[7] = preload( "c2.gif" );                       
            Notes[8] = preload( "cs2.gif" );
	    Notes[9] = preload( "db1.gif" );
	    Notes[10] = preload( "d1.gif" );
            Notes[11] = preload( "ds1.gif" );
            Notes[12] = preload( "eb1.gif" );
            Notes[13] = preload( "e1.gif" );
            Notes[14] = preload( "es1.gif" );
            Notes[15] = preload( "fb1.gif" );
            Notes[16] = preload( "f1.gif" );
            Notes[17] = preload( "fs1.gif" );
            Notes[18] = preload( "gb1.gif" );
            Notes[19] = preload( "g1.gif" );
            Notes[20] = preload( "gs1.gif" );
            Notes[21] = preload( "ab2.gif" );
            Notes[22] = preload( "a2.gif" );
            Notes[23] = preload( "as2.gif" );
            Notes[24] = preload( "bb2.gif" );
            Notes[25] = preload( "b2.gif" );
            Notes[26] = preload( "bs2.gif" );
            Notes[27] = preload( "cb3.gif" );
            Notes[28] = preload( "c3.gif" );
            Notes[29] = preload( "cs3.gif" );
            Notes[30] = preload( "db2.gif" );
            Notes[31] = preload( "d2.gif" );
            Notes[32] = preload( "ds2.gif" );
            Notes[33] = preload( "eb2.gif" );
            Notes[34] = preload( "e2.gif" );
            Notes[35] = preload( "es2.gif" );
            Notes[36] = preload( "fb2.gif" );
            Notes[37] = preload( "f2.gif" );
            Notes[38] = preload( "fs2.gif" );
            Notes[39] = preload( "gb2.gif" );
            Notes[40] = preload( "g2.gif" );
            Notes[41] = preload( "gs2.gif" );
        }

if ( NewBrowser )
        {
		blankstaff = preload( "blankstaff.gif" );
        }

var debug;
AnswerScale = new Array(8);
Correct = new Array(8);
Wrong = new Array(8);
var FirstName = null;
var NoteName2 = null;
var NoteName3 = null;
var NoteName4 = null;
var NoteName5 = null;
var NoteName6 = null;
var NoteName7 = null;
var NoteName8 = null;
var Acc2 = 1;
var Acc3 = 1;
var Acc4 = 1;
var Acc5 = 1;
var Acc6 = 1;
var Acc7 = 1;
var Acc8 = 1;

function GetFirstNote(num)
{
//  var num = 0;
//  num = Math.floor(Math.random() * 9);
  if ( num == 0 )
  {
    document.Form1.firstimage.src = Notes[1].src;
//    document.Form1.firstname.value = "A";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 1;
  }
  else if ( num == 1 )
  {
    document.Form1.firstimage.src = Notes[4].src;
//    document.Form1.firstname.value = "B";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 4;
  }
  else if ( num == 2 )
  {
    document.Form1.firstimage.src = Notes[7].src;
//    document.Form1.firstname.value = "C";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 7;
  }
  else if ( num == 3 )
  {
    document.Form1.firstimage.src = Notes[10].src;
//    document.Form1.firstname.value = "D";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 10;
  }
  else if ( num == 4 )
  {
    document.Form1.firstimage.src = Notes[13].src;
//    document.Form1.firstname.value = "E";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 13;
  }
  else if ( num == 5 )
  {
    document.Form1.firstimage.src = Notes[16].src;
//    document.Form1.firstname.value = "F";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 16;
  }
  else if ( num == 6 )
  {
    document.Form1.firstimage.src = Notes[19].src;
//    document.Form1.firstname.value = "G";
//    document.Form1.accidental1.value = "n";
    AnswerScale[0] = 19;
  }
  else if ( num == 7 )
  {
    document.Form1.firstimage.src = Notes[3].src;
//    document.Form1.firstname.value = "B";
//    document.Form1.accidental1.value = "b";
    AnswerScale[0] = 3;
  }
  else if ( num == 8 )
  {
    document.Form1.firstimage.src = Notes[12].src;
//    document.Form1.firstname.value = "E";
//    document.Form1.accidental1.value = "b";
    AnswerScale[0] = 12;
  }
  else if ( num == 9 )
  {
    document.Form1.firstimage.src = Notes[0].src;
//    document.Form1.firstname.value = "A";
//    document.Form1.accidental1.value = "b";
    AnswerScale[0] = 0;
  }
}

function GetCorrectAnswer()
{
  if (AnswerScale[0] == 1)
  {
   var CorrectAnswer = new Array(1, 4, 8, 31, 34, 38, 41, 22);
  }
  if (AnswerScale[0] == 4)
  {
   var CorrectAnswer = new Array(4, 8, 32, 34, 38, 41, 23, 25);
  }
  if (AnswerScale[0] == 7)
  {
    var CorrectAnswer = new Array(7, 31, 34, 37, 40, 22, 25, 28);
  }
  if (AnswerScale[0] == 10)
  {
    var CorrectAnswer = new Array(10, 13, 17, 19, 1, 4, 8, 31);
  }
  if (AnswerScale[0] == 13)
  {
    var CorrectAnswer = new Array(13, 17, 20, 1, 4, 8, 32, 34);
  }
  if (AnswerScale[0] == 16)
  {
    var CorrectAnswer = new Array(16, 19, 1, 3, 7, 31, 34, 37);
  }
  if (AnswerScale[0] == 19)
  {
    var CorrectAnswer = new Array(19, 1, 4, 7, 31, 34, 38, 40);
  }
  if (AnswerScale[0] == 0)
  {
    var CorrectAnswer = new Array(0, 3, 7, 30, 33, 37, 40, 21);
  }
  if (AnswerScale[0] == 12)
  {
    var CorrectAnswer = new Array(12, 16, 19, 0, 3, 7, 31, 33);
  }
  if (AnswerScale[0] == 3)
  {
    var CorrectAnswer = new Array(3, 7, 31, 33, 37, 40, 22, 24);
  }
//  else {
//  document.Form1.Debug.value = "error of some kind";
//  }
  count = 0;
  while (count <= 7)
  {
    Correct[count] = CorrectAnswer[count];
    count = count + 1;
  }
}

function GetNote(imagesrc, name, accidental, answernum)
{
  var arraynum;
  if (name != "null" && accidental != "null")
  {
    if ( AnswerScale[answernum] >= 21 )
    {
      arraynum = name * 3 + parseInt(accidental) + 21;
      imagesrc.src = Notes[arraynum].src;
      AnswerScale[answernum] = arraynum;
    }else{
    arraynum = name * 3 + parseInt(accidental);
    imagesrc.src = Notes[arraynum].src;
    AnswerScale[answernum] = arraynum;
//    document.Form1.Debug.value = AnswerScale[0] + ", " + AnswerScale[1] + ", " + //AnswerScale[2] + ", " + AnswerScale[3];
    }
  }
//  document.Form1.debug1.value = accidental;
//  document.Form1.debug.value = name;
}

function ChangeOctave(image, name, accidental, answernum)
{
  var arraynum;
  if (name != "null" && accidental != "null")
  {
    if ( AnswerScale[answernum] >= 21 )
    {
      arraynum = AnswerScale[answernum] - 21;
      image.src = Notes[arraynum].src;
      AnswerScale[answernum] = arraynum;
    }
    else
    {
      arraynum = name * 3 + parseInt(accidental) + 21;
      image.src = Notes[arraynum].src;
      AnswerScale[answernum] = arraynum;
    }
  }
}

function SubmitScale()
{
  if (AnswerScale[0] != null)
  {
    count = 0;
    while (count <= 7 )
    {
      Wrong[count] = "";
      count = count + 1;
    }
    document.Form1.Result.value = null;
    document.Form1.Result1.value = "";
    GetCorrectAnswer();
    count = 0;
    while (count <= 7)
    {
      if (Correct[count] != AnswerScale[count])
      {
        Wrong[count] = "  " + (count + 1);
      }
    count = count + 1;
    }
    document.Form1.Result.value = Wrong.join(" ");
    document.Form1.Result1.value = "Fix notes below";
    if ( (Wrong[0] + Wrong[1] + Wrong[2] + Wrong[3] + Wrong[4] + Wrong[5] + Wrong[6] + Wrong[7]) == "")
    {
      document.Form1.Result1.value = "You're Right!";
      document.Form1.Result.value = "None";
    }
//  document.Form1.Debug.value = AnswerScale.join(", ");
//  document.Form1.Debug1.value = Correct.join(", ");
  }
}


function StartOver()
{
  document.Form1.firstimage.src = blankstaff.src;
  document.Form1.image2.src = blankstaff.src;
  document.Form1.image3.src = blankstaff.src;
  document.Form1.image4.src = blankstaff.src;
  document.Form1.image5.src = blankstaff.src;
  document.Form1.image6.src = blankstaff.src;
  document.Form1.image7.src = blankstaff.src;
  document.Form1.image8.src = blankstaff.src;
  document.Form1.firstname.value = "";
  document.Form1.name2.value = "null";
  document.Form1.name3.value = "null";
  document.Form1.name4.value = "null";
  document.Form1.name5.value = "null";
  document.Form1.name6.value = "null";
  document.Form1.name7.value = "null";
  document.Form1.name8.value = "null";
  document.Form1.accidental1.value = "n";
  document.Form1.accidental2.value = "1";
  document.Form1.accidental3.value = "1";
  document.Form1.accidental4.value = "1";
  document.Form1.accidental5.value = "1";
  document.Form1.accidental6.value = "1";
  document.Form1.accidental7.value = "1";
  document.Form1.accidental8.value = "1";
  document.Form1.Result.value = "";
  document.Form1.Result1.value = "";
  var count = 0;
  while (count <= 7 )
  {
    AnswerScale[count] = null;
    count = count + 1;
  }
}

function Reset()
{
  document.Form1.firstname.value = "";
  document.Form1.Result.value = "";
  document.Form1.name2.value = document.Form1.name2.options[0];
  document.Form1.accidental2.value = " ";
}

function Reset() 
{
  FirstName = null;
  NoteName2 = null;
  NoteName3 = null;
  NoteName4 = null;
  NoteName5 = null;
  NoteName6 = null;
  NoteName7 = null;
  NoteName8 = null;
  Acc2 = 1;
  Acc3 = 1;
  Acc4 = 1;
  Acc5 = 1;
  Acc6 = 1;
  Acc7 = 1;
  Acc8 = 1;
  document.Form1.firstname.options[0].selected = true;
  document.Form1.name2.options[0].selected = true;
  document.Form1.name3.options[0].selected = true;
  document.Form1.name4.options[0].selected = true;
  document.Form1.name5.options[0].selected = true;
  document.Form1.name6.options[0].selected = true;
  document.Form1.name7.options[0].selected = true;
  document.Form1.name8.options[0].selected = true;
  document.Form1.accidental2.options[0].selected = true;
  document.Form1.accidental3.options[0].selected = true;
  document.Form1.accidental4.options[0].selected = true;
  document.Form1.accidental5.options[0].selected = true;
  document.Form1.accidental6.options[0].selected = true;
  document.Form1.accidental7.options[0].selected = true;
  document.Form1.accidental8.options[0].selected = true;
  document.Form1.Result.value = "";
  document.Form1.Result1.value = "";
  document.Form1.firstimage.src = blankstaff.src;
  document.Form1.image2.src = blankstaff.src;
  document.Form1.image3.src = blankstaff.src;
  document.Form1.image4.src = blankstaff.src;
  document.Form1.image5.src = blankstaff.src;
  document.Form1.image6.src = blankstaff.src;
  document.Form1.image7.src = blankstaff.src;
  document.Form1.image8.src = blankstaff.src;
//  for (var i = 0; i < document.Form1.name2.length; i++) 
//  {      
//    if (document.Form1.name2.options[i].defaultSelected == true) 
//    {         
//      document.Form1.name2.options[i].selected = true      
//    }   
//  }
}

