  var lightBoxIsTarget = true;
  var xmlReqList;
  var xmlReqs = new Array();
  var urls = new Array();
  var request_listUrl;
  var request_container;
  var lightboxContent;
  var request_counter = 0;
  var executeFunctions = null;

  var BrowserDetect = {
	  init: function () {
		  this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		  this.version = this.searchVersion(navigator.userAgent)
			  || this.searchVersion(navigator.appVersion)
			  || "an unknown version";
		  this.OS = this.searchString(this.dataOS) || "an unknown OS";
	  },
	  searchString: function (data) {
		  for (var i=0;i<data.length;i++)	{
			  var dataString = data[i].string;
			  var dataProp = data[i].prop;
			  this.versionSearchString = data[i].versionSearch || data[i].identity;
			  if (dataString) {
				  if (dataString.indexOf(data[i].subString) != -1)
					  return data[i].identity;
			  }
			  else if (dataProp)
				  return data[i].identity;
		  }
	  },
	  searchVersion: function (dataString) {
		  var index = dataString.indexOf(this.versionSearchString);
		  if (index == -1) return;
		  return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	  },
	  dataBrowser: [
		  { 	string: navigator.userAgent,
			  subString: "OmniWeb",
			  versionSearch: "OmniWeb/",
			  identity: "OmniWeb"
		  },
		  {
			  string: navigator.vendor,
			  subString: "Apple",
			  identity: "Safari"
		  },
		  {
			  prop: window.opera,
			  identity: "Opera"
		  },
		  {
			  string: navigator.vendor,
			  subString: "iCab",
			  identity: "iCab"
		  },
		  {
			  string: navigator.vendor,
			  subString: "KDE",
			  identity: "Konqueror"
		  },
		  {
			  string: navigator.userAgent,
			  subString: "Firefox",
			  identity: "Firefox"
		  },
		  {
			  string: navigator.vendor,
			  subString: "Camino",
			  identity: "Camino"
		  },
		  {		// for newer Netscapes (6+)
			  string: navigator.userAgent,
			  subString: "Netscape",
			  identity: "Netscape"
		  },
		  {
			  string: navigator.userAgent,
			  subString: "MSIE",
			  identity: "Explorer",
			  versionSearch: "MSIE"
		  },
		  {
			  string: navigator.userAgent,
			  subString: "Gecko",
			  identity: "Mozilla",
			  versionSearch: "rv"
		  },
		  { 		// for older Netscapes (4-)
			  string: navigator.userAgent,
			  subString: "Mozilla",
			  identity: "Netscape",
			  versionSearch: "Mozilla"
		  }
	  ],
	  dataOS : [
		  {
			  string: navigator.platform,
			  subString: "Win",
			  identity: "Windows"
		  },
		  {
			  string: navigator.platform,
			  subString: "Mac",
			  identity: "Mac"
		  },
		  {
			  string: navigator.platform,
			  subString: "Linux",
			  identity: "Linux"
		  }
	  ]

  };
  BrowserDetect.init();

  function size_column_content(divID) {
    var mainholder = document.getElementById('mainholder');
    var content    = document.getElementById(divID);
    var col1       = getChildByClass(content,'div','column1');
    var col2       = getChildByClass(content,'div','column2');
    var col3       = getChildByClass(content,'div','column3');
    var checkCol1  = col1;
    // check if the div's exist
    if(!divID) return;
    if(!mainholder) return;
    if(!(col1 && col2 && col3)) return;

    if(checkCol1.offsetHeight < col2.offsetHeight)
      checkCol1 = col2;
    if(checkCol1.offsetHeight < col3.offsetHeight)
      checkCol1 = col3;

    // in ie after placing content with ajax the mainholder is not resized
    // so check if the main holder is atleast the size of the bigest collumn
    if (mainholder.offsetHeight - checkCol1.offsetHeight < 0 || content.resized)
    {
      content.resized = true;
      content.style.height = checkCol1.offsetHeight + 'px';
    }

    // force the browser (IE) to parse the lightbox again so the multiselects will be visible again
    content.style.display = 'none';
    content.style.display = 'block';
  }

  function request_init(targetId, list, executeFunctions)
  {
    this.executeFunctions = executeFunctions;
    
    if(request_container = document.getElementById(targetId))
    {
      request_unload();

      request_container.innerHTML = '';

      request_placeLoadingIcon();
    }

    if((list) && (list!=null))
      request_listUrl = list;

  }

  function request_placeLoadingIcon()
  {
    // Makes sure the opacity layer is resized so you can actually see it when you get a loading icon
    sizeLightBox();

    // Bepaling van de huidige venster grootte van een non-ie browser
    var height = window.innerHeight;
    var elem = null;

    // IE 6 / IE 7  Zuigt
    if (height == null) {
      height = document.documentElement.clientHeight;
    }

    if (elem = document.getElementById('lightbox-opacity-loading')) {
      if (height > 0)
        elem.style.height = height + 'px';

      elem.className = 'visible';
    }
  }

  function request_hideLoadingIcon()
  {
    var elem = null;

    if (elem = document.getElementById('lightbox-opacity-loading'))
      elem.className = 'hidden';

  }

  function request_unload()
  {
    xmlReqs = new Array();
    urls = new Array();
    request_listUrl = null;
    request_counter++;
  }

  function request_getList()
  {
    if(window.XMLHttpRequest)
      xmlReqList = new XMLHttpRequest();
    else if(window.ActiveXObject)
      xmlReqList = new ActiveXObject("Microsoft.XMLHTTP");
    else
      alert('not supported');

    xmlReqList.onreadystatechange = request_loadList;
    xmlReqList.open ('POST', request_listUrl, true);
    xmlReqList.send ("foo");

    request_listUrl = null;
  }

  function request_loadList()
  {
    if(xmlReqList.readyState != 4) return;

    var domxml = new xml();
    domxml.loadXML(xmlReqList.responseText);

    nodes = domxml.dom.getElementsByTagName('categorie');
    request_unload();
    for(var i=0; i<nodes.length; i++)
    {
      var categorieId = nodes[i].getAttribute('id');
      var parentDiv = document.getElementById(categorieId);
      if(!parentDiv) continue;

      childNodes = nodes[i].getElementsByTagName('item');
      for(j=0; j<childNodes.length; j++)
      {
        if(domxml.hasNodeValue(childNodes.item(j)))
        {
          var div = document.createElement("div");
          div.setAttribute("id", categorieId + "_" + j);
          parentDiv.appendChild(div);
          request_addUrl(domxml.getNodeValue(childNodes[j]),categorieId + "_" + j);
        }
      }
    }

    if (nodes && nodes.length > 0)
      request_retrieve();
    else
      request_hideLoadingIcon();
  }

  function request_addUrl(url, targetId, params, callMethod)
  {
    var num = urls.length;

    urls[num] = new Array();
    urls[num]['url'] = url;

    if (targetId)
      urls[num]['target'] = targetId;
    if (params)
      urls[num]['params'] = params;

    // when GET is used as method IE caches the content, to prevent this the POST method is used (ules you want to cache ofcourse)
    // we can not use 'non cache' headers because these can cause the browser to crash !!!!
    if (callMethod && (callMethod == 'POST' || callMethod == 'GET'))
      urls[num]['callMethod'] = callMethod;
    else
      urls[num]['callMethod'] = 'POST';
  }

  function request_retrieve(callback, callbackParams)
  {
    var url = new Array();

    if (urls.length > 0)
    {
      for (var urlIndex in urls)
      {
        url = urls[urlIndex];
        request_XMLHttpRequest(url['url'], url['target'], callback, callbackParams, url['callMethod']);
      }

      urls = new Array();
    }
  }

  function initializeJavascript()
  {
    //initialize
    lightboxContent = document.getElementById('lightbox');
    var target      = request_container;
    // check if the extra paramter is passed in
    var parameters  = initializeJavascript.arguments;
    var element     = (parameters[0]) ? parameters[0] : false;
    if(element)
    {
      if (typeof(element) == 'object')
      {
        target = element;
      }
      else if(typeof(element) == 'string' || typeof(element) == 'number')
      {
        if(element = document.getElementById(element))
          target          = element;
      }
      lightboxContent   = target;
      request_container = target;
    }

    scanTT(target);
    var elements = target.getElementsByTagName('form');

    if (elements)
    {
      for (var i = 0; i < elements.length; i++)
      {
        var multiselect = elements[i];

        if (inputs = multiselect.getAttribute('multiselect'))
        {
          // reset some global variables for the multiselect !!!
          thing     = '';
          c         = Array();
          submiting = false;
          // initiate the multiselectfields
          var inputArr = inputs.split(',');
          for(var j=0; j < inputArr.length; j++)
            multiselectInit( inputArr[j], "img/button-multiselect-on.gif", "img/button-multiselect-hov.gif", "multi-arrow", "textfield", "multi-optionDiv", "multi-cell", "multi-cellHover", "multi-cellSelected");
        }
      }
    }

    new validator();
    validator.InitForm(target.id);
  }

  function request_placeContent(num,target,req_count)
  {
    if(req_count!= request_counter)
      return;
    if(xmlReqs[num].readyState != 4)
      return;

    var status = 0;

    // Fix for NS_ERROR_NOT_AVAILABLE
    try {
      status = xmlReqs[num].status;
    }
    catch (e) {
      return;
    }

    if(xmlReqs[num].status != 200)
    {
      return;
    }

    // remove old printboxes
    removeChildsFromElement('printcontentholder');

    if (!target || (target=='null'))
    {
      request_container.innerHTML = xmlReqs[num].responseText;

      toggleLightBox('show');

      request_hideLoadingIcon();
    }
    else if(targetDiv = document.getElementById(target))
    {
      targetDiv.innerHTML = xmlReqs[num].responseText;
    }

    if (this.executeFunctions != null)
      eval(this.executeFunctions);
  }

  function request_placeLightbox(num, target, req_count)
  {
    if(req_count!= request_counter)
      return;

    if(xmlReqs[num].readyState != 4)
      return;

    if(xmlReqs[num].status != 200)
      return;

    // remove old printboxes
    removeChildsFromElement('printcontentholder');

    if (!target || (target=='null'))
    {
      var a = document.createElement('div');
      a.innerHTML = xmlReqs[num].responseText;
      request_container.appendChild(a);
    }
    else if (targetDiv = document.getElementById(target))
    {
      targetDiv.innerHTML += xmlReqs[num].responseText;
    }

    initializeJavascript();

    if ((num==(xmlReqs.length-1)) && request_listUrl)
    {
      request_getList();
    }
    else if (num==(xmlReqs.length-1))
    {

      if (this.executeFunctions != null)
        eval(this.executeFunctions);

      // If the target area is the lightbox, only show it at the last second
      if (target == 'lightbox' || request_container.id == 'lightbox')
      {
        window.onresize = sizeLightBox;

        if (toggleLightBox('show'))
        {

          if (typeof(aq) == 'function')
            aq();
        }

        sizeLightBox();

      }

      request_hideLoadingIcon();

    }
  }

  function request_XMLHttpRequest(url, target, callback, callbackParams, callMethod)
  {
    if (callback == null)
      callback = 'request_placeLightbox';

    var num = xmlReqs.length;

    if (!target)
      var target = null;

    if (window.XMLHttpRequest)
      xmlReqs[num] = new XMLHttpRequest();
    else if (window.ActiveXObject)
      xmlReqs[num] = new ActiveXObject("Microsoft.XMLHTTP");

    var extraCallbackParams = '';

    if (callbackParams && callbackParams.length > 0)
    {
      for(index in callbackParams)
      {
        extraCallbackParams += ',\'' + callbackParams[index] + '\'';
      }
    }

    if (!callMethod || callMethod == 'undefined' || callMethod == undefined) // last one for IE
      callMethod = 'POST';

    xmlReqs[num].onreadystatechange = new Function("", callback+"("+num+",'"+target+"',"+request_counter + extraCallbackParams + ")");
    xmlReqs[num].open(callMethod, url, true);
    xmlReqs[num].send(null);
  }