// platformDetect.js

//setCookie(), getCookie(), deleteCookie()

//this will run all of the tests for site prereqs
function runTests(){
	var passesTests = true;
	var messages = '';

	if( !detectCookies() ){
		passesTests = false;
		messages += 'no.cookies.key';}
	if( yourOS=="unknown" ){
		passesTests = false;
		messages += 'unsupported.os.key';}
// put browser checks here
	if( browserName=="unknown" ){
		passesTests = false;
		messages += 'unsupported.browser.key';}
	if( javaOK!="Yes" ){
		passesTests = false;
		messages += 'java.failed.key';}
	if( flashOK!="Yes" ){
		passesTests = false;
		messages += 'flash.failed.key';}
	if( shockwaveOK!="Yes" ){
		passesTests = false;
		messages += 'shockwave.failed.key';}
	if( 32!="Yes" ){
		passesTests = false;
		messages += 'quicktime.failed.key';}
		
	return true;
}

function isProperlyConfigured( bSetCookie )
{
	if( detectCookies() && canDetectPlugins() && detectQuickTime() && detectDirector() && detectFlash())
	{
		if( bSetCookie )
			setCookie( 'prereqsOK', 'Yes', 10000 );
		return true;
	}
	return false;
}

function detectCookies(){
	// client accepts cookies?
	if(document.cookie == '' || getCookie( 'cookiesEnabled' ) == 'no cookie by that name' ) {
	    document.cookie = 'cookiesEnabled=1'; // set a cookie
	    if(document.cookie.indexOf('cookiesEnabled=1') != -1) {// is it there?
		cookiesEnabled = true;
		return true;
	    }
	} else { // already a cookie there, so it must have cookies on
	  cookiesEnabled = true;
	  return true;
	 }
	 return false;
}

function setCookie (name, value, hours, path, domain, secure) {
    if (cookiesEnabled) { 
	if(hours) {
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
    }
}

function getCookie(name) {
    if(document.cookie == '') { // no cookies
	return 'no cookies found ' + document.cookie;
	//return false;
    } else { // there is a cookie
	var firstChar, lastChar;
	var wholeCookie = document.cookie;
	firstChar = wholeCookie.indexOf(name);	// find the start of 'name'
	if((firstChar != -1)) { // if the cookie was found
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = wholeCookie.indexOf(';', firstChar); // find the end of the 'value'
	    if(lastChar == -1) lastChar = wholeCookie.length;
	    return unescape(wholeCookie.substring(firstChar, lastChar));
	} else { // no cookie by that name
	    //return false;
	    return 'no cookie by that name';
	}
    }
}

function deleteCookie(name, path, domain) {

  var theValue = getCookie(name); // retrieve the value
  if(theValue) {
      document.cookie = name + '=null; expires=Thu, 01-Jan-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
}

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;

function goURL(daURL) {
	window.location = daURL;
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) || 
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }	
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
	if( getFlashVersion() >= 6 )
		pluginFound = true;
	else pluginFound = false;

    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) {
	
	// windows nt doesn't support shockwave
	if( is_winnt )
		return redirectCheck(false, redirectURL, redirectIfFound);

    pluginFound = detectNumericVersion('Shockwave','Director', '8.0');

    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('SWCtl.SWCtl') && isGoodShockwaveVersion(8.5));

    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = ( detectNumericVersion('QuickTime', '5.0' ) )
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB)
		pluginFound = detectQuickTimeActiveXControl();

    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime7(redirectURL, redirectIfFound)
{
	pluginFound = false;
	if ( is_mac || is_mac68k || is_macppc )
		pluginFound = false;
	else
	{
		if ( detectNumericVersion('QuickTime', '7' ) )
			pluginFound = true;
		if ( detectNumericVersion('QuickTime', '7.0.4' ) )
			pluginFound = false;
		if ( !pluginFound && detectableWithVB )
		{
			if ( detectQuickTime7ActiveXControlMore() && detectQuickTime7ActiveXControlLess() )
				pluginFound = true;
			else
				pluginFound = false;
		}
	}

    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime704(redirectURL, redirectIfFound)
{
	pluginFound = false;
	if ( is_mac || is_mac68k || is_macppc )
		pluginFound = false;
	else
	{
		if ( detectNumericVersion('QuickTime', '7.0.4' ) )
			pluginFound = true;
		if ( !pluginFound && detectableWithVB )
		{
			if ( detectQuickTime704ActiveXControl() )
				pluginFound = true;
			else
				pluginFound = false;
		}
	}

    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }	
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media' );
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}
function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;

    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
	    
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin

function detectNumericVersion() {
    // allow for multiple checks in a single pass
    var daPlugins = detectNumericVersion.arguments;
    // version to check
    var chkVers = daPlugins[daPlugins.length - 1];
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length - 1; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length - 1) {
	    	pluginFound = chkVersion( navigator.plugins[pluginsArrayCounter].description+" "+navigator.plugins[pluginsArrayCounter].name, chkVers );
		if(pluginFound == true){
		break;
		}
	    }
	}
    }

    return pluginFound;
} 


// detectNumericVersion v1.0 
// Plugin version checking with numeric conversion and beta filtering 
// You must send the entire name and description of the plugin to this function in 'desc'
function chkVersion( desc, chkvers ) {
	chkvers = processLetters(chkvers.split(""));
	chkvers = chkvers.split(".");
	var test = desc.split(" ");
	for(var j = 0; j< test.length; j++){
		var temp = processLetters(test[j].split(""));		
		if(parseInt(temp.split(".").join(""))+0 > 0){
			vers=temp.split(".");
			j= test.length;
		}
	}
	//document.write("<br><br>"+convertVersionToNumber(vers)+" "+convertVersionToNumber(chkvers));
	return convertVersionToNumber(vers) >= convertVersionToNumber(chkvers);
}
function convertVersionToNumber(a) {
	var out = 0;
	for (var n = 0; n<a.length; n++) {
		var dec = "1";
		for (var d = 0; d<n; d++) {
			dec = dec+"0";
		}
		out = parseFloat(out) + (a[n]/  parseInt(dec));
	}
	return out;
}
function processLetters(a){
	var out = "";
	for(var i = 0; i<a.length;i++){
	   if(a[i] == "." || (a[i]+0)>0 || a[i] == "0"){
		out += a[i];
	   }
	}
	return(out);
}
// replaced above - IE on MAC doesn't support Array.push
//function processLetters(a){
//	var out = new Array();
//	for(var i = 0; i<a.length;i++){
//	   if(a[i] == "." || (a[i]+0)>0 || a[i] == "0"){
//		out.push(a[i]);
//	   }
//	}
//	return(out.join(""));
//}

// Flash Version Detector  v1.1.5
// http://www.dithered.com/javascript/flash_detect/index.html
// code by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
// with VBScript code from Alastair Hamilton

var flashVersion = 0;
function getFlashVersion() {
	var agent = navigator.userAgent.toLowerCase();
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') {
			if (flashPlugin.description.indexOf('9.') != -1) flashVersion = 9;
			else if (flashPlugin.description.indexOf('8.') != -1) flashVersion = 8;
			else if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
			else if (flashPlugin.description.indexOf('6.') != -1 && flashPlugin.description.substring(flashPlugin.description.length - 2,flashPlugin.description.length) > 78) flashVersion = 6;
			else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
			else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
			else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;		
		}
	}
	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obFlash \n');
		document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.8") \n');
		document.write('if IsObject(obFlash) then \n');
		document.write('flashVersion = 8 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") end if \n');
		document.write('if flashVersion < 8 and IsObject(obFlash) then \n');
		document.write('flashVersion = 7 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
		document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
		document.write('flashVersion = 6 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
		document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
		document.write('flashVersion = 5 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
		document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
		document.write('flashVersion = 4 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
		document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
		document.write('flashVersion = 3 \n');
		document.write('end if');
		document.write('</scr' + 'ipt\> \n');
  }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;

// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
	var quicktimeVersion = 0;
    document.writeln('<scr' + 'ipt language="VBScript"\>');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 Then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
	document.writeln('        quicktimeVersion = CInt(Hex(hasQuickTimeChecker.QuickTimeVersion) / 1000000) \n');
	document.writeln('        If quicktimeVersion >= 5 Then ' );
    document.writeln('          detectQuickTimeActiveXControl = True');
    document.writeln('        End If' );  
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime 7 to 7.0.3 (more than 7)');
    document.writeln('Function detectQuickTime7ActiveXControlMore()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTime7ActiveXControlMore = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTime7ActiveXControlMore = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
	document.writeln('        quicktimeVersion = Int(Hex(hasQuickTimeChecker.QuickTimeVersion) / 10000) \n');
	document.writeln('        If quicktimeVersion >= 700 Then ' );
    document.writeln('          detectQuickTime7ActiveXControlMore = True');
    document.writeln('        End If' );
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime 7 to 7.0.3 (less than 7.0.4)');
    document.writeln('Function detectQuickTime7ActiveXControlLess()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTime7ActiveXControlLess = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTime7ActiveXControlLess = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
	document.writeln('        quicktimeVersion = Int(Hex(hasQuickTimeChecker.QuickTimeVersion) / 10000) \n');
    document.writeln('        If quicktimeVersion < 704 Then ');
    document.writeln('          detectQuickTime7ActiveXControlLess = True');
    document.writeln('        End If' );
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime 7.0.4');
    document.writeln('Function detectQuickTime704ActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTime704ActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTime704ActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
	document.writeln('        quicktimeVersion = Int(Hex(hasQuickTimeChecker.QuickTimeVersion) / 10000) \n');
    document.writeln('        If quicktimeVersion = 704 Then ');
    document.writeln('          detectQuickTime704ActiveXControl = True');
    document.writeln('        End If' );
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

// Added by Mriad
//vb function to get shockwave version
  document.writeln('function getVBDirectorVersion()');
  document.writeln('on error resume next ');
  document.writeln('getVBDirectorVersion=\"\"');
  document.writeln('set tSWControl = CreateObject("SWCtl.SWCtl") ');
  document.writeln('if IsObject(tSWControl) then ');
  document.writeln('getVBDirectorVersion = tSWControl.ShockwaveVersion("") ');
  document.writeln('end if');  
  document.writeln('end function');

//End of MRIAD


    document.writeln('</scr' + 'ipt\>');
}

// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//     is_sun, is_sun4, is_sun5, is_suni86
//     is_irix, is_irix5, is_irix6
//     is_hpux, is_hpux9, is_hpux10
//     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//     is_linux, is_sco, is_unixware, is_mpras, is_reliant
//     is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));
    
    var is_chimera = (agt.indexOf("chimera") != -1);
    var is_safari = (agt.indexOf("safari") != -1);

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var winOffset = agt.indexOf("winnt");
    if( winOffset == -1 )
    	winOffset = agt.indexOf("windows nt");
    var is_winnt = ((winOffset != -1) && (agt.indexOf("nt 3", winOffset)!=-1) || (agt.indexOf("nt3", winOffset)!=-1) || (agt.indexOf("nt 4", winOffset)!=-1) || (agt.indexOf("nt4", winOffset)!=-1));
	var is_winxp = ((winOffset != -1) && (!is_winnt) && (!is_win2k))
    var is_win32 = (is_win95 || is_winnt || is_win2k || is_winxp || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);    
    var is_aix2  = (agt.indexOf("aix 2") !=-1);    
    var is_aix3  = (agt.indexOf("aix 3") !=-1);    
    var is_aix4  = (agt.indexOf("aix 4") !=-1);    
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
    var is_mpras    = (agt.indexOf("ncr")!=-1); 
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
                 is_sco ||is_unixware || is_mpras || is_reliant || 
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));

	var gotFlash = detectFlash( false, false );
	var gotDir = detectDirector( false, false );
	var gotQT = detectQuickTime( false, false );
	
function clientDump()
{
	var availheight=screen.availHeight;
	var availwidth=screen.availWidth;
	var colordepth=screen.colorDepth ;
	var height=screen.height;
	var width=screen.width;
	
    var strClientDescription = 'UserAgent: ' + navigator.userAgent+'<br>\n';

    strClientDescription += 'Screen resolution: '+width+' x '+height+'<br>\n';
    strClientDescription += 'Color depth: ' + colordepth + ' bit<br>\n';
    strClientDescription += 'Avail. screen width: ' + availwidth + '<br>\n';
    strClientDescription += 'Avail. screen height: ' + availheight + '<br>\n';

	if( detectCookies() )
	    strClientDescription += 'Cookies enabled<br>\n';
	else strClientDescription += 'Cookies DISABLED<br>\n';	

    strClientDescription += 'Plugins:<br>\n';

		detect=getNumericQuickTimeversion();
		tr=((detect>0)?"True (" + detect +")":"False")
		strClientDescription += "Detect QuickTime : " + tr + "<br>\n";
		
		detect= getNumericDirectorVersion()
		tr=((detect>0)?"True (" + detect +")":"False")
		strClientDescription += "Detect Shockwave Director :  " +tr+ "<br>\n";

		detect= getNumericFlashVersion()
		tr=((detect>0)?"True (" + detect +")":"False")
		strClientDescription += "Detect Flash  " + tr + "<br>\n";

	return strClientDescription;
}

function isGoodBrowser()
{
  return (is_ie5up || is_nav6up || is_opera5up || is_chimera || is_safari );
}
function isGoodOS()
{
  return (is_win32 || is_linux || is_mac );
}
function isGoodClient()
{
  return (isGoodOS() && isGoodBrowser() && detectCookies() );
}


//BY MRIAD
//to check that the minimum shockwave version is arVersion  ( = 8.5)
function isGoodShockwaveVersion(arVersion )
{


var ShockVersionOK = 0;
var tVersionIndex =0;
var minVersion ="" ;
var versionStr  ="";

minVersion ="" + arVersion
	tVersionIndex = minVersion.indexOf(".")
	var Min_MajorVersion = minVersion.substring(tVersionIndex-2, tVersionIndex);
	
	var Min_MinorVersion = minVersion.substring(tVersionIndex+1, tVersionIndex+2);
versionStr=getVBDirectorVersion();
if (versionStr != "") 
{
	tVersionIndex = versionStr.indexOf(".")
	var tMajorVersionString = versionStr.substring(tVersionIndex-2, tVersionIndex);
	
	var tMinorVersionString = versionStr.substring(tVersionIndex+1, tVersionIndex+2);

	if (parseInt(tMajorVersionString) > Min_MajorVersion ) 
	{ 
		ShockVersionOK = 1;

	}	
	else
	{
		if (parseInt(tMajorVersionString) == Min_MajorVersion && parseInt(tMinorVersionString) >= Min_MinorVersion ) 
		{
			ShockVersionOK = 1;
		}

	}
  
}
return ShockVersionOK
}

//End of MRIAD
//document.write("ALL CHECKED IS "+clientDump());



//vbdetect.js

if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    
    var quicktimeVersion = 0;
    document.writeln('<scr' + 'ipt language="VBScript"\>');
    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 Then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');


// Added by Mriad
//vb function to get shockwave version (found in the top function)

   document.writeln('\'and the following function handles QuickTime');
   document.writeln('Function getVBQuickTimeversion()');
   document.writeln('  on error resume next');
   document.writeln('  getVBQuickTimeversion=""');
   document.writeln('  If detectableWithVB Then');
   document.writeln('    detectQuickTimeActiveXControl = False');
   document.writeln('    hasQuickTimeChecker = false');
   document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
   document.writeln('    If IsObject(hasQuickTimeChecker) Then');
   document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
   document.writeln('        getVBQuickTimeversion= (Hex(hasQuickTimeChecker.QuickTimeVersion) / 1000000) \n');
   document.writeln('      End If');
   document.writeln('    End If');
   document.writeln('  End If');
   document.writeln('End Function');


  document.writeln('function getVBFlashVersion()');
  document.writeln('on error resume next ');
  document.writeln('getVBFlashVersion=""');
  document.writeln('set tSWControl = CreateObject("ShockwaveFlash.ShockwaveFlash") ');
  document.writeln('if IsObject(tSWControl) then ');
  document.writeln('getVBFlashVersion = tSWControl.GetVariable(\"$version\") ');
  document.writeln('end if');  
  document.writeln('end function');

//End of MRIAD


   document.writeln('</scr' + 'ipt\>');
}


//function to return the name and description of the plugin if found
function getPluginName() {
    // allow for multiple checks in a single pass
    var daPlugins =getPluginName.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {

	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name

	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length ; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		//document.write( navigator.plugins[pluginsArrayCounter].description+" "+navigator.plugins[pluginsArrayCounter].name);
	    	return ( navigator.plugins[pluginsArrayCounter].description+" "+navigator.plugins[pluginsArrayCounter].name);
		break;
	    }
	}
    }

    return '';
} 


function processLettersWithcomma(a){
	var out = "";
	for(var i = 0; i<a.length;i++){
	   if(a[i] == "." || a[i] == "," || (a[i]+0)>0 || a[i] == "0"){
		out += a[i];
	   }
	}
	return(out);
}

function convertVersionToNumber2(a) {

	if (a=="")
	return 0

	var out = 0;
	var dec = "1";
	var temp ="";
	for (var n = 0; n<a.length; n++) {

		if (n!=0) {
		temp = a[n].toString()

			
			for (var d = 0; d<temp.length ; d++) {
				dec = dec+"0";
			}
		}
		out = parseFloat(out) + (a[n]/  parseInt(dec));
	}
	return out;
}

// You must send the entire name and description of the plugin to this function in 'desc'

function getVersion( desc) {



	var test = desc.split(" ");
	
	for(var j = 0; j< test.length; j++){
		
		var temp = processLettersWithcomma(test[j].split(""));	
		if(parseInt(temp.split(".").join(""))+0 > 0){
			vers=temp.split(".");
			j= test.length;
		}
	}
	//document.write("<br><br>"+convertVersionToNumber2(vers));
	return vers
}


//returns the plugin textversion if found

function getTextPluginVersion()
{

var daPlugins = getTextPluginVersion.arguments
var str="";

if (daPlugins.length> 0 )
{

//argumets array is transformed to a [Object object] when transfered to the other function
//so i 've splited it into text and concatenated them ("arg1","arg2","arg3".....)
// and the evaluted the string function as a function call 

str = '\"' + daPlugins[0] + '\"';

	for (i=1;i< daPlugins.length;i++)
	{
	str = str + "," +"\"" + daPlugins[i] + "\"";
	}
}
pluginName = eval("getPluginName(" + str + ")");
return getVersion( pluginName );
}


//for js browsers

function getNumericPluginVersion()
{
var pluginName
var pluginversion

var daPlugins = getNumericPluginVersion.arguments
var str="";

if (daPlugins.length> 0 )
{

//argumets array is transformed to a [Object object] when transfered to the other function
//so i 've splited it into text and concatenated them ("arg1","arg2","arg3".....)
// and the evaluted the string function as a function call 

str = '\"' + daPlugins[0] + '\"';

	for (i=1;i< daPlugins.length;i++)
	{
	str = str + "," +"\"" + daPlugins[i] + "\"";
	}
}


pluginName = eval("getPluginName(" + str + ")");

if (pluginName == "")
return 0

pluginversion = getVersion( pluginName );

if (pluginversion!="" )
{
return convertVersionToNumber2(vers);
}
else
return 0;

}


function getVBTextFlashVersion()
{
	var ver = getVBFlashVersion();
	if (ver=="")
	return "";

	return getVersion(ver)

	
}


function getVBNumericFlashVersion()
{
	var ver = getVBFlashVersion();

	if (ver=="")
	return "";

	ver=getVersion(ver);

	if (ver=="")
	return "";

	eval("arr = new Array(" + ver + ")");
	return convertVersionToNumber2(arr);

}



function getVBNumericQuickTimeversion()
{
	return parseFloat(getVBQuickTimeversion());
}


function getVBNumericDirectorVersion()
{
	var ver = getVBDirectorVersion();

	if (ver=="")
	return "";

	ver=getVersion(ver);


	if (ver=="")
	return "";

	return convertVersionToNumber2(ver);

}

/////
//
//
//
///////




function getDirectorVersion2()
{

// windows nt doesn't support shockwave
   if( is_winnt )
     return ""

    pluginFound = getPluginName('Shockwave','Director');


    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBDirectorVersion();

    return pluginFound ;

}


function getFlashVersion2()
{
    pluginFound = getPluginName('Shockwave','Flash');

    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBFlashVersion();

    return pluginFound ;

}

function getQuickTimeversion2()
{
    pluginFound = getPluginName('QuickTime');

    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBQuickTimeversion();

    return pluginFound ;

}

function getNumericDirectorVersion()
{

// windows nt doesn't support shockwave
   if( is_winnt )
     return ""

    pluginFound = getNumericPluginVersion('Shockwave','Director');

    // if not found, try to detect with VisualBasic


    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBNumericDirectorVersion();

    return pluginFound ;
}
function getNumericFlashVersion()
{
    pluginFound = getNumericPluginVersion('Shockwave','Flash');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBNumericFlashVersion();
    return pluginFound ;
}
function getNumericQuickTimeversion()
{
    pluginFound = getNumericPluginVersion('QuickTime');

    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) 
	pluginFound = getVBNumericQuickTimeversion();

    return pluginFound ;

}