function SuppressError() {return true;}
window.onerror = SuppressError;

function loadnav(pgname)
{top.location.href = "dynframeset.htm?"+pgname+".htm"}

function checkframe(pgname)
{
if (top.location.href==self.location.href)
loadnav(pgname)
}

<!---------------------Chord Generator Script---------------------------------
/*Chord Generator Script written by Sayuri Prior (email@astroguitar.cjb.net)
   http://astroguitar.cjb.net
   Please contact me if you have any comments/questions regarding this script.
   And please don't reproduce or modify it without first contacting me. Thanks :)
*/

// ------------------------- SETTING UP THE GUITAR -------------------------
note = new Array('C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B');
notelow = new Array('c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b');
sopen = new Array();

noRows = 6, noCols = 20;  // rows are strings (0 is sixth), cols are frets (0 is open)
guitar = new Array();
for (rowCnt=0; rowCnt < noRows; rowCnt++)
  { guitar[rowCnt] = new Array();
     for (colCnt=0; colCnt < noCols; colCnt++)
      {guitar[rowCnt][colCnt] = "[" + rowCnt + "," + colCnt + "]";}
  }

run_number = 0;
print_number = 1;


function MakeGuitar()
{
//assigns notes for 6 open strings
for (i=0; i<6; i++) {sopen[i] = document.cgen["tuning"+i].selectedIndex;}


// assigns notes on all 6 strings and open -> 19th  fret
for (i=0; i<6; i++) {
for (j=0; j<21; j++) {
k = (sopen[i] + j)%12;
guitar[i][j] = k;
                      }
                    }
}


//------------------------------------ BEGIN FUNCTION GenChord ----------------------------------------------------
function GenChord(cgen)
{
run_number++;
chord_number = 0;
d = document.cgen;

MakeGuitar();

// clears display only if 'No clear' is unchecked
continued = 1;
if (document.cgen.noclear.checked == false)
{document.cgen.display.value = ("");
continued = 0;}

tonic = document.cgen.crd.selectedIndex;  // selected tonic chord
// ---------------------- CHORD TYPES ---------------------------------
if (document.cgen.type[0].checked == true)  // major
{C = new Array( 0, 4, 7)}
else if (document.cgen.type[1].checked == true)  // minor
{C = new Array(0, 3, 7)}
else if (document.cgen.type[2].checked == true)  // dim
{C = new Array(0, 3, 6)}
else if (document.cgen.type[3].checked == true)  // aug
{C = new Array(0, 4, 8)}
else if (document.cgen.type[4].checked == true)  // sus2
{C = new Array(0, 2, 7)}
else if (document.cgen.type[5].checked == true)  // sus4
{C = new Array(0, 5, 7)}
else if (document.cgen.type[6].checked == true)  // 5
{C = new Array(0, 7)}
if (document.cgen.type[7].checked == true)  // 6
{C = new Array( 0, 4, 7, 9)}
else if (document.cgen.type[8].checked == true)  // 7
{C = new Array(0, 4, 7, 10)}
else if (document.cgen.type[9].checked == true)  // maj7
{C = new Array(0, 4, 7, 11)}
else if (document.cgen.type[10].checked == true)  // add9
{C = new Array(0, 4, 7, 2)}
else if (document.cgen.type[11].checked == true)  // 9
{C = new Array(0, 4, 7, 10, 2)}



noRows = 12, noCols = 5;  // rows are tonics, cols are chord notes
chord = new Array();
for (rowCnt=0; rowCnt < noRows; rowCnt++)
  { chord[rowCnt] = new Array();
     for (colCnt=0; colCnt < noCols; colCnt++)
      {chord[rowCnt][colCnt] = "[" + rowCnt + "," + colCnt + "]";}
  }
//asigns the 12 tonic chords up to 5 notes each
for (i=0; i<12; i++)  {
for (j=0; j<5; j++)  {
k = (C[j] + i)%12;
chord[i][j] = k;
                           }
                            }
numnotes = 0
for (k=0; k<5; k++) {
if (chord[tonic][k] < 12)
numnotes += 1       }


// ---------------DISPLAY FIRST PART OF HEADER ----------

if (continued==1){print_number++}
var different_tuning = 0;

// Display the tuning if alternate (1st print) or different (all other prints)

if ((print_number == 1)&&(d.tunetype[1].checked == true))
{
d.display.value += ("Tuning: ")
for (var i=0; i<6; i++) {d.display.value += (note[sopen[i]])}
d.display.value += ("\n" +"==================" +"\n\n")
}

if ((run_number > 1)&&(print_number != 1))
{
for (var i=0; i<6; i++)
{if (sopenold[i] != sopen[i]) {different_tuning = 1}}
if (different_tuning == 1)
  {
d.display.value += ("Tuning: ")
for (var i=0; i<6; i++)
 {d.display.value += (note[sopen[i]])}
 d.display.value += ("\n" +"==================" +"\n\n")
  }
}

sold = new Array();   // chord from last run of neck loop
for (i=0; i<6; i++) {sold[i]=""};

// ----------------------- MAIN ROUTINE STARTS HERE ------------------
neck_loop:
for (m=document.cgen.span.value; m <= document.cgen.upto.value ; m++) {
s = new Array();
for (i=0; i<6; i++) {s[i] = ""}
different_chord = 0


// ---------------------- WORKING OUT THE BASS NOTE -----------------

var bass=""
// sets selected bass note or uses tonic if none selected
if (document.cgen.bassnote.selectedIndex == -1)
{ bassnote1 = chord[tonic][0] }
else {bassnote1 = document.cgen.bassnote.selectedIndex}


bassstring_loop:
for (i=0; i<4; i++) {         // tries sixth -> third strings for bass
for (j=m-document.cgen.span.value+1; j<=m; j++)  { // tries  frets m-3 ->m-1

if (j == m-document.cgen.span.value+1)
{
if  ( guitar[i][0] == bassnote1 )
{s[i] = 0
bass = i
break bassstring_loop;}                         // break out of fret loop here
}

if  ( guitar[i][j] == bassnote1 )
{s[i] = j
bass = i
break bassstring_loop;}            // break out of fret loop here
else if ( (guitar[i][j] != bassnote1) && (s[i] == "") )
 {s[i] = "x"   }

                          }   // end of fret loop

 if (bass != "") {break;}          }     //end  or break out of string loop here


//------------------------- WORKING OUT THE OTHER NOTES -------------------

note_loop:
for (k=1; k<numnotes; k++) {             // for all  chord notes exc bass
string_loop:
for (i=bass+1; i<6; i++) {            // for string above bass to first
for (j=m-document.cgen.span.value+1; j<=m; j++) {     //for frets m-3 -> m-1


if (s[i] != "") {continue string_loop}
if ( (guitar[i][j] == chord[tonic][k]) &&   (s[i] == "") )
{s[i] = j
continue note_loop}

if (j == m)
{
if (s[i] != "") {continue string_loop}
if ( (guitar[i][0] == chord[tonic][k]) &&   (s[i] == "") )
{s[i] = 0
continue note_loop}
}

}                                  // end fret  loop
}                                  // end strings loop
}                                     // end chord note loop


for (i=bass+1; i<6; i++) {            // for string above bass to first
fret_loop:
for (j=m-document.cgen.span.value+1; j<=m; j++) {    //for frets m-3 -> m-1
for (k=0; k<numnotes; k++) {             // for all  chord notes


if ( (guitar[i][j] == chord[tonic][k]) &&  (s[i] == "") )
{s[i] = j
break fret_loop}


if (j == m)
{
if ( (guitar[i][0] == chord[tonic][k]) &&  (s[i] == "") )
{s[i] = 0
break fret_loop}
}
}                // end chord note loop

}                                  // end fret  loop
if ( (guitar[i][j] != chord[tonic][k])   && (s[i] == "") && (s[i] != "0") )
 {s[i] = "x"  }
}                                  // end strings loop

// ------------------ DISPLAYING THE OUTPUT  ---------------------------------

if  ((chord_number == 0)||(continued==1))  {

for (p=0; p<12; p++)
 {  if (cgen.type[p].checked == true)  {
   document.cgen.display.value += ("Chord: " +note[cgen.crd.selectedIndex] +cgen.type[p].value
+((bassnote1 != chord[tonic][0]) ? "/"+note[bassnote1]+" " : "") )
                                                          }
 }

document.cgen.display.value += ("   Notes: ") ;
for (q=0; q<numnotes; q++)
{ document.cgen.display.value += (note[ (C[q] + tonic)%12 ] ) }
    document.cgen.display.value += ("\n")
                                                              }  // end of header


continued = 0;

           // find out how many chord notes have been included
included = 0;
for (k=0; k<numnotes; k++) {
for (i=0; i<6; i++) {
if (s[i] != "x") {
if (note[chord[tonic][k]] == note[guitar[i][s[i]]])
{included += 1;
break;}
                      }    }
                                           }
for (i=0; i<6; i++){ if (s[i]!= sold[i]) different_chord=1 }
chord_number++;

if ((included ==  numnotes)&&(different_chord==1))
{ // only print chords with all notes which are different from the last printed chord

document.cgen.display.value += ("\n"  +"(" )
for(i=0; i<6; i++) {document.cgen.display.value += (s[i])}
document.cgen.display.value += (")"  +" = ")  // chord
for (i=0; i<6; i++) {
sold[i] = s[i]
if (s[i] != "x")
{ document.cgen.display.value += ( note[guitar[i][s[i]]] +" "  ) }  // notes
                          }
                                          }

                               } // end of neck loop



document.cgen.display.value += ("\n\n" +"_______________________________"+"\n\n");

sopenold = new Array();
for (var i=0; i<6; i++) {sopenold[i] = sopen[i]}

}  // ------------------------------ END OF FUNCTION GenChord ----------------------------------------



function FindNote(cgen)
{
MakeGuitar();
for (i=0;i<6;i++) {
document.cgen["d"+i].value = ("")
if ( (cgen["s"+i].value >= 0 )  && (cgen["s"+i].value < 21)  && (cgen["s"+i].value != "") ) {
document.cgen["d"+i].value = ( note[guitar[i][cgen["s"+i].value]] +" " )
                                                                                                                                       }
                        }
}

function ClearNote()
{
for (i=0; i<6; i++)                             {
document.cgen["s"+i].value = ("")
document.cgen["d"+i].value = ("") }
}

function FindFret(cgen)
{
MakeGuitar();
for (i=0;i<6;i++) {
document.cgen["s"+i].value = ("")
if (cgen["d"+i].value != "")  {
for (j=0;j<12;j++) {
if  ( (cgen["d"+i].value == note[guitar[i][j]])  || (cgen["d"+i].value == notelow[guitar[i][j]]) )
{cgen["s" +i].value = (j)}
                          }
                                          }
                        }
}

function ClearDisplay(cgen)
{document.cgen.display.value = ("")}



function createwin()
{
win2=window.open('', 'printversion', 'resizable=1,menubar=1,scrollbars=1,height=385,width=402,left=15,top=100')
var a = win2.document;
a.open("text/html")
a.writeln("<Head><Title>Printer-Friendly Version</Title></Head>")
a.writeln("<body><center><table><tr><td align=center><PRE>")
a.writeln("G U I T A R   C H O R D S" +"</PRE><br><table><tr><td>")
a.writeln("<PRE>"+document.cgen.display.value+"</PRE>")
a.writeln("</td></tr></table><font face=Arial size=-2>")
a.writeln("<center>"+"Generated by AstroGuitar Chord Generator"+"<br>")
a.writeln("http://beam.to/astroguitar"+"</center>")
a.writeln("<br><br><font size=-1>")
a.writeln("<a href='javascript:print();'>Print</a>" +"&nbsp;&nbsp;")
a.writeln("<a href='javascript:close();'>Close</a>")
a.writeln("</td></tr></table></center></body>")
a.close()
}


function autobass()
{ document.cgen.bassnote.selectedIndex = document.cgen.crd.selectedIndex;}


function standardise()
{
standard = new Array(4, 9, 2, 7, 11, 4)
for (var i = 0; i < 6 ; i++)
  {    document.cgen["tuning"+i].selectedIndex = standard[i]	}
}

function anytuning()
{document.cgen.tunetype[1].checked = true }

function ResetAll()
{
d = document.cgen;
d.upto.value = 5;
d.span.value = 3;
d.crd.selectedIndex = 0;
d.bassnote.selectedIndex = 0;
d.type[0].checked = true;
d.tunetype[0].checked = true;
d.noclear.checked = false;
ClearDisplay();
ClearNote();
standardise();
print_number = 1;
}

