var roboguru_chordVariation = 0;

function roboguru_select(layerId)
{
	document.getElementById('robogurufinder').style.display = 'none';
	document.getElementById('robogurutuner').style.display = 'none';
	document.getElementById('robogurumetronome').style.display = 'none';

	document.getElementById(layerId).style.display = 'block';
	if (layerId == 'robogurumetronome')
	{	
		setTimeout("roboguru_metronome_init()", 2000);
	}
}

function roboguru_updateChordSelect()
{
	var obj = document.getElementById('robogurunotes');
	note = obj.options[obj.selectedIndex].value;

	var chordsSelect = document.getElementById('roboguruchords')

	while (chordsSelect.options.length) 
		chordsSelect.options[0] = null;

	for (var chordName in roboguruChords[note])
		chordsSelect.options[chordsSelect.options.length] = new Option(chordName, chordName);
		
	chordsSelect.selectedIndex = 0;
	roboguru_chordVariation = 0;
	roboguru_updateFretBoard();
}

function roboguru_onChordSelect()
{
	roboguru_chordVariation = 0;
	roboguru_updateFretBoard();
}

function roboguru_updateFretBoard()
{
	var	variations = roboguru_getVariations();
	roboguru_drawChord(variations[roboguru_chordVariation]);
}

function roboguru_getVariations()
{
	var chordsSelect = document.getElementById('roboguruchords');
	var chordName = chordsSelect.options[chordsSelect.selectedIndex].value;	
	var obj = document.getElementById('robogurunotes');
	var note = obj.options[obj.selectedIndex].value;
	return roboguruChords[note][chordName];
}

function roboguru_changeVariation()
{
	var	variations = roboguru_getVariations();
	roboguru_chordVariation++;
	if (roboguru_chordVariation >= variations.length)
		roboguru_chordVariation = 0;	
	roboguru_updateFretBoard();
}
