// tools.js
// ---
// general javascript tools for use with different scripts
// -
// Author: Pekka Jääskeläinen
// 2007
//

// browser variables
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);



// addLoadEvent by Peter-Paul Koch
// http://simonwillison.net/2004/May/26/addLoadEvent/
//
// makes it possible to add multiple functions to be executed with the javascript window.onload handler

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

// element is a wrapper function to get element fetching to work in internet explorer 4

function element(id)
{
	if(ie4)	// Explorer 4
		return document.all[id];
	else	// Explorer 5+ Netscape 6+ and Mozilla and Firefox
		return document.getElementById(id);
}

// load URL into a true fullscreen mode

function fullScreen(theURL) {
  window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
}

// general selection method. gets an selection group id and the object that needs to be selected from that group.
// selection_arrays size may be modified to suit heavier solutions if needed

var selection_array = new Array(10);
function select(id, obj) {

  if(selection_array[id] != null) {
    selection_array[id].className = null;
  }

  obj.className = "selected";
  selection_array[id] = obj;
}

