/**
  * JsLib.js
  *
  * Author:
  *	Ruud Heemskerk
  * Copyright:
  *	(c) 2003 2r Computer & Software Service
  */

// Constants
var EVENT_WINDOW_ONLOAD = 0;
var EVENT_WINDOW_UNLOAD = 1;

// Variables used to store event actions.
var sWindowOnLoadEvent = '';
var sWindowUnLoadEvent = '';

// Function to add actions to events.
function addToEvent(iEvent, sScript) {
	switch(iEvent) {
		case EVENT_WINDOW_ONLOAD:
			sWindowOnLoadEvent += sScript + ";";
			break;
		case EVENT_WINDOW_UNLOAD:
			sWindowUnLoadEvent += sScript + ";";
			break;
	}
}

// The actual event fire function.
function fireEvent(iEvent) {
	switch(iEvent) {
		case EVENT_WINDOW_ONLOAD:
			eval(sWindowOnLoadEvent);
			break;
		case EVENT_WINDOW_UNLOAD:
			eval(sWindowUnLoadEvent);
			break;
	}
}

// Bind onload function to window.onload.
window.onload = function(){fireEvent(EVENT_WINDOW_ONLOAD)};
window.unload = function(){fireEvent(EVENT_WINDOW_UNLOAD)};
