var Rhythm = new Rhythm();
//var Rhythm = {};

$(document).ready(function(){
	$("#addrhythm").validate();
	//var drumType = $("#rhythm-drum").attr("selectedIndex");
	//var timingID = $("#rhythm-timing").attr("selectedIndex");
	
	var drumType = $("#rhythm-drum").val();
	var timingID = $("#rhythm-timing").val();
	
	var showhidespeed = 300;
	
	$("#binaryaddrow").click(function() { Rhythm.addRowToTable('tabtablebinary', 16, 4, 'b') });
	$("#ternaryaddrow").click(function() { Rhythm.addRowToTable('tabtableternary',24, 3, 't') });
	
	$("#addrow").hide();
	
	$("#tabinputboxes").hide();	
	var drumType;
	var timingID;
	$("#rhythm-timing").change(
		function() {
		
			Rhythm.noBars = 0;
			Rhythm.noBeatsInTab = 0;
			//alert ("Just changed no bars is " + Rhythm.noBars);
			//Rhythm.notesPerBar = 0;
		
			$(".addnotationrow").remove();
			//if ($("#rhythm-timing").attr("selectedIndex") !=  "")
			if ($("#rhythm-timing").val() !=  "")
			{
				//if ($("#rhythm-drum").attr("selectedIndex") !=  "")
				if ($("#rhythm-drum").val() !=  "")
				{
					//var drumType = $("#rhythm-drum").attr("selectedIndex");
					drumType = $("#rhythm-drum").val();
					timingID = $("#rhythm-timing").val();
					
					Rhythm.addBar(timingID, drumType);
					Rhythm.addRowButtons();	
					
				}
				else
					alert("Please select a drum first!");
			}
		});
	$("#addrow").click(function() { Rhythm.addBar(timingID, drumType) });
	$("#taboptions").hide();
	$("#split-how-many").hide(300);
	$("#split-how-many").click(function() {
	
	});
	$("#split-2").click(function() {	
		Rhythm.splitNote($(".selected").prev(), $(".selected").next(), 2, $(".selected"));
		$("#split-how-many").hide(300);	
		return false;
	});
	$("#split-3").click(function() {
	
		Rhythm.splitNote($(".selected").prev(), $(".selected").next(), 3, $(".selected"));
		$("#split-how-many").hide(300);	
		return false;
	});
	$("#dontSplitNote").click(function() {
		$("#taboptions").hide(300);	
		return false;
	});
	$("#splitNote").click(function() { 	
		$("#taboptions").hide(300);
		$("#split-how-many").show(300);
		return false;
	});
	
});

