/*
Plugin Detector()
Plugin Detector for Rover
*/
// Start the Plugin detection
var WM_startTagFix = '</';
var msie_windows = 0;
 if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  msie_windows = 1;
  document.writeln('<script language="VBscript">');
  document.writeln('\'This will scan for plugins for all versions of Internet Explorer that have a VBscript engine version 2 or greater.');
  document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  document.writeln('Dim WM_detect_through_vb');
  document.writeln('WM_detect_through_vb = 0');
  document.writeln('If ScriptEngineMajorVersion >= 2 then');
  document.writeln('  WM_detect_through_vb = 1');
  document.writeln('End If');
  document.writeln('Function WM_activeXDetect(activeXname)');
  document.writeln('  on error resume next');
  document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  document.writeln('     If (err) then');
  document.writeln('        WM_activeXDetect = False');
  document.writeln('     End If');
  document.writeln('   Else');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('   End If');
  document.writeln('End Function');
  document.writeln(WM_startTagFix+'script>');
}

function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){
var i,plugin_undetectable=0,detected=0, daPlugin=new Object();
  if (msie_windows && WM_detect_through_vb){
      plugin_undetectable = 0;
  } else {
      plugin_undetectable = 1;
  }
  if(navigator.plugins) {
      numPlugins = navigator.plugins.length;
      if (numPlugins > 1) {
	  if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) {
	      if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) {
		  for(i in navigator.plugins) {
		      if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) {
			  detected=1;
			  break;
		      }
		  }
	      } else {
		  for (i = 0; i < numPlugins; i++) {
		      daPlugin = navigator.plugins[i];
		      if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
			  detected=1;
			  break;
		      }
		  }
	      }

	      // Mac weirdness
      if (navigator.mimeTypes[pluginmime] == null) {
		  detected = 0;
	      }
	  }
	  return detected;
      } else if((msie_windows == 1) && !plugin_undetectable){
	  return WM_activeXDetect(activeXname);
      } else { 		
	  return 0;
      }
  } else {
      return 0;
  }
}
var exists = WM_pluginDetect('Rover', '3dml', 'model/vnd.flatland.3dml', 'FlatlandRover.Rover');

// var exists = WM_pluginDetect('RoverNP', '3dmt', 'model/vnd.flatland.3dmt', 'FlatlandRovet.Rovet');

if (exists)
	{
	Write3D();
	}
else
	{
	// Check the users OS
	checkOS();
	}


// Plugin detection done
// If the plugin was found we bounce the user to the View-IT! 3D site
// Else lets check to see which OS they are using

function checkOS() 
{
  if(navigator.userAgent.indexOf('Win') != -1)
  	{
  	var OpSys = "Windows Platform";
	// Check which browser is being used
    	whichone()}
  else if(navigator.userAgent.indexOf('Mac') != -1)
 	{
	CheckMac()
	}
}
// Ok, so it's a MAC, lets check the browser!
function CheckMac()
{
	document.write("We are sorry, but at the moment we do not offer the Flatland Rover Plug-in for the MAC platform<br>");
	document.write("Please click <a href=" +document.referrer+ ">HERE</a> to return the previous page.");
	
// if (navigator.appName.indexOf("Explorer") ==-1)
// 	{
//	document.write("Clicking <a href='http://www.inside-track.co.uk/3dml/download/exes/flatlandNS.bin' target='_new'>here</a> will initiate Download Manager on your computer.<p>");
//	document.write("Allow Download Manager to finish transferring the plug-in to your selected destination.<p>");
//	document.write("Locate the Flatland Rover installer file and double click the icon to start the installation process.<p>");
//	document.write("Follow the on-screen instructions.<p>");
//	document.write("Once  installation is complete, close Netscape Navigator and then re-start it before returning to our website.<p>");
//	}
// else
//	{
//	document.write("We are sorry, but at the moment no version of the Rover Plug-in exists for Internet Explorer on the MAC platform<br>");
//	document.write("Please click <a href=" +document.referrer+ ">HERE</a> to return the previous page.");
//	}
}
// If the OS is MAC then retrieve the MAC plugin
// ELSE lets check the browser on Windows
// If IE is detected, then retrieve the IE plugin
// ELSE retrieve the NS plugin
function whichone()
{
if (navigator.appName.indexOf("Explorer") ==-1)
	{
	document.write("We are sorry, but at the moment we do not offer the Flatland Rover Plug-in for the Netscape Browser<br>");
	document.write("Please click <a href=" +document.referrer+ ">HERE</a> to return to the referrer page.");
	
//	document.write("<LEFT><FONT FACE='Arial' SIZE='2' COLOR='#000000'>You do not have the Rover Plugin installed<p>");
//	document.write("Please note these key points to help you download and install Rover.<p>");
//	document.write("1. Click OK in the first dialogue box that you see.<p>");
//	document.write("2. Then, make a note of the location displayed next to 'Save in'.<p>");
//	document.write("3. Click Save. The download will begin. It should take less than five minutes. Then click &nbsp;&nbsp;&nbsp;&nbsp;Close.<p>");
//	document.write("4. Use My Computer or Windows Explorer to run the 'flatlandNS34.exe' from the location you &nbsp;&nbsp;&nbsp;&nbsp;noted earlier.<p>");
//	document.write("5. Follow on-screen instructions to install Rover.<p>");
//	document.write("6. Once the installation is complete, close the Netscape Navigator window.<p>");
//	document.write("7. Then re-start Netscape Navigator before returning to this website.<p>");
//	document.write("<CENTER><FONT FACE='Arial' SIZE='5' COLOR='#0000ff'>First, click <a href='http://www.inside-track.co.uk/3dml/download/exes/flatlandNS34.exe' target='_new'>here</a> to start downloading Rover.</b></font><p>");
	}
else
	{
	document.writeln("<FONT FACE='Arial' SIZE='2' COLOR='#000000'>View this 3D website with Rover. For your protection, please read any Security notices displayed and the computer specification shown below.<p>");
	document.writeln("Click <b>Yes</b> to install the Rover player. Once Rover is installed, the 3D site will load automatically for you to enter, and you will also be able to enter other Rover 3D websites. Your personal computer requires the following minimum specification:<p>");
	document.writeln("<ul>");
	document.writeln("<li>Microsoft Windows 98 OSR2 / ME / 2000 / XP");
	document.writeln("<li>Microsoft DirectX 8.0 or above (you can check by clicking <b>Run</b> in the Start menu and keying in <b>dxdiag</b>. The DirectX version number is shown at the bottom of the System Information list)");
	document.writeln("<li>Pentium 400MHz processor or equivalent");
	document.writeln("<li>32Mb available RAM");
	document.writeln("<li>4Mb 3D accelerated video card or on-board 3D graphics capability");
	document.writeln("</ul></FONT>");
	document.writeln("<OBJECT CLASSID='clsid:05DD4F80-A223-11d1-852A-C03906C10000' CODEBASE='http://www.inside-track.co.uk/downloads/ieflatland.cab#version=1,5,3,0' WIDTH='1' HEIGHT='1' BGCOLOR='OOOOOO' NAME='Flatland' ID='Flatland' ALIGN='absmiddle'>");
	document.writeln("</OBJECT></b></font><p>");
	}
}

self.setInterval('CheckBusy()', 250)

function CheckBusy()
{
if(navigator.appName.indexOf("Explorer") != -1)
	{
	if(document.readyState == "complete")
		{
		Write3D();
		}
	}
}


function Write3D()
{
	if(navigator.appName.indexOf("Explorer") == -1)
	{parent.location.href = "csopen1_files/csopen1.html";}
	else
	{parent.location.href = "csopen1_files/csopen1.html";}
}

