var playing;
var isFlash6 = false;

if (document.images) {
	var playButton = new Image();
	var stopButton = new Image();
	playButton.src = buttonLocation + 'button-play.gif';
	stopButton.src = buttonLocation + 'button-stop.gif';
}

if (navigator.plugins && navigator.plugins.length > 0) {
	if (navigator.plugins["Shockwave Flash"]) {
		var flash_mode = 0;
		var plugin_version = 0;
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
				continue;
			plugin_version = words[i];
		}
		if (plugin_version >= 6) {
			var plugin = navigator.plugins["Shockwave Flash"];
			var numTypes = plugin.length;
			for (j = 0; j < numTypes; j++) {
				mimetype = plugin[j];
				if (mimetype) {
					if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
						flash_mode = 1;
					if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
						flash_mode = 0;
				}
			}
		}
		isFlash6 = (flash_mode && (plugin_version >= 6));
	}
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && (navigator.userAgent.indexOf("Windows 95") >= 0 || navigator.userAgent.indexOf("Windows 98") >= 0 || navigator.userAgent.indexOf("Windows NT") >= 0)) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('	On Error Resume Next\n');
	document.write('	isFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	document.write('<\/script\>\n');
}

function preview(track, vcode) {
	var playerObj = navigator.appName.indexOf("Microsoft") != -1 ? document.all.player : document.player;
	if (track.src == playButton.src) {
		if (isFlash6) {
			if (playing != null && playing != track) stopPreview();
			playing = track;
			playerObj.SetVariable("_root.vcode", vcode);
			playerObj.SetVariable("_root.command", "play");
			playing.src = stopButton.src;
		} else {
			alert('To preview this content you need to have Adobe Flash Player 6 or above installed.\nPlease visit http://www.adobe.com/go/getflashplayer');
		}
	} else {
		playerObj.SetVariable("_root.command", "stop");
		stopPreview();
	}
}

function stopPreview() {
	if (playing != null) {
		playing.src = playButton.src;
		playing = null;
	}
}

function player_DoFSCommand(command, args) {
	if (command == 'stop') stopPreview();
}

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 player_FSCommand(ByVal command, ByVal args)\n');
	document.write('	  Call player_DoFSCommand(command, args)\n');
	document.write('  End Sub\n');
	document.write('<\/script\>\n');
}
