function getPlayCookie () {
	cookies = document.cookie.split(';');
	for (ii=0; ii<cookies.length; ii++) {
		elements = cookies[ii].split('=');
		if (elements[0] == 'AudioPlay' || elements[0] == ' AudioPlay') {
			return elements[1];
		}
	}
	return 'inline';
}
function setPlayCookie (popupPlay) {
	value = 'inline';
	if (popupPlay) {
		value = 'popup';
	}
	future = new Date (2100, 1, 1);
	cookieString = "AudioPlay=" + value;
	cookieDate = "expires=" + future.toGMTString();
	cookiePath = "path=/";
	cookie = cookieString + '; ' + cookieDate + '; ' + cookiePath;
	document.cookie = cookie;
	return;
}
var audioWindow;
function displayControlsFromCookie () {

	mode = getPlayCookie();
	if (mode == 'inline') {
		document.writeln ("			<div id='PlayPage' style='display:block;'>");
		document.writeln ("				<object ID='BHM_Player' CLASSID='CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95' CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701' STANDBY='Loading Microsoft Windows® Media Player components...' TYPE='application/x-oleobject' width='280' height='46'>");
		document.writeln ("					<param name='fileName' value='http://www.BassetHoundMusic.com/playlist/playlist.php?f=m3u'>");
		document.writeln ("					<param name='animationatStart' value='true' />");
		document.writeln ("					<param name='transparentatStart' value='true' />");
		document.writeln ("					<param name='autoStart' value='true' />");
		document.writeln ("					<param name='showControls' value='true' />");
		document.writeln ("					<param name='Volume' value='-300' />");
		document.writeln ("					<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='http://www.BassetHoundMusic.com/Audio/musicPlayList.m3u' name='MediaPlayer1' width='280' height='46' autostart='1' showcontrols='1' volume='-300' />");
		document.writeln ("				</object>");
		document.writeln ("			</div>");
		document.writeln ("			<div id='PlayPageInst'>Switch to <a href='' onclick='location.href=switchPlay(\"pop\"); return false;'>continous play</a> mode<br />may require popup approval</div>");

	 } else if (mode == 'popup') {
		if ((audioWindow && audioWindow.closed) || !audioWindow) {
			audioWindow = window.open ('', 'BHM_Radio', 'status,scrollbars,height=200,width=400');
			if (window.audioWindow.location.protocol != 'http:') {
				audioWindow.location.href = 'http://BassetHoundMusic.com/playlist/playlist.php';
			}
		}
		document.writeln ("			<div id='PlayPopInst'>Switch to <a href='' onclick='location.href=switchPlay(\"page\"); return false;'>page play</a> mode</div>");
	}
}
function switchPlay(type) {
	if (type == 'pop') {
		setPlayCookie (1);

	 } else {
		setPlayCookie (0);
		if (audioWindow) {
			audioWindow.close();
		}
	}
	return location.href;
}















function switchPlay1(type) {
	if (type == 'pop') {
		setPlayCookie (1);
		
		if (isMSIE()) {
			t = document.getElementById ('BHM_Player');
			t.controls.stop();
		}
		t = document.getElementById ('PlayPage');
		t.style.display = 'none';
		t = document.getElementById ('PlayPageInst');
		t.style.display = 'none';
		t = document.getElementById ('PlayPopInst');
		t.style.display = 'block';
		if ((audioWindow && audioWindow.closed) || !audioWindow) {
			audioWindow = window.open ('', 'BHM_Radio', 'status,scrollbars,height=200,width=400');
			if (window.audioWindow.location.protocol != 'http:') {
				audioWindow.location.href = 'http://BassetHoundMusic.com/playlist/playlist.php';
			}
		}
		
	 } else {
		setPlayCookie (0);
		if (audioWindow) {
			audioWindow.close();
		}
		t = document.getElementById ('PlayPopInst');
		t.style.display = 'none';
		t = document.getElementById ('PlayPage');
		t.style.display = 'block';
		t = document.getElementById ('PlayPageInst');
		t.style.display = 'block';
		if (isMSIE()) {
			t = document.getElementById ('BHM_Player');
			t.controls.start();
		}
	}
	return false;
}
function isMSIE() {
	return 1;
}

