/*
BrowserInfo

Author: Jonathan Mangano
Dependencies: PluginDetector.js, CookieLibrary.js
*/

// this is where we write out the VBScript for MSIE Windows

var isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != -1);
var BI_startTagFix = '</';
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Opera') == -1)) { //is IE
  document.writeln('<OBJECT ID="RealPlayerIE" NAME="RealPlayerIE2" CLASSID="CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA">'+BI_startTagFix+'OBJECT>');
  if (navigator.userAgent.indexOf('Win') != -1) { //is IE on windows
	document.writeln('<OBJECT ID="WMP64" WIDTH=1 HEIGHT=1 classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="#Version=6,4,5,715">'+BI_startTagFix+'OBJECT>');
	document.writeln('<object ID="WMP7" WIDTH="1" HEIGHT="1" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" CODEBASE="#Version=7,0,0,1954">'+BI_startTagFix+'object>');
	
    document.writeln('<script language="VBscript">');

    document.writeln('Function WMP64activeXDetect()');
    document.writeln('  on error resume next');
    document.writeln('  If ScriptEngineMajorVersion >= 2 then');
    document.writeln('     WMP64activeXDetect = False');
    document.writeln('     WMP64activeXDetect = (WMP64.FileName="")');
    document.writeln('     If (err) then');
    document.writeln('        WMP64activeXDetect = False');
    document.writeln('     End if');
    document.writeln('   Else');
    document.writeln('     WMP64activeXDetect = False');
    document.writeln('   End If');
    document.writeln('End Function');

    document.writeln('Function WMP7activeXDetect()');
    document.writeln('  on error resume next');
    document.writeln('  If ScriptEngineMajorVersion >= 2 then');
    document.writeln('     WMP7activeXDetect = False');
    document.writeln('     WMP7activeXDetect = (WMP7.URL = "")');
    document.writeln('     If (err) then');
    document.writeln('        WMP7activeXDetect = False');
    document.writeln('     End if');
    document.writeln('   Else');
    document.writeln('     WMP7activeXDetect = False');
    document.writeln('   End If');
    document.writeln('End Function');

    document.writeln(BI_startTagFix+'script>');
  }
} 

function acceptsSessionCookies() {
	var accepts = 'n';
	if (WM_acceptsSessionCookies) {
		accepts = 'y';
	}
	return accepts;
}

function acceptsPersistentCookies() {
	var accepts = 'n';
	if (WM_acceptsPersistentCookies) {
		accepts = 'y';
	}
	return accepts;
}

function acceptsCookies() {
	if (acceptsPersistentCookies() == 'y') {
		return 'p';
	}
	if (acceptsSessionCookies() == 'y') {
		return 's';
	} 
	return 'n';
}

/* Returns the version number if possible */
function hasFlash() {
	var supports = 'u';
	if(WM_pluginDetect('Flash 6', 'swf','application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash.6')) { 
		supports='6';
	} else if(WM_pluginDetect('Flash 5', 'swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.5')) {
		supports='5';
	} else if(WM_pluginDetect('Flash 4', 'swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.4')) { 
		supports='4';
	} else if(WM_pluginDetect('Flash 3', 'swf','application/x-shockwave-flash','ShockwaveFlash.ShockwaveFlash.3')) { 
		supports='3';
	} else if (WM_pluginDetect('Flash', 'swf', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash')) {
		supports='y';
	}
 	return supports;
}

/* Returns the version number if possible */
function hasRealPlayer() {
	var supports = 'u';

	//This detects if realplayer is supported
	if(WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin', 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)')) {
		supports = 'y';
	} else if(WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin','rmocx.RealPlayer G2 Control')) {
		supports = 'y';
	} else if(WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin','RealVideo.RealVideo(tm) ActiveX Control (32-bit)')) {
		supports = 'y';
	}

/*
	//This detects the exact version
	if (document.RealPlayerIE) {
    	supports = document.RealPlayerIE.GetVersionInfo();
    	if (supports == null || supports == '') {
    		supports ='y';
    	}
	}
	else if (document.RealPlayerNS && (navigator.userAgent.indexOf('Netscape6') == -1)) {
       	supports = document.RealPlayerNS.GetVersionInfo();
	    if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.') != -1)) { // stupid, stupid Netscape 4 bug...
        	supports = supports.trim();
		}
    	if (supports == null || supports == '') {
    		supports ='y';
    	}
	}
*/

	return supports;
}

/* Returns the version number if possible */
function hasWindowsMediaPlayer() {
	var supports = 'u';
	
	if(WM_pluginDetect('', '', 'application/x-drm-v2','') || WM_pluginDetect('', '', 'application/x-ms-wmd','')) {
		supports = '7';
	} else if(WM_pluginDetect('', '', 'video/x-ms-wm','') && WM_pluginDetect('', '', 'video/x-ms-wmv','')) {
		supports = '6.4';
	} else if(WM_pluginDetect('', '', 'video/x-ms-asf','')) {
		supports = '6.3';
	} else if(WM_pluginDetect('', '', 'application/x-mplayer2', 'MediaPlayer.MediaPlayer.1')) {
		supports = '5.2';
	}
/*
	if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('Opera') == -1)) {
		if (WMP7activeXDetect()) {
			supports = WMP7.versionInfo;
		} else if (WMP64activeXDetect()) {
			supports = '6.4';
		}
	}	
*/
	return supports;
}