function Article(){
	this.id = 0;
	this.status = 0;
	this.type = 0;
	this.scope = 0;
	this.level = 0;
	this.fetchSize = 0;
	this.startDate = new Date();
	this.stopDate = new Date();
	this.titel = '';
	this.oms = '';
	this.tekst = '';
	this.settings = {};
	
	this.setId = function(id) {
		this.id=parseInt(id);
	}
	this.getId = function(){
		return this.id;
	}
	this.setStatus = function(status) {
		this.status=parseInt(status);
	}
	this.getStatus = function(){
		return this.status;
	}
	this.setType = function(type) {
		this.type=parseInt(type);
	}
	this.getType = function(){
		return this.type;
	}
	this.setScope = function(num) {
		this.scope=parseInt(num);
	}
	this.getScope = function(){
		return this.scope;
	}
	this.setLevel = function(num) {
		this.level=parseInt(num);
	}
	this.getLevel = function(){
		return this.level;
	}
	this.setFetchSize = function(num) {
		this.fetchSize=parseInt(num);
	}
	this.getFetchSize = function(){
		return this.fetchSize;
	}
	this.setStartDate = function(val){
		this.startDate = val;
	}
	this.getStartDate = function (format){
		return dateFormat(this.startDate,format);
	}
	this.setStopDate = function(val){
		this.stopDate = val;
	}
	this.getStopDate = function (format){
		return dateFormat(this.stopDate,format);
	}
	this.setTitel = function(val){
		this.titel = val;
	}
	this.getTitel = function(){
		return this.titel;
	}
	this.setTekst = function(val){
		this.tekst = val;
	}
	this.getTekst = function(){
		return this.tekst;
	}
	this.setOms = function(val){
		this.oms = val;
	}
	this.getOms = function(){
		return this.oms;
	}
	this.setValue = function (key,value){
		this.settings[key]=value;
	}
	this.getValue = function(key){
		value = this.settings[key];
		if (value === undefined) {
			value = '';
		}
		return value;
	}
	
	//Zit hier nog vast, zelfs al doe ik de request synchroon, de onreadystatechange is te laat.
	/*		//gebruik een calback methode zoals in onderstaand voorbeeld
	* 		article = new Article();
			function haalinfo(id){
				...
				article.load(id,"setArticle()");
				...
			}
			function setArticle(){
				$('titel').value=article.getTitel();
			}
	*/
	this.load = function(id,func) {
		this.id = id;
		var t = this;
		var req = new XMLHttpRequest();
		if (req) {
	 		req.onreadystatechange = function() {
		    	if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
					var xml = req.responseXML;
					if (xml.documentElement) {
						t.loadXML(xml);
						if (func) eval(func);
						//setTimeout(func,0);
					}
		    	}
			}
	  	}
	 	req.open('GET', '/scripts/classes/kmonet/xml/Article.jsp?id='+id+'&noCache='+new Date().getTime()); //asynchroon
	 	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-15');
		req.send(null);
	}
	this.loadXML = function(xml){
		var root = xml.getElementsByTagName('article')[0];
		if (xml.getElementsByTagName('type')[0].firstChild.nodeValue == 0){
			this.setId(this.id); //opgelet dit is het gevraagde id
			this.setStatus(-1);
			this.setTitel("Page not Found");
			this.setTekst("De pagina die je hebt gevraagd bestaat niet (meer).");
		}else{
			this.setId(this.getNodeValue(root,'id'));
			this.setType(this.getNodeValue(root,'type'));
			this.setStatus(this.getNodeValue(root,'status'));
			this.setStartDate(this.getNodeValue(root,'startDate'));
			this.setStopDate(this.getNodeValue(root,'stopDate'));
			this.setTitel(this.getNodeValue(root,'titel'));
			this.setTekst(this.getNodeValue(root,'tekst'));
			this.setOms(this.getNodeValue(root,'oms'));
			var settings = root.getElementsByTagName('settings')[0];
			this.setFetchSize(settings.childNodes.length);
			for (var iNode = 0; iNode < settings.childNodes.length; iNode++) {
				var setting = settings.childNodes.item(iNode);
				this.setValue(setting.nodeName,this.getNodeValue(settings,setting.nodeName));
			}
		}
	}
	this.getNodeValue = function (el,name){
		if (el.getElementsByTagName(name)[0].firstChild == null) return '';
		else return el.getElementsByTagName(name)[0].firstChild.nodeValue;
	}
}
/*
	Date Format 1.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT license
	With code by Scott Trenda (Z and o flags, and enhanced brevity)
*/

/*** dateFormat
	Accepts a date, a mask, or a date and a mask.
	Returns a formatted version of the given date.
	The date defaults to the current date/time.
	The mask defaults ``"ddd mmm d yyyy HH:MM:ss"``.
*/
var dateFormat = function () {
	var	token        = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloZ]|"[^"]*"|'[^']*'/g,
		timezone     = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (value, length) {
			value = String(value);
			length = parseInt(length) || 2;
			while (value.length < length)
				value = "0" + value;
			return value;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask) {
		// Treat the first argument as a mask if it doesn't contain any numbers
		if (
			arguments.length == 1 &&
			(typeof date == "string" || date instanceof String) &&
			!/\d/.test(date)
		) {
			mask = date;
			date = undefined;
		}

		date = date ? new Date(date) : new Date();
		if (isNaN(date))
			throw "invalid date";

		var dF = dateFormat;
		mask   = String(dF.masks[mask] || mask || dF.masks["default"]);

		var	d = date.getDate(),
			D = date.getDay(),
			m = date.getMonth(),
			y = date.getFullYear(),
			H = date.getHours(),
			M = date.getMinutes(),
			s = date.getSeconds(),
			L = date.getMilliseconds(),
			o = date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4)
			};

		return mask.replace(token, function ($0) {
			return ($0 in flags) ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":       "ddd mmm d yyyy HH:MM:ss",
	shortDate:       "m/d/yy",
	mediumDate:      "mmm d, yyyy",
	longDate:        "mmmm d, yyyy",
	fullDate:        "dddd, mmmm d, yyyy",
	shortTime:       "h:MM TT",
	mediumTime:      "h:MM:ss TT",
	longTime:        "h:MM:ss TT Z",
	isoDate:         "yyyy-mm-dd",
	isoTime:         "HH:MM:ss",
	isoDateTime:     "yyyy-mm-dd'T'HH:MM:ss",
	isoFullDateTime: "yyyy-mm-dd'T'HH:MM:ss.lo"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"zon", "maa", "din", "woe", "don", "vri", "zat",
		"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"
	],
	monthNames: [
		"jan", "feb", "mar", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec",
		"januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
	]
};

// For convenience...
Date.prototype.format = function (mask) {
	return dateFormat(this, mask);
}
