
Array.prototype.verwerk=function(f){var r=[];for (var i=0,l=this.length;i<l;i++) r[i]=f(this[i],i);return r};
Number.prototype.bedragWeergave=function(){
	var arr=this.afronden(2).toString().split('.');
	if (arr.length<3){
		var Heel=arr[0];
		var Breuk=arr.length==1?'00':(arr[1].length==1?arr[1]+'0':arr[1]);
		var r='';
		for (var n=3;n<Heel.length;n+=3){r='.'+Heel.substr(Heel.length-n,3)+r}
		Heel=Heel.substr(0,Heel.length-n+3)+r;
		return Heel+','+Breuk;
	}
};

function xpABNS(n,f){[Array,Boolean,Number,String].verwerk(function(c){c.prototype[n]=f})};
xpABNS('functie',function(f){return f(this)});
xpABNS('object',function(o){return new o(this)});
Array.prototype.naarObject=function(){var r={};this.verwerk(function(i,n){r[i]=n});return r};
Array.prototype.plus=function(a){return this.concat([a])};
Array.prototype.afronden=function(nDec){
	nDec=parseInt(nDec)?Math.pow(10,nDec):1;
	return Math.round(this*nDec)/nDec;
};
//alleen voor legacy omgeving
X(String.prototype,{
	vervang:function(a,b,cs){
		if ((cs?this.indexOf(a):this.toLowerCase().indexOf(a.toLowerCase()))==-1) return this;
		'\\?$&^|.*+(){}[]'.split('').verwerk(function(x){a=a.replace(RegExp('\\'+x,'g'),'\\'+x)});
		return this.replace(RegExp(a,'g'+(cs?'':'i')),b==u?'':b);
	},
	isGetal:function(){return isNum(parseFloat(this))},

	autocast:function(){
		//Bedoeld om string-waarden (bijvoorbeeld uit een querystring) om te zetten naar het juiste JS datatype (automatische casting)
		if (this.isGetal() && parseFloat(this)+''==this) return parseFloat(this);
		else if (this=='') return;
		return this;
	},
	naarObject:function(vervangPlus,scheiding){
		var o={};
		if (!scheiding) scheiding='&';
		if (this!=''){
		var vertaal=vervangPlus?function(s){return unescape(s.vervang('+',' '))}:unescape;//decodeURI en decodeURIComponent nog bekijken en regExp gebruiken
			var KeyItem=this.split('&').verwerk(function(paar){
				if (paar.bevat('=')) {Key=vertaal(paar.tot('='));Item=vertaal(paar.na('='))}//.autocast()}
				else {Key=vertaal(paar);Item=u}
				if (Key in o){
					if (is(o[Key],Array)) o[Key].push(Item);
					else o[Key]=[o[Key],Item];
				}
				else o[Key]=Item;
			})
		}
		return o;
	},
	uitvullen:function(Karakter,Lengte,bRechts){
		var v='';
		for (var x=this.length;x<Lengte;x++){v+=Karakter}
		return bRechts?this+v:v+this;
	},
	begintMet:function(s){return this.indexOf(s)===0},
	eindigtMet:function(s){var i=this.lastIndexOf(s);return i>-1&&i==this.length-s.length},
	bevat:function(s){return this.indexOf(s)>-1},
	tel:function(s){return this.split(s).length-1},
	tot:function(n,laatste){
		if (n.constructor===Number) return this.substring(0,laatste?this.length-n-1:n);
		else return this.bevat(n)?this.substring(0,this[(laatste?'lastI':'i')+'ndexOf'](n)):laatste?this:'';
	},
	na:function(n,laatste){
		if (n.constructor===Number) return this.substring(laatste?this.length-n:n+1);
		else return this.bevat(n)?this.substring(this[(laatste?'lastI':'i')+'ndexOf'](n)+n.length):laatste?'':this;
	},
	tm:function(n,laatste){
		if (n.constructor===Number) return this.substring(0,laatste?this.length-n:n+1);
		else return this.bevat(n)?this.substring(0,this[(laatste?'lastI':'i')+'ndexOf'](n)+n.length):laatste?this:'';
	},
	vanaf:function(n,laatste){
		if (n.constructor===Number) return this.substring(laatste?this.length-n-1:n);
		else return this.bevat(n)?this.substring(this[(laatste?'lastI':'i')+'ndexOf'](n)):laatste?'':this;
	},
	trimBegin:function(n){
		if (n.constructor===Number) return this.substr(n);
		else{
			if (this.begintMet(n)) return this.substr(n.length);
			else return this;
		}
	},
	trimEind:function(n){
		if (n.constructor===Number) return this.substr(0,this.length-n);
		else{
			if (this.eindigtMet(n)) return this.substr(0,this.length-n.length);
			else return this;
		}
	},
	trim:function(){return this.ltrim().rtrim()/*return this.replace(/^\s*|\s*$/g,'')*/},
	rtrim:function(){
		var whitespace=' \t\n\r',s=this;
		if (whitespace.indexOf(s.charAt(s.length-1))!=-1){
			var i=s.length-1;
			while (i>=0 && whitespace.indexOf(s.charAt(i))!=-1) i--;
			s=s.substring(0,i+1);
		}
		return s;
	},
	ltrim:function(){
		var whitespace=' \t\n\r',s=this;
		if (whitespace.indexOf(s.charAt(0))!=-1){
			var j=0, i=s.length;
			while (j<i && whitespace.indexOf(s.charAt(j))!=-1) j++;
			s=s.substring(j,i);
		}
		return s;
	}
})
;
	if (!Array.prototype.push) Array.prototype.push=function(e){this[this.length]=e;return this.length}
X(Array.prototype,{
heeftIndex:function(i){return i>-1 && i<this.length},
deval:function(){return '['+this.verwerk(function(i){return Deval(i)}).join(',')+']'},
//voert FilterFunctie uit voor elk item in de array
//retourneert [falseArray,trueArray] waarin items worden geplaatst afhankelijk van of het resultaat van FilterFunctie true of false is
filter:function(FilterFunctie){
	var trueArray=[],falseArray=[];
	for (var index=0;index<this.length;index++) (FilterFunctie(this[index],index)?trueArray:falseArray).push(this[index]);
	return [falseArray,trueArray];
}
})

//Vergelijkingsfuncties te gebruiken als parameter voor Array.sort
function compRandom(){return Math.floor(Math.random()*3)-1}
function compNum(a,b){return a-b}
function compAlpha(a,b){return compChar(a.toUpperCase(),b.toUpperCase())}
function compChar(a,b){return a>b?1:a<b?-1:0}//default
function compDate(a,b){
	if (isDate(a)) return isDate(b)?compChar(a,b):1;
	else return isDate(b)?-1:0;
}
;
//voor beide omgevingen benodigd
X(String.prototype,{
	isEmail:function(){return (/^_?[A-Za-z0-9]+([\&\_.-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([\_.-]?[A-Za-z0-9]+)*(\.[A-Za-z0-9]{2,4})+$/i).test(this)},
	isPostcode:function(){return (/^[1-9]{1}[0-9]{3}\s{0,1}?[a-zA<WBR>-Z]{2}$/i).test(this)},
	isLeeg:function(){return this==''},

	wisHTML:function(behoudFormat){
		if (behoudFormat){
			var t=d.cE('div');
			t.innerHTML=this;
			return t.innerText;
		}
		else return this.replace(/<\/?[^>]+>/gi,'');
	},
	wisTag:function(tag){
		if (this.toLowerCase().indexOf('<'+tag.toLowerCase())>-1){
			var Temp=this.vervang('</'+tag,'<'+tag,false).split('<'+tag);
			for (var Teller=1;Teller<Temp.length;Teller++) Temp[Teller]=Temp[Teller].substr(Temp[Teller].indexOf('>')+1);
			return Temp.join('');
		}
		else return this;
	},
	HTMLencode:function(){
		var t=d.cE('div');
		t.appendChild(d.cT(this));
		return t.innerHTML;
	},
	HTMLdecode:function(){
		var t=d.cE('div');
		t.appendChild(d.cT(this));
		return t.innerHTML;
	},
	nodeList:function(){
		var t=d.cE('div');
		t.innerHTML=this;
		return t.childNodes;
	},
	node:function(){return this.nodeList()[0]},
	naarNumber:function(){
		var t=parseFloat(this);
		return isNaN(t)?0:t;
	},
	deval:function(){return '\''+this.vervang('\\','\\\\').vervang('\t','\\t').vervang('\r','\\r').vervang('\f','\\f').vervang('\b','\\b').vervang('\"','\\"').vervang('\'','\\\'').vervang('\n','\\n').vervang('</'+'script>','</\'+\'script>')+'\''}
})

//DEPRECATED!!!
function isEmail(s){return s.toString().isEmail()}
function Vervang(s,a,b,cs){return s.toString().vervang(a,b,cs)}
function LTrim(s){return s.toString().ltrim()}
function RTrim(s){return s.toString().rtrim()}
function Trim(s){return s.toString().trim()}
function isGetal(s){return s.toString().isGetal()}
function NaarJSWaarde(s){return s.toString().autocast()}
function OpmaakRotOp(s){return s.toString().wisHTML()}
;
X(Date.prototype,{
addYears:function(n){this.setFullYear(this.getFullYear()+n);return this},
addMonths:function(n){this.setMonth(this.getMonth()+n);return this},
addDays:function(n){this.setDate(this.getDate()+n);return this}
})
;
/* Cref 2004-2006 iov Cipix */
//Standaard variabelen, constanten en instanties
var u;
_=null;
$='';
w=this;
d=document;
d.E=Elm=d.getElementById;
d.EN=d.getElementsByName;
d.ET=d.getElementsByTagName;
//d.ES=cssQuery;
/*
Om het Eolas patent te omzeilen moet de code waarmee het object-element gemaakt wordt
in een externe javascript file staan die fysiek wordt ge-include vanuit het document
waarin het object wordt gebruikt. Vandaar onderstaande wrapper:
*/
d.cE=function(t){return d.createElement(t)};
d.cT=d.createTextNode;
d.cA=d.createAttribute;
d.dE=d.documentElement;
d.H=d.dE.childNodes[0];

//onload moet false retourneren als het script nog niet is geladen: laadScript('mijnScript.js',function(){if (!w.mijnFunctie) return false;mijnFunctie()});
laadScript=function(src,onload,checkInterval){
	if (!d.E(src)){
		var s=d.cE('script');
		s.id=s.src=src;
		d.H.appendChild(s);
	};
	if (onload){
		var check=function(){setTimeout(function(){if (onload()==false) check()},checkInterval||100)};
		setTimeout(check,0);//als ie al geladen is, direct uitvoeren maar wel consequent in een apparte thread
	};
	return s;
}

//APIid is te verkrijgen middels:
//http://www.google.com/maps/api_signup?url=<PROTOCOL>://<DOMEIN>
//bijv: http://www.google.com/maps/api_signup?url=http://bla.com
laadGoogleAPI=function(APIid,onload){
	if (w.google && w.google.loader) return;
	//indien geen versienummer wordt meegegeven aan google.laad worden deze defaults gebruikt
	var globaleVersies={maps:2};
	laadGoogleAPI.onload=function(){
		//ter vervanging van google.load, bewust niet google.load overschrijven omdat google die wellicht zelf ook gebruikt
		google.laad=function(ns,onload,optVersie){google.load(ns,optVersie||globaleVersies[ns]||1,{callback:onload||Nix,nooldnames:true})}
		if (onload) onload(google);
	}
	var d=Lokatie.Domein;
	APIid=d.eindigtMet('.cipix.nl')
		?'ABQIAAAA8Q3Yd71NhbBR0MWvksPETRS0Y1Gn44A0pQw6GPYHSi2anfTRKxSHq12XIcS0yL2yWo_1WILK1aRfww'
		:d.eindigtMet('.cimple.nl')
			?'ABQIAAAA8Q3Yd71NhbBR0MWvksPETRQkS563KkYVfn4Rro8Pgypaiol8vxQsZOfdWj-4ygPi6XEECHMXwpKOXQ'
			:APIid;
	laadScript('http://www.google.com/jsapi?'+(APIid?'key='+APIid+'&':'')+'callback=laadGoogleAPI.onload');
}

function leesVirtueelDomein(){return d.ET('base')[0].href.na('Frontend/').tot('/')}

//uitfaseren!
function Maak(eOuder,Naam,Tag){
	if (Naam in eOuder) eOuder.removeChild(eOuder[Naam]);
	var e=d.cE(Tag?Tag:'span');
	if (Tag=='a'){
		e.href='javascript:;';
		e.onclick=Nix;
	}
	e.className=Naam;
	eOuder.appendChild(e);
	cx(eOuder,Naam,e);
	return e;
}

function X(O,p){
	if (p!=u)	for (var x in p) O[x]=p[x];
	return O;
}

function sA(e,a,w){e[a]=w}
function gA(e,a){return e[a]}

function bouw(CSSdef_props_subs,props,subs,rbouwfa){
	//var bouwfa=rbouwfa?rbouwfa:[];
	var id=classes='';
	var CSSdef;
	if (is(CSSdef_props_subs,Array)){
		CSSdef=CSSdef_props_subs[0];
		props=CSSdef_props_subs[1];
		subs=CSSdef_props_subs[2];
	}
	else CSSdef=CSSdef_props_subs;
	if (CSSdef){
		if (CSSdef.bevat('.')){
			classes=CSSdef.na('.');
			CSSdef=CSSdef.tot('.');
		}
		var id=CSSdef.na('#',1);
		CSSdef=CSSdef.tot('#',1);
	}
	else CSSdef='';
	var tag=CSSdef==''?'SPAN':CSSdef;
	tag=d.cE(tag);
	if (id!='') sA(tag,'id',id);
	if (classes!='') sA(tag,'className',classes.vervang('.',' '));
	if (props){
		if ('style' in props){
			X(tag.style,props.style);
			delete props.style;//dus kan slechts voor 1 tag worden gebruikt nu maar wordt toch vervangen binnenkort
		}
		for (var x in props) sA(tag,x,props[x]);//NIET via cx! (dan gaat t in dit geval JUIST lekken)
	}
	if (tag.tagName=='A'&&tag.href==''){
		sA(tag,'href','javascript:;');
		if (gA(tag,'onclick')==u) sA(tag,'onclick',Nix);
	}
	//if (tag.onbouw) bouwfa.push(tag);
	if (subs){
		if (subs.constructor===Array){
			for (var x=0;x<subs.length;x++) tag.appendChild(subs[x].tagName?subs[x]:bouw(subs[x],u,u));//,bouwfa));
		}
		else tag.appendChild(d.cT(subs));
	}
	//if(!rbouwfa) bouwfa.verwerk(function(t){t.onbouw.apply(t)});
	return tag;
}

function isClassAan(e,Naam){return (' '+e.className+' ').bevat(' '+Naam+' ')}
function zetClassAan(e,Naam){if (!isClassAan(e,Naam)) e.className+=' '+Naam;return e}
function zetClassUit(e,Naam){if (isClassAan(e,Naam)) e.className=(' '+e.className+' ').vervang(' '+Naam+' ',' ').trim();return e}
function toggleClass(e,Naam){e.className=isClassAan(e,Naam)?(' '+e.className+' ').vervang(' '+Naam+' ',' ').trim():e.className+' '+Naam;return e}
//visueel de functionaliteit van een element in- of uitschakelen
function zetStatus(e,b){
	e.disabled=!b;
	w['zetClass'+(b?'Uit':'Aan')](e,'uit');
}

function Mail(Van,Aan,CC,BCC,Onderwerp,Inhoud,AlsHTML,SMTP,Poort,Bijlagen){
	var m=this;
	m.Van=Van;
	m.Aan=Aan;
	m.CC=CC;
	m.BCC=BCC;
	m.Onderwerp=Onderwerp;
	m.Inhoud=Inhoud;
	m.AlsHTML=AlsHTML;
	m.SMTP=SMTP?SMTP:'localhost';
	m.Poort=Poort?Poort:25;
	m.Bijlagen=Bijlagen?Bijlagen:[];
	m.Verstuur=function(f){new HTTPVerzoek('/?Verzoek=mail'+'&sessieId='+Client.Lees('SessieID'),m,f).Start()}
}

//functie binnen de context van een objectinstantie uitvoeren
//Eventueel later ook arguments doorgeven
function Pointer(I,FN){return function(W){return I[FN](W)}}

function Bestand(Pad){
	var Slash=Pad.lastIndexOf('\\');
	if (Slash==-1) Slash=Pad.lastIndexOf('/');
	var t=unescape(Pad).slice(Slash+1);
	this.Extensie=t.slice(t.lastIndexOf('.')+1);
	this.toString=function(){return t};
}

//tijdelijk makkelijk soundfunctietje, alleen IE
function Snd(Lokatie){
	if (!Snd.e){
		Snd.e=d.cE('bgsound');
		Snd.e.loop=1;
		Snd.e.autostart=true;
		d.H.appendChild(Snd.e);
	}
	Snd.e.src=Lokatie;
}

//nuttig voor a-tags?
function Nix(){return false}

function is(o,c){return o!=u&&o!=_&&o.constructor&&o.constructor===c}

function AlsIsAfbeelding(AlsURL,DanFunctie,AndersFunctie){
	var v=parseInt(navigator.appVersion.na('MSIE '));
	if (v>6){//IE>6 voert de onload en onerror events niet uit dus dan checken we alleen de extensie
		switch (AlsURL.Document.Extensie.toLowerCase()){
			case 'gif':
			//case 'png':
			case 'jpg':
			case 'jpeg':
				DanFunctie();
			break;
			default:
				AndersFunctie();
		}
	}
	else{
		var Afb=new Image;
		Afb.onload=Afb.onabort=DanFunctie; //doen we nog wat met onabort?
		Afb.onerror=AndersFunctie;
		setTimeout(function(){Afb.src=AlsURL},1);//via timeout zodat de afbeelding altijd wordt geladen
	}
}

function isNum(Waarde){return typeof(Waarde)=='number' && !isNaN(Waarde)}
function isLeeg(x){
	if (x==_||x==u||x=='') return true;
	if (x.tagName){
		var Waarde
		switch (x.tagName.toLowerCase()){
			case 'select': return x[x.selectedIndex].value.trim()=='';break;
			case 'input':
			case 'textarea': return x.value.trim()=='';break;
		}
		return false;
	}
	else{
		for (var t in x) return false;
		return true;
	}
}
function isArray(obj){return (obj && obj.constructor && obj.constructor===Array)}
function isDate(obj){return (obj && obj.constructor && obj.constructor===Date)}
function isFunctie(obj){return typeof obj=='function'}

var HoogsteZ=1000;

//activeert debug-modus
function Debug(){window.open('/Backend/Debug','Debug','width=200,height=500,resizable=yes,scrollbars=yes,alwaysRaised=yes,screenX=800,screenY=30,left=800,top=30')}

function Random(min,max){
	if (max==u){
		var t=1;
		for (;min>1;min--) t*=10;
		min=t;
		max=t*10-1;
	}
	return Math.floor(min+(Math.random()*(max-min+1)));
}

function Timer(){return (new Date).getTime()}

function Stopwatch(){
	var s=this;
	s.Reset=function(){s.StartTijd=Timer()}
	s.MSec=function(){return Timer()-s.StartTijd}
	s.Sec=function(){return s.MSec()/1000}
	s.Min=function(){return s.Sec()/60}
	s.toString=function(){
		var t=s.MSec();
		var ms=t%60000;
		var m=(t-ms)/60000;
		ms=ms%1000;
		return m.toString().uitvullen(0,2)+':'+((t-ms)/1000).toString().uitvullen(0,2)+'.'+ms.toString().uitvullen(0,3);
	}
	s.Reset();
}

//void wordt niet afgevangen en andere objecten dan instanties van prototypes ook niet
//Doet toSource() niet exact hetzelfde? Ja dus maar werkt niet in IE
function Deval(Waarde){
	if (Waarde==_) return '_';
	if (Waarde==u) return 'u';
	switch (Waarde.constructor){
		case Array:
		case String:
			return Waarde.deval();
		case Number:
			return Waarde.toString();
		case Boolean:
			return (Waarde?1:0);
		default:
			if (Waarde.callee){
				Waarde.verwerk=Array.prototype.verwerk;
				Waarde.deval=Array.prototype.deval;
				return Waarde.deval();
			}
			return '({'+Keys(Waarde).verwerk(function(i){return Deval(i)+':'+Deval(Waarde[i])}).join(',')+'})';
	}
}

function Keys(Object){
	var Temp=[];
	for (Key in Object){Temp.push(Key)}
	return Temp;
}

//Retourneert de waarden van een object als Array
function Items(Object){
	var Temp=[];
	for (Key in Object){Temp.push(Object[Key])}
	return Temp;
}

function BekijkObject(Object,gesorteerd){return (gesorteerd?Keys(Object).sort():Keys(Object)).verwerk(function(t){
	var w;
	try{w=Object[t]}
	catch(e){w='[geen toegang]'}
	return  t+'='+w;
})}

function ObjectNaarString(o){
	return Keys(o).verwerk(function(k){
		var Waarden=o[k];
		var f=function(i){return encodeURIComponent(k)+'='+(i==_||i==u?'':(is(i,Boolean)?(i?1:0):encodeURIComponent(i)))}
		return (Waarden!=u && Waarden!=_ && Waarden.constructor===Array)?Waarden.verwerk(f).join('&'):f(Waarden);
	}).join('&');
}

//Kon dit maar via een prototype...
//Werkt voor functie argumenten, NodeLists en HTMLCollections
function NaarArray(NodeList){
	var Temp=[];
	for (var x=0;x<NodeList.length;x++) Temp.push(NodeList[x]);
	return Temp;
}

function Bestandsnaam(Lokatie){
	var Slash=Lokatie.lastIndexOf('\\');
	if (Slash==-1) Slash=Lokatie.lastIndexOf('/');
	return unescape(Lokatie.slice(Slash+1));
}

function BytesAlsString(Bytes){
	K=1024;
	if (Bytes<K) return Bytes+' Bytes';
	if (Bytes<K*K) return parseInt(Bytes/K)+' KB';
	if (Bytes<K*K*K) return (Bytes/(K*K)).afronden(2)+' MB';
	if (Bytes<K*K*K*K) return (Bytes/(K*K*K)).afronden(2)+' GB';
}

//in PaginaStart functie opnemen indien nodig
function updateLegacyArgs(){
	Lokatie.ClientArgs=location.hash.na('#').naarObject(false,'*');
	Lokatie.ServerArgs=Lokatie.ClientArgs.pagina?('pagina='+Lokatie.ClientArgs.pagina).naarObject():{};
}
;
//IE DOM garbage collection fix:
var Vuilnisbak=new function(){
	var v=this;
	var Labels={'toString':[]};//nog nakijken of toString goed wordt opgelost...
	var Reacties=[];
	v.Legen=function(){
		var x;
		for (x=0;x<Reacties.length;x++) Reacties[x].Stop();
		for (var l in Labels){
			var a=Labels[l];
			for (x=0;x<a.length;x++){
				try{
					a[x][l]=_;
				}
				catch(e){}
			}
		}
	}
	v.Markeer=function(e,l){
		if (l==u){
			if (e && !e._V){
				e._V=1;
				if (e.constructor===Reactie) Reacties.push(e);
			}
		}
		else{
			if (l in Labels) Labels[l].push(e);
			else Labels[l]=[e];
		}
	}
}

//cx=extend maar dan clean, nog uitzoeken of arrays, dates en regexps etc worden opgeschoond...
function cx(e1,l,e2){
	if (e2!==u){
		if (!is(e2,String)&&!is(e2,Number))Vuilnisbak.Markeer(e1,l);
		e1[l]=e2;
	}
	return e1;
}
;
Init=function(){
	Verwijzer=new URL(d.referrer);
	Lokatie=new URL(location.href);
	Lokatie.VirtueelDomein=leesVirtueelDomein();
	Muis={'links':1,'midden':4,'rechts':2};
	Muis.Actief=({});
	new Reactie(document,'mousedown',function(){
		switch (this.Event.button){
			case 3:
				Muis.Actief[Muis.links]=Muis.Actief[Muis.rechts]=true;
				delete Muis.Actief[Muis.midden];
			break;
			case 5:
				Muis.Actief[Muis.links]=Muis.Actief[Muis.midden]=true;
				delete Muis.Actief[Muis.rechts];
			break;
			case 6:
				Muis.Actief[Muis.midden]=Muis.Actief[Muis.rechts]=true;
				delete Muis.Actief[Muis.links];
			break;
			case 7:
				Muis.Actief[Muis.links]=Muis.Actief[Muis.midden]=Muis.Actief[Muis.rechts]=true;
			break;
			default:
				delete Muis.Actief[Muis.links];
				delete Muis.Actief[Muis.midden];
				delete Muis.Actief[Muis.rechts];
				Muis.Actief[this.Event.button]=true;
		}
	}).Start();
	new Reactie(d,'mouseup',function(){delete Muis.Actief[this.Event.button]}).Start();
	new Reactie(d,'mousemove',function(){
		Muis.x=this.Event.x;
		Muis.y=this.Event.y;
	}).Start();
	var w=window;
	w.Toets={'Actief':({}),'backspace':8,'tab':9,'formfeed':12,'enter':13,'shift':16,'ctrl':17,'alt':18,'pause':19,'capslock':20,'escape':27,'space':32,'pageup':33,'pagedown':34,'end':35,'home':36,
		'left':37,'up':38,'right':39,'down':40,'printscreen':44,'ins':45,'del':46,'wsl':91,'wsr':92,'context':93,
		'n0':96,'n1':97,'n2':98,'n3':99,'n4':100,'n5':101,'n6':102,'n7':103,'n8':104,'n9':105,'*':106,'+':107,'-':109,'.':110,'/':111,
		'f1':112,'f2':113,'f3':114,'f4':115,'f5':116,'f6':117,'f7':118,'f8':119,'f9':120,'f10':121,'f11':122,'f12':123,
		'numlock':144,'scrolllock':145,'mail':180,';':186,'=':187,',':188,'-':189,'.':190,'/':191,'`':192,'[':219,'\\l':220,']':221,'\'':222,'\\r':226};
	for (var x=48;x<58;x++){Toets[x-48]=x}
	for (var x=65;x<91;x++){Toets[String.fromCharCode(x+32)]=x} //zonder +32 in geval van Mozilla?
	new Reactie(d,'keydown',function(){Toets.Actief[this.Event.keyCode]=true}).Start();
	new Reactie(d,'keyup',function(){if (Toets.Actief[this.Event.keyCode]) delete Toets.Actief[this.Event.keyCode]}).Start();
	new Reactie(w,'blur',function(){Muis.Actief=({});Toets.Actief=({})}).Start();
	w.onload=Init.onload;
}
//LET OP! nog niet op basis van GebruikerId en AutorisatieId bepalen of een gebruiker ergens recht op heeft! (gebruiken voor stijlen e.d.)
Init.cimple = function(items, route, taalcode, GebruikerId, AutorisatieId, HomepageId, maxBreedte, jpgCompressie, Aanmeldpogingen, WachtwoordGemaild, magSchrijven) {
  if (!w.CG) new CimpleGUI();
  w.cimple = { paginas: items, route: route, taalcode: taalcode, gebruikerId: GebruikerId, autorisatieId: AutorisatieId, homePaginaId: HomepageId, magSchrijven: magSchrijven, vorigePaginaId: Lokatie.Args.pagina }; //Wordt gebruikt door CWF
  w.Body = d.E('Body');
  var pId = Lokatie.Args.pagina = route[route.length - 1], p = items[pId];
  w.WeergaveOptie = p[0];
  w.PaginaTitel = p[1];
  w.Paginanivos = p[2]; //nivo's ingesteld voor deze pagina
  w.WebsiteTitel = items[route[0]][1];
  d.titel = d.title = WebsiteTitel + ' - ' + PaginaTitel;
  w.Route = route.naarObject();
  w.MaxBreedte = maxBreedte;
  w.JPGCompressie = jpgCompressie;
  //w.nieuwsbriefActief = nieuwsbriefActief;
  CG.Aanmeldpogingen = Aanmeldpogingen;
  CG.WachtwoordGemaild = WachtwoordGemaild;
  if (CG.frontendTekst[taalcode]) Init.perPagina();
  else laadScript('/?verzoek=frontendTekst&taalcode=' + taalcode + '&sessieId=' + Client.Lees('SessieID'));
}

Init.taalReactie=function(arr){
	CG.frontendTekst[cimple.taalcode]=arr;
	Init.perPagina();
}

Init.perPagina=function(){
	if (w.CimpleEditModus) CimpleEditModus(true);
	if (w._gat){
		//Analytics site overlay
		if (location.href.bevat('/#gaso')){
			(new Image).src='/?verzoek=&legacy='+Random(6);
			alert(CG.frontendTekst(44));
			location.replace('/?pagina='+Lokatie.Args.pagina+location.hash);
		}
		//alleen pagina loggen EN alleen loggen als er naar een andere pagina is genavigeerd
		if (w.pageTracker && Lokatie.Args.pagina!=cimple.vorigePaginaId) pageTracker._trackPageview('/?pagina='+Lokatie.Args.pagina);
	}
}

//instructies waar het document voor geladen dient te zijn:
Init.onload=function(){
	var w=window;
	if (w.IEemu) IEemu();
	if (w.browserFix) browserFix();
	if (w.Start) Start();
  if (w.PaginaStart) PaginaStart();
	//BlijfWakker(60);//wordt nu in CWF afgehandeld maar dan verloopt de sessie dus als je in legacy werkt!
	new Reactie(w,'unload',function(){Vuilnisbak.Legen();if (w.GUnload) GUnload()}).Start();
}
;
/*
Koppelt standaard gedrag voor een knop aan een element
Via classes kunnen de verschillende stati worden opgemaakt (.Knop, .Knop_Over, .Knop_Neer, .Knop_Uit)
*/
function Knop(knop){
	if (!knop) return false;
	if (knop.ZetStijl) return knop;
	knop.mouseover=false;
	knop.mousedown=false;
	knop.ExclusieveModus=false;
	var StijlStatus=function(Status){
		if (!Status) Status='';
		else Status='_'+Status;
		return knop.Stijl.join(Status+' ')+Status;
	}
	var Toekennen=function(Weergave){
		if (knop.ExclusieveModus) knop.className=StijlStatus(Weergave);
		else knop.className+=' '+StijlStatus(Weergave);
	}
	cx(knop,'Render',function(){//Nog stijlen toevoegen voor Sleep en Binnen collectie: (Eerste, Laatste, Afwissel, Selectie)
		knop.className=StijlStatus();
		if (knop.disabled) Toekennen('Uit');
		else{
			if (knop.mousedown) Toekennen('Neer');
			else{
				if (knop.mouseover) Toekennen('Over');
			}
		}
		//knop.innerHTML=Vervang(knop.className,' ','<br>');//debug
	})
	cx(knop,'ZetStijl',function(){//weer public gaan ondersteunen (arguments lezen)
		var classes=knop.className.split(' ');
		knop.Stijl=[];
		for (var x=0;x<classes.length;x++){
			var multiclass=classes[x].split('_');
			var tmp=[multiclass[0]];
			for (y=1;y<multiclass.length;y++){tmp[y]=tmp[y-1]+'_'+multiclass[y]}
			knop.Stijl=knop.Stijl.concat(tmp);
		}
		knop.Render();
	})
	cx(knop,'MouseOver',new Reactie(knop,'mouseenter',function(){
		var knop=this.Object;
		knop.mouseover=true;
		knop.Render();
		this.Stop();
	}));
	cx(knop,'Focus',new Reactie(knop,'focus',function(){
		var knop=this.Object;
		knop.mouseover=true;
		knop.Render();
		this.Stop();
	}));
	cx(knop,'MouseOut',new Reactie(knop,'mouseleave',function(){
		var knop=this.Object;
		knop.mouseover=false;
		knop.mousedown=false;
		knop.Render();
		knop.MouseOver.Start();
		knop.Focus.Start();
	}));
	cx(knop,'Blur',new Reactie(knop,'blur',function(){
		var knop=this.Object;
		knop.mouseover=false;
		knop.mousedown=false;
		knop.Render();
		knop.MouseOver.Start();
		knop.Focus.Start();
	}));
	cx(knop,'MouseDown',new Reactie(knop,'mousedown',function(){
		var knop=this.Object;
		knop.mousedown=true;
		knop.Render();
	}));
	cx(knop,'MouseUp',new Reactie(knop,'mouseup',function(){
		//if (document.selection) document.selection.empty(); //dit staat voorlopig even uit ivm edit-knoppen
		var knop=this.Object;
		knop.mousedown=false;
		knop.Render();
	}));
	cx(knop,'Aan',function(){
		knop.disabled=false;
		knop.Render();
		knop.Focus.Start();
		knop.Blur.Start();
		knop.MouseOver.Start();
		knop.MouseOut.Start();
		knop.MouseDown.Start();
		knop.MouseUp.Start();
	})
	cx(knop,'Uit',function(){
		knop.disabled=true;
		knop.Render();
		knop.Focus.Stop();
		knop.Blur.Stop();
		knop.MouseOver.Stop();
		knop.MouseOut.Stop();
		knop.MouseDown.Stop();
		knop.MouseUp.Stop();
	})
	knop.ZetStijl();
	if (knop.disabled) knop.Uit(knop.Aan());
	else knop.Aan();
	return knop;
}
;//uitbreiden met Timeout en Interval events (Object=Timeout en Object=Interval, Type=msec)
//Uitbreiden met makkelijk te raadplegen muis en toetsenbord eigenschappen
//De volgorde van uitvoeren van meerdere events per type verschilt tussen IE en NS
Reactie=function(Object,Type,Functie){
	var r=this;
	var args;
	var _isActief=false;
	cx(r,'Object',Object);
	Vuilnisbak.Markeer(r);
	r.Type=Type;
	//zodat IE en NS hetzelfde reageren
	if (Type=='error' && window.onerror==u){
		tmpError=[];
		onerror=function(){
			if (arguments[2]) tmpError=[arguments[0],arguments[2]];
			else tmpError=['NS6 fout','0'];
		}//geen true returnen anders worden er geen events meer uitgevoerd door IE
	}
	var tmpFunctie=function(){
		if (r.Type=='error'){
			r.Fout=tmpError[0];
			r.Regel=tmpError[1];
		}
		if (window.event) r.Event=event;
		else{
			if (typeof arguments[0]=='object') r.Event=arguments[0];
		}
		//if (r.Event.x==u){
			Muis.x=r.Event.clientX||r.Event.pageX||0;
			Muis.y=r.Event.clientY||r.Event.pageY||0;
		//}
		var Return;
		Return=Functie.apply(r,args);
		if (Return==false&&r.Event.preventDefault) r.Event.preventDefault();
		return Return;
	};
	r.Start=function(){
		if (!_isActief){
			_isActief=true;
			args=arguments;
			if (w.IEemu) return r.Object.addEventListener(r.Type,tmpFunctie,false);
			else return r.Object.attachEvent('on'+r.Type,tmpFunctie);
		}
	}
	r.Stop=function(){
		if (_isActief){
			_isActief=false;
			if (w.IEemu) return r.Object.removeEventListener(r.Type,tmpFunctie,false);
			else return r.Object.detachEvent('on'+r.Type,tmpFunctie);
		}
	}
	r.isActief=function(){return _isActief}
}
;
/*vertaalt een URL naar een object
Wat te doen met case-sensitivity van QS keys?*/
function URL(url){
	var U=this;
	U.Kopie=function(){return new URL(U.toString())}
	U.toString=function(){
		var Protocol=U.Protocol?(U.Protocol=='unc'?'\\\\':(U.Protocol+'://')):'';
		var Domein=U.Domein?U.Domein:'';
		var Poort=U.Poort?':'+U.Poort:'';
		var Slash=Domein==''?'':'/';
		var Pad=U.Pad?U.Pad+'/':'';
		var Document=U.Document?U.Document:'';
		var Args=ObjectNaarString(U.Args);
		if (Args!='') Args='?'+Args;
		var Anker=U.Anker?'#'+U.Anker:'';
		return Protocol+Domein+Poort+Slash+Pad+Document+Args+Anker;
	}
	url=url.vervang('\\','/');
	U.Anker=url.na('#',1);//.autocast();
	url=url.tot('#',1);
	U.Args=url.na('?',1).naarObject();
	url=url.tot('?',1);
	if (url.bevat('://')){
		U.Protocol=url.tot('://');
		url=url.na('://');
		U.Domein=url.tot('/');
		if (U.Domein.bevat(':')){
			U.Poort=parseInt(U.Domein.na(':',1));
			U.Domein=U.Domein.tot(':',1);
		}
		url=url.na('/');
	}
	else{
		if (url.begintMet('//')){
			U.Protocol='unc';
			U.Domein=url.na('//').tot('/');
			url=url.na(U.Domein+'/');
		}
	}
	if (url.bevat('/')){
		U.Pad=url.tot('/',1);
		url=url.na('/',1);
	}
	U.Document=new Bestand(url);
}
;
/*
Naamgeving en interface nog aanpassen:
Client.Browser.Versie
Client.Venster.Breedte
Client.Monitor.Kleurdiepte
Client.OS.Versie
Client.IP
Client.Flash.Versie
Etc....
*/
var Client=new function(){
	var c=this,Cache,cStr,Datum=new Date,SchrijfDatum=Datum.addYears(1).toGMTString(),WisDatum=Datum.addYears(-1).toGMTString();
	c.update=function(){
		if (d.cookie!==cStr){
			var Cookies=(cStr=d.cookie).split('; ');
			Cache={};
			for (var x=0;x<Cookies.length;x++){
				var Cookie=Cookies[x].split('=');
				Cache[unescape(Cookie[0])]=unescape(Cookie[1]);
			}
		}
	}
	c.update();
	c.Schrijf=function(Label,Waarde){
		if (!is(Waarde,String)) throw 'Alleen stringwaarden toegestaan voor cookies';
		Cache[Label]=Waarde;
		d.cookie=escape(Label)+'='+escape(Waarde)+'; expires='+SchrijfDatum;
	}
	c.Lees=function(Label){return Cache[Label]||''}
	c.Wis=function(Label){
		if (Label!='SessieID'){
			d.cookie=escape(Label)+'=; expires='+WisDatum;
			delete Cache[Label];
		}
	}
	c.WisAlle=function(){
		for (var x in Cache) c.Wis(x);
		Cache={};
	}
	c.Labels=function(){return Keys(Cache)}
	c.Waarden=function(){return Items(Cache)}
}
;
/*
Vanwege het gemak wordt de functie contentLink nu ook voor spans gebruikt.
Later eventueel eerst alles verzamelen wat als extra info gedownload moet worden voor de links en dit in 1 request lezen
*/
function contentLink(a){
	if (a.tagName=='SPAN'){
		var f=w[a.className.na(' ')];
		if (f&&f.apply) f.apply(a);
		return;
	}
	if (!a.href) return;
	var isIntern=a.href.begintMet(location.protocol+'//'+location.hostname),isPagina;
	if (isIntern){
		isPagina=a.href.bevat('pagina=');
		if (isPagina) contentLink.paginaArr.push(parseInt(a.href.na('pagina='),10));
		else contentLink.documentArr.push(unescape(a.href.na('/Documenten/')));//documenten
	}
	var linkType=a.className=isPagina?'pagina':a.href.begintMet('mailto:')?'email':isIntern?'document':a.href.begintMet('javascript:')?'javascript':'extern';
	if (linkType=='document'){
		var ext=a.href.na('.',true).toUpperCase();
		a.className+=' T_'+ext;
		if (ext=='FLV'){
			a.href=contentLink.flvswf+'?open='+a.href.na(location.hostname).vanaf('/');
			a.onclick=function(){return flvp.aOnclick(a)};
		}
	}
	else if (a.href.bevat('xml=rss')) a.className='document  T_RSS';
	a.onmouseover=function(){
		a.onmouseover=_;
		switch(linkType){
			case 'pagina':
				contentLink.paginaTitel(a);
			break;
			case 'email':
				var adr=a.href.na(':');
				var t=a.innerHTML;
				a.href='mailto:'+escape(adr);
				if (a.innerHTML!=t) a.innerHTML=adr;//reactie op beveiliging
				a.title=CG.frontendTekst(16,adr);
			break;
			case 'document':
				a.target='_blank';
				contentLink.documentDetail(a);
			break;
			case 'extern':
				//alleen als expliciet is aangegeven in de editor dat ie NIET in een nieuw venster moet worden geopend (ivm automatisch gegenereerde links door plakken)
				if (a.target!='_self') a.target='_blank';
				a.title='open '+(a.href.na('//').trimEind('/'));
			break;
			case 'javascript':
				a.onclick=new Function(a.href.na(':')+';return false');
				a.href='klik:';
			break;
		}
		if (a.target=='_blank') a.title+=' \n'+CG.frontendTekst(22);
	}
};
contentLink.paginaArr=[];
contentLink.paginas={};
contentLink.paginaTitel=function(a){
	var aanwezig=parseInt(a.href.na('pagina='),10) in contentLink.paginas;
	if (!aanwezig && contentLink.paginaArr.length>0) new HTTPVerzoek('/?Verzoek=PaginaInfo',{paginas:contentLink.paginaArr.join(',')},function(){
			contentLink.paginaArr.length=0;
			X(contentLink.paginas,this.Respons);
			contentLink.paginaTitelBijwerken(a);
		}).Start();
	else contentLink.paginaTitelBijwerken(a);
};
contentLink.paginaTitelBijwerken=function(a){
	var titel=contentLink.paginas[parseInt(a.href.na('pagina='),10)];
	switch (titel){
		case _:
			a.className+=' dood';
			a.title=CG.frontendTekst(23);
		break;
		case $:
			a.className+=' dood';//nog class verzinnen
			a.title=CG.frontendTekst(24);
		break;
		default:
			a.title=CG.frontendTekst(17)+' '+CG.frontendTekst(20)+' \''+titel+'\''+a.title+(a.href.bevat('xml=rss')?'\n'+CG.frontendTekst(21):'');
	}
};
contentLink.flvswf='/Backend/SWF/FLVplayer.swf';
contentLink.documentArr=[];
contentLink.documenten={};
contentLink.documentDetail=function(a){
	var aanwezig=unescape(a.href.na('/Documenten/')) in contentLink.documenten;
	if (!aanwezig && contentLink.documentArr.length>0) new HTTPVerzoek('/?Verzoek=BestandInfo',{documenten:contentLink.documentArr.join('\n')},function(){
			contentLink.documentArr.length=0;
			X(contentLink.documenten,this.Respons);
			contentLink.documentDetailBijwerken(a);
		}).Start();
	else contentLink.documentDetailBijwerken(a);
};
contentLink.documentDetailBijwerken=function(a){
	if (!a.href.bevat('/Documenten/')) return;
	var bytes=contentLink.documenten[unescape(a.href.na('/Documenten/'))];
	if (bytes==_){
		if (!w.CimpleProxy){//uit zolang er geen alternatief is
			a.className+=' dood';
			a.title=CG.frontendTekst(23);
		}
	}
	else{
		var isFLV=a.href.na('.',true).toUpperCase()=='FLV';
		a.title=(isFLV?CG.frontendTekst(19):CG.frontendTekst(17)+' '+CG.frontendTekst(18))+' \n\''+Bestandsnaam(a.href)+'\' ('+BytesAlsString(bytes)+')'+a.title;//+(isFLV?$:' \nin een nieuw venster');
		//zou interessant zijn als we hier de speelduur van de FLV konden bepalen... Indexing Service plug-in? Kan via ActionScript...
	}
};
;
/*TODO:
Echte events genereren
ServerThread UITFASEREN!!! alleen nog UploadThread vervangen door Bestandskeuze
(en op termijn kijken in hoeverre XMLrequest gebruikt kan worden)*/
HTTPVerzoek=function(pURL,POST,pReactie,pTimeout){
	var vrz=this,eFrames=HTTPVerzoek.eFrames();
	if (!pURL){
		pURL=Lokatie.Kopie();
		if (Lokatie.ServerArgs) X(pURL.Args,Lokatie.ServerArgs);
	}
	vrz.URL=pURL;
	vrz.POST=POST?POST:{};//Form element danwel Object
	if (pReactie) vrz.Reactie=pReactie;
	if (pTimeout) vrz.Timeout=pTimeout;
	var TimeoutPointer;
	var IFRAME;
	vrz.isActief=function(){return IFRAME!=u}
	//uiteindelijk server-side te raadplegen als bijv: Do While Not Verzoek.isGeannuleerd
	vrz.Annuleer=function(){
		this.isGeannuleerd=true;
		Stop();
	}
	var Timeout=function(){
		vrz.TimedOut=true;
		Stop();
	}
	var Stop=function(){
		clearTimeout(TimeoutPointer);
		if (!vrz.TimedOut && !vrz.isGeannuleerd){
			try{
				var Respons=IFRAME.contentWindow.document.body;
				switch(Respons.innerHTML){
					case '@': vrz.Respons=eval(unescape(Respons.id));break;
					case '$': vrz.Respons=unescape(Respons.id).autocast();break;
					case '!': vrz.Respons=_;vrz.Fout=true;f=eval(unescape(Respons.id));window.onerror(f[0],f[1],f[2],f[3],f[4]);break;
					default: vrz.Respons=Respons.innerHTML.autocast();
				}
				if (vrz.Respons=='SESSIEFOUT'){
					alert([
						'Uw sessie is verlopen.',
						'Dit kan bijvoorbeeld zijn veroorzaakt doordat uw computer',
						'gedurende langere tijd in standby-modus heeft gestaan of',
						'doordat u langere tijd geen internet verbinding heeft gehad.',
						'',
						'Uw browser wordt nu ververst.'
					].join('\n'));
					location.reload();
				}
			}
			catch(e){
				//toegang geweigerd op IFRAME.contentWindow.document.body.
				//nog bepalen wat we hiermee doen aangezien het niet bekend is wanneer dit optreedt.
			}
		}
		IFRAME.detachEvent('onload',Stop);
		if (vrz.TimedOut||vrz.isGeannuleerd) IFRAME.src='about:blank';
		var tmpIFRAME=IFRAME;//want IFRAME wordt in een andere thread overschreven
		IFRAME=u;
		setTimeout(function(){
			try{eFrames.removeChild(tmpIFRAME)}
			catch(e){}
		},1000);
		if (vrz.Reactie) vrz.Reactie();
		vrz.TimedOut=vrz.isGeannuleerd=vrz.Fout=false;
	}
	this.Start=function(vf,vs){
		if (vrz.URL.constructor!==URL) vrz.URL=new URL(vrz.URL);
		//vrz.URL.Args.cwf=1;//hoeft niet
		Client.update();
		vrz.URL.Args.sessieId=Client.Lees('SessieID');//XSRF beveiliging
		var vfIsf=is(vf,Function);
		var ID=Random(8);
		if (vfIsf) vrz.URL.Args.VerzoekID=ID;
		if (IFRAME) Stop();
		IFRAME=d.cE('IFRAME');
		/* maar weer uitgeschakeld omdat in Chrome de event anders niet wordt getriggerd
		
		if (w.Opera||w.Safari) IFRAME.attachEvent('onload',function(){//triggeren het onload event bij aanmaken
			IFRAME.detachEvent('onload',arguments.callee);
			IFRAME.attachEvent('onload',Stop);
		});
		else */
		IFRAME.attachEvent('onload',Stop);//cross-browser dankzij Mozilla.js
		if (isLeeg(vrz.POST)){
			IFRAME.src=vrz.URL.toString();
			if (IFRAME.src.begintMet('?')) IFRAME.src='/'+IFRAME.src;//quick fix
			eFrames.appendChild(IFRAME);
		}
		else{
			var isF=vrz.POST.tagName && vrz.POST.tagName.toLowerCase()=='form';
			var f=isF?vrz.POST:d.cE('FORM');
			f.method='post';
			f.action=vrz.URL;
			if (!isF){
				for (var n in vrz.POST){
					POSTarr=vrz.POST[n];
					if (!isArray(POSTarr)) POSTarr=[POSTarr];
					for (var t=0;t<POSTarr.length;t++){
						var v=POSTarr[t];
						if (typeof v=='boolean') v=v?1:0;
						else{
							if (v==_||v==u) v='';	
						}
						var e=d.cE('textarea');
						e.name=n;
						e.value=v;
						f.appendChild(e);
					}
				}
			}
			eFrames.appendChild(IFRAME);
			f.target=IFRAME.contentWindow.name='W'+ID;
			if (isF) f.submit();//mag in IE6 niet (Access is denied) nadat f.reset() een keer is uitgevoerd
			else{
				eFrames.appendChild(f);
				f.submit();
				eFrames.removeChild(f);
			}
		}
		if (vrz.Timeout) TimeoutPointer=setTimeout(Timeout,vrz.Timeout);
		if (vfIsf){
			if (vs==u) vs=3;
			var sw=new Stopwatch;
			var v={'ID':ID};
			var url=Lokatie.Kopie();
			url.Args={Verzoek:'LeesVoortgang',VerzoekID:ID};
			var mvv=new HTTPVerzoek(url,_,function(){
				v.AantalTotaal=this.Respons?this.Respons[1]:1;
				if (vrz.isActief()){
					v.AantalVerwerkt=this.Respons[0];
					setTimeout(mvv.Start,vs*1000);
				}
				else v.AantalVerwerkt=v.AantalTotaal;
				v.SecondesVerstreken=sw.Sec();
				v.AantalResterend=v.AantalTotaal-v.AantalVerwerkt;
				v.AantalPerSeconde=parseInt(v.AantalVerwerkt/v.SecondesVerstreken);
				v.SecondesResterend=parseInt(v.AantalResterend/v.AantalPerSeconde);
				v.Percentage=parseInt(v.AantalVerwerkt/v.AantalTotaal*100);
				vf.apply(v);
			})
			setTimeout(function(){if (vrz.isActief()) mvv.Start()},2000);//effe afwachten...
		}
	}
}

HTTPVerzoek.eFrames=function(){
	var e=d.cE('DIV');
	eFrames=function(){return e};
	e.style.display='none';
	return d.body.appendChild(e);
}
;Bestandskeuze=function(eKlik){
	var f=d.cE('form');
	f.encoding='multipart/form-data';
	f.className='Bestandskeuze';
	f.style.width=eKlik.offsetWidth+'px';
	f.style.height=eKlik.offsetHeight+'px';
	f.title=eKlik.title;
	var pos=eKlik.style.position;
	eKlik.style.position='absolute';
	f.style.left=eKlik.offsetLeft+'px';
	f.style.top=eKlik.offsetTop+'px';
	eKlik.style.position=pos;
	new Reactie(f,'mouseover',function(){eKlik.focus()}).Start();//in function wrappen want wordt ge-applyed op Reactie object
	new Reactie(f,'mouseout',function(){eKlik.blur()}).Start();
	var eOuder=eKlik.parentNode;
	var eFile=d.cE('input');
	eFile.name=eFile.type='file';
	f.appendChild(eFile);
	eOuder.appendChild(f);
	var bk=this;
	new Reactie(eFile,'change',function(){
		bk.Keuze=new URL(this.Object.value);
		if (bk.KeuzeEvent) bk.KeuzeEvent();
	}).Start();
	this.Overdracht=function(URL,Reactie,Timeout){
		var o=new HTTPVerzoek(URL,f,Reactie,Timeout);
		o.Bestand=this.Keuze;
		return o;
	}
	this.Reset=f.reset;//in IE6 kan het formulier niet meer worden gesubmit na deze aanroep (Access is denied)
}
;function sleep(e,eHandvat){
	var s=sleep,eAfm=d.dE.clientWidth?d.dE:d.body;
	if (!eHandvat) eHandvat=e;
	if (!s.moveReactie){
		s.moveReactie=new Reactie(d,'mousemove',function(){
			if (d.selection) d.selection.empty();
			if(Muis.x<0||Muis.y<0||Muis.x>eAfm.clientWidth||Muis.y>eAfm.clientHeight) return s.stopSleep();
			s.e.style.left=(Muis.x-s.offsetX)+'px';
			s.e.style.top=(Muis.y-s.offsetY)+'px';
		});
		s.stopSleep=function(){
			zetClassUit(s.e,'sleep');
			s.moveReactie.Stop();
			s.stopMoveReactie.Stop();
			s.verlaatBodyReactie.Stop();
		}
		s.stopMoveReactie=new Reactie(d,'mouseup',s.stopSleep);
		s.verlaatBodyReactie=new Reactie(d.body,'mouseleave',s.stopSleep);
	}
	new Reactie(eHandvat,'mousedown',function(){
		s.e=e;
		zetClassAan(e,'sleep');
		e.style.left=e.offsetLeft+'px';
		e.style.top=e.offsetTop+'px';
		s.offsetX=Muis.x-e.offsetLeft;
		s.offsetY=Muis.y-e.offsetTop;
		s.moveReactie.Start();
		s.stopMoveReactie.Start();
		s.verlaatBodyReactie.Start();
	}).Start();
};//Later ontvangers uitlezen
foutje=onerror=function(Description,URL,Line,Column,File){
	try{
		var foutId=Line+Description;
		if (Lokatie.Domein==Lokatie.VirtueelDomein&&!foutje.reedsGerapporteerd[foutId]){//geen meldingen van search cache
			foutje.reedsGerapporteerd[foutId]=true;
			//window.onerror=null;
			new Mail(
				'fout@'+Lokatie.Domein.vervang('www.'),'cref@cipix.nl,toon@cipix.nl,maarten@cipix.nl',_,_,
				'Fout: Cimple 3.5 - '+(File?File:'JavaScript')+' regel '+Line+(Column?', kolom '+Column:'')+': '+Description.tot('\n'),
				'<div style="font-family:Tahoma;font-size:8pt">'+
					Description.vervang('\n','<br>')+'<br>'+
					'<a href="'+location.href+'"> '+location.href+'</a><br>'+
					navigator.userAgent+'<br>'+
					'CimpleEditModus: '+(!!w.CimpleEditModus)+'<br><br>'+
					(document.cookie||'GEEN COOKIES!!!')+'<br><br>'+
					BekijkObject(foutje.info).join('<br>')+
				'</div>'
				,true
			).Verstuur();
			return true;
		}
	}
	catch(e){}
};
foutje.info={};
foutje.reedsGerapporteerd={};//let op! wordt gereset na browser refresh, gaat dus uit van navigatie via CWF

;
/*
Dit is een aanzet. Uiteindelijk moet de GUI vanuit deze class worden gerenderd en bestuurd.
Ook alle editing zaken moeten onderdeel van deze class worden.
ActieveGebruiker wordt een subclass en rechten worden zo toegepast.
*/
function CimpleGUI(){
	w.CG=this;
	//zorgt voor het aan/uit zetten van de knoppen afhankelijk van de gebruikersnaam
	CG.CheckAanmeldKnoppen=function(){
		if (d.E('CimpleGebruikersnaam').value.trim().isLeeg()){
			zetStatus(d.E('CimpleAanmelden'),false);
			zetStatus(d.E('CimpleMailWachtwoord'),false);
			return false;
		}
		else{
			if (CG.Aanmeldpogingen<3) zetStatus(d.E('CimpleAanmelden'),true);
			if (!CG.WachtwoordGemaild) zetStatus(d.E('CimpleMailWachtwoord'),true);
			return true;
		}
	};
	var leesTekst=function(args){
		var r=args.callee[cimple.taalcode][args[0]];
		//alert(Deval(args)+'\n'+r);
		for (var n=1;n<args.length;n++) r=r.vervang('['+(n-1)+']',args[n]);
		return r;
	};
	CG.frontendTekst=function(n){return leesTekst(arguments)};
	CG.cimpleTekst=function(n){return leesTekst(arguments)};
	var login=function(){return !!CG.Aanmelden(d.E('CimpleGebruikersnaam').value,d.E('CimpleWachtwoord').value)};
	var LoginBalk;
	function maakLoginBalk(){
		return bouw('div#CimpleLoginBalk',_,[
			['form#CimpleForm',{onsubmit:login},[
				['table',{width:'100%'},[['tbody',_,[
					['tr',_,[
						['input',{type:'submit'}],//staat hier ivm IE gedrag
						['td',_,[['img',{src:'/Backend/GIF/Iconen/Klein/Cimple.gif'}]]],
						['td.GUI',{nowrap:true},[['b',_,'Cimple 3.5 - '+CG.frontendTekst(27)+' :']]],
						['td.GUI',{nowrap:true},[['span',_,CG.frontendTekst(25)+':'],['input#CimpleGebruikersnaam',{type:'text',maxlength:32,onkeyup:CG.CheckAanmeldKnoppen}]]],
						['td.GUI',{nowrap:true},[['span',_,CG.frontendTekst(26)+':'],['input#CimpleWachtwoord',{type:'password',maxlength:32}]]],
						['td',{nowrap:true},[
							['a#CimpleAanmelden.cimple-button',{onclick:login},[['span.GUI',{style:{backgroundImage:'url(/Backend/GIF/Iconen/Klein/OK.gif)'}},CG.frontendTekst(27)]]],
							['a#CimpleMailWachtwoord.cimple-button',{onclick:function(){CG.WachtwoordMailen(Trim(d.E('CimpleGebruikersnaam').value))}},[['span.GUI',{style:{backgroundImage:'url(/Backend/GIF/Iconen/Klein/Mail.gif)'}},CG.frontendTekst(29)]]],
							['a#CimpleAnnuleerAanmelden.cimple-button',{onclick:function(){CG.DeactiveerAanmelden()}},[['span.GUI',{style:{backgroundImage:'url(/Backend/GIF/Iconen/Klein/Annuleren.gif)'}},CG.frontendTekst(30)]]]
						]]
					]]
				]]]]
			]]
		]);
		CG.CheckAanmeldKnoppen();
	}
	CG.ActiveerAanmelden=function(Gebruikersnaam){
		wincReactie.Stop();
		Snd('/Backend/WAV/2.wav');
		if (!LoginBalk) LoginBalk=maakLoginBalk();
		d.body.insertBefore(LoginBalk,d.body.firstChild);
		d.E('CimpleWachtwoord').value='';
		if (Gebruikersnaam){
			d.E('CimpleGebruikersnaam').value=Gebruikersnaam;
			d.E('CimpleWachtwoord').focus();
		}
		else{
			d.E('CimpleGebruikersnaam').value='';
			d.E('CimpleGebruikersnaam').focus();
		}
		CG.CheckAanmeldKnoppen();
	}
	//CG.ActiveerAanmelden=function(Gebruikersnaam){alert('Tijdelijk niet beschikbaar')}
	CG.DeactiveerAanmelden=function(){d.body.removeChild(LoginBalk);wincReactie.Start()}
	CG.Aanmelden=function(Gebruikersnaam,Wachtwoord,Onthouden){
		laadScript('/Backend/JS/Opties/TEA.js',function(){
			if (!w.TEAencrypt) return false;
			var verzoek=new HTTPVerzoek;
			X(verzoek.URL.Args,{
				Verzoek:'cimpleLogin',
				hash:TEAencrypt(Gebruikersnaam.trim()+'\n'+Wachtwoord.trim(),Client.Lees('SessieID')),
				onthouden:Onthouden
			});
			verzoek.Reactie=function(){
				if (this.Fout) return false;//nog wat meer mee doen...
				if (isNaN(this.Respons)){
					CG.AanmeldenMislukt(Gebruikersnaam=='cipix'?this.Respons:null);
					CG.CheckAanmeldKnoppen();
				}
				else{
					//if (Onthouden) Client.Schrijf('CimpleGebruikerID',gId);//gebeurt nu serverside, nu wordt alleen homepageId geretourneerd
					if (CG.AanmeldReactie) CG.AanmeldReactie(this.Respons);
					else location.reload();
				}
			};
			verzoek.Start();
		});
	}
	CG.Afmelden=function(){this.Aanmelden('','',true)}
	CG.AanmeldenMislukt=function(Reden){
		CG.Aanmeldpogingen++;
		var Melding=CG.frontendTekst(31)+'.';//1
		if (CG.Aanmeldpogingen<3) Melding+='\n\n'+CG.frontendTekst(32)+'.';
		if (CG.Aanmeldpogingen==2) Melding+='\n\n1 '+CG.frontendTekst(33)+'.';//2
		if (CG.Aanmeldpogingen>2){
			zetStatus(d.E('CimpleAanmelden'),false);
			CG.Aanmelden=CG.AanmeldenMislukt;
			Melding+='\n\n'+CG.frontendTekst(34)+'.';
			//if (isClassAan(d.body,'login')) Melding+='\n\nIndien u uw wachtwoord bent vergeten kunt u\nde knop \''+Trim(d.E('CimpleMailWachtwoord').innerText)+'\' gebruiken.';
		}
		alert(Melding);
		if (Reden) alert(Reden);
		if (LoginBalk && LoginBalk.style.display=='block') d.E('CimpleWachtwoord').focus();
	}
	CG.WachtwoordMailen=function(Gebruikersnaam){
		var verzoek=new HTTPVerzoek;
		verzoek.URL.Args.Verzoek='cimpleMailWachtwoord';
		verzoek.POST.CimpleGebruikersnaam=Gebruikersnaam.trim();
		verzoek.Reactie=function(){
			if (this.Respons){
				alert(CG.frontendTekst(35));
				d.E('CimpleGebruikersnaam').focus();
			}
			else{
				zetStatus(d.E('CimpleMailwachtwoord'),false);
				CG.WachtwoordGemaild=true;
				alert(CG.frontendTekst(36));
				d.E('CimpleWachtwoord').focus();
			}
		}
		verzoek.Start();
	}
	CG.Zoek=function(id){
		laadArgs({pagina:id,zoek:d.E('ZoekVeld').value.trim()},true);
		if (!w.CimpleProxy) d.E('ZoekKnop').disabled=true;
		return false;
	}
	var wincReactie=new Reactie(document,'keyup',function(){
		if ((Toets.Actief[Toets.wsl]||Toets.Actief[Toets.wsr]) && this.Event.keyCode==w.Toets.c) CG.ActiveerAanmelden();
	});
	wincReactie.Start();
}

function Par(e){
	if (CG.OpenPar) CG.OpenPar.className=CG.OpenPar.className.vervang(' Open');
	e.className += ' Open';
	cx(CG,'OpenPar',e);
}

function laadArgs(argsObj,force){
	p=argsObj.pagina||Lokatie.Args.pagina;
	var argsObjKopie=X({},argsObj);//voor de zekerheid een kopietje want argsObj zou ergens anders ook nog gebruikt kunnen worden
	delete argsObjKopie.pagina;
	argsObjKopie=ObjectNaarString(argsObjKopie);
	var hash='#pagina='+p+(argsObjKopie?'&'+argsObjKopie:'');
	location.hash=hash+(force&&(location.hash.bevat('*')?location.hash.tot('*'):location.hash)==hash?'&':'');
}
function openPagina(id,force){laadArgs({pagina:id},force)}
function gaNaar(id){try{(d.E(id)||d.EN(id)[0]).scrollIntoView()}catch(e){}}
function LinkOver(e){/*depracated*/}
;//http://webfx.eae.net/dhtml/ieemu/

//Mozilla (Gecko engine) gebaseerde browsers zoals Firefox en Netscape compatible maken met IE
//wordt ook door WebKit based browsers uitgevoerd maar die ondersteunen geen prototype uitbreiding op DOM objecten :(
function IEemu(){
	extendEventObject();
	emulateEventHandlers('click','dblclick','mouseover','mouseout','mousedown','mouseup','mousemove','mouseenter','mouseleave','keydown','keypress','keyup');
	emulateAttachEvent();
	emulateAllModel();
	emulateElement()
	emulateCurrentStyle();
	emulateHTMLModel();
}

//nodig ivm buggy IE DOM
function cx(e1,l,e2){if (e1) e1[l]=e2;return e1}

//Extends the event object with srcElement,cancelBubble,returnValue,fromElement and toElement
function extendEventObject() {
	Event.prototype.__defineSetter__('returnValue',function (b) {
		if (!b) this.preventDefault();
		return b;
	});

	Event.prototype.__defineSetter__('cancelBubble',function (b) {
		if (b) this.stopPropagation();
		return b;
	});

	Event.prototype.__defineGetter__('srcElement',function () {
		var node=this.target;
		while (node.nodeType != 1) node=node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__('fromElement',function () {
		var node;
		if (this.type == 'mouseover')
			node=this.relatedTarget;
		else if (this.type == 'mouseout')
			node=this.target;
		if (!node) return;
		while (node.nodeType != 1) node=node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__('toElement',function () {
		var node;
		if (this.type == 'mouseout')
			node=this.relatedTarget;
		else if (this.type == 'mouseover')
			node=this.target;
		if (!node) return;
		while (node.nodeType != 1) node=node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__('offsetX',function () {
		return this.layerX;
	});
	Event.prototype.__defineGetter__('offsetY',function () {
		return this.layerY;
	});
}

//Emulates element.attachEvent as well as detachEvent
function emulateAttachEvent() {
	HTMLDocument.prototype.attachEvent=HTMLElement.prototype.attachEvent=function (sType,fHandler) {
		var shortTypeName=sType.replace(/on/,'');
		fHandler._ieEmuEventHandler=function (e) {
			window.event=e;
			return fHandler();
		};
		this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
	};
	HTMLDocument.prototype.detachEvent=HTMLElement.prototype.detachEvent=function (sType,fHandler) {
		var shortTypeName=sType.replace(/on/,'');
		if (typeof fHandler._ieEmuEventHandler == 'function') this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
		else this.removeEventListener(shortTypeName,fHandler,true);
	};
}

//This function binds the event object passed along in an event to window.event
function emulateEventHandlers() {
	for (var i=0; i<arguments.length; i++) {
		document.addEventListener(arguments[i],function (e) {
			window.event=e;
		},true);	//using capture
	}
	//vanaf hier: eigen shit! :) over en out worden alleen getriggered als er zich daadwerkelijk zichtbare pixels onder de cursor bevinden en als de cursor de pixel niet 'overslaat'
	d.addEventListener('mouseover',function (e) {
		if (d._eEnter!==e.srcElement){
			d._eEnter=e.srcElement;
			//d._eEnter.fireEvent('onmouseenter');
			HTMLElement.prototype.fireEvent.apply(d._eEnter,['onmouseenter']);//WebKit heeft HTMLElement.prototype.fireEvent niet toegepast
		}
	},true);
	d.addEventListener('mouseout',function (e) {
		if (d._eLeave!==e.srcElement){
			d._eLeave=e.srcElement;
			//d._eLeave.fireEvent('onmouseleave');
			HTMLElement.prototype.fireEvent.apply(d._eLeave,['onmouseleave']);//WebKit heeft HTMLElement.prototype.fireEvent niet toegepast
		}
	},true);
}
// mimic the "createEventObject" method for the d object
d.createEventObject=HTMLDocument.prototype.createEventObject = function() {
	return d.createEvent("Events");
};
// mimic the "createEventObject" method
HTMLElement.prototype.createEventObject = function() {
	return this.ownerDocument.createEventObject();
};
// mimic the "fireEvent" method
HTMLElement.prototype.fireEvent = function($name, $event) {
	if (!$event) $event = this.ownerDocument.createEventObject();
	$event.initEvent($name.slice(2), false, false);
	this.dispatchEvent($event);
	// not sure that this should be here??
	if (typeof this[$name] == "function") this[$name]();
	else if (this.getAttribute($name)) eval(this.getAttribute($name));
};

//Simple emulation of document.all this one is far from complete. Be cautious
function emulateAllModel() {
	var allGetter=function () {
		var a=this.getElementsByTagName('*');
		var node=this;
		a.tags=function (sTagName) {
			return node.getElementsByTagName(sTagName);
		};
		return a;
	};
	HTMLDocument.prototype.__defineGetter__('all',allGetter);
	HTMLElement.prototype.__defineGetter__('all',allGetter);
}

function emulateElement() {
	HTMLElement.prototype.__defineGetter__('parentElement',function () {
		if (this.parentNode == this.ownerDocument) return null;
		return this.parentNode;
	});

	HTMLElement.prototype.__defineGetter__('children',function () {
		var tmp=[];
		var j=0;
		var n;
		for (var i=0; i<this.childNodes.length; i++) {
			n=this.childNodes[i];
			if (n.nodeType == 1) {
				tmp[j++]=n;
				if (n.name) {	//named children
					if (!tmp[n.name])
						tmp[n.name]=[];
					tmp[n.name][tmp[n.name].length]=n;
				}
				if (n.id)		//child with id
					tmp[n.id]=n
			}
		}
		return tmp;
	});

	HTMLElement.prototype.contains=function (oEl) {
		if (oEl == this) return true;
		if (oEl == null) return false;
		return this.contains(oEl.parentNode);
	};
}

function emulateCurrentStyle() {
	HTMLElement.prototype.__defineGetter__('currentStyle',function () {
		return this.ownerDocument.defaultView.getComputedStyle(this,null);
		/*
		var cs={};
		var el=this;
		for (var i=0; i<properties.length; i++) {
			cs.__defineGetter__(properties[i],encapsulateObjects(el,properties[i]));
		}
		return cs;
		*/
	});
}

function emulateHTMLModel() {
	//This function is used to generate a html string for the text properties/methods
	//It replaces '\n' with '<BR'> as well as fixes consecutive white spaces
	//It also repalaces some special characters
	function convertTextToHTML(s) {
		s=s.toString().replace(/\&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\n/g,'<BR>');
		while (/\s\s/.test(s))
			s=s.replace(/\s\s/,'&nbsp; ');
		return s.replace(/\s/g,' ');
	}

	HTMLElement.prototype.insertAdjacentHTML=function (sWhere,sHTML) {
		var df;	//DocumentFragment
		var r=this.ownerDocument.createRange();

		switch (String(sWhere).toLowerCase()) {
			case 'beforebegin':
				r.setStartBefore(this);
				df=r.createContextualFragment(sHTML);
				this.parentNode.insertBefore(df,this);
				break;

			case 'afterbegin':
				r.selectNodeContents(this);
				r.collapse(true);
				df=r.createContextualFragment(sHTML);
				this.insertBefore(df,this.firstChild);
				break;

			case 'beforeend':
				r.selectNodeContents(this);
				r.collapse(false);
				df=r.createContextualFragment(sHTML);
				this.appendChild(df);
				break;

			case 'afterend':
				r.setStartAfter(this);
				df=r.createContextualFragment(sHTML);
				this.parentNode.insertBefore(df,this.nextSibling);
				break;
		}
	};

	HTMLElement.prototype.__defineSetter__('outerHTML',function (sHTML) {
	   var r=this.ownerDocument.createRange();
	   r.setStartBefore(this);
	   var df=r.createContextualFragment(sHTML);
	   this.parentNode.replaceChild(df,this);

	   return sHTML;
	});

	HTMLElement.prototype.__defineGetter__('canHaveChildren',function () {
		switch (this.tagName) {
			case 'AREA':
			case 'BASE':
			case 'BASEFONT':
			case 'COL':
			case 'FRAME':
			case 'HR':
			case 'IMG':
			case 'BR':
			case 'INPUT':
			case 'ISINDEX':
			case 'LINK':
			case 'META':
			case 'PARAM':
				return false;
		}
		return true;
	});

	HTMLElement.prototype.__defineGetter__('outerHTML',function () {
		var attr,attrs=this.attributes;
		var str='<' + this.tagName;
		for (var i=0; i<attrs.length; i++) {
			attr=attrs[i];
			if (attr.specified)
				str += ' ' + attr.name + '="' + attr.value + '"';
		}
		if (!this.canHaveChildren)
			return str + '>';

		return str + '>' + this.innerHTML + '</' + this.tagName + '>';
	});

	HTMLElement.prototype.__defineSetter__('innerText',function (sText) {
		this.innerHTML=convertTextToHTML(sText);
		return sText;
	});

	var tmpGet;
	HTMLElement.prototype.__defineGetter__('innerText',tmpGet=function () {
		var r=this.ownerDocument.createRange();
		r.selectNodeContents(this);
		return r.toString();
	});

	HTMLElement.prototype.__defineSetter__('outerText',function (sText) {
		this.outerHTML=convertTextToHTML(sText);
		return sText;
	});
	HTMLElement.prototype.__defineGetter__('outerText',tmpGet);

	HTMLElement.prototype.insertAdjacentText=function (sWhere,sText) {
		this.insertAdjacentHTML(sWhere,convertTextToHTML(sText));
	};
}
;//alleen voor browsers die geen behaviors ondersteunen (zoals Opera)
function behave(){
	var divs=Venster.getElementsByTagName('div');
	for (var x=0;x<divs.length;x++){
		var div=divs[x];
		if (div.className.begintMet('Paragraaf_Tekst')){
			behave.contentLink(div,'a');
			behave.contentLink(div,'span');
		}
	}
}
behave.contentLink=function(div,tn){
	var as=div.getElementsByTagName(tn);
	for (var y=0;y<as.length;y++) contentLink(as[y])
}
;