var sc = new Array();
var perc = new Array();
var instr = new Array();
var filters = new Array();
var ruletypes = new Array();
var genres = new Array();

var is_bad_with_arrays = 0;
is_bad_with_arrays = testBrowserArrays();

sc = getScalesValues();

perc = getPercussionValues();

instr = getInstrumentValues();

filters = getFilterValues();

ruletypes = getRuletypeValues();

genres = getGenreValues();



function writeScaleOptions() {
	var to_print;

	to_print = '<select name="value_scale_select" id="value_scale_select" onChange="adjustScaleValue();return true" class="greyText">';
	if (is_bad_with_arrays) {
		var order_arr = new Array();
		for (var j in sc)		{ order_arr[sc[j][0]] = j; }
		for (var i in order_arr)	{ to_print = to_print + '<option value="' + order_arr[i] + '">' + sc[order_arr[i]][1] + "</option>"; }
	}
	else {
		for (var i in sc)		{ to_print = to_print + '<option value="' + i + '">' + sc[i][1] + "</option>"; }
	}
	to_print = to_print + '</select>';

	return to_print;
}



function adjustScaleValue() {
	var value_scale_select = document.getElementById('value_scale_select').options[document.getElementById('value_scale_select').selectedIndex].value;
	if ((value_scale_select) && (value_scale_select != 0) && (value_scale_select != "undefined")) {
		document.getElementById('value_scale').value = value_scale_select;
		adjustNKMIDValue();
		playTone();
	}
}



function getScaleIndexByValue(value) {
	return (sc[value]) ? sc[value][0] : sc[0][0];
}



function writeScaleNotes(notesString) {
	if (document.getElementById('check_note_name_0')) {
		var notes_str = new String(notesString);
		var notes_arr = new Array();
		notes_arr = notes_str.split(', ');
		for (var i = 0; i < 12; i++) {
			document.getElementById('check_note_name_' + i).innerHTML = notes_arr[i];
		}
	}
}



function adjustScaleValueFromNotes() {
	var scale_value = getScaleValueFromNotes();
	document.getElementById('value_scale').value = scale_value;
	document.getElementById('value_scale_select').options[getScaleIndexByValue(scale_value)].selected = true;
	adjustNKMIDValue();
	playTone();
}



function writePercussionOptions() {
	var to_print;

	to_print = '<select name="value_percussion" id="value_percussion" onChange="adjustNKMIDValue(); playTone()" class="greyText">';
	if (is_bad_with_arrays) {
		var order_arr = new Array();
		for (var j in perc)		{ order_arr[perc[j][0]] = j; }
		for (var i in order_arr)	{ to_print = to_print + '<option value="' + order_arr[i] + '">' + perc[order_arr[i]][1] + "</option>"; }
	}
	else {
		for (var i in perc)		{ to_print = to_print + '<option value="' + i + '">' + perc[i][1] + "</option>"; }
	}
	to_print = to_print + '</select>';

	return to_print;
}



function getPercussionIndexByValue(value) {
	return (perc[value]) ? perc[value][0] : perc[0][0];
}



function writeInstrumentOptions(which) {
	var to_print;

	to_print = '<select name="value_instrument' + which + '" id="value_instrument' + which + '" class="greyText" onChange="adjustNKMIDValue(); playTone()">';
	if (is_bad_with_arrays) {
		var order_arr = new Array();
		for (var j in instr)		{ order_arr[instr[j][0]] = j; }
		for (var i in order_arr)	{ to_print = to_print + '<option value="' + order_arr[i] + '">' + instr[order_arr[i]][1] + "</option>"; }
	}
	else {
		for (var i in instr)		{ to_print = to_print + '<option value="' + i + '">' + instr[i][1] + "</option>"; }
	}
	to_print = to_print + '</select>';

	return to_print;
}



function getInstrumentNameByValue(value) {
	return (instr[value]) ? instr[value][1] : instr[0][1];
}



function getInstrumentIndexByValue(value) {
	return (instr[value]) ? instr[value][0] : instr[0][0];
}



function getAdditionalFilters(def_vals) {
	var filters_this = new Array();
	for (var i in filters) { filters_this[i] = [filters[i][0], filters[i][1]]; }
	var filter_map = {
		1: 'Lead',
		2: 'Lead',
		3: 'Chords',
		4: 'Chords',
		5: 'Bass',
		6: 'Bass',
		9: 'Polyphonic'
	};
	var filter_idxs = new Array();
	filter_idxs = { 'Lead': [2, 4], 'Chords': [2, 6], 'Bass': [2, 8], 'Polyphonic': [1, 2] };
	for (var k = 1; k <= 5; k++) {
		if ((def_vals['filter'+k]) && (!filters_this[def_vals['filter'+k]])) {
			var name = filter_map[Math.floor(def_vals['filter'+k] / 100)];
			filter_idxs[name][0]++;
			var real_name = name + ' ' + filter_idxs[name][0];
			for (var i in filters_this) {
				if (filters_this[i][0] >= filter_idxs[name][1]) {
					filters_this[i][0]++;
				}
			}
			filters_this[def_vals['filter'+k]] = [filter_idxs[name][1]++, real_name];
			for (var i in filter_idxs) {
				if ((filter_idxs[i][1] >= filter_idxs[name][1]) && (i != name)) {
					filter_idxs[i][1]++;
				}
			}
		}
	}
	return filters_this;
}



function getFiltersOrder(filters_this) {
	var order_arr = new Array();
	for (var j in filters_this) { order_arr[filters_this[j][0]] = j; }
	return order_arr;
}



function writeFilterOptions(which, selected, filters_this, order_arr) {
	var to_print;
	var selected_idx = (filters_this[selected]) ? filters_this[selected][0] : filters_this[0][0];

	to_print = '<select name="value_filter' + which + '" id="value_filter' + which + '" onChange="adjustNKMIDValue(); playTone()" class="greyText">';
	for (var i = 0; i < order_arr.length; i++) {
		to_print = to_print + '<option value="' + order_arr[i] + '"';
		if (i == selected_idx) { to_print = to_print + ' selected'; }
		to_print = to_print + '>' + filters_this[order_arr[i]][1] + "</option>";
	}
	to_print = to_print + '</select>';

	return to_print;
}



function writeRuletypeOptions() {
	var to_print;

	to_print = '<select name="value_ruletype_select" id="value_ruletype_select" onChange="playChoice(\'RuleType\')" class="greyText">';
	if (is_bad_with_arrays) {
		var order_arr = new Array();
		for (var j in ruletypes)	{ order_arr[ruletypes[j][0]] = j; }
		for (var i in order_arr)	{ to_print = to_print + '<option value="' + order_arr[i] + '">' + ruletypes[order_arr[i]][1] + "</option>"; }
	}
	else {
		for (var i in ruletypes)	{ to_print = to_print + '<option value="' + i + '">' + ruletypes[i][1] + "</option>"; }
	}
	to_print = to_print + '</select>';

	return to_print;
}



function getRuletypeIndexByValue(value) {
	return (ruletypes[value]) ? ruletypes[value][0] : ruletypes['31'][0];
}



function writeGenreOptions() {
	var to_print;

	to_print = '<select name="value_genre_select" id="value_genre_select" class="greyText" style="margin-bottom:10px; margin-right:10px">';
	if (is_bad_with_arrays) {
		var order_arr = new Array();
		for (var j in genres)		{ order_arr[genres[j][0]] = j; }
		for (var i in order_arr)	{ to_print = to_print + '<option value="' + order_arr[i] + '">' + genres[order_arr[i]][1] + "</option>"; }
	}
	else {
		for (var i in genres)		{ to_print = to_print + '<option value="' + i + '">' + genres[i][1] + "</option>"; }
	}
	to_print = to_print + '</select>';

	return to_print;
}



function getGenreIndexByValue(value) {
	return (genres[value]) ? genres[value][0] : genres[1][0];
}



function getGenreNameByValue(value) {
	return (genres[value]) ? genres[value][1] : genres[1][1];
}



function getGenreValueByName(name) {
	for (var i in genres) {
		if (genres[i][1] == name) {
			return i;
		}
	}
	return genres[1][0];
}



function getGenreRandomValue() {
	var genre_values = new Array();
	for (var i in genres) {
		if (i > 1) { genre_values.push(i); }
	}
	var random_index = Math.floor(Math.random() * genre_values.length);
	return genre_values[random_index];
}



function getInstrumentValues() {
	return {
0: [0, "None"],
1: [1, "Grand Piano"],
3: [2, "Grand Piano (Electric)"],
2: [3, "Bright Piano"],
4: [4, "Honky-Tonk Piano"],
5: [5, "Electric Piano 1"],
6: [6, "Electric Piano 2"],
7: [7, "Harpsichord"],
8: [8, "Clavi"],
9: [9, "Celesta"],
47: [10, "Harp"],
113: [11, "Tinkle Bell"],
12: [12, "Vibraphone"],
13: [13, "Marimba"],
14: [14, "Xylophone"],
116: [15, "Woodblock"],
15: [16, "Tubular Bells"],
17: [17, "Drawbar Organ"],
18: [18, "Percussive Organ"],
19: [19, "Rock Organ"],
20: [20, "Church Organ"],
21: [21, "Reed Organ"],
23: [22, "Harmonica"],
22: [23, "Accordion"],
24: [24, "Tango Accordion"],
25: [25, "Guitar (Nylon)"],
26: [26, "Guitar (Steel)"],
27: [27, "Guitar (Jazz)"],
28: [28, "Guitar (Clean)"],
29: [29, "Guitar (Muted)"],
30: [30, "Guitar (Overdriven)"],
31: [31, "Guitar (Distortion)"],
32: [32, "Guitar (Harmonics)"],
33: [33, "Acoustic Bass"],
34: [34, "Electric Bass (Finger)"],
35: [35, "Electric Bass (Pick)"],
36: [36, "Electric Bass (Fretless)"],
37: [37, "Slap Bass 1"],
38: [38, "Slap Bass 2"],
39: [39, "Synth Bass 1"],
40: [40, "Synth Bass 2"],
41: [41, "Violin"],
42: [42, "Viola"],
43: [43, "Cello"],
44: [44, "Contrabass"],
49: [45, "Strings"],
50: [46, "Strings (Legato)"],
45: [47, "Strings (Tremolo)"],
46: [48, "Strings (Pizzicato)"],
51: [49, "Synth Strings 1"],
52: [50, "Synth Strings 2"],
53: [51, "Voice (Aahs)"],
54: [52, "Voice (Oohs)"],
55: [53, "Voice (Synth)"],
61: [54, "French Horn"],
57: [55, "Trumpet"],
60: [56, "Trumpet (Muted)"],
58: [57, "Trombone"],
59: [58, "Tuba"],
62: [59, "Brass Section"],
63: [60, "Synth Brass 1"],
64: [61, "Synth Brass 2"],
65: [62, "Sax (Soprano)"],
66: [63, "Sax (Alto)"],
67: [64, "Sax (Tenor)"],
68: [65, "Sax (Baritone)"],
73: [66, "Piccolo Flute"],
74: [67, "Flute"],
69: [68, "Oboe"],
70: [69, "English Horn"],
72: [70, "Clarinet"],
71: [71, "Bassoon"],
81: [72, "Synth Lead 1 (Square)"],
82: [73, "Synth Lead 2 (Sawtooth)"],
83: [74, "Synth Lead 3 (Calliope)"],
84: [75, "Synth Lead 4 (Chiff)"],
85: [76, "Synth Lead 5 (Charang)"],
86: [77, "Synth Lead 6 (Voice)"],
87: [78, "Synth Lead 7 (Fifths)"],
88: [79, "Synth Lead 8 (Bass + Lead)"],
89: [80, "Synth Pad 1 (New Age)"],
90: [81, "Synth Pad 2 (Warm)"],
91: [82, "Synth Pad 3 (Polysynth)"],
92: [83, "Synth Pad 4 (Choir)"],
93: [84, "Synth Pad 5 (Bowed)"],
94: [85, "Synth Pad 6 (Metallic)"],
95: [86, "Synth Pad 7 (Halo)"],
96: [87, "Synth Pad 8 (Sweep)"],
97: [88, "Synth FX 1 (Rain)"],
98: [89, "Synth FX 2 (Soundtrack)"],
99: [90, "Synth FX 3 (Crystal)"],
100: [91, "Synth FX 4 (Atmosphere)"],
101: [92, "Synth FX 5 (Brightness)"],
102: [93, "Synth FX 6 (Goblins)"],
103: [94, "Synth FX 7 (Echoes)"],
104: [95, "Synth FX 8 (Sci-Fi)"],
105: [96, "Sitar"],
106: [97, "Banjo"],
111: [98, "Fiddle"],
107: [99, "Shamisen (Japanese Lute)"],
108: [100, "Koto (Japanese Zither)"],
109: [101, "Kalimba (African)"],
110: [102, "Bag Pipe"],
16: [103, "Dulcimer"],
76: [104, "Pan Flute"],
78: [105, "Shakuhachi (Japanese Flute)"],
75: [106, "Recorder"],
80: [107, "Ocarina (Peruvian Wind)"],
112: [108, "Shanai (Indian Reed)"],
48: [109, "Timpani (Kettle Drums)"],
114: [110, "Agogo (Brazilian Bell)"],
115: [111, "Steel Drums"],
117: [112, "Taiko (Japanese Drum)"],
118: [113, "Melodic Tom"],
119: [114, "Synth Drum"],
10: [115, "Glockenspiel"],
11: [116, "Music Box"],
120: [117, "Reverse Cymbal"]
	};
}



function getFilterValues() {
	return {
0: [0, "None"],
1: [1, "Polyphonic"],
10: [2, "Lead 1"],
16: [3, "Lead 2"],
20: [4, "Chords 1"],
21: [5, "Chords 2"],
51: [6, "Bass 1"],
52: [7, "Bass 2"]
	};
}



function getPercussionValues() {
	return {
0: [0, "None"],
1: [1, "Metronome"],
101: [2, "Swing 1"],
102: [3, "Swing 2"],
121: [4, "Jazz 1"],
122: [5, "Jazz 2"],
123: [6, "Jazz 3"],
127: [7, "Jazz Waltz 1"],
128: [8, "Jazz Waltz 2"],
129: [9, "Jazz Waltz 3"],
131: [10, "Blues 1"],
132: [11, "Blues 2"],
133: [12, "Blues 3"],
301: [13, "Rock 1"],
311: [14, "Rock 2"],
322: [15, "Rock 3"],
323: [16, "Rock 4"],
325: [17, "Rock 5"],
321: [18, "Rock Ballad 1"],
324: [19, "Rock Ballad 2"],
361: [20, "Punk 1"],
362: [21, "Punk 2"],
331: [22, "Heavy Metal 1"],
332: [23, "Heavy Metal 2"],
333: [24, "Heavy Metal 3"],
334: [25, "Heavy Metal 4"],
341: [26, "Country 1"],
342: [27, "Country 2"],
343: [28, "Country 3"],
344: [29, "Country 4"],
345: [30, "Country 5"],
346: [31, "Country 6"],
347: [32, "Country 7"],
348: [33, "Country Ballad 1"],
349: [34, "Country Ballad 2"],
351: [35, "Shuffle 1"],
352: [36, "Shuffle 2"],
353: [37, "Shuffle 3"],
501: [38, "Shuffle 4"],
401: [39, "Dance 1"],
402: [40, "Dance 2"],
403: [41, "Dance 3"],
404: [42, "Dance 4"],
431: [43, "House 1"],
432: [44, "House 2"],
433: [45, "House 3"],
434: [46, "House 4"],
551: [47, "Soul 1"],
552: [48, "Soul 2"],
553: [49, "Soul 3"],
555: [50, "Soul Ballad 1"],
554: [51, "Soul Ballad 2"],
556: [52, "Soul Ballad 3"],
571: [53, "Funk 1"],
572: [54, "Funk 2"],
573: [55, "Funk 3"],
574: [56, "Funk 4"],
575: [57, "Funk 5"],
576: [58, "Funk 6"],
577: [59, "Funk 7"],
578: [60, "Funk 8"],
579: [61, "Funk 9"],
584: [62, "Funk 10"],
586: [63, "Funk 11"],
581: [64, "Go-Go 1"],
582: [65, "Go-Go 2"],
583: [66, "Go-Go 3"],
585: [67, "Go-Go 4"],
112: [68, "New Jack 1"],
113: [69, "New Jack 2"],
114: [70, "New Jack 3"],
115: [71, "New Jack 4"],
451: [72, "Hip Hop 1"],
452: [73, "Hip Hop 2"],
453: [74, "Hip Hop 3"],
454: [75, "Hip Hop 4"],
455: [76, "Hip Hop 5"],
456: [77, "Hip Hop 6"],
457: [78, "Hip Hop 7"],
458: [79, "Hip Hop 8"],
459: [80, "Hip Hop 9"],
460: [81, "Hip Hop 10"],
461: [82, "Hip Hop 11"],
462: [83, "Hip Hop 12"],
463: [84, "Hip Hop 13"],
651: [85, "Rumba 1"],
652: [86, "Rumba 2"],
681: [87, "Samba 1"],
682: [88, "Samba 2"],
711: [89, "Afro-Cuban 1"],
712: [90, "Afro-Cuban 2"],
713: [91, "Afro-Cuban 3"],
714: [92, "Afro-Cuban 4"],
601: [93, "Afro-Cuban 5"],
715: [94, "Afro-Cuban 6"],
721: [95, "Mambo 1"],
722: [96, "Mambo 2"],
723: [97, "Mambo 3"],
801: [98, "Bolero"],
803: [99, "Calypso"],
804: [100, "Beguine 1"],
805: [101, "Beguine 2"],
807: [102, "Reggae 1"],
808: [103, "Reggae 2"],
809: [104, "Reggae 3"],
810: [105, "Ska"],
821: [106, "Bossa Nova 1"],
822: [107, "Bossa Nova 2"],
823: [108, "Bossa Nova 3"],
830: [109, "Tango"],
901: [110, "Middle Eastern"],
911: [111, "African 1"]
	};
}



function getRuletypeValues() {
	return {
7   : [0, "7 (r=1)"],
15  : [1, "15 (r=3/2)"],
30  : [2, "30"],
31  : [3, "31 (r=2)"],
55  : [4, "55"],
61  : [5, "61"],
62  : [6, "62"],
79  : [7, "79"],
91  : [8, "91"],
103 : [9, "103"],
110 : [10, "110"],
157 : [11, "157"],
167 : [12, "167"],
773 : [13, "773"],
1047: [14, "1047"],
1585: [15, "1585"]
	};
}



function getGenreValues() {
	return {
1:  [0, 'Any'],
15: [1, 'Classical'],
10: [2, 'Piano'],
11: [3, 'Guitar'],
25: [4, 'Ambient'],
30: [5, 'Rock/Pop'],
40: [6, 'Dance'],
45: [7, 'Hip Hop'],
60: [8, 'R&B'],
55: [9, 'Blues'],
50: [10, 'Jazz'],
65: [11, 'Country'],
70: [12, 'Latin'],
80: [13, 'World'],
90: [14, 'Experimental'],
95: [15, 'Signal Tones']
	};
}



function getScalesValues() {
	return {
0:    [0, " "],
3926: [1, "Adonai Malakh (Israel)"],
2477: [2, "Aeolian Flat 1"],
2937: [3, "Algerian"],
3156: [4, "Altered Pentatonic"],
3456: [5, "Alternating Tetramirror"],
2772: [6, "Arezzo Major Diatonic Hexachord"],
2184: [7, "Augmented Chord"],
3248: [8, "Balinese Pentachord"],
3285: [9, "Bhairubahar Thaat (India)"],
2322: [10, "Bi Yu (China)"],
2418: [11, "Blues"],
3510: [12, "Blues Diminished"],
2964: [13, "Blues Dorian Hexatonic"],
3062: [14, "Blues Enneatonic"],
2422: [15, "Blues Heptatonic"],
2930: [16, "Blues Modified"],
2934: [17, "Blues Octatonic"],
3872: [18, "Blues Pentacluster"],
2386: [19, "Blues Pentatonic"],
3442: [20, "Blues Phrygian"],
2419: [21, "Blues With Leading Tone"],
2504: [22, "Center-Cluster Pentamirror"],
2896: [23, "Chad Gadyo (Israel)"],
2634: [24, "Chaio (China)"],
3799: [25, "Chromatic Bebop"],
4092: [26, "Chromatic Decamirror"],
3934: [27, "Chromatic Diatonic Dorian"],
3676: [28, "Chromatic Dorian"],
2515: [29, "Chromatic Dorian Inverse"],
4064: [30, "Chromatic Heptamirror"],
4032: [31, "Chromatic Hexamirror"],
2972: [32, "Chromatic Hypodorian"],
2510: [33, "Chromatic Hypodorian Inverse"],
3257: [34, "Chromatic Hypolydian"],
3305: [35, "Chromatic Hypolydian Inverse"],
3700: [36, "Chromatic Hypophrygian Inverse"],
3301: [37, "Chromatic Lydian"],
3385: [38, "Chromatic Lydian Inverse"],
3698: [39, "Chromatic Mixolydian"],
2675: [40, "Chromatic Mixolydian Inverse"],
4088: [41, "Chromatic Nonamirror"],
4080: [42, "Chromatic Octamirror"],
3968: [43, "Chromatic Pentamirror"],
3805: [44, "Chromatic Permuted Diatonic Dorian"],
2507: [45, "Chromatic Phrygian"],
3740: [46, "Chromatic Phrygian Inverse"],
3840: [47, "Chromatic Tetramirror"],
3584: [48, "Chromatic Trimirror"],
4094: [49, "Chromatic Undecamirror"],
2336: [50, "Diminished Chord"],
2925: [51, "Diminished Scale"],
2340: [52, "Diminished Seventh Chord"],
2775: [53, "Dominant Bebop"],
2706: [54, "Dominant Pentatonic"],
2902: [55, "Dorian"],
2910: [56, "Dorian Aeolian"],
2918: [57, "Dorian Flat 5"],
2836: [58, "Dorian Pentatonic"],
3392: [59, "Dorian Tetrachord"],
3290: [60, "Dorico Flamenco"],
3428: [61, "Double-Phrygian Hexatonic"],
2729: [62, "Eskimo Hexatonic 2 (North America)"],
2704: [63, "Eskimo Tetratonic (North America)"],
2911: [64, "Full Minor"],
3549: [65, "Genus Chromaticum"],
2805: [66, "Genus Diatonicum Veterum Correctum"],
2640: [67, "Genus Primum"],
2130: [68, "Genus Primum Inverse"],
2261: [69, "Genus Secundum"],
3292: [70, "Gipsy Hexatonic"],
2870: [71, "Gnossiennes"],
3449: [72, "Half-Diminished Bebop"],
2648: [73, "Han-kumoi (Japan)"],
2777: [74, "Harmonic Major"],
2905: [75, "Harmonic Minor"],
3286: [76, "Harmonic Minor Inverse"],
2848: [77, "Harmonic Minor Tetrachord"],
3929: [78, "Harmonic Neapolitan Minor"],
2837: [79, "Hawaiian"],
2840: [80, "Hira-joshi (Japan)"],
3426: [81, "Honchoshi Plagal Form (Japan)"],
3038: [82, "Houseini (Greece)"],
2517: [83, "Houzam (Greece)"],
2486: [84, "Hungarian Major"],
2765: [85, "Ionian Sharp 5"],
3170: [86, "Iwato (Japan)"],
3376: [87, "Javanese Pentachord"],
2901: [88, "Jazz Minor"],
3414: [89, "Jazz Minor Inverse"],
2942: [90, "Kiourdi (Greece)"],
3154: [91, "Kokin-joshi, Miyakobushi (Japan)"],
2724: [92, "Kung (China)"],
3434: [93, "Locrian"],
2921: [94, "Locrian 2"],
3436: [95, "Locrian Double-Flat 7"],
3430: [96, "Locrian Natural 6"],
3424: [97, "Locrian Pentamirror"],
2741: [98, "Lydian"],
2733: [99, "Lydian Augmented"],
2869: [100, "Lydian Diminished"],
2709: [101, "Lydian Hexatonic"],
2746: [102, "Lydian Minor"],
2736: [103, "Lydian Pentachord"],
2485: [104, "Lydian Sharp 2"],
2453: [105, "Lydian Sharp 2 Hexatonic"],
3501: [106, "Magen Abot (Israel)"],
2773: [107, "Major"],
2781: [108, "Major Bebop"],
2716: [109, "Major Bebop Hexatonic"],
2192: [110, "Major Chord"],
3289: [111, "Major Gipsy"],
2794: [112, "Major Locrian"],
2778: [113, "Major Minor"],
3039: [114, "Major and Minor Mixed"],
2768: [115, "Major Pentachord"],
2708: [116, "Major Pentatonic"],
2049: [117, "Major Seventh Interval"],
2052: [118, "Major Sixth Interval"],
2752: [119, "Major Tetrachord"],
2176: [120, "Major Third Interval"],
3291: [121, "Maqam Hijaz (Arabia)"],
3558: [122, "Maqam Shadd'araban (Arabia)"],
3253: [123, "Marva Thaat (India)"],
3386: [124, "Mela Bhavapriya (India)"],
2739: [125, "Mela Citrambari (India)"],
2489: [126, "Mela Dhatuvardhani (India)"],
3260: [127, "Mela Dhavalambari (India)"],
3379: [128, "Mela Divyamani (India)"],
3673: [129, "Mela Ganamurti (India)"],
2521: [130, "Mela Gangeyabhusani (India)"],
3388: [131, "Mela Gavambodhi (India)"],
3283: [132, "Mela Hatakambari (India)"],
3642: [133, "Mela Jalarnava (India)"],
3641: [134, "Mela Jhalavarali (India)"],
2908: [135, "Mela Jhankaradhvani (India)"],
2490: [136, "Mela Jyotisvarupini (India)"],
2748: [137, "Mela Kantamani (India)"],
2745: [138, "Mela Latangi (India)"],
3669: [139, "Mela Manavati (India)"],
2780: [140, "Mela Mararanjani (India)"],
2771: [141, "Mela Naganandini (India)"],
3258: [142, "Mela Namanarayani (India)"],
3638: [143, "Mela Navanitam (India)"],
2867: [144, "Mela Nitimati (India)"],
3637: [145, "Mela Pavani (India)"],
2522: [146, "Mela Ragavardhani (India)"],
3635: [147, "Mela Raghupriya (India)"],
2483: [148, "Mela Rasikapriya (India)"],
3674: [149, "Mela Ratnangi (India)"],
3411: [150, "Mela Rupavati (India)"],
3382: [151, "Mela Sadvidhamargini (India)"],
3644: [152, "Mela Salaga (India)"],
2874: [153, "Mela Sanmukhapriya (India)"],
3420: [154, "Mela Senavati (India)"],
2492: [155, "Mela Sucaritra (India)"],
3381: [156, "Mela Suvarnangi (India)"],
2876: [157, "Mela Syamalangi (India)"],
3667: [158, "Mela Tanarupi (India)"],
3670: [159, "Mela Vanaspati (India)"],
2899: [160, "Mela Varunapriya (India)"],
3251: [161, "Mela Visvambhari (India)"],
2524: [162, "Mela Yagapriya (India)"],
3822: [163, "Messiaen Mode 3"],
3003: [164, "Messiaen Mode 3 Inverse"],
3900: [165, "Messiaen Mode 4"],
2535: [166, "Messiaen Mode 4 Inverse"],
3640: [167, "Messiaen Mode 5"],
2275: [168, "Messiaen Mode 5 Inverse"],
3770: [169, "Messiaen Mode 6"],
2795: [170, "Messiaen Mode 6 Inverse"],
4030: [171, "Messiaen Mode 7"],
3055: [172, "Messiaen Mode 7 Inverse"],
3380: [173, "Messiaen Truncated Mode 2"],
3276: [174, "Messiaen Truncated Mode 3"],
2457: [175, "Messiaen Truncated Mode 3 Inverse"],
3120: [176, "Messiaen Truncated Mode 5"],
2145: [177, "Messiaen Truncated Mode 5 Inverse"],
2600: [178, "Messiaen Truncated Mode 6"],
2210: [179, "Messiaen Truncated Mode 6 Inverse"],
2906: [180, "Minor"],
2388: [181, "Minor Added Sixth Pentatonic"],
3030: [182, "Minor Bebop"],
2966: [183, "Minor Bebop Hexatonic"],
2320: [184, "Minor Chord"],
2873: [185, "Minor Gipsy"],
2898: [186, "Minor Hexatonic"],
2922: [187, "Minor Locrian"],
3063: [188, "Minor Pentatonic With Leading Tones"],
2050: [189, "Minor Seventh Interval"],
2056: [190, "Minor Sixth Interval"],
2304: [191, "Minor Third Interval"],
2816: [192, "Minor Trichord"],
2774: [193, "Mixolydian"],
2790: [194, "Mixolydian Flat 5"],
2646: [195, "Mixolydian Hexatonic"],
2258: [196, "Mixolydian Pentatonic"],
2766: [197, "Mixolydian Sharp 5"],
3547: [198, "Moorish Phrygian"],
3413: [199, "Neapolitan Major"],
3417: [200, "Neapolitan Minor"],
3756: [201, "Neapolitan Minor Mode"],
3387: [202, "Neveseri (Greece)"],
2669: [203, "Nohkan (Japan)"],
3302: [204, "Oriental"],
3680: [205, "Oriental Pentacluster"],
2742: [206, "Overtone"],
3352: [207, "Pelog (Bali)"],
2064: [208, "Perfect Fifth Interval"],
2112: [209, "Perfect Forth Interval"],
3418: [210, "Phrygian"],
3930: [211, "Phrygian Aeolian"],
3482: [212, "Phrygian Flat 4"],
2394: [213, "Phrygian Hexatonic"],
3450: [214, "Phrygian Locrian"],
2880: [215, "Phrygian Tetrachord"],
3328: [216, "Phrygian Trichord"],
3435: [217, "Prokofiev Scale"],
2726: [218, "Prometheus"],
3238: [219, "Prometheus Neapolitan"],
2916: [220, "Pyramid Hexatonic"],
2884: [221, "Raga Abhogi (India)"],
2865: [222, "Raga Amarasenapriya (India)"],
2888: [223, "Raga Audav Tukhari (India)"],
2886: [224, "Raga Bagesri, Sriranjani, Kapijingla (India)"],
3225: [225, "Raga Bauli (India)"],
2514: [226, "Raga Bhanumanjari (India)"],
3317: [227, "Raga Bhatiyar (India)"],
2628: [228, "Raga Bhavani (India)"],
3370: [229, "Raga Bhavani (India)"],
2649: [230, "Raga Bhinna Pancama (India)"],
2245: [231, "Raga Bhinna Shadja, Hindolita (India)"],
2712: [232, "Raga Bhupeshwari, Janasammodini (India)"],
2180: [233, "Raga Bilwadala (India)"],
2737: [234, "Raga Caturangini (India)"],
3636: [235, "Raga Chandrajyoti (India)"],
2374: [236, "Raga Chandrakauns Kafi, Surya (India)"],
2377: [237, "Raga Chandrakauns Kiravani (India)"],
2373: [238, "Raga Chandrakauns Modern, Marga Hindola (India)"],
3368: [239, "Raga Chhaya Todi (India)"],
3400: [240, "Raga Chitthakarshini (India)"],
2878: [241, "Raga Cintamani (India)"],
3097: [242, "Raga Deshgaur (India)"],
2641: [243, "Raga Desh (India)"],
2137: [244, "Raga Devaranjani (India)"],
3256: [245, "Raga Dhavalangam (India)"],
2228: [246, "Raga Dhavalashri (India)"],
2800: [247, "Raga Dipak (India)"],
2257: [248, "Raga Gambhiranata (India)"],
3410: [249, "Raga Gandharavam (India)"],
3281: [250, "Raga Gaula (India)"],
3153: [251, "Raga Gauri (India)"],
2889: [252, "Raga Ghantana (India)"],
2630: [253, "Raga Guhamanohari (India)"],
3369: [254, "Raga Gurjari Todi (India)"],
2705: [255, "Raga Hamsadhvani (India)"],
3237: [256, "Raga Hamsanandi, Puriya (India)"],
2757: [257, "Raga Hamsa Vinodini (India)"],
2346: [258, "Raga Harikauns (India)"],
2632: [259, "Raga Haripriya (India)"],
3244: [260, "Raga Hejjajji (India)"],
2213: [261, "Raga Hindol (India)"],
3250: [262, "Raga Indupriya (India)"],
2618: [263, "Raga Jaganmohanam (India)"],
2402: [264, "Raga Jayakauns (India)"],
3157: [265, "Raga Jivantika (India)"],
2355: [266, "Raga Jivantini, Gaurikriya (India)"],
2234: [267, "Raga Jyoti (India)"],
3228: [268, "Raga Kalagada (India)"],
3164: [269, "Raga Kalakanthi (India)"],
3284: [270, "Raga Kalavati, Ragamalini (India)"],
2266: [271, "Raga Kamalamanohari (India)"],
3354: [272, "Raga Kashyapi (India)"],
2246: [273, "Raga Khamaji Durga (India)"],
2262: [274, "Raga Khamas, Baduhari (India)"],
2392: [275, "Raga Kokil Pancham (India)"],
3145: [276, "Raga Kshanika (India)"],
3593: [277, "Raga Kumarapriya (India)"],
2721: [278, "Raga Kumurdaki (India)"],
2134: [279, "Raga Kuntvarali (India)"],
2713: [280, "Raga Latika (India)"],
3144: [281, "Raga Lavangi (India)"],
2358: [282, "Raga Madhukauns (India)"],
2263: [283, "Raga Madhuri (India)"],
2194: [284, "Raga Mahathi (India)"],
3288: [285, "Raga Malahari (India)"],
2611: [286, "Raga Malarani (India)"],
2225: [287, "Raga Malashri (India)"],
3222: [288, "Raga Malayamarutam (India)"],
2378: [289, "Raga Malkauns (India)"],
2197: [290, "Raga Mamata (India)"],
3218: [291, "Raga Manaranjani (India)"],
2838: [292, "Raga Manavi (India)"],
3249: [293, "Raga Mandari, Gamakakriya (India)"],
2260: [294, "Raga Mand (India)"],
2390: [295, "Raga Manohari (India)"],
2582: [296, "Raga Matha Kokila (India)"],
3272: [297, "Raga Megharanjani (India)"],
3265: [298, "Raga Megharanji (India)"],
2643: [299, "Raga Megh (India)"],
2903: [300, "Raga Mian Ki Malhar, Bahar (India)"],
2452: [301, "Raga Mohanangi (India)"],
2725: [302, "Raga Mruganandana (India)"],
2353: [303, "Raga Multani (India)"],
3632: [304, "Raga Nabhomani (India)"],
2645: [305, "Raga Nagagandhari (India)"],
2769: [306, "Raga Nalinakanti, Kedaram (India)"],
2385: [307, "Raga Nata, Madhuranjani (India)"],
2650: [308, "Raga Navamanohari (India)"],
2860: [309, "Raga Neelangi (India)"],
2693: [310, "Raga Neroshta (India)"],
2209: [311, "Raga Nigamagamini (India)"],
2613: [312, "Raga Nishadi (India)"],
2096: [313, "Raga Ongkari (India)"],
3161: [314, "Raga Padi (India)"],
2783: [315, "Raga Pahadi (India)"],
2265: [316, "Raga Paraju, Simhavahini (India)"],
3162: [317, "Raga Phenadyuti (India)"],
2633: [318, "Raga Priyadharshini (India)"],
2133: [319, "Raga Puruhutika, Purvaholika (India)"],
3596: [320, "Raga Putrika (India)"],
2758: [321, "Raga Rageshri, Nattaikurinji (India)"],
2759: [322, "Raga Ragesri (India)"],
3031: [323, "Raga Ramdasi Malhar (India)"],
3321: [324, "Raga Ramkali (India)"],
2853: [325, "Raga Ranjani, Rangini (India)"],
2481: [326, "Raga Rasamanjari (India)"],
3158: [327, "Raga Rasavali (India)"],
2629: [328, "Raga Rasranjani (India)"],
3224: [329, "Raga Reva, Revagupti (India)"],
3270: [330, "Raga Rudra Pancama (India)"],
3346: [331, "Raga Rukmangi (India)"],
3350: [332, "Raga Salagavarali (India)"],
2354: [333, "Raga Samudhra Priya (India)"],
2761: [334, "Raga Sarasanana (India)"],
2614: [335, "Raga Sarasvati (India)"],
2268: [336, "Raga Saravati (India)"],
2128: [337, "Raga Sarvasri (India)"],
3128: [338, "Raga Saugandhini, Yashranjani (India)"],
3293: [339, "Raga Saurashtra (India)"],
2330: [340, "Raga Shailaja (India)"],
2612: [341, "Raga Shri Kalyan (India)"],
2597: [342, "Raga Shubravarni (India)"],
2866: [343, "Raga Simharava (India)"],
4059: [344, "Raga Sindhi Bhairavi (India)"],
2897: [345, "Raga Sindhura Kafi (India)"],
2770: [346, "Raga Siva Kambhoji, Vivardhini (India)"],
3273: [347, "Raga Sohini (India)"],
2647: [348, "Raga Sorati (India)"],
2900: [349, "Raga Suddha Bangala (India)"],
3660: [350, "Raga Suddha Mukhari (India)"],
3416: [351, "Raga Suddha Simantini (India)"],
2593: [352, "Raga Sumukam (India)"],
2872: [353, "Raga Syamalam (India)"],
2393: [354, "Raga Takka (India)"],
2259: [355, "Raga Tilang, Savitri (India)"],
2842: [356, "Raga Trimurti (India)"],
2609: [357, "Raga Vaijayanti (India)"],
2198: [358, "Raga Valaji (India)"],
3274: [359, "Raga Vasantabhairavi (India)"],
3269: [360, "Raga Vasanta, Chayavati (India)"],
2868: [361, "Raga Vijayanagari (India)"],
3633: [362, "Raga Vijayasri (India)"],
2227: [363, "Raga Vijayavasanta (India)"],
3401: [364, "Raga Viyogavarali (India)"],
2230: [365, "Raga Vutari (India)"],
2740: [366, "Raga Yamuna Kalyani (India)"],
2264: [367, "Raga Zilaf (India)"],
3402: [368, "Ritsu (Japan)"],
2518: [369, "Rock 'n' Roll"],
2249: [370, "Romanian Bacovia"],
3254: [371, "Romanian Major"],
2970: [372, "Sabach (Greece)"],
3160: [373, "Sakura Pentatonic (Japan)"],
2114: [374, "Sansagari (Japan)"],
2644: [375, "Scottish Pentatonic"],
3220: [376, "Scriabin"],
3072: [377, "Semitone Interval"],
3509: [378, "Shostakovich Scale"],
3562: [379, "Spanish Octatonic"],
3520: [380, "Spanish Pentacluster"],
3546: [381, "Spanish Phrygian"],
3498: [382, "Super Locrian"],
2642: [383, "Suspended Pentatonic"],
3835: [384, "Symmetrical Decatonic"],
2807: [385, "Taishikicho, Ryo (Japan)"],
2857: [386, "Takemitsu Tree Line Mode 1"],
2858: [387, "Takemitsu Tree Line Mode 2"],
2080: [388, "Tritone Interval"],
4095: [389, "Twelve-Tone Chromatic"],
3500: [390, "Ultra Locrian"],
2048: [391, "Unison"],
2306: [392, "Ute Tritonic (North America)"],
2907: [393, "Utility Minor"],
3307: [394, "Verdi Enigmatic"],
3243: [395, "Verdi Enigmatic Ascending"],
3275: [396, "Verdi Enigmatic Descending"],
2818: [397, "Warao Tetratonic (South America)"],
2560: [398, "Wholetone Interval"],
2730: [399, "Wholetone Scale"],
2731: [400, "Wholetone Scale With Leading Tone"],
2720: [401, "Wholetone Tetramirror"],
2688: [402, "Wholetone Trichord"],
3830: [403, "Youlan Scale (China)"],
2909: [404, "Zirafkend (Arabia)"]
	};
}



function testBrowserArrays() {
	var br_test = new Array();
	var br_test_str = new String();
	br_test = getBrTestValues();
	for (var j in br_test) {
		br_test_str = br_test_str + br_test[j][0];
	}
	if (br_test_str == 'abcd')	{ return false; }
	else				{ return true; }
}



function getBrTestValues() {
	return {
4  : ["a"],
2  : ["b"],
1  : ["c"],
3  : ["d"]
	};
}


