// Sets cookie values. Expiration date is optional
function setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value) +
	((expire == null) ? "" : ("; expires=" + expire.toGMTString())) +
	"; path=/";
}
function getCookie(name) {
	var search = name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1) { // if cookie exists
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return null;
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// название функции менять нельзя
function controls_DoFSCommand(command, args) {
	//var controlsObj = isInternetExplorer ? document.all.controls : document.controls;
	if ('sound_on' == command) {
		setCookie('sound_on', ('true' == args ? '1' : '0'));
	}
	if ('current_track' == command) {
		setCookie('current_track', args);
	}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub controls_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call controls_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function drawFlash(path_to_xml) {
	var sound_on = getCookie('sound_on');
	if (null == sound_on) {
		sound_on = "0";
	}
	var current_track = getCookie('current_track');
	if (null == current_track) {
		current_track = "0";
	}

	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="controls" width="206" height="90" align="middle">');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="movie" value="/design/music/music.swf?xml_list='+path_to_xml+'&amp;sound_on='+sound_on+'&amp;current_track='+current_track+'" />');
	document.writeln('<param name="menu" value="false" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="bgcolor" value="#7a0001" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<embed src="/design/music/music.swf?xml_list='+path_to_xml+'&amp;sound_on='+sound_on+'&amp;current_track='+current_track+'" quality="high" wmode="transparent" bgcolor="#7a0001" width="206" height="90" swLiveConnect=true id="controls" name="controls" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
}

