
                   /*  -- (c)  Copyright John Page 2007 -- */



/*
This script is used to load the applet(s) into the page that invokes it.

The invoker must provide an array of strings containing the following entries:

var applets=[
	["Isosceles" , "600", "300" , "applet1" , "param", "jarxyz.jar" ]
	];

These are:
applet class name,
applet width in px,
applet height in px,
name of div holding applet,
a parameter (user defined) //optional
optional jar file name     //optional - if present, need a dummy param

*/

var containerDiv, appletName, appletWidth, appletHeight, param, jarName;

var HTML;

for (var i=0; i<applets.length; i++)   //load each applet defined in the array (usually just one)
     { containerDiv =  document.getElementById(applets[i][3]);  //applet container div
       if (!containerDiv)   
         { //alert ("unable to find applet container div "+applets[i][3] );
         }
       else
         { appletName   = applets[i][0];
           appletWidth  = applets[i][1];
           appletHeight = applets[i][2];

           //see if there is a parameter
           param = "";
           if (applets[i].length > 4)
               { param  = applets[i][4];
               }

           //See if there is a jar file
           //see if a params
           jarName = "";
           if (applets[i].length > 5)
             { jarName  = applets[i][5];
             }

           if (navigator.appName=="Microsoft Internet Explorer")             {
               HTML  =  "<OBJECT classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' \n";
               HTML +=    "width='"+appletWidth+"' height='"+appletHeight+"' align='baseline' \n";
               HTML +=    "codebase='http://java.sun.com/products/plugin/1.4/jinstall-14-win32.cab#Version=1,4,0,mn'> \n";
               HTML +=    "<PARAM NAME='code'       VALUE='" +appletName+ ".class'> \n";
               HTML +=    "<PARAM NAME='codebase'   VALUE='classes/'>";
               HTML +=    "<PARAM NAME='type'       VALUE='application/x-java-applet;version=1.4'> \n";
               HTML +=    "<PARAM NAME='scriptable' VALUE='true'> \n";
               HTML +=    "<PARAM NAME='param1'     VALUE='" +param+ "'>";
               HTML +=    "<PARAM NAME='archive'    VALUE='" +jarName+ "'>";
               HTML += " </OBJECT> \n";
             }

           else  //firefox, safari
             { HTML  =       "<EMBED type='application/x-java-applet;version=1.4'  \n";
               HTML +=       "width='"+appletWidth+"' height='"+appletHeight+"' align='baseline' \n";
               HTML +=       "code='" +appletName+ ".class' \n";
               HTML +=       "codebase= 'classes/' \n";
               HTML +=       "param1='"  + param   + "' ";
               HTML +=       "archive='" + jarName + "' ";
               HTML +=       "pluginspage='http://java.sun.com/j2se/1.4/download.html'> \n";
               HTML +=       "</EMBED> \n";
               HTML +=       "<NOEMBED> Java plug-in Version 1.4 or later required. </NOEMBED> \n";
             }
           
           containerDiv.innerHTML = HTML;

         }
     }
