
  <!-- Copyright: Luc Vlaming -->

  var iWidth, iHeight;

  function giveWindowSizes() {
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      iWidth = window.innerWidth;
      iHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      iWidth = document.documentElement.clientWidth;
      iHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      iWidth = document.body.clientWidth;
      iHeight = document.body.clientHeight;
    }
  }

  function resizeWindow() {
    giveWindowSizes();
    var x = iWidth;
    var y = iHeight;
  	if (x < 800) {
  	  x = 800; 
  	}
  	
  	var minRatio = 3/4.35;
  	var maxRatio = 3/6;
  	
    if (x / y > minRatio) {
      y = x * minRatio;
    }

    //resize text
    var scaling=1;
    if ((navigator.platform=="Win32") && (navigator.appName=="Microsoft Internet Explorer")) {
      scaling=1.05;
    }

 		var unit = scaling * y / 460;
 		
 		document.body.style.fontSize = Math.round(unit * 12) + "px";
 		return true;
  }

  function printpage() {
    window.print();  
  }

  
  function switch_textimage(number, max, basedir, commentaar) {
    var item = Math.floor(Math.random() * max);
    eval("document.getElementById('foto_" + number + "').src = '" + basedir + "' + foto_" + number + "[" + item + "];");
    eval("document.getElementById('foto_" + number + "').alt = fotocommentaar_" + number + "[" + item + "];");
	eval("if (document.getElementById('foto_" + number + "_link').onclick != null) { document.getElementById('foto_" + number + "_link').href = '" + basedir + "' + foto_" + number + "[" + item + "]; document.getElementById('foto_" + number + "_link').onclick = function() { photo_show_image('Foto - " + commentaar + "', '" + basedir + "' + foto_" + number + "[" + item + "]); return false; } } ");
    eval("document.getElementById('foto_" + number + "_copyright').innerHTML = fotocopyright_" + number + "[" + item + "];");
  }
  
  function switch_image(image, file, klasse, override_selected) {
    if (document.getElementById(image).className.search(/img_selected/i) == -1 || override_selected) {
      document.getElementById(image).src = file;
      if (typeof klasse != 'undefined') {
        document.getElementById(image).className = klasse;
      }
    }
  }  

  var oldthumb;
  var oldthumbclass;
  var oldbigfile;
  
  var preloader_wait = false;
  
  var last_big_picture;
  
  function switch_big_image(thumb, file, klasse) {
    if (typeof klasse == 'undefined') {
      return;
    }
    
    preloader_wait = true;
    
    document.getElementById('commentaar').innerHTML = 'bezig met laden van foto ...';
    
    if (typeof oldthumb != 'undefined') {
      document.getElementById(oldthumb).className = oldthumbclass;
      if (typeof oldbigfile != 'undefined') {
        document.getElementById(oldthumb).src = oldbigfile + '.thumb_transp'; 
      }
    }
    
    oldthumb = thumb;
    oldbigfile = file;
    oldthumbclass = document.getElementById(thumb).className; 
    
    document.getElementById(thumb).className = oldthumbclass + ' img_selected';
    document.getElementById(thumb).src = file + '.thumb'; 
    
    last_big_picture = file;
    document.getElementById('photo_preload').className = klasse;
    document.getElementById('photo_preload').src = file;
  }
  
  function switch_preload_image() {
    if (typeof last_big_picture != 'undefined' && document.getElementById('photo_preload').src.search(last_big_picture) == -1) {
      return;
    }
    if (document.getElementById('photo_preload').className == 'height' && document.getElementById('photo').className == 'width') {
      document.getElementById('photo').className = document.getElementById('photo_preload').className;
    }
  	document.getElementById('photo').src = document.getElementById('photo_preload').src;
  	document.getElementById('commentaar').innerHTML = comments[oldthumb];
  	document.getElementById('copyright_msg').innerHTML = copyright_msg[oldthumb];
  }

  function photo_resize(object) {
    giveWindowSizes();
    if (object.width * 3 > object.height * 4) {
      object.width = iWidth;
      window.resizeBy(0, -(iHeight - object.height));
    } else {
      object.height = iHeight;
      window.resizeBy(-(iWidth - object.width), 0);
    }
  }
  
  function search_photo_resize(object) {
    giveWindowSizes();
	window.resizeBy((iWidth - object.offsetWidth), -(iHeight - object.offsetHeight));
  }

  function photo_show_image(title, image) {
    photoWindow = window.open('', '', 'width=800,height=600,location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=no,scrollbars=no'); 
    photoWindow.document.write('<html><head><title>Scala-Welzijnswerk - ' + title + '</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta http-equiv="imagetoolbar" content="no" />');
    photoWindow.document.write('<script type="text/javascript" src="/themes/bredeschool-haulerwijk.nl/base/javascript-print-.js"></script><style type="text/css"><!-- img {cursor: hand; margin: 0px; padding: 0px; position: fixed !important; position: absolute; left: 0px; top: 0px; } --></style>');
    photoWindow.document.write('</head><body>');
    photoWindow.document.write('	<img src="' + image + '" onclick="window.close()" onload="photo_resize(this);" alt="sluit venster" />');
    photoWindow.document.write('</body></html>');
	photoWindow.document.close();
  }
  
  function search_foto_show_big(filename, name, commentaar, copyright, filename_link) {
    photoWindow = window.open('', '', 'width=800,height=600,location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=no,scrollbars=yes'); 
    photoWindow.document.write('<html><head><title>Scala-Welzijnswerk - ' + filename + '</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta http-equiv="imagetoolbar" content="no" />');
    photoWindow.document.write('<script type="text/javascript" src="/themes/bredeschool-haulerwijk.nl/base/javascript-print-.js"></script><style type="text/css"><!-- #fotoinfo { width: auto; height: auto; }; img {cursor: hand; margin: 0px; padding: 0px; } --></style>');
    photoWindow.document.write('</head><body onload="search_photo_resize(document.getElementById(\'fotoinfo\'));">');
	photoWindow.document.write('<div id="fotoinfo"><input class="small button black" type="button" value="Fotolink op klembord" onclick="window.clipboardData.setData(\'Text\',\'' + filename_link + ', 6, fotocommentaar\'); return false;" />');
	photoWindow.document.write('<p class="small black">Naam: ' + name + '<br />');
  	photoWindow.document.write('Commentaar: ' + commentaar + '<br />');
  	photoWindow.document.write('Copyright: ' + copyright + '<br />');
  	photoWindow.document.write('Bestandsnaam: ' + filename_link + '</p>');
    photoWindow.document.write('<img src="' + filename + '" onclick="window.close()" alt="sluit venster" /></div>');
    photoWindow.document.write('</body></html>');
	photoWindow.document.close();
  }
  
  var do_slideshow = false;
  var slideshow_counter = 100;
  function photoalbum_slideshow() {
    //find the current selected photo and go to the next one
    if (do_slideshow == false) {
      return;
    }
    if (slideshow_counter < 100) {
      slideshow_counter++;
      setTimeout("photoalbum_slideshow()", 100);
      return;
    } else {
      slideshow_counter = 0;
    }
    var tmp = 0;
    for (key in comments) {
      if (key == oldthumb) {
        tmp = 1;
      }
      if (tmp == 1 && key != oldthumb) {
         tmp = key;
         break;
      }
    }
    if (tmp == 1) { //last one was the one selected
      window.location=nextfotopage;
    }
    document.getElementById(tmp+"p").onclick();
    setTimeout("photoalbum_slideshow()", 100);
  }
