/* MidiControl class */

// constructor
function MidiControl()
{
	this.song = this.getMidiSetting();		// 0 for no music, > 0 for music
}


/* methods */

MidiControl.prototype.getMidiSetting = function ()
{
	// get cookie string
	var cookie_str = document.cookie;
	var midi_val;


	// 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;
}

MidiControl.prototype.setMidiSetting = function (midi_val)
{
	// get current date
	var 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();
}

MidiControl.prototype.midiToggle = function ()
{
	if (this.song == 1)
		// stop the song in variable
		this.song = 0;
	else
		// start the song in variable
		this.song = 1;

	// save midi setting to cookie
	this.setMidiSetting(this.song);

	return true;
}

MidiControl.prototype.midiEnabled = function ()
{
	var midi_val;				// boolean midi value


	if (this.song == 1)
		// midi is enabled
		midi_val = true;
	else
		// midi is disabled
		midi_val = false;

	return midi_val;
}
