// WWW Server (webp)


  function wf(){}

  var WF = new wf();
  WF.ie=document.all;
  if (WF.ie) {
    if (window.XMLHttpRequest) {
      WF.ie7_8 = true;
    } else {
      WF.ie7_8 = false;
    }
  }

  WF.zIndexTooltip="8888";
  WF.zIndexTooltipIframe="8887";
  // dynamisch wijzigbaar: popup Z-indexes
  //WF.zIndexPopup="99";
  //WF.zIndexPopupShadow="98";
  //WF.zIndexPopupIframe="97";
  WF.zIndexBarIframe="97";
  WF.zIndexBarDiv="98";


  WF.GEBI = function(id, alertOnError){ // shortcut for document.getElementByID
    if (alertOnError == undefined) alertOnError=true;
    var r = document.getElementById(id);
    if (r != undefined) return r;
    // if we get here: element was not found
    if (alertOnError) {
      
    }
  }

  WF.GEBN = function(name) { // shortcut for document.getElementByName
    var r = document.getElementsByName(name);
    if (r != undefined) return r;
    // if we get here: element was not found
    //
  }



  WF.setVisible = function(id, Visible) {
    if (document.layers) { // NETSCAPE browser; extsstr: note: UNTESTED
      document.layers[id].position = (Visible == true) ? "relative" : "absolute";
      document.layers[id].visibility = (Visible == true) ? "show" : "hide";
      return;
    }

    obj = WF.GEBI(id);
    try {
      // INTERNET EXPLORER: fix shift bug: gewoon een hoogte zetten (0 blijkt automatisch te zijn)
      // fix mag NIET uitgevoerd worden voor FireFox
      if (document.all) obj.style.height = "0";
      obj.style.position = (Visible == true) ? "relative" : "absolute";
      obj.style.visibility = (Visible == true) ? "visible" : "hidden";
    } catch(er) {
      alert("Javascript error in SetVisible: " + er + "\nID is : " + id);
    }
  }

 function DotsToComma(str) {  return str.replace(".",",");  };
 function CommaToDots(str) {  return str.replace(",",".");  };

  

    WF.DOM = new Object();

    WF.DOM.getViewPortHeight = function() {
      if (self.innerHeight) // all except Explorer
      {
	      return self.innerHeight;
      }
      else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
      {
        return document.documentElement.clientHeight;
      }
      else if (document.body) // other Explorers
      {
        return document.body.clientHeight;
      }
    }

    WF.DOM.getViewPortWidth = function() {
    if (self.innerHeight) // all except Explorer
      {
        return self.innerWidth;
      }
      else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
      {
        return document.documentElement.clientWidth;
      }
      else if (document.body) // other Explorers
      {
        return document.body.clientWidth;
      }
    }

    WF.DOM.getScrollTop = function() {
      if (self.pageYOffset) // all except Explorer
      {
        return self.pageYOffset;
      }
      else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
      {
        return document.documentElement.scrollTop;
      }
      else if (document.body) // all other Explorers
      {
        return document.body.scrollTop;
      }
    }

    WF.DOM.getPosX = function(obj, bSkipSPAN){
      if (bSkipSPAN == undefined) bSkipSPAN = false;
      var curleft = 0;
      try{
        if (obj.offsetParent)  {
          while (obj.offsetParent){
            if (bSkipSPAN){
              if (obj.tagName != "SPAN") curleft += obj.offsetLeft;
            } else  curleft += obj.offsetLeft;
            obj = obj.offsetParent;
          }
        } else if (obj.x)  curleft += obj.x;
      } catch(ignore){}
      return curleft;
    }

    WF.DOM.getPosY = function(obj, bSkipSPAN){
      if (bSkipSPAN == undefined) bSkipSPAN = false;
      var curtop = 0;
      try {
        if (obj.offsetParent)  {
          while (obj.offsetParent)  {
            if (bSkipSPAN){
              if (obj.tagName != "SPAN") curtop += obj.offsetTop;
            } else curtop += obj.offsetTop;
            obj = obj.offsetParent;
          }
        }  else if (obj.y)  curtop += obj.y;
      } catch(ignore){}
      return curtop;
    }

    WF.DOM.getScrollLeft = function() {
      if (self.pageYOffset) // all except Explorer
      {
        return self.pageXOffset;
      }
      else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
      {
        return document.documentElement.scrollLeft;
      }
      else if (document.body) // all other Explorers
      {
        return document.body.scrollLeft;
      }
    }

    WF.DOM.ToggleVisibility = function(obj) {

      obj.style.display = (obj.style.display == "" || obj.style.display == "block" || obj.style.display == "inline")?obj.style.display="none":obj.style.display="block";
    }
  

    WF.event = new Object();

    WF.event.onloadFunc = new Array();

    WF.event.addOnload = function(newFunction){
     WF.event.onloadFunc[WF.event.onloadFunc.length] = newFunction;
    }

    WF.event.execOnload = function(){
      try{
      for (var i=0;i<WF.event.onloadFunc.length;i++) {
        try {
          WF.event.onloadFunc[i]();
        }catch(e){alert("Exception in onload function #"+i+": \n" +e.message);}
      }
      }catch(e){alert("Exception in onload function: " +e.message);}
    }

    WF.event.addEventListener= function(eventNameStr, object, extraFunction){ 
      if(WF.ie) { // IE
        object.attachEvent("on"+eventNameStr, extraFunction);
      } else { // FF
        object.addEventListener(eventNameStr, extraFunction, false);
      }
    }

    WF.event.addOnchange = function(objID, extraFunction){
      WF.event.addEventListener("change", WF.GEBI(objID), extraFunction);
    }

    WF.event.addOnresize = function(extraFunction){
      WF.event.addEventListener("resize", window, extraFunction);
    }

    WF.event.addOnscroll = function(func) {
      WF.event.addEventListener("scroll",window,func);
    }

    WF.event.countdowns = new Object();

    WF.event.KeyPressCountDown = function(ID,Func,Delay) {
      this.ID = ID;
      this.func = Func;
      this.delay = Delay ||2000;
      this.counter = Delay;
      this.iv;

      this.reset = function() {
        clearInterval(this.iv);
        this.counter = this.delay + 500;
        this.iv = setInterval("WF.event.countdowns['"+this.ID+"'].check()",500);
      }

      this.keydown = function() {
        WF.event.countdowns[this.ID].reset();
      }

      this.check = function () {
        this.counter -= 500;
        if(this.counter <= 0) {
          this.func();
          clearInterval(this.iv);
        }
      }

      this.cancel = function() {
        clearInterval(this.iv);
      }
    }

    WF.event.addOnKeyPressCountDown = function(Delay,Func,Obj) {
      var ID = Obj.id || Obj.name;
      if(ID == "" || ID == undefined)
        throw("Object for countdown must have an id or a name");
      WF.event.countdowns[ID] = new WF.event.KeyPressCountDown(ID,Func,Delay);
      WF.event.addEventListener("keydown",Obj,function(){WF.event.countdowns[ID].reset();});
    }

    WF.event.cancelOnKeyPressCountDown = function(Obj) {
      var ID = Obj.id || Obj.name;
      if(ID == "" || ID == undefined)
        throw("Object for countdown must have an id or a name");
      WF.event.countdowns[ID].cancel();
    }

  


  WF.debug = new Object();

  WF.debug.FireBugConsoleAvailable=false; // default to false
  try{
    console.assert(true); // test if console object exists
    WF.debug.FireBugConsoleAvailable=true;
  } catch(ignore){}

  WF.debug.info = function(s){
    if (WF.debug.FireBugConsoleAvailable) console.info(s);
  }

  WF.debug.log = function(s){ WF.debug.info(s);} // wrapper for info

  WF.debug.logError = function(s){
    if (WF.debug.FireBugConsoleAvailable) console.error(s);
  }

  WF.debug.warn = function(s){
    if (WF.debug.FireBugConsoleAvailable) console.warn(s);
  }

  



  WF.ajax = new Object();
  WF.ajaxQueue = function(){};
  WF.ajaxShowPopups = true;

  
  WF.ajaxQueue.requests=new Array();
  WF.ajaxQueue.queueBusy = false;
  WF.ajaxQueue.lastPopup;
  WF.ajaxQueue.lastBar;



  WF.ajaxQueue.hideOwnPopup = function(){

    if (WF.bar.counter == WF.ajaxQueue.lastBar) WF.bar.hide();
  }


  WF.ajaxQueue.sendAjaxObj = function(obj){
    try {
      if (obj.params["PRECALLBACK"] != null) obj.params["PRECALLBACK"]();
      document.body.style.cursor = "progress";
      if (obj.params["DIALOGMSG"] != "" ||
          obj.params["DIALOGTYPE"] & 4) {

        WF.ajaxQueue.lastDialogMsg = obj.params["DIALOGMSG"];

        if((obj.params["DIALOGTYPE"] & 4) == 4) {

          if((obj.params["DIALOGTYPE"] & 1) == 1)
          if(WF.ajaxShowPopups){
             WF.popup.showBusy();
          }
            /*$(obj.dialogDiv).dialog("open");*/
          else if((obj.params["DIALOGTYPE"] & 2) == 2)
            WF.ajaxQueue.lastBar = WF.bar.showBusy();
        } else {
          if((obj.params["DIALOGTYPE"] & 1) == 1)
          if(WF.ajaxShowPopups){
             WF.popup.showBusy();
          }
           /* $(obj.dialogDiv).dialog("open");*/

          else if((obj.params["DIALOGTYPE"] & 2) == 2)
            WF.ajaxQueue.lastBar = WF.bar.show(3,0,obj.params["DIALOGMSG"]);
        }
      }

      obj.ajaxObj.onreadystatechange = function(){WF.ajax.defaultCallback(obj)};

      if(obj.params["METHOD"] == "GET") {
        if (obj.paramstr != "") obj.params["URL"] += "?" + obj.paramstr;
        obj.ajaxObj.open(obj.params["METHOD"],obj.params["URL"], true);
        obj.ajaxObj.send(null);
      } else {
        obj.ajaxObj.open(obj.params["METHOD"],obj.params["URL"], true);
        obj.ajaxObj.send(obj.paramstr);
      }
    } catch(e) {
      document.body.style.cursor = "auto";
      if(WF.ajaxShowPopups){
        WF.ajaxQueue.hideOwnPopup();
        WF.popup.show({ HTML: "Ajax Error:" + e,
                        TITLE: "Error",
                        BUTTONS: WF.popup.POPUP_OK,
                        CALLBACKFNC: function(){},
                        CLOSE: true
                     });
      }
      obj.ajaxObj = null;
      obj=null;
      return false;
    }
    return true;
  }

  WF.ajaxQueue.trySendNext = function() {
    if (this.queueBusy) return;

    if (this.requests.length <= 0) { 
      ;
      return;
    }

    this.queueBusy = this.sendAjaxObj(this.requests.shift());
    if (!this.queueBusy) this.done;  
  }

  WF.ajaxQueue.add = function(obj) {
    if (obj.params["USEQUEUE"]) {
      this.requests.push(obj);
      this.trySendNext();
    } else {
      this.sendAjaxObj(obj);
    }
  }

  WF.ajaxQueue.done = function(obj) {
    try{
      obj.ajaxObj = null;
      obj = null;
    } catch(ignore){}
    this.queueBusy = false;
    this.trySendNext();
  }


 
  WF.ajax.getNewAjaxObject = function(){
    if (WF.ie) {
      return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
      return new XMLHttpRequest();
    }
  }



  
  WF.ajax.object = function(passedParamsObj){
    this.ajaxObj=null;  // ajax object die de call uitvoert
    this.paramstr="";   // string met parameters
    this.dialogDiv;
    this.id = WF.utils.guid();
    this.params = {URL: null,                 
                   PARAMS: new Object(),      
                   PRECALLBACK: null,         
                   CALLBACK: null,            
                   DIALOGMSG: "",             
                   DIALOGTYPE: 1,             
                   USEQUEUE: true,            
                   XML: true,                 
                   METHOD: "POST",            
                   JSON: false                
                  }

    this.getXMLValue = function(NodeName){ // Get Node Value
      try {
        return WF.utils.trimMore(WF.utils.getXMLValue(this.ajaxObj.responseXML, NodeName));
      } catch(ignore){ return "";};
    }

    if (this.params["DIALOGMSG"] != "" || this.params["DIALOGTYPE"] & 4) {
      if(WF.ajaxShowPopups){
//          WF.debug.log("creating the dialog");
          WF.popup.showBusy();
      }
     /* this.dialogDiv = $("<div id='div"+this.id+"'>Searching...</div>").appendTo(document.body);*/
    /*  $(this.dialogDiv).dialog({
                               autoOpen: false,
                               draggable: false,
                               modal: true,
                               width: "auto",
                               height: "auto",
                               resizable: false
                               });*/
    }
    else if((this.params["DIALOGTYPE"] & 1) == 1) {
      if(WF.ajaxShowPopups){
//          WF.debug.log("creating the dialog with text: " + this.params.DIALOGMSG || "Searching...");
          WF.popup.showBusy();
     /* this.dialogDiv = $("<div id='div"+this.id+"'>"+(this.params.DIALOGMSG || "Searching...")+"</div>").appendTo(document.body);
      $(this.dialogDiv).dialog({
                               autoOpen: false,
                               draggable: false,
                               modal: true,
                               width: "auto",
                               height: "auto",
                               resizable: false
                               });*/

      }
    }

    
    for (var argName in passedParamsObj) {
      this.params[argName.toUpperCase()] = passedParamsObj[argName];
    }

    
    if (this.params["URL"] == null) throw "WF: No URL passed in function WF.ajax.add()";
    if (this.params["CALLBACK"] == null) throw "WF: No callback fucntion passed in function WF.ajax.add()";
    if (this.params["XML"] && this.params["JSON"]) throw "WF: JSON and XML can not both be true";
    this.params["METHOD"] = this.params["METHOD"].toUpperCase();
    if (this.params["METHOD"] != "POST" &&
        this.params["METHOD"] != "GET" &&
        this.params["METHOD"] != "HEAD") throw "WF: Method parameter is incorrect ("+this.params["METHOD"]+")";


   
   this.ajaxObj  = WF.ajax.getNewAjaxObject();
   this.paramstr = "";

   
   var idx = this.params["URL"].indexOf("?");
   if (idx >= 0) {
     this.paramstr = this.params["URL"].substring(idx+1);
     this.params["URL"] = this.params["URL"].substring(0,idx);
   }

   var tmpparamstr="";
   for(var i in this.params["PARAMS"]) {
     if (WF.validation.isArray(this.params["PARAMS"][i])) {
        if(this.params["PARAMS"][i].length == 0) {
          tmpparamstr += "&" + i + "=";
        } else {
          for(var k=0;k<this.params["PARAMS"][i].length;k++) {
            tmpparamstr += "&" + i + "=" + escape(this.params["PARAMS"][i][k]);
          }
        }
      } else {
        tmpparamstr += "&" + i + "=" + escape(this.params["PARAMS"][i]);
      }
    }

    if (this.paramstr == "") {
      this.paramstr = tmpparamstr.replace(/./, ""); //wis voorloop "&"
    } else {
      this.paramstr += tmpparamstr; // concat parameters
    }



    
    if (this.paramstr == "") this.params["METHOD"]="GET";
  }



  
  WF.ajax.defaultCallback = function(obj) {
    if (obj.ajaxObj.readyState != 4) return; // not complete: do nothing

    var canDoCallback = true;
    document.body.style.cursor = "auto";
    switch (obj.ajaxObj.status)  {
      case 200:
        var ret = "";
        var msg = "";
        if (obj.params["XML"]) {
          ret=obj.getXMLValue("AjaxRetCode");
          msg = obj.getXMLValue("AjaxRetMessage");
        }
        else if (obj.params["JSON"]) {

          var jsonobj = eval("(" + obj.ajaxObj.responseText + ")");
          try {
            msg = jsonobj.header.statusmsg;
            ret = jsonobj.header.statuscode;
          } catch(e) {
            ret = 2;
            msg = "";
          }
        }
        if (ret != ""){
          if (ret == "-1" ||
              ret == -1) {
            if(WF.ajaxShowPopups){
              WF.popup.show({ HTML: "UNEXPECTED ERROR: " + msg,
                              TITLE: "Error",
                              BUTTONS: WF.popup.POPUP_OK,
                              CALLBACKFNC: function(){},
                              CLOSE: true
                           });
            }
            canDoCallback = false;
          }
          if (ret == "0") {
            if(WF.ajaxShowPopups){
              WF.popup.show({ HTML: msg,
                              TITLE: "Error",
                              BUTTONS: WF.popup.POPUP_OK,
                              CALLBACKFNC: function(){},
                              CLOSE: true
                           });
            }
          }
          if (ret == "1") {
            if(WF.ajaxShowPopups){
              WF.popup.show({ HTML: msg,
                              TITLE: "Error",
                              BUTTONS: WF.popup.POPUP_OK,
                              CALLBACKFNC: function(){},
                              CLOSE: true
                           });
            }
            canDoCallback = false;
          }
        }

        if (canDoCallback) {
            try {
              //if(obj.dialogDiv) {
               // alert("should hide now");
               if(WF.ajaxShowPopups){
                WF.popup.hide();
               }
/*                $(obj.dialogDiv).dialog("close");*/
             // }
            } catch(e){WF.debug.log("error:" + e);}
            try {
              WF.bar.hide();
            } catch(e){}
            if (obj.params["CALLBACK"] != undefined) {
                if (obj.params["XML"]) {
                  obj.params["CALLBACK"](obj.ajaxObj.responseXML);
                }
                else if (obj.params["JSON"]) {
                  if(obj.ajaxObj.responseText != "")
                    obj.params["CALLBACK"](jsonobj);
                }
                else {
                  obj.params["CALLBACK"](obj.ajaxObj.responseText);
                }
            }
        }
        break;
    case 400:
      if(WF.ajaxShowPopups){
        WF.popup.show({ HTML: "Error 400 - Bad Request",
                        TITLE: "Error",
                        BUTTONS: WF.popup.POPUP_OK,
                        CALLBACKFNC: function(){},
                        CLOSE: true
                     });
      }
      break;
    case 401:
      if(WF.ajaxShowPopups){
         WF.popup.show({ HTML: "Error 401 - Unauthorized: No permission",
                        TITLE: "Error",
                        BUTTONS: WF.popup.POPUP_OK,
                        CALLBACKFNC: function(){},
                        CLOSE: true
                     });
       }
       break;
    case 403:
      if(WF.ajaxShowPopups){
        WF.popup.show({ HTML: "Error 403 - Forbidden: No permission",
                        TITLE: "Error",
                        BUTTONS: WF.popup.POPUP_OK,
                        CALLBACKFNC: function(){},
                        CLOSE: true
                     });
      }
      break;
    case 404:
      if(WF.ajaxShowPopups){
        WF.popup.show({ HTML: "Error 404 - Not Found: Action can not be performed because the URL is not found",
                        TITLE: "Error",
                        BUTTONS: WF.popup.POPUP_OK,
                        CALLBACKFNC: function(){},
                        CLOSE: true
                     });
      }
      break;
    default:
      break;
  }
    WF.ajaxQueue.done(obj);  // start next ajax in queue
  }


  
  WF.ajax.add = function(passedParamsObj){
    try{
      WF.ajaxQueue.add(new WF.ajax.object(passedParamsObj)); // add to queue + start queue processing (if not already busy)
    } catch(e){alert(e)}
  }


  

  WF.popup = new Object();

  WF.popup.initialised=false;
  WF.popup.active=false;
  WF.popup.counter = 0;

  WF.popup.POPUP_OK     = 1;
  WF.popup.POPUP_CANCEL = 2;
  WF.popup.POPUP_YES    = 4;
  WF.popup.POPUP_NO     = 8;

  WF.popup.POPUP_Result = 0;
  WF.popup.POPUP_Callback;

  WF.popup.isAutoSize;
  WF.popup.params;

  WF.popup.init = function() {
    function getDiv(parentobj, classname){
      var t=document.createElement("div");
      t.setAttribute("id", "id"+classname);
      t.className= classname;
      parentobj.appendChild(t);
      return t;
    }
    function getCell(parentRow, classname){
      var c=parentRow.insertCell(parentRow.cells.length);
      c.style.className=classname;
      c.setAttribute("id", "id"+classname);
      c.style.padding=WF.ie?"4":"4px";
      c.style.margin=WF.ie?"0":"0px"
      c.style.whiteSpace="nowrap";
      return c;
    }

    WF.popup.modalDiv = getDiv(document.body, "popupModalDiv"); // grijze achtergrond zodat ze nergens meer kunnen op klikken
    WF.popup.wrapper = getDiv(document.body, "popupWrapper");
    WF.popup.table = document.createElement("table");
    WF.popup.table.className="popupTable";
    WF.popup.table.style.padding=WF.ie?"0":"0px";
    WF.popup.table.style.margin=WF.ie?"0":"0px"
    WF.popup.table.cellSpacing=0;

    WF.popup.table.style.width="1"; // FF 2 + IE7 hebben dit nodig om correcte autosize te doen

    WF.popup.wrapper.appendChild(WF.popup.table);
    WF.popup.rowTitle = WF.popup.table.insertRow(0);
    WF.popup.rowTitle.className="popupRowTitle";
    WF.popup.rowMessage = WF.popup.table.insertRow(1);
    WF.popup.rowMessage.className="popupRowMessage";
    WF.popup.rowButtons = WF.popup.table.insertRow(2);
    WF.popup.rowButtons.className="popupRowButtons";
    WF.popup.rowButtons.style.textAlign="right";

    WF.popup.cellTitleText = getCell(WF.popup.rowTitle, "popupCellTitleText");
    WF.popup.cellTitleCloseButton = getCell(WF.popup.rowTitle, "popupCellTitleCloseButton");
    WF.popup.cellTitleCloseButton.style.textAlign="right";
    var tmp=document.createElement("img");
    tmp.className="popupImgCloseImage";
    tmp.setAttribute("src", "http://www.admb.be/pls/portal/docs/PAGE/LAYOUT_SITE/WEBFRAMEWORK/VBK_CLOSE_CROSS.GIF");
    WF.popup.cellTitleCloseButton.appendChild(tmp);
    WF.event.addEventListener("click", tmp, WF.popup.hide);
    WF.popup.cellMessage = getCell(WF.popup.rowMessage, "popupCellMessage");
    WF.popup.cellMessage.colSpan=2;
    WF.popup.divMessage = document.createElement("div");
    WF.popup.cellMessage.appendChild(WF.popup.divMessage);
    WF.popup.cellButtons = getCell(WF.popup.rowButtons, "popupCellButtons");
    WF.popup.cellButtons.colSpan=2;

    WF.popup.shadow   = getDiv(document.body, "popupShadow");

    WF.popup.ifr=document.createElement("iframe");
    WF.popup.ifr.setAttribute("src", "about:blank");
    WF.popup.ifr.scrolling="no";
    WF.popup.ifr.frameborder="0";
    with(WF.popup.ifr.style){;
      position="absolute";
      width = 0;
      height = 0;
      top = 0;
      left = 0;
      backgroundColor="white";
      opacity=".5";
      filter="alpha(opacity=50)";
      mozOpacity="0.5";
      display="none";
      border="none";
      margin="0px";
      padding="0px";
    }
    document.body.appendChild(WF.popup.ifr);

    WF.event.addOnresize(WF.popup.reposition);
    WF.event.addOnscroll(WF.popup.reposition);
    WF.popup.initialised=true;
    WF.popup.hide();
  }

  WF.popup.resizeShadow = function(){
    var wr=WF.popup.wrapper;

    WF.popup.shadow.style.width = wr.offsetWidth + "px";
    WF.popup.shadow.style.height = wr.offsetHeight + "px";

    if(WF.ie) {
        sfr = WF.popup.ifr.style;
        sfr.width = wr.offsetWidth;
        sfr.height = wr.offsetHeight;
    }

  }

  WF.popup.setDimensions = function(){
   if (WF.popup.active) {
      var maxw=WF.DOM.getViewPortWidth()-50;
      var maxh=WF.DOM.getViewPortHeight()-100;
      var params=WF.popup.params;
      var w;
      var h;

      var wr=WF.popup.wrapper;
      var d=WF.popup.divMessage;

      WF.popup.wrapper.style.position="absolute";
      WF.popup.wrapper.visibility="hidden";
      WF.popup.wrapper.style.display="";

      // always reset divMessage properies
      d.style.overflow="";
      d.style.width="";
      d.style.height="";

      var autosize= WF.popup.isAutoSize;

      if ((WF.popup.cellTitleText.innerHTML == "") && (!params["CLOSE"])) {
        WF.popup.rowTitle.style.display = "none";
      } else {
        WF.popup.rowTitle.style.display = "";
      }

      var neededw=0;
      if (!autosize) {
        w=params["WIDTH"];
        h=params["HEIGHT"];
        wr.style.width=WF.ie?w:w +"px";

        if (h != "") wr.style.height=WF.ie?h:h +"px";
      } else {

        // autosize, but not wider than viewport
        // if size is too big => resize divMessage

        if (WF.ie && !WF.ie7_8) { //extsstr 06.01.2008 + inftvdi 10/06/2010: IE7/IE8 werkt zoals FF
           wr.style.width="1%";
           wr.style.height="1%";
         } else {
           wr.style.width="";
           wr.style.height="";
         }

         // if height or width too large==> set divMessage to fixed size, wrapper will fit to this size

         if (d.offsetWidth > maxw) {
           w=maxw;
           d.style.width=WF.ie?w:w +"px";
           d.style.overflowX="scroll";
           //WF.popup.wrapper.style.position="absolute";
         }

         if (d.offsetHeight > maxh) {
           h=maxh;
           d.style.height=WF.ie?h:h +"px";
           d.style.overflowY="scroll";
         }
      }

      WF.popup.resizeShadow();

    }
    WF.popup.modalDiv.style.display="";
    WF.popup.shadow.style.display="";
    WF.popup.wrapper.style.visibility="visible";

    WF.popup.modalDiv.style.left = "0px"
    WF.popup.modalDiv.style.top = "0px";
  }

  WF.popup.reposition = function(){
    if (WF.popup.active) {
      // CENTER the popup on the screen: get inner window height/width
      var t=WF.DOM.getScrollTop();
      var l=WF.DOM.getScrollLeft();
      var maxw=WF.DOM.getViewPortWidth();
      var maxh=WF.DOM.getViewPortHeight();
      var params=WF.popup.params;

      //position outer div (set it fullsreen)
      var modalh = Math.max(document.body.parentNode.scrollHeight, document.body.parentNode.clientHeight);
      var modalw = Math.max(document.body.parentNode.scrollWidth, document.body.parentNode.clientWidth);
      WF.popup.modalDiv.style.width = modalw+"px";
      WF.popup.modalDiv.style.height = modalh+"px";

      //the inner div needs to be positioned in the center
      var s = WF.popup.wrapper.style;
      var top = (t + (maxh - WF.popup.wrapper.offsetHeight)/2);
      var left = (l + (maxw - WF.popup.wrapper.offsetWidth)/2);
      //alert (top + ", " + left)
      s.position="absolute";
      s.top = WF.ie?top:top + "px";
      s.marginLeft = WF.ie?left:left + "px";

      //position the shadow div
      WF.popup.shadow.style.marginLeft = WF.ie?left+3:left + 3 + "px";
      WF.popup.shadow.style.top = WF.ie?top+3:top + 3 + "px";

      if(WF.ie) {
        WF.popup.delayedIfrReposition(); //reposition now
        setTimeout("WF.popup.delayedIfrReposition();", 1); // IE sometimes acts to slow==> try again in 1 ms
      }
    }
  }

  WF.popup.delayedIfrReposition = function(){
    with (WF.popup.ifr.style) {
      display=WF.popup.wrapper.style.display;
      top = WF.popup.wrapper.offsetTop;
      marginLeft = WF.popup.wrapper.offsetLeft;
      width=WF.popup.wrapper.clientWidth+2+3; // +2 for border? +3 for shadow
      height=WF.popup.wrapper.clientHeight+2+3; // +2 for border? +3 for shadow
    }
  }

  WF.popup.buttonClick = function (buttonNr){
    WF.popup.POPUP_Result = buttonNr;
    WF.popup.hide();
    if (WF.popup.POPUP_Callback != undefined) WF.popup.POPUP_Callback(buttonNr);
  }

  /*
  *  params
  *  {
  *    html: ,
       title: ,
       buttons: ,
       callBackFnc: ,
       width: ,
       height: ,
       zIndex: ,
       close:

  *  }
  */
  WF.popup.show = function(passedParamsObj) {
    var params = { HTML: "",
                   TITLE: "",
                   BUTTONS: 0,
                   CALLBACKFNC: function(){},
                   WIDTH: "",
                   HEIGHT: "",
                   ZINDEX: 99,
                   CLOSE: true
    };

    for (var argName in passedParamsObj) {
      params[argName.toUpperCase()] = passedParamsObj[argName];
    }

    if (params["TITLE"].length>100) params["TITLE"] = params["TITLE"].substring(0,100);

    // save params for later use (in reposition)
    WF.popup.params = params;
    WF.popup.isAutoSize = ((params["WIDTH"] == "") || (params["WIDTH"] == "auto"))

    WF.popup.counter++;
    if (!WF.popup.initialised) WF.popup.init();

    WF.popup.wrapper.style.zIndex=params["ZINDEX"];
    WF.popup.table.zIndex=params["ZINDEX"];
    WF.popup.shadow.style.zIndex=parseInt(params["ZINDEX"])-1;
    WF.popup.ifr.style.zIndex = parseInt(params["ZINDEX"]) -2;
    WF.popup.modalDiv.style.zIndex = parseInt(params["ZINDEX"]) -2; // gray over ganse viewport zodat niks anders meer kan geklikt worden

    function getButton(button){
      var ret = '<input id="idPopupButton'+button+'" type="button" class="knop" onclick="WF.popup.buttonClick('+button+');" value="DESC">&nbsp;';
      if (button == WF.popup.POPUP_OK) return ret.replace(/DESC/, "Ok");
      if (button == WF.popup.POPUP_YES) return ret.replace(/DESC/, "Ja");
      if (button == WF.popup.POPUP_NO) return ret.replace(/DESC/, "Neen");
      if (button == WF.popup.POPUP_CANCEL) return ret.replace(/DESC/, "Annuleren");
      return "";
    }

    // create buttons (extsstr: not yet fully tested)
    // use bitwise AND to generate button HTML
    var buttonhtml="";
    buttonhtml += getButton(params["BUTTONS"] & WF.popup.POPUP_OK);
    buttonhtml += getButton(params["BUTTONS"] & WF.popup.POPUP_YES);
    buttonhtml += getButton(params["BUTTONS"] & WF.popup.POPUP_NO);
    buttonhtml += getButton(params["BUTTONS"] & WF.popup.POPUP_CANCEL);

    WF.popup.POPUP_Callback = params["CALLBACKFNC"];
    WF.popup.currentContents = params["HTML"];

    WF.popup.cellTitleCloseButton.style.display= (params["CLOSE"])?"":"none";
    WF.popup.cellTitleText.innerHTML = params["TITLE"]; // nooit meer dan 100 chars om overflow te vermijden

    try{
      WF.popup.divMessage.innerHTML = "";
      WF.popup.divMessage.appendChild(params["HTML"]);
    }catch(e){
      WF.popup.divMessage.innerHTML = params["HTML"];
    }

    WF.popup.cellButtons.innerHTML = buttonhtml;

    WF.popup.active = true;


    var focusID=-1;
    if (params["BUTTONS"] & WF.popup.POPUP_OK) focusID=WF.popup.POPUP_OK
      else if (params["BUTTONS"] & WF.popup.POPUP_YES) focusID=WF.popup.POPUP_YES
      else if (params["BUTTONS"] & WF.popup.POPUP_NO) focusID=WF.popup.POPUP_NO
      else if (params["BUTTONS"] & WF.popup.POPUP_CANCEL) focusID=WF.popup.POPUP_CANCEL;
    if (focusID > 0) setTimeout("WF.popup.focusButton('idPopupButton"+ focusID+"');",1); 
    WF.popup.setDimensions();
    WF.popup.reposition();
    return WF.popup.counter;
  }

  WF.popup.focusButton = function (id){
    //todo:extsstr:WF.GEBI(id).focus();    // problem is we generate HTML code for the buttons, not DOM objects !!
  }

  WF.popup.hide = function(){
    WF.popup.active = false;
    if (!WF.popup.initialised){
    
      return;
    }
    WF.popup.modalDiv.style.display="none";
    WF.popup.wrapper.style.display="none";
    WF.popup.shadow.style.display="none";
    WF.popup.ifr.style.display="none";
  }

  WF.popup.showBusy = function() {
    return WF.popup.show( { HTML: "<img src='http://www.admb.be/pls/portal/docs/PAGE/LAYOUT_SITE/WEBFRAMEWORK/BUSY_SPINNER_MEDIUM.GIF'> One moment please",
                   TITLE: "",
                   BUTTONS: 0,
                   CALLBACKFNC: function(){},
                   CLOSE: false
    });

  }

  WF.alert = function(msg, title){
    if (title==undefined) title=window.document.title;
    WF.popup.show({HTML: msg,
                  TITLE: title,
                  BUTTONS: WF.popup.POPUP_OK,
                  CLOSE:true})
  }

  WF.event.addOnload(WF.popup.init, "Init Popup");

  

  WF.toolTip = new Object();

  WF.toolTip.toolTipVisible;
  WF.toolTip.offsetypoint;
  WF.toolTip.tipDiv;
  WF.toolTip.tipTable;
  WF.toolTip.tipTD;
  WF.toolTip.tipIFrame;
  WF.toolTip.toolTipInitialised = false;
  WF.toolTip.ieTrueBody;

  WF.toolTip.ietruebody = function(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
  }


  WF.toolTip.initTooltip = function() {
    var div=document.createElement("div");
    document.body.appendChild(div);

    var table=document.createElement("table");
    div.appendChild(table);
    var tr=table.insertRow(0);
    var td=tr.insertCell(0);
    td.setAttribute("nowrap","");
    td.setAttribute("id", "idToolTip");

    WF.toolTip.toolTipVisible = false;
    WF.toolTip.offsetypoint=20; //Customize y offset of tooltip
    WF.toolTip.tipDiv   = div;
    WF.toolTip.tipTable = table;
    WF.toolTip.tipTD    = td;
    WF.toolTip.tipIFrame;
    WF.toolTip.ieTrueBody = WF.toolTip.ietruebody();

    var s = WF.toolTip.tipDiv.style;
    s.top="0";
    s.left="0";
    s.width="0";
    s.height="0";
    s.border="1px solid black";
    s.padding = "2px";
    s.backgroundColor="lightyellow";
    s.zIndex=WF.zIndexTooltip;

    if (WF.ie) {
      var iframe=document.createElement("iframe");
      iframe.setAttribute("src", "about:blank");
      iframe.scrolling="no";
      iframe.frameborder="0";
      iframe.style.position="absolute";
      iframe.style.width = div.offsetWidth;
      iframe.style.height = div.offsetHeight;
      iframe.style.top = div.style.top;
      iframe.style.left = div.style.left;
      iframe.style.zIndex = WF.zIndexTooltipIframe;
      iframe.style.display="block";
      document.body.appendChild(iframe);
      WF.toolTip.tipIFrame = iframe;
    }

    // eens initeel aan/uit zetten om visuele bugs op te lossen
    div.style.position="absolute";
    div.style.visibility="visible";
    if (WF.ie) s.display="block";

    WF.toolTip.tooltipInitialised = true;
    WF.toolTip.hide();
    document.onmousemove=WF.toolTip.positiontip;
  }

  WF.toolTip.positiontip=function(e){
    if (WF.toolTip.toolTipVisible){
       var tipDiv = WF.toolTip.tipDiv; var yoffset = WF.toolTip.offsetypoint;
      if (WF.ie) {
        var curX=event.clientX+WF.toolTip.ieTrueBody.scrollLeft
        var curY=event.clientY+WF.toolTip.ieTrueBody.scrollTop;
        var rightedge=WF.toolTip.ieTrueBody.clientWidth-event.clientX;
        var bottomedge=WF.toolTip.ieTrueBody.clientHeight-event.clientY-yoffset;
      } else {
        var curX=e.pageX;
        var curY=e.pageY;
        var rightedge=window.innerWidth-e.clientX-20;
        var bottomedge=window.innerHeight-e.clientY-yoffset-20;
      }

      var leftedge=0;
      if (curX<leftedge) {
        tipDiv.style.left="5px";
      } else if (rightedge<tipDiv.offsetWidth){
        //move the horizontal position of the menu to the left by it's width
        var maxmove = curX - 5;
        var shouldmove = tipDiv.offsetWidth - rightedge;
        if (shouldmove > maxmove) {
          var x = 5;
        } else {
          var x = curX-shouldmove;
        }
        tipDiv.style.left= x + "px";
      } else
        //position the horizontal position of the menu where the mouse is positioned
        tipDiv.style.left=curX+"px";

      //same concept with the vertical position
      if (bottomedge<tipDiv.offsetHeight)
        tipDiv.style.top=(WF.ie)? WF.toolTip.ieTrueBody().scrollTop+event.clientY-tipDiv.offsetHeight-yoffset+"px" : window.pageYOffset+e.clientY-tipDiv.offsetHeight-yoffset+"px";
      else
        tipDiv.style.top=curY+yoffset+"px";

      tipDiv.style.position="absolute";
      tipDiv.style.visibility="visible";

      if (WF.ie) {
        tipDiv.style.zIndex=WF.zIndexTooltip;
        var s=WF.toolTip.tipIFrame.style;
        s.width = tipDiv.offsetWidth;
        s.height = tipDiv.offsetHeight;
        s.top = tipDiv.style.top;
        s.left = tipDiv.style.left;
        s.zIndex = WF.zIndexTooltipIframe;
        s.display="block";
        s.opacity="0";
        s.filter="alpha(opacity=0)";

      }
      tipDiv.style.opacity=".9";
      tipDiv.style.filter="alpha(opacity=90)";
      tipDiv.style.mozOpacity="0.9";
    }
  }

  WF.toolTip.show=function(ToolText){
    if(!WF.toolTip.tooltipInitialised)
      WF.toolTip.initTooltip();

    try{
      WF.toolTip.tipTD.innerHTML="";
      WF.toolTip.tipTD.appendChild(ToolText);
    }catch(e){
      WF.toolTip.tipTD.innerHTML=ToolText;
    }

    var tblrow = WF.toolTip.tipTable.rows[0];
    var s=WF.toolTip.tipDiv.style;
    s.width= (tblrow.offsetWidth + 6) + "px";
    s.height= (tblrow.offsetHeight + 6) + "px";
    s.border="1px solid black";
    s.padding = "2px";
    s.backgroundColor="lightyellow";
    WF.toolTip.toolTipVisible=true;
  }

  WF.toolTip.hide=function(){
    if (WF.toolTip.tooltipInitialised) {
      WF.toolTip.toolTipVisible=false;
      var s=WF.toolTip.tipDiv.style;
      s.postion="absolute";
      s.visibility="hidden";
      s.left="0";
      s.top="0";
      s.width="0";
      s.height="0";
      if (WF.ie) WF.toolTip.tipIFrame.style.display="none";
    }
  }

  WF.event.addOnload(WF.toolTip.initTooltip, "initToolTip"); 

 

  WF.bar = new Object();

  WF.bar.initialised = false;
  WF.bar.iframe;
  WF.bar.div;
  WF.bar.span;
  WF.bar.msg = "";
  WF.bar.style = "";
  WF.bar.timeOut;
  WF.bar.interVal;
  WF.bar.counter = 0;

  WF.bar.STYLE_OK = 0;
  WF.bar.STYLE_ERROR = 1;
  WF.bar.STYLE_WARNING = 2;
  WF.bar.STYLE_BUSY = 3;

  WF.bar.init = function() {
    /*
    * Create the Div and set initially invisible
    */

    WF.bar.div = document.createElement("div");
    WF.bar.div.className = "";
    var s = WF.bar.div.style;
    s.position = "absolute";
    s.display = "none";
    s.clear = "both";
    s.zIndex = WF.zIndexBarDiv;
    document.body.appendChild(WF.bar.div);

    WF.bar.span = document.createElement("span");
    WF.bar.div.appendChild(WF.bar.span);

    WF.bar.iframe = document.createElement("iframe");
    WF.bar.iframe.setAttribute("src", "about:blank");
    WF.bar.iframe.scrolling="no";
    WF.bar.iframe.frameborder="0";
    with (WF.bar.iframe.style) {
      position="absolute";
      zIndex = WF.zIndexBarIframe;
      display="none";
      clear="both";
      height=WF.bar.div.offsetHeight;
    }
    document.body.appendChild(WF.bar.iframe);


    WF.bar.initialised = true;
  }

  WF.bar.position = function() {
    var s = WF.bar.div.style;
    var is = WF.bar.iframe.style;
    s.left = "0pt";
    s.top = (WF.DOM.getViewPortHeight() +
             WF.DOM.getScrollTop() -
             WF.bar.div.offsetHeight) + "px";

    is.left=s.left;
    is.top=s.top;

    if(WF.ie) {
      s.width = WF.DOM.getViewPortWidth();
      is.width = WF.DOM.getViewPortWidth()-5;
    } else {
      s.width = "100%";
      is.width = "98%";
    }
  }

  WF.bar.setStyle = function(style) {
    switch(style) {
      case 0:
        WF.bar.div.className = "barOK";
        break;
      case 1:
        WF.bar.div.className = "barError";
        break;
      case 2:
        WF.bar.div.className = "barWarning";
        break;
      case 3:
        WF.bar.div.className = "barBusy";
        break;
      default:
        WF.bar.div.className = "barWarning";
    }
  }

  WF.bar.setMessage = function(msg) {
    WF.bar.msg = msg;
    WF.bar.span.innerHTML = msg;
  }

  WF.bar.setTimeOut = function(sec) {
    WF.bar.timeOut = setTimeout("WF.bar.hide()",sec);
  }

  WF.bar.show = function(style,duration,msg) {
    WF.bar.counter++;
    if(!WF.bar.initialised)WF.bar.init();
    WF.bar.setStyle(style);
    WF.bar.setMessage(msg);
    if(duration > 0)
      WF.bar.setTimeOut(duration*1000);
    var s = WF.bar.div.style;
    s.display = "block";
    WF.bar.iframe.style.display="block";
    WF.bar.position();
    WF.bar.interVal = setInterval("WF.bar.position()",200);
    return WF.bar.counter;
  }

  WF.bar.hide = function() {
    if(WF.bar.initialised == true){
      var s = WF.bar.div.style;
      s.display = "none";
      WF.bar.iframe.style.display="none";
      clearInterval(WF.bar.interVal);
    }
  }

  WF.bar.showBusy = function() {
    return WF.bar.show(3,0,"One moment please");
  }


  WF.utils = new Object();

   WF.utils.dateRegExSlashes  = /^[0-9]{1,2}\/[0-9]{1,2}(\/([0-9]{2,4})?)?$/;
   WF.utils.dateRegExDDMMRRRR = /^[0-9]{1,2}([0-9]{2}([0-9]{2}([0-9]{2})?)?)?$/;

  WF.utils.toNumber = function(strNumber, emptyStrIsZero) {
    if (emptyStrIsZero == undefined) emptyStrIsZero = false;
    strNumber = WF.utils.trim(strNumber);
    if (emptyStrIsZero && (strNumber =="")) return 0;
    return parseFloat(WF.utils.stringReplace(strNumber, "," ,"."));
   }

  WF.utils.formatNumber = function (strNumber, emptyStrIsZero) { // converts string to number, and resets to string, using "," as decimal separator
    return WF.utils.stringReplace("" + WF.utils.toNumber(strNumber+"", emptyStrIsZero), ".", ",");
   }

  WF.utils.trim = function (str) {
    if (str == undefined) return "";
    str = str.replace( /^\s+/g, "" );// strip leading
    return str.replace( /\s+$/g, "" );// strip trailing
  }

  WF.utils.roundTo = function (nbr, nbrOfDecimals) {
    return parseInt(Math.round(nbr*Math.pow(10,nbrOfDecimals))) / Math.pow(10,nbrOfDecimals);
  }

  WF.utils.trimMore = function(str) { // trim, maar wis ook trailing newlines
    if (str == undefined) return "";
    str = str.replace( /^(\s|\\n)+/g, "" );// strip leading
    return str.replace( /(\s|\\n)+$/g, "" );// strip trailing
  }

  WF.utils.stringHxToChr = function(source){
    source = WF.utils.stringReplace(source,"%25","%");
    source = WF.utils.stringReplace(source,"%60","`");
    source = WF.utils.stringReplace(source,"%7E","~");
    source = WF.utils.stringReplace(source,"%21","!");
    source = WF.utils.stringReplace(source,"%23","#");
    source = WF.utils.stringReplace(source,"%24","$");
    source = WF.utils.stringReplace(source,"%5E","^");
    source = WF.utils.stringReplace(source,"%26","&");
    source = WF.utils.stringReplace(source,"%28","(");
    source = WF.utils.stringReplace(source,"%29",")");
    source = WF.utils.stringReplace(source,"%3D","=");
    source = WF.utils.stringReplace(source,"%5B","[");
    source = WF.utils.stringReplace(source,"%7B","{");
    source = WF.utils.stringReplace(source,"%5D","]");
    source = WF.utils.stringReplace(source,"%7D","}");
    source = WF.utils.stringReplace(source,"%7C","|");
    source = WF.utils.stringReplace(source,"%3B",";");
    source = WF.utils.stringReplace(source,"%3A",":");
    source = WF.utils.stringReplace(source,"%27","\"\"");
    source = WF.utils.stringReplace(source,"%22","\"");
    source = WF.utils.stringReplace(source,"%2C",",");
    source = WF.utils.stringReplace(source,"%3C","<");
    source = WF.utils.stringReplace(source,"%3E",">");
    source = WF.utils.stringReplace(source,"%3F","?");
    source = WF.utils.stringReplace(source,"%20"," ");
    source = WF.utils.stringReplace(source,"%2B","+");
    source = WF.utils.stringReplace(source,"%2E",".");
    source = WF.utils.stringReplace(source,"%2A","*");
    source = WF.utils.stringReplace(source,"%5C","\\");
    source = WF.utils.stringReplace(source,"%2F","/");
    return source;
  }

  WF.utils.stringReplace = function(source, search, replaceby){
    return source.split(search).join(replaceby);  
  }

  WF.utils.getXMLValue = function(xml, NodeName, idx){ // Get Node Value
    try {
      if (idx == undefined) idx=0;
      return WF.utils.trimMore(xml.getElementsByTagName(NodeName)[idx].childNodes[0].nodeValue);
    } catch(ignore){
      return "";
    };
  }

  WF.utils.nvl = function(tst,rep) {
    if(rep == undefined) throw "Replacement can not be undefined";
    if(tst == "" ||tst == undefined)
      return rep;
    else
      return tst;
  }

  WF.utils.truncDate = function (date){
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);

    return date;
  }

  WF.utils.toDate = function (datestr){
    //-- trek datum uit mekaar, en maak er integers van (dan hebben we geen gezever met voorloopnullen)
    var parts = datestr.split("/");
    for(var i = 0; i < parts.length; i++) parts[i] = parts[i] * 1;

    //indien enkel laatste 2 cijfers van het jaartal meegegeven
    //berekenen of de datum 1900 of 2000 is
    //kleiner dan 38 --> 1900
    //groter dan 38 --> 2000
    if ((parts[2] + "").length < 4)
    {
       var y = parts[2] % 100;
	     parts[2] +=  (y < 38) ? 2000 : 1900;
    }

    //-- maak van de parts een date
    d = new Date();
    d.setDate(1); // eerst dag op 1ste van de maand zetten, anders zou op de 31ste conversie naar een maand met 30 dagen automatisch een maand opschuiven
    d.setFullYear(parts[2]);
    d.setMonth(parts[1]-1);
    d.setDate(parts[0]);
    return d;
  }

  WF.utils.strToDate = function(datestr) {
    return WF.utils.toDate(datestr);
  }

  WF.utils.dateToStr = function (mydate){
    var y = parseInt(mydate.getFullYear());
    var m = parseInt(mydate.getMonth() + 1);
    var d = parseInt(mydate.getDate());
    if (m < 10) {
      var mm = "0"+m;
    }else{
      var mm = m;
    }
    if (d < 10) {
      var dd = "0"+d;
    }else{
      var dd = d;
    }
    return dd+"/"+mm+"/"+y;
  }

  WF.utils.formatDateStr = function(dateStr, dateSeparator){
    if (dateSeparator==undefined) dateSeparator = "/";
    // note: dateStr MUST BE A VALID DATE STRING (check with isDate())
    var d;
    var m;
    var y;

    dateStr = WF.utils.trim(dateStr.replace (/[\\\-\.]/g, "/")); // convert to trimmed slashformat if possible
    if (dateStr=="") return "";
    if (WF.utils.dateRegExSlashes.test(dateStr)) {
      parts = dateStr.split("/");
      d = parseInt(parts[0],10);
      m = parseInt(parts[1],10);
      if ((parts.length==3) && parts[2].length>0) {
        y = parseInt(parts[2],10);
      } else {
        y = new Date().getFullYear(); // current year
      }
    } else {
      d = parseInt(dateStr.substring(0,2),10);
      m = dateStr.substring(2,4);
      if (m.length==0) {
        m = new Date().getMonth()+1;
      } else {
        m = parseInt(m, 10);
      }
      y = dateStr.substring(4);
      if (y.length==0) {
        y = new Date().getFullYear();
      } else {
        y = parseInt(y,10);
      }
    }
    if (y<999) y = 2000 + y;

    var ret="";
    if (d<10) ret+="0";
    ret+=d + dateSeparator;
    if (m<10) ret+="0";
    ret+=m + dateSeparator + y;
    return ret;
  }


  WF.utils.radioValue = function(radioButtonName) {
    var i = 0;
    var r = WF.GEBN(radioButtonName);
    if (r == undefined) {
      alert("Javascript funtie radioValue heeft radiobutton met name = '" + radioButtonName + "' niet gevonden.");
      return "";
    }
    for (var i = 0; i < r.length; i++) {
      if (r[i].checked) return r[i].value;
    }

    try {
      return WF.GEBI(radioButtonName).value;
    }catch(e) {
      return "";
    }
    return "";
  }

  WF.utils.setSelectValue = function(obj,value,searchInValue) {
    if(searchInValue == undefined){
      for (var i=0; i < obj.options.length; i++){
        if(obj.options[i].value == value)
          obj.options[i].selected = true;
      }
    }else{
      for (var i=0; i < obj.options.length; i++){
        if(obj.options[i].value.search(value) != -1)
          obj.options[i].selected = true;
      }
    }
  }

  WF.utils.lpad = function (str, len, pad) {
   var rij = str.split('');
   var nog =  len - str.length;
   for (var i = 0; i < nog; i++)
   {
     rij.splice(0, 0, pad);
   }
   return rij.join('');
  }

  WF.utils.rpad = function (str, len, pad)   {
     var rij = str.split('');
     var nog =  len - str.length;
     for (var i = 0; i < nog; i++)
     {
       rij.push(pad);
     }
     return rij.join('');
   }
  

  WF.validation = new Object();

  WF.validation.isNumber = function(n, allowNegative, allowDecimals) {
    if (allowNegative == undefined) allowNegative = true;
    if (allowDecimals == undefined) allowDecimals = false;

     if (allowNegative) {
       if (allowDecimals) {
         var regexp = /^-?[0-9]*(\.|,)?[0-9]*$/;
       } else {
         var regexp = /^-?[0-9]*$/;
       }
     } else {
       if (allowDecimals) {
         var regexp = /^[0-9]*(\.|,)?[0-9]*$/;
       } else {
         var regexp = /^[0-9]*$/;
       }
     }
     return regexp.test(n);
   }

  WF.validation.isArray = function(v) {
    return v && typeof v == "object" && typeof v.length == "number" &&  !(v.propertyIsEnumerable("length"));
  }

  WF.validation.isEmail = function(email) {
    return email.match(/^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[_A-Za-z0-9-]+)$/);
  }

  WF.validation.isRRN = function(rrn) {
    if(rrn.length != 11)
      return false;
    var part1 = rrn.substring(0,9);
    var part2 = rrn.substring(9,11);
    if((97-part1%97) == part2) {
      return true;
    }
    else {
      return false;
    }
  }

  WF.validation.isDate = function(dateStr, allowEmpty) {
      if (allowEmpty == undefined) allowEmpty=false;
      var d;
      var m;
      var y;
      var ok=false;

      dateStr = WF.utils.trim(dateStr.replace (/[\\\-\.]/g, "/")); // convert to trimmed slashformat if possible
      if (allowEmpty && (dateStr=="")) return true;

      if (WF.utils.dateRegExSlashes.test(dateStr)) {
        parts = dateStr.split("/");
        d = parseInt(parts[0],10);
        m = parseInt(parts[1],10);
        if ((parts.length==3) && parts[2].length>0) {
          y = parseInt(parts[2],10);
        } else {
          y = new Date().getFullYear(); // current year
        }
        ok=true;
      }

      if (WF.utils.dateRegExDDMMRRRR.test(dateStr)) {
        d = parseInt(dateStr.substring(0,2),10);
        m = dateStr.substring(2,4);
        if (m.length==0) {
          m = new Date().getMonth()+1;
        } else {
          m = parseInt(m, 10);
        }
        y = dateStr.substring(4);
        if (y.length==0) {
          y = new Date().getFullYear();
        } else {
          y = parseInt(y,10);
        }
        ok=true;
      }

      if (!ok) return false;

      if (y<999) y = 2000 + y;

      var testdate = new Date(y, m-1, d);
      var testy = parseInt(testdate.getFullYear(),10);
      var testm = parseInt(testdate.getMonth() + 1,10);
      var testd = parseInt(testdate.getDate(),10);

      if ((y != testy) || (m != testm) || ( d != testd)) return false;

      //-- als we hier geraken is het okay
      return true;

  }

  WF.validation.isDateObject = function(d) {
    return d.constructor.indexOf("Date") > 0;
  }

  WF.validation.isON = function(string) {
    string = WF.utils.trim(string);
    if (string.length == 9) string = "0" + string;
    if (!string.match(/^[0-2][0-9]{9}$/)) return "";
    var main = string.substring(0,8);
    var check = string.substring(8,10);
    var ret = (97 - (main % 97) + "");
    if (ret.length == 1) ret = "0" + ret;
    if (ret == check) return string; else return "";
  }



    WF.utils.guid = function()
      {
        var result, i, j;
        result = "";
        for(var j=0; j<32; j++)  {
          if( j == 8 || j == 12|| j == 16|| j == 20)
            result = result + "-";
          i = Math.floor(Math.random()*16).toString(16).toUpperCase();
          result = result + i;
        }
        return result
      } 
