// Flux detection script

var isFlux = 0;
var enable3D = 1;


// Firefox, Netscape, Mozilla, Opera plugin check for Flux, basically anything but I.E.
if (navigator.plugins && navigator.plugins.length > 0) {
  var numPlugins = navigator.plugins.length;
// loop through plugins
  for (i = 0; i < numPlugins; i++) {
    var plugin = navigator.plugins[i];
	if (plugin.name == 'Flux Player') {
		isFlux = 1;
	}
  }
  
// Check Internet Exploder for Flux
} else if (navigator.appName == "Microsoft Internet Explorer") {
  if (navigator.appVersion.indexOf('Win') != -1) {
	// IEDetectObject is used to detect ActiveX Controls
    document.writeln('<SCRIPT LANGUAGE="VBScript">');
    document.writeln('function IEDetectObject(activeXControlName)');
    document.writeln('  On Error Resume Next');
    document.writeln('  IEDetectObject = IsObject(CreateObject(activeXControlName))');
    document.writeln('End function');
    document.writeln('</SCR' + 'IPT>');

	if (IEDetectObject('ANIMA.AnimaCtrl.1'))   {
	  isFlux = 1;
    }
  }
}

var isWindows   = 0;
if (navigator.appVersion.indexOf('Win')  != -1) {isWindows   = 1;}

if (enable3D == 0) {
	ShowComingSoon()
}
else if (isWindows == 1) {
	if (isFlux) {
		ShowChurch();
		//document.writeln('<font color="white">show church</font>');
		}
	else {
		//document.writeln('<font color="white">ShowGetFlux</font>');
		ShowGetFlux();
	}
}
else {
	ShowMacintosh();
}

function ShowComingSoon() {
	document.writeln('<br><br><center><div id="fluxplayer"><div id="message">');
	document.writeln('<h1>Coming Soon: Cyama 3D!</h1>');
	document.writeln('Cyama will be releasing it\s 3D environment in the next few weeks, which will include message walls, contemplative space, ');
	document.writeln('cool information from Cyama\'s partners such as ads, streaming music and video, and customizable image galleries.');
	document.writeln('Check back soon for the grand opening of Cyama 3D.');
	document.writeln('<p>');
	document.writeln('<br><br><a href=\'#\' onClick=\'window.close()\'>Close Window</a></div></div></center>');
}

function ShowChurch() {
		document.writeln('<br><br><center>');
		document.writeln('<object width="1000" height="562" name="FLUX" id="FLUX" type="model/x3d" codebase="http://www.mediamachines.com/flux2b3/flux.xpi" >');
		document.writeln('<PARAM NAME="BgColor" VALUE="0x000000">');
		document.writeln('<PARAM NAME="Dashboard" VALUE="0">');
		document.writeln('<PARAM NAME="PrimitiveQuality" VALUE="BEST">');
		document.writeln('<PARAM NAME="MaxTextureSize" VALUE="0">');
		document.writeln('<PARAM NAME="RightMouseMenu" VALUE="SHORT">');
		document.writeln('</object>');
		document.writeln('<br><a href="#" onClick=\'window.close()\'>Close</a></center>');
}

function ShowMacintosh() {
	document.writeln('<br><br><center><div id="fluxplayer"><div id="message">');
	document.writeln('<h1>Sad Face. Flux is Windows Only Currently</h1>');
	document.writeln('Ut oh.  I\'m sorry the FLUX plugin required to run the Cyama 3D space is currently only available for the PC.');
	document.writeln('<p>The Flux Player currently works on the Windows operating system on versions XP, Me, and 2000. We hope to make the Flux Player');
	document.writeln('available to all you Mac and Linux folks soon, but we don\'t have a firm date for that yet.');
	document.writeln('<br><br><a href=\'#\' onClick=\'window.close()\'>Close Window</a></div></div></center>');
}

function ShowGetFlux()
{
	document.writeln('<br><br><center><div id="fluxplayer"><div id="message">');
	document.writeln('<h1>Get the Flux 3D Player Now!</h1>');
	document.writeln('It looks like you\'re missing the Flux Player. Flux is a technology that allows you to access and interact with Cyama\'s 3D online world. It\'s fast');
	document.writeln('and easy to download. Go <a href="http://www.cyama.com/pages.php?caption=Download_Flux_Player">get the Flux Player</a> now!');
	document.writeln('<br><br><a href="http://www.cyama.com/pages.php?caption=Download_Flux_Player">Get Flux</a><br><br>');
	document.writeln('<br><a href=\'#\' onClick=\'window.close()\'>Close Window</a></div></div></center>');
}

