
appletString = new Array(8);
appletString[1]="<h>Introduction</h>The entrance page of AcuteApplets.";
appletString[2]="<h>Examples</h>Use the examples to get inspiration. Copy code and the graphics to your implementation.";
appletString[3]="<h>Tutorials</h>The tutorals will be the main resource for you when learning to use AcuteApplets.";
appletString[4]="<h>Documentation</h>Detailed information about AcuteApplets in different topics.";
appletString[5]="<h>Download</h>Get all the files and graphics you might need from the download section.";
appletString[6]="<h>Register</h>When you want to use the applet on your own site, you have to register.";
appletString[7]="<h>Contact Info</h>Contact us if you need support or you have anything else on your mind.";

// Function used to hide any JavaScript errors from the user.
function stopError() {
  return true;
}

isInited = false;
function init() { 

  // Make the browser ignore any errors.
  window.onerror = stopError;

  if(document.images) { 
    // Preload images.
    menuNormalPic = new Image()
    menuNormalPic.src = "buttons/bar_short.gif";
    menuOverPic = new Image()
    menuOverPic.src = "buttons/bar_long.gif";
  }

  isInited = true;
}

function changeImage(imgName, imgObj) { 
  if(document.images && isInited == true) { 
    if(menuNormalPic.complete && menuOverPic.complete) {
      document.images[imgName].src = eval(imgObj+".src"); 
    }
  }
} 

function menuOver(isActive, nr) { 
  // Change the bullet image if the menuitem is active.
  if(isActive == true) {
    eval("changeImage('menuCircle"+nr+"Img', 'menuOverPic');");
  }

  // Call the applet.
  // We can not know if the applet is loaded, but we are ignoring those
  // errors anyway. 
  if(document.scroller && isInited == true) {
    document.scroller.loadTemp(appletString[nr], "", 500);
  }
}

function menuOut(isActive, nr) { 
  // Change the bullet image if the menuitem is active.
  if(isActive == true) {
    eval("changeImage('menuCircle"+nr+"Img', 'menuNormalPic');");
  }

  // Call the applet.
  // We can not know if the applet is loaded, but we are ignoring those
  // errors anyway. 
  if(document.scroller && isInited == true) {
    document.scroller.unloadTemp(4000);
  }
}

function loadMsg(text, delay) {

  if(document.scroller && isInited == true) {
    document.scroller.loadTemp(text, "", delay);
  }

}

function unloadMsg(delay) {

  if(document.scroller && isInited == true) {
    document.scroller.unloadTemp(delay);
  }

}



function labPanelUpdate() {
  var message = "";
  var style = "";
  if(document.labPanelForm.message) {
    message = document.labPanelForm.message.value;
  }
  if(document.labPanelForm.style) {
    style = document.labPanelForm.style.value;
  }
  if(document.applets[1]) {
    document.applets[1].loadMain(message, style);
  }
}


function labPanelReset() {

  if(document.labPanelForm.style) {
    document.labPanelForm.style.value = labPanelStyle;
  }
  if(document.labPanelForm.message) {
    document.labPanelForm.message.value = labPanelMessage;
  }
  if(document.applets[1]) {
    document.applets[1].loadMain(labPanelMessage, labPanelStyle);
  }
}


function labPanelWrite(messageR, styleR, appletW, appletH) {

  var htmlStart = 
    "<TABLE BORDER=0 width=100% cellspacing=0 bgcolor=#aaaaaa cellpadding=1>\n" +
      "<TR><TD>\n" + 
        "<TABLE BORDER=0 width=100% cellspacing=0 bgcolor=#f8f8f8 cellpadding=10>\n" +
          "<TR><TD>\n" + 
            "<div align=center>\n" +
              "<TABLE BORDER=0 cellspacing=0 bgcolor=#dddddd cellpadding=1>\n" +
                "<TR><TD><APPLET code=\"AcuteScroller.class\" archive=\"AcuteScroller.jar\" codebase=\"/\" name=\"labPanelApplet\" width=\"" + appletW + "\" height=\"" + appletH + "\">\n" +
                  "<PARAM name=\"Message\" value=\"" + labPanelMessage + "\">\n" +
                  "<PARAM name=\"Style\" value=\"" + labPanelStyle + "\">\n" +
                  "<PARAM name=\"Domain-Keys\" value=\"16273, 13988\">\n" +
                  "</APPLET></TD></TR>\n" +
                "</TABLE>\n" +
              "</div>\n" +
            "</TD></TR>\n" +
            "<TR><TD>\n" + 
              "<FORM method=\"post\" action=\"http://www.acuteapplets.com/cgi/viewsource/viewsource.cgi\" name=\"labPanelForm\">\n" +
                "<DIV align=\"center\">\n";

  var htmlStyle = "<B>Applet Style Input:</B><BR><TEXTAREA name=\"style\" cols=\"35\" rows=\"" + styleR + "\" wrap=\"VIRTUAL\">" + labPanelStyle + "</TEXTAREA><br>&nbsp;<br>&nbsp;\n";
  var htmlMessage = "<B>Applet Message Input:</B><BR><TEXTAREA name=\"message\" cols=\"35\" rows=\"" + messageR + "\" wrap=\"VIRTUAL\">" + labPanelMessage + "</TEXTAREA><br>&nbsp;\n";

  var htmlEnd =   "<INPUT type=\"button\" value=\"Send to Applet\" onClick=\"labPanelUpdate()\"> \n" +
                  "<INPUT type=\"button\" value=\"Reset\" onClick=\"labPanelReset()\"> <br>\n" +
                  "<INPUT type=\"submit\" value=\"View HTML Source\" onClick=\"document.labPanelForm.target='SourceWindow'\">\n" +
                  "<INPUT name=\"applet_width\" type=\"hidden\" value=\"" + appletW + "\">\n" +
                  "<INPUT name=\"applet_height\" type=\"hidden\" value=\"" + appletH + "\">\n" +
                "</FORM>\n" +
              "</DIV>\n" +
//              "<p align=right><A HREF=\"TutLabPanel.shtml\">(About this Lab Panel)</A></P>\n" +
            "</TD></TR>\n" +
          "</TABLE>\n" +
        "</TD></TR>\n" +
      "</TABLE>";

  document.write(htmlStart);

  if(labPanelStyle != "") {
    document.write(htmlStyle);
  }

  if(labPanelMessage != "") {
    document.write(htmlMessage);
  }
  document.write(htmlEnd);

}



