﻿//***********************************************
//Copyright © 2002-2005 Harbinger Knowledge Products
//all rights reserved
//***********************************************
//Windows Media Player
//RealPlayer
//QuickTime

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);
var pluginlist="";
var bRealPlayer=false;
var bQuicktime=false;
var msg;

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
//function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

if (ie && win) 
{ 
	pluginlist =  detectIE("rmocx.RealPlayer G2 Control.1","Real Player") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","Quick Time") + detectIE("MediaPlayer.MediaPlayer.1","Media Player") ; 

}

if (ns || !win) 
{	
	for (var i=0;i<navigator.plugins.length;i++) 
	{	
		if(navigator.plugins[i].name.indexOf('RealPlayer') != -1 && bRealPlayer==false)
		{
			pluginlist=pluginlist + 'Real Player'+",";
			bRealPlayer=true;
		}
		else if(navigator.plugins[i].name.indexOf('QuickTime') != -1 && bQuicktime==false)
		{
			pluginlist=pluginlist + 'Quick Time'+","; 
			bQuicktime=true;
		}
		else if(navigator.plugins[i].name.indexOf('Windows Media Player') != -1)
			pluginlist=pluginlist + 'Media Player'+",";
	}
	
}

if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

var gID;
var gTopFrame;
function GetPlugin(playerpath,launchpage,framename,toppage,topframe,callfunction)
{
	var player="";
	if (pluginlist.length < 1 )
		alert("Sound will not play as no player is detected.");
	else
	{
	//	pluginlist=pluginlist.toLowerCase();
		//alert(CheckIfPlayerSet());
		if((!CheckIfPlayerSet()) || launchpage=="")
				var winPlayers=window.showModalDialog(playerpath,pluginlist+ "##" + FileTypes ,"dialogWidth:32; dialogHeight:25; center:yes; scrollbars:auto; resizable:no; status:no; help:no;");
		
	}
	if(launchpage!="")
		window.document.frames[framename].location=launchpage;	
	if(toppage!="")
		window.document.frames[topframe].location=toppage;	
	if(callfunction ==true)
	{
		gTopFrame=topframe;
		gID=window.setTimeout("CheckTop();",1000);
	}
	

}
function CheckTop()
{
	if(window.topFrame.GetBookMark) 
	{
		window.clearTimeout(gID);
		loadPageLessSCO();
	}
	else
		gID=window.setTimeout("CheckTop();",1000);	
	

}

function CheckIfPlayerSet()
{
		var arrFileTypes=FileTypes.split(",");
		var filetypeindex;

		for(filetypeindex=0;filetypeindex<arrFileTypes.length;filetypeindex++)
		{
			//	alert(getCookie(arrFileTypes[filetypeindex]+ "player"));
				
				if(getCookie(arrFileTypes[filetypeindex]+ "player")!="" && getCookie(arrFileTypes[filetypeindex]+ "player")!=null)
						return true;
		}
		
		return false;
}
