var newWindow;
var pict     = new Array();
var format   = new Array();
var folder   = "gfx/foto-page/";
var th_folder= "gfx/foto-page/thumb/";
var i        = 0;
var objTd;
var width;
var height;

function maak_lijst()
{
  vul_lijst( 'h105 tegenhandstand', '4x3' );
  vul_lijst( 'h121 tegenstaan voeten', '3x4' );
  vul_lijst( 'h137 staan op hoofd', '3x4' );
  vul_lijst( 'h143 zit op hoofd', '3x4' );
  vul_lijst( 'h144 handstand overtrek', '3x4' );
  vul_lijst( 'h149 plat af', '3x4' );
  vul_lijst( 'newline', '' );

  vul_lijst( 'h152 handstand uitgezet', '3x4' );
  vul_lijst( 'h162 tussendoor af', '3x4' );
  vul_lijst( 'p284 snoek voeten', '3x4' );
  vul_lijst( 'p295 handstand', '4x3' );
  vul_lijst( 'p311 rug aan rug', '4x3' );
  vul_lijst( 'p321 zit op hoofd', '3x4' );
  vul_lijst( 'newline', '' );

  vul_lijst( 'p354 mo', '3x4' );
  vul_lijst( 'p493 van onderen', '4x3' );
  vul_lijst( 'p596 in publiek', '4x3' );
  vul_lijst( 'p600 naar tegenplank', '4x3' );
  vul_lijst( 'p619 naar staan op voeten', '4x3' );
}

function toon_index()
{
  var str = "";

  str +=
    "<img src=\"gfx/butler.gif\" alt=\"2 Acrobats\" width=135 height=180 border=0>" +
    "";

  document.getElementById( "thumb" ).innerHTML = str;

  var str = "";
  str += begin_table();

  for( idx = 0; idx < pict.length; idx++)
  {
    if ( pict[idx] == "newline" )
    {
      str += end_table();
      str += begin_table();
      continue;
    }

    zet_formaat( "thumb", format[idx] );

    str += 
/*    "<td background=back_" + format[idx] + ".gif>" + */
      "<td height=120>" +
      "<a href=\"javascript:toon_foto('" + idx + "');\" onMouseOver=\"self.status='';return true\">" +
      "<img src=\"" + th_folder + pict[idx] + ".jpg\" alt=\"toon " + pict[idx] + "\"" +
      " width=" + width + " height=" + height + " border=0></a>" +
      "</td>" +
      "";
  }

  str += end_table();

  document.getElementById( "album" ).innerHTML = str;
}

function toon_foto( nr )
{
  var prev;
  var next;
  var str = "";

  str += begin_table();

  prev = nr - 1;
  if ( prev < 0 )
  {
    prev = pict.length - 1;
  }
  if ( pict[prev] == "newline" )
  {
    prev--;
  }

  zet_formaat( "thumb", format[prev] );

  str += 
    "<td class='text' height=120>" +
    "<a href=\"javascript:toon_foto('" + prev + "');\" onMouseOver=\"self.status='';return true\">" +
    "<img src=\"" + th_folder + pict[prev] + ".jpg\" alt=\"toon " + pict[prev] + "\"" +
    " width=" + width + " height=" + height + " border=0>" +
    "<br>previous" +
    "</a>" +
    "</td>" +
    end_table() +
    "";

  str += begin_table();
  str += 
    "<td class='text' height=60>" +
    "<a href=\"javascript:toon_index();\" onMouseOver=\"self.status='';return true\">" +
    "index" +
    "</a>" +
    "</td>" +
    end_table() +
    "";

  str += begin_table();
  next = nr - 1 + 2;
  if ( next == pict.length )
  {
    next = 0;
  }
  if ( pict[next] == "newline" )
  {
    next++;
  }

  zet_formaat( "thumb", format[next] );

  str += 
    "<td class='text' height=120>" +
    "<a href=\"javascript:toon_foto('" + next + "');\" onMouseOver=\"self.status='';return true\">" +
    "next<br>" +
    "<img src=\"" + th_folder + pict[next] + ".jpg\" alt=\"toon " + pict[next] + "\"" +
    " width=" + width + " height=" + height + " border=0>" +
    "</a>" +
    "</td>" +
    end_table() +
    "";

  document.getElementById( "thumb" ).innerHTML = str;

  str = begin_table();

  zet_formaat( "groot", format[nr] );

  str += 
      "<td width=500>" +
      "<img src=\"" + folder + pict[nr] + ".jpg\" alt=\"" + pict[nr] + "\"" +
      " width=" + width + " height=" + height + " border=0></a>" +
      "</td>" +
      end_table() +
      "";

  document.getElementById( "album" ).innerHTML = str;
}

function vul_lijst( pct, frmt )
{
  pict[i]	= pct;
  format[i]	= frmt;
  i++;
}

function zet_formaat( type, frmt )
{
  if ( type == "thumb" )
  {
    if ( frmt == "2x3" ) { width  =  "64"; height = "96"; }
    if ( frmt == "3x2" ) { width  =  "96"; height = "64"; }
    if ( frmt == "3x4" ) { width  =  "72"; height = "96"; }
    if ( frmt == "4x3" ) { width  =  "96"; height = "72"; }
  }
  else
  {
    if ( frmt == "2x3" ) { width  = "240"; height = "360"; }
    if ( frmt == "3x2" ) { width  = "480"; height = "320"; }
    if ( frmt == "3x4" ) { width  = "270"; height = "360"; }
    if ( frmt == "4x3" ) { width  = "480"; height = "360"; }
  }
}
 
function begin_table()
{
  return (
    "<table cellspacing=0 cellpadding=5 border=0>" +
    "  <tr valign=middle align=center>"
    );
}

function end_table()
{
  return (
/*  "    <td><img src=../leeg.gif height=120 width=0></td>" + */
    "  </tr>" +
    "</table>"
    );
}

function showphoto( naam, formaat )
{

  parent.foto.location.href = "foto-main.htm?" + naam + ".jpg";

/*
  var cellwidth;
  var cellheight;
  var pictwidth;
  var pictheight;

  if ( formaat == "2x3" )
  { cellwidth  = "330"; cellheight = "490"; pictwidth  = "320"; pictheight = "480"; }
  if ( formaat == "3x2" )
  { cellwidth  = "490"; cellheight = "330"; pictwidth  = "480"; pictheight = "320"; }
  if ( formaat == "3x4" )
  { cellwidth  = "370"; cellheight = "490"; pictwidth  = "360"; pictheight = "480"; }
  if ( formaat == "4x3" )
  { cellwidth  = "490"; cellheight = "370"; pictwidth  = "480"; pictheight = "360"; }

  newWindow = window.open( "", "", "width=520,height=520,resizable,scrollbars,dependent");
  newWindow.focus();

  newWindow.document.open();
  newWindow.document.write(
    "<html>\n" +
    "<head>\n" +
    "  <title>2 Acrobats</title>\n" +
    "  <link rel=\"stylesheet\" href=\"style.css\">\n" +
    "</head>\n" +
    "<body>\n" +
    "\n" +
    "<center>\n" +
    "\n" +
    "<table cellspacing=0 cellpadding=0 border=0>\n" +
    "  <tr valign=top>\n" +
    "    <td width=" + cellwidth + " height=" + cellheight + " background=back_groot_" + formaat + ".gif>\n" +
    "      <img src='" + naam + ".jpg' width=" + pictwidth + " height=" + pictheight + " border=0><br>\n" +
    "    </td>\n" +
    "  </tr>\n" +
    "</table>\n" +
    "\n"
    );

  newWindow.document.write(
    "</center>\n" +
    "</body>\n" +
    "</html>\n"
    );
*/
}

function getObj(cellNm)
{
  var objBr = new checkBrowser();
  var obj;
  if (objBr.ns6)
  {					
    obj = document.getElementById(cellNm);				
  }
  else if (objBr.ns)
  {					
    obj = eval("window.document." + cellNm);
  }
  else
  {
    obj = document.all[cellNm];
  }
	
  return obj;
}

function checkBrowser()
{
  var b = navigator.appName;
  if (b=="Netscape")
  {
    this.b = "ns";
  } 
  else if (b=="Microsoft Internet Explorer")
  { 
    this.b = "ie";
  }
  else
  { 
    this.b = b;
  }

  this.v = parseFloat(navigator.appVersion);

  this.ie4=(navigator.userAgent.indexOf('MSIE 4')>0);
  this.ie5=(navigator.userAgent.indexOf('MSIE 5')>0);
  this.ie55=(navigator.userAgent.indexOf('MSIE 5.5')>0);
  this.ie6=(navigator.userAgent.indexOf('MSIE 6')>0);
  this.ns4=(this.b=="ns" && this.v>=4.08 && this.v<5);
  this.ns6=(this.b=="ns" && this.v>=5);
  this.mac = (navigator.appVersion.indexOf("Macintosh")>0);
  this.win = (navigator.appVersion.indexOf("Win")>0);
  this.ie5mac = (this.ie5) && (this.mac);
  
  // is the users browser compatible with the webapplication?
  this.ie = ((this.ie5 || this.ie55 || this.ie6) || (this.ie4 && !this.mac)) 	
  this.ns = (this.ns4);
  this.compatible=(this.ie || this.ns || this.ns6); 	
  return (this)
}

