// slshow.js
//
// Functions for slideshow presentations.
//   Winfried Beer, 08.08.2002
//

// --- default for picnames array
var slshow_recdim    = 2;
var slshow_picnames  = new Array("dummy1.jpg","dummytext", "exampleimg.jpg","example text");
var slshow_firstpic  = 1;
var slshow_lastpic   = slshow_picnames.length/slshow_recdim;
var slshow_prefix    = "";
var slshow_midfix   = "";
var slshow_postfix   = "";
var slshow_imgwidth  = 640;
var slshow_imgheight = 480;
var slshow_timedelay = 8000;  // 8 sec
var slshow_pause     = 0;     // 0: automatic show; 1: paused
var slshow_slideorder= 0;
var slshow_loadmode  = 0;
var slshow_loopmode  = 0;
var slshow_style     = 0;     // style, eg. 0=mini, 1=medium, 20=seamless, ...

var slshow_picidx = slshow_firstpic;
var slshow_timer = 0;
var slshow_imgcache = new Image();
var slshow_imgpreload = new Image();
var slshow_isdefaultconfig = 1;

var slshow_obj_controlform;
var slshow_obj_picimg;
var slshow_obj_picidx;
var slshow_obj_infosel;
var slshow_obj_pause;
var slshow_obj_slideorder;
var slshow_obj_loadmode;
var slshow_obj_timedelay;

var slshow_rndarr    = new Array(0,1);
var slshow_invrndarr = new Array(0,1);

// --------------------------------------------------------------------
function slshow_init(prefix,midfix,postfix, picarr,recdim, firstpic,lastpic, imgwidth,imgheight) {
  var i,tmparr;
  slshow_recdim    = recdim;
  slshow_picnames  = picarr;
  slshow_firstpic  = firstpic;
  slshow_lastpic   = lastpic;
  slshow_prefix    = prefix;
  slshow_midfix    = midfix;
  slshow_postfix   = postfix;
  slshow_imgwidth  = imgwidth;
  slshow_imgheight = imgheight;

  // -- create random array (for random slide show order)
  slshow_rndarr = slshow_randomarray(slshow_lastpic-slshow_firstpic-1);
  // set first and last element of rndarr to 0 resp. slshow_lastpic-slshow_firstpic
  for (i=0;i<slshow_rndarr.length;i++) {
    slshow_rndarr[i]++;
  }
  tmparr=new Array(1);
  slshow_rndarr=tmparr.concat(slshow_rndarr);
  slshow_rndarr=slshow_rndarr.concat(tmparr);
  slshow_rndarr[0]=0;
  slshow_rndarr[slshow_lastpic-slshow_firstpic]=slshow_lastpic-slshow_firstpic;

  // -- create key index of random array
  slshow_invrndarr = new Array(slshow_rndarr.length);
  for (i=0;i<slshow_invrndarr.length;i++) {
    slshow_invrndarr[slshow_rndarr[i]]=i;
  }
  slshow_refresh();
}

// --------------------------------------------------------------------
function slshow_settimedelay(timedelay) {
  if (timedelay!=slshow_timedelay) {
    slshow_timedelay = timedelay; // miliseconds between automatic slideshow
    slshow_refresh();
  }
}
// --------------------------------------------------------------------
function slshow_gettimedelay() {
  return slshow_timedelay;
}

// --------------------------------------------------------------------
function slshow_setpause(pause) {
  if (pause!=slshow_pause) {
    slshow_pause=pause;
    slshow_refresh();
  }
}
// --------------------------------------------------------------------
function slshow_getpause() {
  return slshow_pause;
}

// --------------------------------------------------------------------
function slshow_setslideorder(slideorder) {
  slshow_slideorder = slideorder;  // 0: sequential, 1: random
  slshow_saveconfig();
}
// --------------------------------------------------------------------
function slshow_getslideorder() {
  return slshow_slideorder;
}

// --------------------------------------------------------------------
function slshow_setloadmode(loadmode) {
  slshow_loadmode  = loadmode;    // 0: simple, 1: hidden load, 2: preload
  slshow_saveconfig();
}
// --------------------------------------------------------------------
function slshow_getloadmode() {
  return slshow_loadmode;
}

// --------------------------------------------------------------------
function slshow_setloopmode(loopmode) {
  slshow_loopmode  = loopmode;    // 0: once, 1: loop
  slshow_saveconfig();
}
// --------------------------------------------------------------------
function slshow_getloopmode() {
  return slshow_loopmode;
}

// --------------------------------------------------------------------
function slshow_getimgwidth() {
  return slshow_imgwidth;
}
// --------------------------------------------------------------------
function slshow_getimgheight() {
  return slshow_imgheight;
}

// --------------------------------------------------------------------
function slshow_getfirstpicidx() {
  return slshow_firstpic;
}
// --------------------------------------------------------------------
function slshow_getlastpicidx() {
  return slshow_lastpic;
}

// --------------------------------------------------------------------
function slshow_getpicidx() {
  return slshow_picidx;
}
// --------------------------------------------------------------------
function slshow_setpicidx(idx) {
  if (isNaN(idx)) {
    idx=slshow_firstpic;
  }
  if (idx > slshow_lastpic ) {
    idx = slshow_lastpic;
  }else if (idx < slshow_firstpic) {
    idx = slshow_firstpic;
  }
  if (slshow_picidx!=idx) {
    slshow_picidx=idx;
    slshow_refresh();
  }
}

// --------------------------------------------------------------------
function slshow_getimgurl(idx) {
  var str,k;
  str=picnames[idx*slshow_recdim];
  if (slshow_midfix!="") {
    k=str.lastIndexOf("/");
    if (k>=0) {
      str=str.substr(0,k+1)+slshow_midfix+str.substr(k+1,str.length-k-1);
    }
  }
  str=slshow_prefix+str+slshow_postfix;
  return str;
}

// --------------------------------------------------------------------
function slshow_getconfigstring() {
  var str="";
  str=str+"&idx="+slshow_picidx;
  str=str+"&order="+slshow_slideorder;
  str=str+"&load="+slshow_loadmode;
  str=str+"&delay="+slshow_timedelay;
  str=str+"&pause="+slshow_pause;
  str=str+"&loop="+slshow_loopmode;
  return str;
}

// --------------------------------------------------------------------
function slshow_setconfigstring(str) {
  var vars,def,i;
  vars=str.split("&");
  for (i=0;i<vars.length;i++) {
    def=vars[i].split("=",2);
    switch (def[0]) {
    case "idx": slshow_picidx=parseInt(def[1]); break;
    case "order": slshow_order=parseInt(def[1]); break;
    case "load": slshow_loadmode=parseInt(def[1]); break;
    case "delay": slshow_timedelay=parseInt(def[1]); break;
    case "pause": slshow_pause=parseInt(def[1]); break;
    case "loop": slshow_loopmode=parseInt(def[1]); break;
    }
  }
}


// --------------------------------------------------------------------
function slshow_saveconfig() {
  // save current config in html form element
  if (slshow_obj_picidx) {
    slshow_obj_picidx.value=""+slshow_picidx+"      "+slshow_getconfigstring();
  }
}

// --------------------------------------------------------------------
function slshow_loadconfig() {
  if (slshow_obj_picidx) {
    str=slshow_obj_picidx.value;
    slshow_setconfigstring(str);
  }
}

// --------------------------------------------------------------------
// Do some configuration after loading (or risizing) document.
// Special actions to preserve former config (in form elements) are done.
// Include this in your body header: eg.
//  <body onload="slshow_onload()" onresize="slshow_onload()">
// --------------------------------------------------------------------
function slshow_onload() {
  var str,i,k,t;  

  // --- define objects for form elemens and image object
  //     (works only after full document load)

  if (slshow_style<20) {  // 0-9=mini, 10-19=midi
    slshow_obj_controlform = document.forms["controlform"];
    slshow_obj_picimg      = document.images["picimg"];
  }else if (slshow_style<30) {  // seamless
    if (document.all) {
      slshow_obj_controlform = document.all.forms["controlform"];
      slshow_obj_picimg      = document.all.images["picimg"];
    } else if (document.layers) {   
      slshow_obj_controlform = document.layers["Buttons"].document.forms["controlform"];
      if (document.layers["Picture"]) {
        //slshow_obj_picimg      = document.layers["Picture"].document.layers[0].document.images["picimg"];
        slshow_obj_picimg      = document.layers["Picture"].document.images["picimg"];
        //slshow_obj_picimg      = document.images["picimg"];
      }
    }
  }
  slshow_obj_picidx      = slshow_obj_controlform.elements["picidx"];
  slshow_obj_infosel     = slshow_obj_controlform.elements["infosel"];
  slshow_obj_config      = slshow_obj_controlform.elements["config"];
  slshow_obj_pause       = slshow_obj_controlform.elements["pause"];
  slshow_obj_slideorder  = slshow_obj_controlform.elements["slideorder"];
  slshow_obj_loadmode    = slshow_obj_controlform.elements["loadmode"];
  slshow_obj_timedelay   = slshow_obj_controlform.elements["timedelay"];

  // --- set some saved current values from form elements again
  // Very nice after "reload", "resize" or revisiting this page
  // -> restore of configuration, because values of form elements
  // are not destroyed.

  // read saved config string and write them to variables
  slshow_loadconfig();
 
  // --- now we got our configuration into variables, 
  //     change elements if needed

  slshow_refresh();
}

// --------------------------------------------------------------------
// refresh form elements and picture
// --------------------------------------------------------------------
function slshow_refresh() {
  var img,str,i,k,t;

  // -- always stop timer
  if (slshow_timer) {
    slshow_timer=window.clearTimeout(slshow_timer);
  }

  // -- save config
  slshow_saveconfig();

  // -- refresh form element "pause"
  if (slshow_obj_pause) {
    if (slshow_pause==0) {
      str=" [ ] ";
    }else{
      str=" ] [ ";
    }
    if (slshow_obj_pause.value!=str) {
      slshow_obj_pause.value=str;
    }
  }

  // -- refresh form element "slideorder"
  if (slshow_obj_slideorder) {
    k=slshow_getslideorder();
    if (k!=slshow_obj_slideorder.selectedIndex) {
      slshow_obj_slideorder.selectedIndex=k;
    }
  }

  // -- refresh form element "loadmode"
  if (slshow_obj_loadmode) {
    k=slshow_getloadmode();
    if (k!=slshow_obj_loadmode.selectedIndex) {
      slshow_obj_loadmode.selectedIndex=k;
    }
  }

  // -- refresh form element "timedelay"
  if (slshow_obj_timedelay) {
    k=slshow_obj_timedelay.selectedIndex;
    t=slshow_gettimedelay();
    if (t!=slshow_obj_timedelay.options[k].value) {
      k=slshow_obj_timedelay.length;
      for (i=0;i<slshow_obj_timedelay.length;i++) {
        if (slshow_obj_timedelay.options[i].value==t) {
          k=i;
          break;
        }
      }
      if (k==slshow_obj_timedelay.length) { // no timedelay value found, append new list option
        slshow_obj_timedelay.options[k]=new Option((t/1000)+" sec");
        slshow_obj_timedelay.options[k].value=t;
      }
      slshow_obj_timedelay.selectedIndex=k;
      //slshow_settimedelay(slshow_obj_timedelay.options[k].value);
    }
  }

  // -- start refreshing/loading picture 
  if (slshow_obj_picimg) {
    img=slshow_getimgurl(slshow_picidx);
    if (slshow_loadmode>0) { // wait for complete load before display (using event handle "onload")
      if (slshow_obj_infosel) {  // show info text
        slshow_obj_infosel.options[0].text="loading image "+slshow_picidx+" ...";
        slshow_obj_infosel.options[1].text="";
      }
      slshow_imgcache.onload=slshow_imgloaded;  // continue after complete image loading
      slshow_imgcache.onerror=slshow_imgloaded;  // no image found -> continue too! (automatic slide show)
      slshow_imgcache.src=img;
    }else{
      slshow_imgloaded(); // continue imediately
    }
  }else{ // no picimg -> continue too (update text fields)
    slshow_imgloaded();
  }
}

// --------------------------------------------------------------------
function slshow_imgloaded() {
  var img,text1,text2,idx;

  // -- continue refreshing/loading picture
  img=slshow_getimgurl(slshow_picidx);
  info=picnames[slshow_picidx*slshow_recdim+1];
  if (slshow_recdim==1) {
    text1="";
    text2="";
  } else if (slshow_recdim==2) { 
    text1=picnames[slshow_picidx*slshow_recdim+1];
    text2="";
  }else{
    text1=picnames[slshow_picidx*slshow_recdim+1];
    text2=picnames[slshow_picidx*slshow_recdim+2];
  }

  // -- refresh form element "picidx"
  if (slshow_obj_picidx) {
    if ( slshow_obj_picidx.value!=slshow_picidx) {
      slshow_obj_picidx.value=""+slshow_picidx+"      "+slshow_getconfigstring();
    }
    slshow_obj_picidx.focus();
  }

  // -- refresh form element "infosel"
  if (slshow_obj_infosel) { 
    slshow_obj_infosel.selectedIndex=-1;
    slshow_obj_infosel.options[0].text=text1;
    slshow_obj_infosel.options[1].text=text2;
  }

  // -- refresh picture
  if (slshow_obj_picimg) {
    slshow_obj_picimg.src=img;
  }

  if (slshow_loadmode==2) { // preload
    idx=slshow_picidx;
    if (slshow_slideorder==1) { // random
      idx=slshow_invrndarr[idx-slshow_firstpic]+slshow_firstpic;
    }
    idx++;
    if (idx > slshow_lastpic ) {
      idx = slshow_lastpic;
    }else if (slshow_picidx < slshow_firstpic) {
      idx = slshow_firstpic;
    } 
    if (slshow_slideorder==1) { // random
      idx=slshow_rndarr[idx-slshow_firstpic]+slshow_firstpic;
    }
    slshow_imgpreload.src=slshow_getimgurl(idx);
  }

  if (slshow_pause==0 && !slshow_timer) { // automatic
    slshow_timer=window.setTimeout("slshow_action('right')", slshow_timedelay);
  }
}

// --------------------------------------------------------------------
// Do some actions (e.g "right" to show next picture). If no choice
// is given, configuration from form elements are read.
// --------------------------------------------------------------------
function slshow_action(choice) {
  var k;

  if (!choice) { 
    // --- no action "choice" specified, read all form elements and write config
    //     to variables

    // -- read form element "picidx"
    if (slshow_obj_picidx) {
      slshow_setpicidx(parseInt(slshow_obj_picidx.value));
    }
 
    // -- read form element "slideorder"
    if (slshow_obj_slideorder) {
      k=slshow_obj_slideorder.selectedIndex;
      slshow_setslideorder(k);
    }
		 
    // -- read form element "loadmode"
    if (slshow_obj_loadmode) {
      k=slshow_obj_loadmode.selectedIndex;
      slshow_setloadmode(k);
    }
		 
    // -- read form element "timedelay"
    if (slshow_obj_timedelay) {
      k=slshow_obj_timedelay.selectedIndex;
      slshow_settimedelay(slshow_obj_timedelay.options[k].value);
    }
		 
    return;
  } 

  if (choice=="pause") {
    slshow_setpause(1-slshow_pause);
    return;
  }

  // --- now do all actions to show new picture (left, right, first, etc)
  if (slshow_slideorder==1) { // random
    slshow_picidx=slshow_invrndarr[slshow_picidx-slshow_firstpic]+slshow_firstpic;
  }

  if (choice=="left") {
    slshow_picidx=slshow_picidx-1;
  } else if (choice=="fastleft") {
    slshow_picidx=slshow_picidx-10;
  } else if (choice=="pause") {
    slshow_setpause(1-slshow_pause);
  } else if (choice=="right") {
    slshow_picidx=slshow_picidx+1;
  } else if (choice=="fastright") {
    slshow_picidx=slshow_picidx+10;
  } else if (choice=="first") {
    slshow_picidx=slshow_firstpic;
  } else if (choice=="last") {
    slshow_picidx=slshow_lastpic;
  }

  if (slshow_loopmode==1) {  // loop
    if (slshow_picidx > slshow_lastpic ) {
      slshow_picidx -= (slshow_lastpic-slshow_firstpic+1);
    }else if (slshow_picidx < slshow_firstpic) {
      slshow_picidx += (slshow_lastpic-slshow_firstpic+1);
    }
  }

  if (slshow_picidx > slshow_lastpic ) {
    slshow_picidx = slshow_lastpic;
  }else if (slshow_picidx < slshow_firstpic) {
    slshow_picidx = slshow_firstpic;
  }

  if (slshow_slideorder==1) { // random
    slshow_picidx=slshow_rndarr[slshow_picidx-slshow_firstpic]+slshow_firstpic;
  }

  slshow_refresh();
}

// --------------------------------------------------------------------
// return array with unique random numbers
// --------------------------------------------------------------------
function slshow_randomarray (num) {
  var arr=new Array(num);
  var i,h,rnd,range;

  for (i=0;i<num;i++) {
    arr[i]=i;
  }
  for (i=0;i<num-1;i++) {
    range=num-i;
    rnd=Math.floor(Math.random()*range);  
    if (rnd>=range) {rnd=range-1};   // rnd=[0,..,range-1]
    h=arr[i+rnd];
    arr[i+rnd]=arr[i];
    arr[i]=h;
  }
  return arr;
}

// --------------------------------------------------------------------
function slshow_write_slideshowtable(style,transimg) {
  var str;
  str=slshow_make_slideshowtable(style,transimg);
  document.writeln(str);
}

// --------------------------------------------------------------------
// Use document.write to create all images and forms for the slide show.

// transimg: url to transparent image (dummy image, loaded first)
// --------------------------------------------------------------------
function slshow_make_slideshowtable(style,transimg) {
  var majorstyle,minorstyle,align,str;
  var NL=String.fromCharCode(13);
  slshow_style = style;
 
  majorstyle=Math.floor(style/10);
  minorstyle=style%10;

  switch (minorstyle) {
    case 1: align="align=left"; break;
    case 2: align="align=right"; break;
    case 3: align="align=center"; break;
    default: align=""; break;
  }

  str="";
  if (majorstyle==0) { // mini 
    str=str + "<form name=\"controlform\" onsubmit=\"slshow_action();return false;\">";
    str=str + "<table "+align+" border=0 cellspacing=4 cellpadding=0>";
    str=str + "<tr><td>";
    str=str + slshow_make_picimg(transimg);
    str=str + "</td></tr>";
    str=str + "<tr><td bgcolor=\"#cccccc\" align=center>";
    str=str + slshow_make_navpanel();
    str=str + "</td></tr></table>";
    str=str + "</form>";

  } else if (majorstyle==1) { // medium
    str=str + "<form name=\"controlform\" onsubmit=\"slshow_action();return false;\">";
    str=str + "<table "+align+" border=0 cellspacing=0 cellpadding=0>";
    str=str + "<tr><td colspan=2 align=center>";
    str=str + slshow_make_picimg(transimg);
    str=str + "</td></tr>";
    str=str + "<tr><td align=center bgcolor=\"#cccccc\">";
    str=str + slshow_make_picidx();
    str=str + "</td><td align=center bgcolor=\"#cccccc\">";
    str=str + slshow_make_infosel();
    str=str + "</td></tr><tr><td colspan=2 bgcolor=\"#cccccc\" align=center>";
    str=str + slshow_make_navpanel();
    str=str + "&nbsp;&nbsp;";
    str=str + "<nobr>mode: ";
    str=str + slshow_make_slideorder();
    str=str + slshow_make_loadmode();
    str=str + slshow_make_timedelay();
    str=str + "</nobr>";
    str=str + "</td></tr></table>";
    str=str + "</form>";
 
  } else if (majorstyle==2) { // seamless, full size
    str="";
    // create dummy "div", because first div area has no correct position
    str=str + "<div id=\"dummyle\" style=\"position:absolute;left:100px;top:5px;width:1000px;font-size:18pt;z-index:10\"></div>";
    str=str + NL;
    str=str + "<div id=\"Picture\" style=\"position:absolute;left:0px;top:0px;padding:0px;visibility:visible;z-index:1\">";
    str=str + NL;
    //str=str + "<layer id=\"Picturelayer\" width=\""+slshow_getimgwidth()+"\" height=\""+slshow_getimgheight()+"\">";
    //str=str + NL;
    str=str + "<img name=\"picimg\" src=\""+transimg+"\" width=\""+slshow_getimgwidth()+"\" height=\""+slshow_getimgheight()+"\">";
    str=str + NL;
    //str=str + "</layer>"; 
    //str=str + NL;
    str=str + "</div>";
    str=str + NL;
    str=str + "<div id=\"Buttons\" style=\"position:absolute;left:10px;top:5px;width:1000px;font-size:18pt;z-index:10\">";
    str=str + NL;
    str=str + "<form name=\"controlform\" onsubmit=\"slshow_action();return false;\">";
    str=str + NL;
    str=str + "<table border=0 cellspacing=0 cellpadding=0>";
    str=str + "<tr><td align=center>";
    str=str + slshow_make_picidx();
    str=str + "</td><td align=center>";
    str=str + slshow_make_infosel();
    str=str + "</td></tr><tr><td colspan=2 align=center>";
    str=str + slshow_make_navpanel();
    str=str + "&nbsp;&nbsp;";
    str=str + "<nobr>mode: ";
    str=str + slshow_make_slideorder();
    str=str + slshow_make_loadmode(document);
    str=str + slshow_make_timedelay(document);
    str=str + "<input type=button name=\"close\" value=\"CLOSE\" onClick=\"self.close()\">";
    str=str + "</nobr>";
    str=str + "</td></tr></table>";
    str=str + "</form>";
    str=str + NL;
    str=str + "</div>"; 
    str=str + NL;
  }
 return str;
}

// --------------------------------------------------------------------
function slshow_set_style(style) {
  slshow_style = style;
}

// --------------------------------------------------------------------
function slshow_make_picimg(transimg) {
  var str="";
  str=str + "<img name=\"picimg\" src=\""+transimg+"\" width=\""+slshow_getimgwidth()+"\" height=\""+slshow_getimgheight()+"\">";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_picidx() {
  var str="";
  str=str + "<nobr>";
  str=str + "Nr <tt><input type=text name=\"picidx\" size=4 maxlength=200 onChange=\"slshow_action()\"></tt>";
  str=str + "of "+slshow_getlastpicidx();
  str=str + "</nobr>";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_infosel() {
  var str="";
  str=str + "<small><tt>";
  str=str + "<select name=\"infosel\" size=2>";
  str=str + "<option>";
  str=str + "<option>";
  str=str + "<option> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  str=str + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  str=str + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  str=str + "</select>";
  str=str + "</small></tt>";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_navpanel() {
  var str="";
  str=str + "<nobr>";
  str=str + "<input type=button name=\"first\" value=\"FIRST\" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"fastleft\" value=\" -10 \" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"left\" value=\" &lt; \" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"pause\" value=\" [ ] \" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"right\" value=\" &gt; \" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"fastright\" value=\" +10 \" onClick=\"slshow_action(this.name)\"> ";
  str=str + "<input type=button name=\"last\" value=\"LAST\" onClick=\"slshow_action(this.name)\"> ";
  str=str + "</nobr>";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_slideorder() {
  var str="";
  str=str + "<select name=\"slideorder\" size=1 onChange=\"slshow_action()\">";
  str=str + "<option> sequential";
  str=str + "<option> random";
  str=str + "</select>";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_loadmode() {
  var str="";
  str=str + "<select name=\"loadmode\" size=1 onChange=\"slshow_action()\">";
  str=str + "<option> normal load";
  str=str + "<option> hidden load";
  str=str + "<option> pre load";
  str=str + "</select>";
  return str;
}

// --------------------------------------------------------------------
function slshow_make_timedelay() {
  var str="";
  str=str + "<select name=\"timedelay\" size=1 onChange=\"slshow_action()\">";
  str=str + "<option value=\" 2000\"> 2 sec";
  str=str + "<option value=\" 5000\"> 5 sec";
  str=str + "<option value=\" 8000\"> 8 sec";
  str=str + "<option value=\"10000\">10 sec";
  str=str + "<option value=\"20000\">20 sec";
  str=str + "</select>";
  return str;
}


// --------------------------------------------------------------------
// open seamless window
// --------------------------------------------------------------------
function slshow_open_seamless(url,name) {
  var win;
  var width=screen.width;
  var height=screen.height;

  // Zeichnenprivileg anfordern
  if (!/MSIE/.test(navigator.userAgent)) {
    if (navigator.javaEnabled())  {
      if (netscape.security.PrivilegeManager.enablePrivilege ) {
        netscape.security.PrivilegeManager.enablePrivilege('CanvasAccess');
      }
    }
  }

  if (/Linux/.test(navigator.userAgent)) { // Linux-Fenstersystem
    win=window.open(url,name,"width="+width+",height="+height+",left=-4,top=-22");
    win=window.open(url,name,"width="+width+",height="+height+",left=-4,top=-22");
      // Bug? Zweimal oeffnen, sonst erscheint das Fenster nicht immer. Haengt an den "unerlaubten"
      // Werten für den Ursprungpunkt des Fensters, welche aber mit dem CanvasAccess-Privileg
      // beliebig gesetzt werden können.
  }else if (/Win/.test(navigator.userAgent)) { // Windows-Fenstersystem
    //alwaysLowered=yes,titlebar=no,scrollbars=yes fullscreen=yes (IE)
    win=window.open(url,name,"width="+width+",height="+height+",left=0,top=0,titlebar=no,fullscreen=yes,scrollbars=yes");
  }else { // unbekanntes Fenstersystem
    win=window.open(url,name,"width="+width+",height="+height+",left=0,top=0,titlebar=no");
  }

  if (win.focus) {win.focus();};
  return win;
}


