// returns:
// 0 if the browser is not IE 5.5+
// version number otherwise
function isIE()
{
	var agt = navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	if (ie)
	{
    temp=navigator.appVersion.split("MSIE");
    version=parseFloat(temp[1]);
    return version;
  }
	else
	{
		return 0;
	}
}

function isSupported() {
	var supportedBrowsers = suppBrowsers.split("|");
	var supported = 0;
	var i = 0;
	var br=new Array(4);
	br = getBrowser();
    for (i in supportedBrowsers) {
		var split = supportedBrowsers[i].split("=");
		//check browser identifier
		if (br[0] == split[0]) {
		   //check browser version
		   var supportedVersion = parseFloat(split[1]);
		   var version = parseFloat(br[1].substring(0,3));
		   if (version >= supportedVersion) {
			   supported = 1;
		    }
		    break;	 	   
		}
	}
	return supported;
}


// returns:
// true if the OS is Windows, false otherwise
function isWindows()
{
	var agt = navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	return win;
}

function windowsVersion()
{
	var agt = navigator.userAgent.toLowerCase();
	var temp = agt.split("nt");
	return (parseFloat(temp[1]));
}

// internal class
function detectIE(ClassID,name) 
{
	result = false;
	document.write('<SCR'+'IPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCR'+'IPT>\n');
	if (result) return name+','; else return ''; 
}

// internal class
function detectNS(ClassID,name) 
{
	n = ""; 
	if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; 
	return n;
}

// internal class
function getPlugins()
{
	var agt = navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	var mac = (agt.indexOf("mac")!=-1);
	
	if (ie && win)
	{
		pluginlist = detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player"); 
	}
	if (ns || !win) 
	{
		nse = ""; 
		for (var i=0; i<navigator.mimeTypes.length; i++)
			nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("application/x-mplayer2","Windows Media Player");
	}	
	pluginlist += navigator.javaEnabled() ? "Java," : "";
	if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

	return pluginlist;
}

// returns:
// 0 if no player installed or undetectable
// 1 if player installed but version number undetectable
// version number otherwise
function isWMP()
{
	var list = getPlugins();
	if (isIE())
	{
	  try
	  {
  	  objMediaPlayer = new ActiveXObject("WMPlayer.OCX");
      WMPVer = objMediaPlayer.versionInfo;
      objMediaPlayer = null;
      return WMPVer;
    }
    catch(objError)
    {
      return 0;
    }
  }
  else
  {
    return (pluginlist.indexOf("Windows Media Player") != -1) ? 1 : 0;
  }
}

//used on system check page to show/hide DIVs
function showHideErrors()
{
	var supported = new Boolean(isSupported());
	var playerOk = new Boolean((player=="wmp" && isWMP() >= 9 ) || (player == "flash" && hasFlashPlugin()));
	/*if (playerOk  && supported && isWindows())
	{
		setDontShowAgainCookie();
	}*/
	if (playerOk)
		document.getElementById('warnwmp').style.display = 'none';
	if ((!checkWmp && supported) || (checkWmp && isIE()))
		document.getElementById('warnie').style.display = 'none';
	if (!checkWmp && supported && playerOk) {
		document.getElementById('warnieandwmp').style.display = 'none';
	}
	if (isWindows())
		document.getElementById('warnwin').style.display = 'none';
	if (!checkWmp && supported || (checkWmp && isIE() >= 6 && drmVersion != '')) {
		document.getElementById('warndrm').style.display = 'none';
	}
}


// set a cookie to avoid system checks in the future
function setDontShowAgainCookie() {
   var date = new Date();
   var expires = date.getTime() + (365 * 24 * 60 * 60 * 1000);
   date.setTime(expires);
   document.cookie = "SystemCheckCookie=Done;expires=" + date.toGMTString();
}

// continue after the system check was displayed
function continueAnyway() {
   var dontShowThisAgain = document.getElementById('dontShowThisAgain').checked;
   if (dontShowThisAgain)
      setDontShowAgainCookie();
   
   // D28610  
   // We will not forward to the main page after the systemcheck. Now we will forward
   // to the deeplink which whill be called with the parameter 'continueanyway'.
   //document.location = 'systemCheck.do?method=next&continueanyway=true';
   window.location.href=document.location.href+'&continueanyway=true';
   
}

// repeat the system check again
function repeatSystemCheck() {
   //document.location = 'systemCheck.do?method=show';
   document.location.reload();
}