var qs = document.location.search.substring(1);

// list of redirect pages
var noFlashPage = "noflash.html";
var noWmpPage = "nowmp.html";

var noMacSupportedPageLS = "alt_live_fmbplayer.html";
var noLinuxSupportedPageLS = "alt_live_fmbplayer.html";
var noSupportedOSPageLS = "alt_live_fmbplayer.html";

var odQS = "";

try
{
	if (!playerLive)
	{
		odQS = 'qsLabel=' + playerLabel;
		
		// check if WM domein is used
		if (playerStream.toLowerCase().indexOf("http://wm") != -1)
		{
			// replace domain to url for on demand / all platforms
			odQS += '&qsStream=http://od.mp3' + playerStream.substring(9,playerStream.length);
		}
		else
		{
			// just use what's given
			odQS += '&qsStream=' + playerStream;
		}
	}
}
catch(e)
{
	odQS = "";
}
	
var noMacSupportedPageOD = "alt_od_fmbplayer.html?" + odQS;
var noLinuxSupportedPageOD = "alt_od_fmbplayer.html?" + odQS;
var noSupportedOSPageOD = "alt_od_fmbplayer.html?" + odQS;


var upgradeIEPage = "upgradeIE.html";

function startDetection() {
	var app = navigator.appVersion.toLowerCase();
	var agent = navigator.userAgent.toLowerCase();
	if(app.indexOf("win") != -1) {
		if (app.indexOf("msie") != -1 && app.indexOf("msie 5.0") != -1) {
			// eliminate IE < 5.5
			// ie upgrade!
			window.location.replace(upgradeIEPage);
		} else {
			var theWMPlayer = new WMPlayer();
			if (theWMPlayer.installed) {
				// start Stream if WMPlayer is 7 or higher
				if (theWMPlayer.version >= 7) {
					if (hasReqestedFlashVersion)
					{
						checkAppletNeeded();
						startPlayer();
					}
					else
					{
						// no flash!
						window.location.replace(noFlashPage);  
					}
				} else {
					// wmp upgrade!
					window.location.replace(noWmpPage); 
				}
			} else {
				// no wmp!
				window.location.replace(noWmpPage);  
			}
		}
	} else if (app.indexOf("mac") != -1) {
				
		// no supoort for Mac OS
		if (playerLive)
		{
			window.location.replace(noMacSupportedPageLS);
		}
		else
		{
			window.location.replace(noMacSupportedPageOD);
		}
		
	} else if (app.indexOf("linux") != -1 ||app.indexOf("x11") != -1) {
		if (playerLive)
		{
			window.location.replace(noLinuxSupportedPageLS);
		}
		else
		{
			window.location.replace(noLinuxSupportedPageOD);
		}
		
	} else {
		if (playerLive)
		{
			window.location.replace(noSupportedOSPageLS);
		}
		else
		{
			window.location.replace(noSupportedOSPageOD);
		}
	}
}

