var mywin = false;

function showImage(href,w,h)
{
 // NN: w+20, h+30 is enough; IE needs w+40, h+50
 var f="width="+(w+20)+",height="+(h+30)+",status=no,scrollbars=no,resizable=yes";
 if( mywin ) { mywin.close(); }
 mywin = window.open(href,"fsi",f);
}

function swtch(img,other) {
 document.images[img].src = other;
}

function mailto(name,domain) {
 window.location = "mailto:"+name+'@'+domain;
}

function getContext() {
  var s = location.search;
  var c = false;
  if( s ) {
    // cut "?", ...
    s = s.substr(1).split( "&" );
    for( var i in s ) {
      var v = s[i].split( "=" );
      if( v[0] == "c" ) {
	c = v[1];
	break;
      }
    }
  }
  return parseInt(c) || 0;
}


function nextImage( d )
{
  var n=i+d;
  var len = images.length / 3;
  if( n< 0 ) { n = len-2; }
  if( n >= len-1 ) { n = 0; }
  return n;
}

function testTimeout(a,b) {
    alert( "a : " +a +
	   "\nb: " +b );
}

function switchFoto( d )
{
  var n = nextImage(d);
  // alert( i + " -> " + n + "\nnew img: " + path + images[n*3] );
  i=n;
  n=i*3;
  var w=images[n+1];
  var h=images[n+2];
  swtch( "main", voidImg );
  // window.setTimeout( 'swtch("main","'+path+images[n]+'")', 1000 );
  swtch( "main", path + images[n] );
  window.resizeTo(w+30,h+100);
  document.images["main"].width = w;
  document.images["main"].height = h;
  document.getElementById("title").firstChild.data
      = "Foto "+(nextImage(0)+1)+" ("+images[n]+")";
  // document.images["left"].alt = "Foto "+(nextImage(-1)+1)+" ("+images[-1]+")";
  // document.images["right"].alt = "Foto "+(nextImage(+1)+1)+" ("+images[+1]+")";
}
