// midi_control.js

// song is 0 for no music, 1 for music
var song = getMidiSetting();

function getMidiSetting()
{
	// get cookie string
	var cookie_str = document.cookie;

	// check if midi is disabled (midi_play)
	if (cookie_str.search(/midi_play=0/) != -1)
	{
		// disable midi
		midi_val = 0;
	}
	else
	{
		// enable midi
		midi_val = 1;
	}

	return midi_val;
}

function setMidiSetting(midi_val)
{
	// get current date
	expr_date = new Date;

	// add 1 year for expiration date
	expr_date.setFullYear(expr_date.getFullYear() + 1);

	// save cookie as "midi_play"
	document.cookie = "midi_play=" + midi_val + "; path=/; expires=" + expr_date.toGMTString();
}

function midiToggle()
{
	if (song == 1)
	{
		// stop the song in variable
		song = 0;

		// save midi setting to cookie
		setMidiSetting(song);

		// reopen page
		parent.frames.MidiFrame.open("footer.html","MidiFrame");
	}
	else
	{
		// start the song in variable
		song = 1;

		// save midi setting to cookie
		setMidiSetting(song);

		// reopen page
		parent.frames.MidiFrame.open("footer.html","MidiFrame");
	}

	return true;
}
