var V3Embed = {
  init: function() {
    var tMajorVersion = 10;
    var tMinorVersion = 1;
    this.ShockwaveFound = 0;

    if (navigator.mimeTypes && navigator.mimeTypes["application/x-director"] && navigator.mimeTypes["application/x-director"].enabledPlugin) {
      if (navigator.plugins && navigator.plugins["Shockwave for Director"] && (tVersionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1) {
        var tMajorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2, tVersionIndex);
        var tMinorVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex+1, tVersionIndex+2);
        if (parseInt(tMajorVersionString) >= tMajorVersion) {
          if (tMinorVersion > 0) {
            if (parseInt(tMinorVersionString) >= tMinorVersion) {
              this.ShockwaveFound = 1;
            }
          } else {
            this.ShockwaveFound = 1;
          }
        }
      }	
    } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )) {
      var tVersionString = "";
      document.write('<SCRIPT LANGUAGE=VBScript\> \n');
      document.write('on error resume next \n');
      document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
      document.write('if IsObject(tSWControl) then \n');
      document.write('tVersionString = tSWControl.ShockwaveVersion("") \n');
      document.write('end if');
      document.write('</SCRIPT\> \n');
      if (tVersionString != "") { 
        tVersionIndex = tVersionString.indexOf(".")
        var tMajorVersionString = tVersionString.substring(tVersionIndex-2, tVersionIndex);
        var tMinorVersionString = tVersionString.substring(tVersionIndex+1, tVersionIndex+2);
        if (parseInt(tMajorVersionString) >= tMajorVersion) {
          if (tMinorVersion > 0) {
            if (parseInt(tMinorVersionString) >= tMinorVersion) {
              this.ShockwaveFound = 1;
            }
          } else {
            this.ShockwaveFound = 1;
          }
        }
      }
    }
  },
  
  show: function(img, wrl, w, h, movie) {
    if (this.ShockwaveFound) {
      document.write('<OBJECT classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"');
      document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0"');
      document.write('ID=view3 WIDTH='+w+' HEIGHT='+h+' name="view3">');
      document.write("<param name=src value=\"http://make3d.stanford.edu/shock/view3.dcr\"> ");
      document.write("<param name=sw8 value=\"http://make3d.stanford.edu"+img+'">');
      document.write("<param name=sw9 value=\"http://make3d.stanford.edu"+wrl+'">');
      document.write('<param name=swPassword value="12345"> <param name=swStretchStyle value=fill> ');
      document.write('<param name=swRemote value="swSaveEnabled=\'true\' swVolume=\'true\' swRestart=\'true\' swPausePlay=\'true\' ');
      document.write('swFastForward=\'true\' swContextMenu=\'true\' "> <PARAM NAME=bgColor VALUE=#000000>');
      document.write('<EMBED SRC="http://make3d.stanford.edu/shock/view3.dcr?1174987949" ');
      document.write('sw8="http://make3d.stanford.edu/'+img+'" sw9="http://make3d.stanford.edu'+wrl+'" ');
      document.write('swPassword="12345" bgColor=#000000  WIDTH='+w+' HEIGHT='+h+' ');
      document.write('swRemote="swSaveEnabled=\'true\' swVolume=\'true\' swRestart=\'true\' swPausePlay=\'true\' ');
      document.write('swFastForward=\'true\' swContextMenu=\'true\' " swStretchStyle=fill TYPE="application/x-director" ');
      document.write('PLUGINSPAGE="http://www.macromedia.com/shockwave/download/">');
      document.write('</EMBED></OBJECT>');
    } else {
	// flash detection required in the line below.
        if( typeof(movie) != 'undefined' ) {
	 document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
         document.write(" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+w+"' height='"+h+"'>");
         document.write(" <param name='movie' value='http://make3d.stanford.edu"+movie+"'>");
         document.write(" <param name='quality' value='high'> <param name='bgcolor' value='#FFFFFF'> <param name='loop' value='true'>");
         document.write("<EMBED src='http://make3d.stanford.edu"+movie+"' quality='high' bgcolor='#FFFFFF' width='"+w+"' height='"+h+"' loop='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>");
         document.write("</OBJECT>");
        }
	else {
		document.write('<img src="http://make3d.stanford.edu/'+img+'" width='+w+' height='+h+'>');
	}
    }
  }
}
V3Embed.init();
