function wdLoadNewsAsSub(container, si, sli, preview, offset, display, _callback, pagetype) {
	var oN = new WDNews();
	oN.getAsSub(container, si, sli, preview, offset, display, _callback, pagetype);
	
}

function wdLoadPollAsSub(container, si, sli, preview, offset, display, _callback, pagetype) {
	var oP = new WDPoll();
	oP.getAsSub(container, si, sli, preview, offset, display, _callback, pagetype);
}

function wdLoadCatalogAsSub(container, si, sli, preview, offset, display, _callback, pagetype) {
	var oC = new WDCatalog();
	oC.getAsSub(container, si, sli, preview, offset, display, _callback, pagetype);
}

function wdLoadCatalogSearch(container, si, sli, preview, display, _callback, pagetype) {
	var oC = new WDCatalog();
	oC.getSearchBox(container, si, sli, preview, display, _callback, pagetype);
}

function WDNews() {
	
	var me = this;

	this.toString = function() { return "WDNews"; }
	
	this.Ajax = new Ajax();

	this.getAsSub = function(containerid, si, sli, offset, preview, display, _callback, pagetype) {
		this.ContainerID = containerid;
		this.Display = display;
		this.callback = _callback;
		var url = 'http://www.snefit.nl//wd/wdpages/getNews.php';
		var pvar = 'si='+si+'&sli='+sli+'&type=sub&off='+offset+'&preview='+preview+'&ptype='+pagetype;
		
		this.Ajax.makeRequest('GET', url, pvar, this.onReady);	
	}
	
	this.onReady = function() {
		if (me.Ajax.checkReadyState(null, 'loading news...','news loaded...','news ready...') == "success") {
			
			if (me.ContainerID) {
				var oC = getControl(me.ContainerID);
				oC.innerHTML = me.Ajax.request.responseText;
				if (me.Ajax.request.responseText.length>0) {
					oC.style.display = me.Display;
				} else {
					oC.style.display = 'none';
				}
			}
			if (typeof me.callback == 'function') {
				me.callback(me.ContainerID, me.Ajax.request.responseText, me.Ajax.request.status);
			}
		}
	}
}

function WDPoll() {
	
	var me = this;
	
	this.toString = function() { return "WDPoll"; }
	
	this.Ajax = new Ajax();
	
	this.getAsSub = function(containerid, si, sli, offset, preview, display, _callback, pagetype) {
		this.ContainerID = containerid;
		this.Display = display;
		this.callback = _callback;
		
		var url = 'http://www.snefit.nl//wd/wdpages/polls/getPoll.php';
		var pvar = 'si='+si+'&sli='+sli+'&type=sub&off='+offset+'&preview='+preview+'&ptype='+pagetype;
		
		this.Ajax.makeRequest('GET', url, pvar, this.onReady);
	}

	this.onReady = function() {
		if (me.Ajax.checkReadyState(null, 'loading poll...','poll loaded...','poll ready...') == "success") {
			
			if (me.ContainerID) {
				var oC = getControl(me.ContainerID);
				oC.innerHTML = me.Ajax.request.responseText;
				if (me.Ajax.request.responseText.length>0) {
					oC.style.display = me.Display;
				} else {
					oC.style.display = 'none';
				}
			}
			if (typeof me.callback == 'function') {
				me.callback(me.ContainerID, me.Ajax.request.responseText, me.Ajax.request.status);
			}
		}
	}
}

function WDCatalog() {
	
	var me = this;
	
	this.toString = function() { return "WDCatalog"; }
	
	this.Ajax = new Ajax();
	
	this.getAsSub = function(containerid, si, sli, offset, preview, display, _callback, pagetype) {
		this.ContainerID = containerid;
		this.Display = display;
		this.callback = _callback;
		
		var url = 'http://www.snefit.nl//wd/wdpages/catalog/getCatalog.php';
		var pvar = 'si='+si+'&sli='+sli+'&type=sub&off='+offset+'&preview='+preview+'&ptype='+pagetype;
		
		this.Ajax.makeRequest('GET', url, pvar, this.onReadySub);
	}

	this.getSearchBox = function(containerid, si, sli, preview, display, _callback, pagetype) {
		this.SBContainerID = containerid;
		this.SBDisplay = display;
		this.SBcallback = _callback;
		
		var url = 'http://www.snefit.nl//wd/wdpages/catalog/getSearchBox.php';
		var pvar = 'si='+si+'&sli='+sli+'&preview='+preview+'&ptype='+pagetype;
		
		this.Ajax.makeRequest('GET', url, pvar, this.onReadySearchBox);
	}

	this.onReadySub = function() {
		if (me.Ajax.checkReadyState(null, 'loading catalog...','catalog loaded...','catalog ready...') == "success") {
			
			if (me.ContainerID) {
				var oC = getControl(me.ContainerID);
				oC.innerHTML = me.Ajax.request.responseText;
				if (me.Ajax.request.responseText.length>0) {
					oC.style.display = me.Display;
				} else {
					oC.style.display = 'none';
				}
			}
			if (typeof me.callback == 'function') {
				me.callback(me.ContainerID, me.Ajax.request.responseText, me.Ajax.request.status);
			}
		}
	}
	this.onReadySearchBox= function() {
		if (me.Ajax.checkReadyState(null, 'loading catalogsearchbox...','catalogsearchbox loaded...','catalogsearchbox ready...') == "success") {
			
			if (me.SBContainerID) {
				var oC = getControl(me.SBContainerID);
				oC.innerHTML = me.Ajax.request.responseText;
				if (me.Ajax.request.responseText.length>0) {
					oC.style.display = me.SBDisplay;
				} else {
					oC.style.display = 'none';
				}
			}
			if (typeof me.SBcallback == 'function') {
				me.SBcallback(me.SBContainerID, me.Ajax.request.responseText, me.Ajax.request.status);
			}
		}
	}
}



function WDProxy() {
	var me = this;
	this.toString = function() { return "WDProxy"; }
	this.Ajax = new Ajax();
	
	this.getUrl = function (method, url, vars, callback) {
		this.method = method;
		this.url = url;
		this.vars = vars;
		this.callback = callback;
		
		var proxy = 'http://www.snefit.nl//wd/wdpages/tools/proxy.php';
		var pvar = 'method='+encodeURIComponent(method)+'&url='+encodeURIComponent(url)+'&vars='+encodeURIComponent(vars);	
		this.Ajax.makeRequest('POST', proxy, pvar, this.onReady);
	}
	
	this.onReady = function () {
		if (me.Ajax.checkReadyState(null, 'loading...','loaded...', 'ready...') == "success") {
			
			if (typeof me.callback == 'function') {
				me.callback(me.Ajax.request.responseText, me.Ajax.request.status);
			}
		}
	}
}

function NewFinalize(sContainerID, sResponse, sStatus) {
	alert(sContainerID + '--> ' + sResponse + '--' + sStatus);
	//alert(sStatus + ': We are now in the callback function where you can do your stuff afterwards.' );
}
