  //User variables
  var host = 'http://www.tvotterlo.nl';

  //Browser afhakelijkheden variables
  var ie = (document.all) ? 1:0;
  var className = (ie) ? 'className':'class';
  var object = null;
  var toolbar = null;
  var winSize = new Array();
  var winScroll = new Array();
  
  //Functie met de standaart gegevens die geladen moeten worden
  function windowOnLoad() {
    //'document.getElementById('sub_content').style.height = parseInt(document.getElementById('content').offsetHeight - 2) + 'px';
    windowResize();
    windowScroll();
  }
  
  //Werk de winSize variable bij, en voer vervolgens de events uit
  function windowResize() {
    winSize = {
      x: document.documentElement.clientWidth,
      y: document.documentElement.clientHeight
    }

    //Events
    resizeShowBox();
    replaceToolbar();
  }

  //Werk de winScroll variable bij, en voer vervolgens de events uit
  function windowScroll() {
    winScroll = {
      x: document.documentElement.scrollLeft,
      y: document.documentElement.scrollTop
    }

    //Events
    replaceToolbar();
  }

  //Voor het leegmaken van een object
  function cleanNode(obj) {
    var childs = obj.childNodes.length;
    for (i=0;i<childs;i++) {
      obj.removeChild(obj.firstChild, true);
    }
  }

  //Voor het vragen om dingen aan te passen, verwijderen
  function verwijder(tekst) {
    var agree=confirm(tekst);
    if (agree) {
      return true;
    } else {
      return false;
    }
  }

  function getOffset(objID) {
    if (objID) {
      var x = objID.offsetLeft;
      var y = objID.offsetTop + objID.offsetHeight;
     
      var parent = objID;
      while (parent.offsetParent) {
        parent = parent.offsetParent;
        x += parent.offsetLeft;
        y += parent.offsetTop ;
       }
       return new Array(x,y);
     }
   }

  //Ajax handler
  function createHTTPHandler() {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
  }

  function getNodeValue(obj, tag) {
    var tempObj = obj.getElementsByTagName(tag);
    if (tempObj.length > 0 && tempObj[0].firstChild) {
      return tempObj[0].firstChild.nodeValue;
    } else {
      return "";
    }
  }

  function openHTTPHandler(url, obj) {
    obj.open("GET", host + "/functions/ajaxHandler.php?" + url, true);
    obj.setRequestHeader("Cache-Control", "no-cache");
    obj.setRequestHeader("X_USERAGENT", "GvRStudio");
    obj.setRequestHeader("Content-type", "application/xml");
    obj.send(null);
  }

  window.onresize = windowResize;
  window.onload = windowOnLoad;
  window.onscroll = windowScroll;

  //Functie voor het tonen van de aangemelden personen
  function userSearch(objID) {
    XMLRequestTeam = createHTTPHandler();
    XMLRequestTeam.onreadystatechange=function() {
      if (XMLRequestTeam.readyState==4) {
        //Zorg voor een grijs scherm op de monitor
        //Roept deels fucnties op uit photo.js
        if (!document.getElementById('showBox')) {
          var boxDiv = document.createElement('div');
          boxDiv.setAttribute('id', 'showBox');
          document.body.appendChild(boxDiv);
          object = document.getElementById('showBox');
          resizeShowBox();
          opacObj(75, object);
        }
        //Maak de userlijst aan
        var userDiv = document.createElement('div');
        userDiv.setAttribute('id', 'userSelect');
        var h1 = document.createElement('h3');
        h1.appendChild(document.createTextNode('Selecteer een gebruiker'));

        var img = document.createElement('img');
        img.setAttribute('src', host + '/images/icons/back_to_album.gif');
        img.onclick = function () {
          document.body.removeChild(document.getElementById('showBox'));
          document.body.removeChild(document.getElementById('userSelect'));
        }
        userDiv.appendChild(h1);
        userDiv.appendChild(img);
        var root = XMLRequestTeam.responseXML
        var users = root.getElementsByTagName('user');
        for (i=0;i<users.length;i++) {
          var tempDiv = document.createElement('a');
          tempDiv.setAttribute(className, 'userSelect');
          tempDiv.setAttribute('href', 'javascript:;');
          tempDiv.setAttribute('userID', getNodeValue(users[i], 'userid'));
          tempDiv.onclick = function() {
            document.getElementById(objID).value = this.getAttribute('userID');
            document.body.removeChild(document.getElementById('showBox'));
            document.body.removeChild(document.getElementById('userSelect'));
          }
          var img = document.createElement('img');
          img.setAttribute('src', host + '/images/icons/user.gif');
          tempDiv.appendChild(img);
          var span = document.createElement('span');
          span.appendChild(document.createTextNode(getNodeValue(users[i], 'username')));
          tempDiv.appendChild(span);
          var span = document.createElement('span');
          tempDiv.appendChild(span);
          span.appendChild(document.createTextNode(getNodeValue(users[i], 'name')));
          tempDiv.appendChild(span);
          userDiv.appendChild(tempDiv);
        }
        document.body.appendChild(userDiv);
        obj = document.getElementById('userSelect');
        obj.style.left = parseInt(parseInt(winSize['x'] / 2) - parseInt(obj.offsetWidth / 2) + winScroll['x']) + 'px';
        obj.style.top = parseInt(winSize['y'] / 2 - obj.offsetHeight / 2 + winScroll['y']) + 'px';
      }
    }
    var url = "getUsers";
    openHTTPHandler(url, XMLRequestTeam);
  }

