function Activate()
{
  this.Ajax = null;
  this.cbObj = null;
}

Activate.prototype.onChange = function(link, urlsuffix, cbObj, msgDeactivate, msgActivate, AddConfirm)
{      
  var Activate = '0';
  this.cbObj = cbObj;
  
  var bConfirm  = false; 
  var bContinue = true;   
  if(AddConfirm) { 
    if(this.cbObj.checked) {
      bConfirm = true;  
    }

    if(bConfirm) {
      if(!confirm('Weet u zeker dat u deze woning wilt activeren? De gegevens kunnen hierna niet meer gewijzigd worden.')) {        
        bContinue = false;
      }  
    }
  }
  
  if(bContinue) {  
    if(this.cbObj.checked) {
      Activate = '1';
    } 
    if(Activate == '0') {
      alert(msgDeactivate);
    } else {
      alert(msgActivate);
    }
    this.cbObj.disabled = true;
    this.Ajax = new AjaxComponent(link, urlsuffix + Activate, this.callback.bind(this));
    this.Ajax.initiateWatch();
  } else {
    if(bConfirm) {
      if(this.cbObj.checked) {
        this.cbObj.checked = false;
      } else {
        this.cbObj.checked = true;
      }
    }
  }
}

Activate.prototype.callback = function()
{
  if(this.Ajax != null) {
    this.cbObj.disabled = false;
    this.Ajax = null;
  }
}

function GetRegions(baseUrl)
{
  this.Ajax = null;
  this.txObj = null;
  this.fillObj = null;
  this.baseUrl = baseUrl; 
}

GetRegions.prototype.onChange = function(link, urlsuffix, txObj, id)
{                     
  this.txObj = txObj;
  this.fillObj = document.getElementById(id);        
  var Current = this.txObj.selectedIndex;           
  this.Ajax = new AjaxComponent(link, urlsuffix + Current, this.callback.bind(this));
  this.Ajax.initiateWatch(); 
}

GetRegions.prototype.callback = function()
{
  if(this.Ajax != null) {
      this.fillObj.innerHTML = this.Ajax.responseText;
      // resetFontSize(this.baseUrl);
      this.Ajax = null;      
  }
}

function GetItemsPerPage()
{     
  this.Ajax = null;
  this.selectObj = null;
}

GetItemsPerPage.prototype.onChange = function(link, urlsuffix, selectObj)
{                     
  this.selectObj = selectObj;     
  var Current = this.selectObj.options[this.selectObj.selectedIndex].value;       
  this.Ajax = new AjaxComponent(link, urlsuffix + Current, this.callback.bind(this));
  this.Ajax.initiateWatch(); 
}

GetItemsPerPage.prototype.callback = function()
{
  if(this.Ajax != null) {
      document.getElementById('content').innerHTML = this.Ajax.responseText; 
      this.selectObj = null;
      this.Ajax = null;      
      
      var scripts = document.getElementById('content').getElementsByTagName('script'); 
    
      for (var i=0;i<scripts.length;i++) { 
        if(scripts[i].innerHTML != "") {
          eval(scripts[i].innerHTML); 
        }
      }
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

