//  vrgoo.js

var web3Dbrowser = null;
var web3Dbrowsercontext = null;

var sphereColor0 = null;
var sphereColor1 = null;
var sphereColor2 = null;
var sphereColor3 = null;
var sphereColor4 = null;
var sphereColor5 = null;
var sphereColor6 = null;
var sphereColor7 = null;

var theText0 = null;
var inlineScene0 = null;
var theText1 = null;
var inlineScene1 = null;
var theText2 = null;
var inlineScene2 = null;
var theText3 = null;
var inlineScene3 = null;
var theText4 = null;
var inlineScene4 = null;
var theText5 = null;
var inlineScene5 = null;
var theText6 = null;
var inlineScene6 = null;
var theText7 = null;
var inlineScene7 = null;
var theText8 = null;
var inlineScene8 = null;

window.onload = initX3Dbrowser;


function initX3Dbrowser(){
    
  web3Dbrowser = null;

	if(parent.search.plugin == "Flux"){

  		// Connect host DOM to X3D Browser SAI
  		web3Dbrowser = document.objx3d.getBrowser();  
  
  		if (web3Dbrowser == null){
    			alert("Couldn't get X3D Browser object!");
    			return;
  		}
  		// Connect SAI browserChanged event to DOM
  		listener = new Object();
  		listener.browserChanged = web3DbrowserChanged;
  		// assign DOM  browserChanged() handler
  		web3Dbrowser.addBrowserListener(listener);

  		web3Dbrowser.loadUrlS('vrgoo.x3d');
	}
}


function web3DbrowserChanged(evt)
{
  web3Dbrowsercontext = null;
  
  sphereColor0 = null;
  sphereColor1 = null;
  sphereColor2 = null;
  sphereColor3 = null;
  sphereColor4 = null;
  sphereColor5 = null;
  sphereColor6 = null;
  sphereColor7 = null;
          
  theText0 = null;
  inlineScene0 = null;
  theText1 = null;
  inlineScene1 = null;
  theText2 = null;
  inlineScene2 = null;
  theText3 = null;
  inlineScene3 = null;
  theText4 = null;
  inlineScene4 = null;
  theText5 = null;
  inlineScene5 = null;
  theText6 = null;
  inlineScene6 = null;
  theText7 = null;
  inlineScene7 = null;    
  
  if (evt != 0)    // BROWSER_INITIALIZED = 0
  {
    alert("browserChanged(evt) != 0");
    return;
  }


  web3Dbrowsercontext = web3Dbrowser.getExecutionContext();
  if (web3Dbrowsercontext == null)
  {
    alert("Couldn't get executionContext object!");
    return;
  }


  sphereColor0 = web3Dbrowsercontext.getNode("SPHERECOLOR0");
  theText0 = web3Dbrowsercontext.getNode("THETEXT0");
  inlineScene0 = web3Dbrowsercontext.getNode("INLINESCENE0");
  
  sphereColor1 = web3Dbrowsercontext.getNode("SPHERECOLOR1");
  theText1 = web3Dbrowsercontext.getNode("THETEXT1");
  inlineScene1 = web3Dbrowsercontext.getNode("INLINESCENE1");
  
  sphereColor2 = web3Dbrowsercontext.getNode("SPHERECOLOR2");  
  theText2 = web3Dbrowsercontext.getNode("THETEXT2");
  inlineScene2 = web3Dbrowsercontext.getNode("INLINESCENE2");
  
  sphereColor3 = web3Dbrowsercontext.getNode("SPHERECOLOR3");
  theText3 = web3Dbrowsercontext.getNode("THETEXT3");
  inlineScene3 = web3Dbrowsercontext.getNode("INLINESCENE3");
  
  sphereColor4 = web3Dbrowsercontext.getNode("SPHERECOLOR4");   
  theText4 = web3Dbrowsercontext.getNode("THETEXT4");
  inlineScene4 = web3Dbrowsercontext.getNode("INLINESCENE4");
  
  sphereColor5 = web3Dbrowsercontext.getNode("SPHERECOLOR5");
  theText5 = web3Dbrowsercontext.getNode("THETEXT5");
  inlineScene5 = web3Dbrowsercontext.getNode("INLINESCENE5");
  
  sphereColor6 = web3Dbrowsercontext.getNode("SPHERECOLOR6");  
  theText6 = web3Dbrowsercontext.getNode("THETEXT6");
  inlineScene6 = web3Dbrowsercontext.getNode("INLINESCENE6");
  
  sphereColor7 = web3Dbrowsercontext.getNode("SPHERECOLOR7");
  theText7 = web3Dbrowsercontext.getNode("THETEXT7");
  inlineScene7 = web3Dbrowsercontext.getNode("INLINESCENE7");  
    
  if (sphereColor0 == null)
  {
    alert("Couldn't get SPHERECOLOR0!");
    return;
  }   
  if (theText0 == null)
  {
    alert("Couldn't get THETEXT0!");
    return;
  }
  
  if (inlineScene0 == null)
  {
    alert("Couldn't get INLINESCENE0!");
    return;
  }

}


function LoadObjx3d() {

	if(parent.search.plugin == "Flux"){

		if (window.ActiveXObject){

  			document.write('<object id="objx3d" class="x3dscene" type="model/x3d+xml"');
  			document.write('classid="CLSID:918B202D-8E8F-4649-A70B-E9B178FEDC58"'); // Flux
  			document.write('codebase="http://mediamachines.com/download/SetupFluxPlayer.exe">'); 
			document.write('<param name="src" value="http://www.3dnetpro.com/vrgoo/vrgoo.x3d">');
  			document.write('<param name="DASHBOARD" value="0">');
  			document.write('<param name="BGCOLOR" value="0x000000">');
  			document.write('<div><p><font color="#00FF00">If you can read this please</font> <a href="http://mediamachines.com/download/SetupFluxPlayer.exe"><font color="yellow">click to install Flux Player</font></a><font color="#00FF00">.</font></div>');
  			document.write('</object>');
		}
		else
		{
  			document.write('<object id="objx3d" class="x3dscene" type="model/x3d+xml"');
  			document.write('codebase="http://mediamachines.com/download/SetupFluxPlayer.exe">');
  			document.write('<param name="src" value="http://www.3dnetpro.com/vrgoo/vrgoo.x3d">');
  			document.write('<param name="DASHBOARD" value="0">');
  			document.write('<param name="BGCOLOR" value="0x000000">');
  			document.write('<div><p><font color="#00FF00">If you can read this please</font> <a href="http://mediamachines.com/download/SetupFluxPlayer.exe"><font color="yellow">click to install Flux Player</font></a><font color="#00FF00">.</font></div>');
  			document.write('</object>');
		}
	}
	else if(parent.search.plugin == "Contact"){

		document.write('<object declare id=CC3D classid=clsid:4B6E3013-6E45-11D0-9309-0020AFE05CC8 width="100%" height="95%" type=application/x-oleobject>');
		document.write('<param name="src" value="http://www.3dnetpro.com/vrgoo/vrgoo_contact.x3d"><embed type="application/x-cc3d" src="vrgoo_contact.x3d" name="cc3d"></embed></object>');
	}
	else if(parent.search.plugin == "Octaga"){

		document.write('<object width="100%" height="95%" type="application/octaga" data="vrgoo_octaga.x3d" codebase="http://www.octaga.com/freedownloads/Octaga/current/Octaga.exe">');
		document.write('<PARAM NAME="SRC" VALUE="http://www.3dnetpro.com/vrgoo/vrgoo_octaga.x3d"><PARAM NAME="SplashScreen" VALUE="False"></object>');

	}
	else if (parent.search.plugin == "Cortona"){
		document.write('<object classid="CLSID:86A88967-7A20-11d2-8EDA-00600818EDB1" width=100% height=100% codebase="http://www.parallelgraphics.com/bin/cortvrml.cab#Version=3,1,0,54"><param name=src value="vrgoo_cortona.wrl">');
		document.write('<param name="vrml_background_color" value="#000000"><param name="vrml_splashscreen" value="false"><param name="vrml_dashboard" value="false"><param name="contextmenu" value="false">');
		document.write('<embed type="x-world/x-vrml" src="http://www.3dnetpro.com/vrgoo/vrgoo_cortona.wrl" width=100% height=100% VRML_BACKGROUND_COLOR="#000000" VRML_SPLASHSCREEN="false" VRML_DASHBOARD="true"  CONTEXTMENU="true"  align="middle" frameborder="no"></object>');
	}
}


function LoadAnyPlayerObjx3d() {

}



