var chkIsCompat = !document.compatMode || document.compatMode == "BackCompat";
document.write('<style>' +
'.chkhr {border:0;color:#000;background-color:#000;height:1px;margin:0 2px;}' +
'.chklst {' +
' overflow:auto; border:1px solid black; height:10em; cursor:default;' +
' background:window; z-index:9998;position:absolute' +
'}' +
'.chkpos {' +
' float:left; vertical-align:middle;' +
'}' +
'.chkchk {' +
' border:1px solid threedshadow; padding:1px; margin-left:2px;' +
'}' +
'.chktxt {' +
(chkIsCompat ? 'width:100%;' : '') + 'overflow:hidden; white-space:nowrap; padding-left:5px' +
'}' +
'.inn {' +
//' font-size:100%;' +
' border:0; margin:0; padding-left:1px;' +
'}' +
'.incb {' +
' height:1em; padding-top:25%; padding-bottom:25%;' +
'}' +
/*
'.incbi {' +
//' height:1em;' +
' display:inline-block;' +
' background-color:threedface;padding:0 3px;' +
' border-right:1px solid black; border-bottom:1px solid threeddarkshadow;' +
' border-left:1px solid threedlightshadow; border-top:1px solid threedlightshadow;' +
' cursor:default;' +
//' margin:1px;' +
//' height:expression(parentElement.offsetHeight)' +
'}' +
*/
'.incbi1 {' +
' display:inline-block;' +
' white-space:nowrap;' +
' border-right:1px solid threeddarkshadow; border-bottom:1px solid threeddarkshadow;' +
' border-left:1px solid threedlightshadow; border-top:1px solid threedlightshadow;' +
' cursor:default;' +
' vertical-align:-1px;' +
'}' +
'.incbim {' +
//' vertical-align:top;' +
//' margin: 2px 0px 2px 0px;' +
//' position: relative; left: 0; xfloat:right;' +
'}' +
'.incbi2 {' +
' display:inline-block;' +
' white-space:nowrap;' +
' background-color:threedface;padding:0 3px;' +
' border-right:1px solid threedshadow; border-bottom:1px solid threedshadow;' +
' border-left:1px solid threedhighlight; border-top:1px solid threedhighlight;' +
' cursor:default;' +
'}' +
'.chklih { background-color:highlight; color:highlighttext }' +
'.chkun { width:7px; font-size:7px; line-height:7px; vertical-align:middle; }'+
'SPAN.chkun {padding:0 2px 0 3px; }'+
(window.chklstStyle ||
('.inb1 {' +
//' background-color:red;' +
' border-left:1px solid threedshadow; border-top:1px solid threedshadow;' +
' border-right:1px solid threedhighlight; border-bottom:1px solid threedhighlight;' +
'}' +
'.inb2 {' +
' border-left:1px solid threeddarkshadow; border-top:1px solid threeddarkshadow;' +
' border-right:1px solid threedlightshadow; border-bottom:1px solid threedlightshadow;' +
//' width: 50%; margin-right: 200px;' +
'}')) +
'</style>');

var chklstCurOpen;

function chkcls(e, cn, newstate) {
	var cls = e.className.split(" ");
	var ncls = [];
	for (var i = 0; i < cls.length; i++)
		if (cls[i] != cn)
			ncls[ncls.length] = cls[i];
	if (newstate)
		ncls[ncls.length] = cn;
	e.className = ncls.join(" ");
}
function chklstSetScrollTop(lst, idx) {
	var cs = lst.children || lst.childNodes
	var st = lst.scrollTop;
	var cot = lst.ch ? lst.ch * idx : cs[idx].offsetTop, coh = lst.ch || cs[idx].offsetHeight;
	if (cot == -1 || coh == 0) {
		setTimeout(function(){chklstSetScrollTop(lst, lst.idx);},50);
		return;
	}
	var oh = lst.oh || lst.offsetHeight;
	if (cot < st)
		lst.scrollTop = cot;
	else if (cot + coh - st > oh)
		lst.scrollTop = cot + coh - Math.floor(oh / coh) * coh;
}
function chklstset(lst, idx, ftlen, noval, nofocus) {
	lst.ftlen = ftlen;
	var cs = lst.children || lst.childNodes
	var isinit = lst.idx == -1;
	if (idx != lst.idx) {
		if (lst.idx >= 0)
			chkcls(lst.totext(cs[lst.idx]), "chklih", 0);
		var ct = lst.totext(cs[idx]);
		if (!ct)
			return true;
		chkcls(ct, "chklih", 1);
		if (lst.multi && !nofocus && !window.chknofocus) {
			ct.tabIndex = "0";
			if (ct.focus)
				ct.focus();
		}
		//var t = lst.childNodes[idx].offsetTop + lst.childNodes[idx].offsetHeight;
		//window.status="t+h="+t+" h="+lst.offsetHeight+" st="+lst.scrollTop;
		chklstSetScrollTop(lst, idx);
		lst.idx = idx;
	}
	if (!lst.multi && !noval) {
		var eiv = document.getElementById(lst.id.substr(13));
		if (eiv)
			eiv.value = cs[idx].value;
		var ei = document.getElementById(lst.id.substr(6));
		if (ei)
			if (ei.tagName.toLowerCase() == "input")
				ei.value = lst.totext(cs[idx]).innerText || '';
			else
				ei.innerHTML = lst.totext(cs[idx]).innerHTML;
		//if (lst.onset)
			//lst.onset(cs[idx].value);
		if (!isinit && lst.onchange) {
			eiv.selectedIndex = idx == 0 ? 0 : 1;
			eiv.options = [{text:lst.totext(cs[0]).innerText,value:cs[0].value}, {text:lst.totext(cs[idx]).innerText,value:cs[idx].value}];
			lst.onchange.call(eiv);
		}
	}
}

function chklstkeyp(evt, lst) {
	var kc = evt.keyCode;
	if (kc >= 32) {
		var cs = lst.children || lst.childNodes
		var nft = (lst.ftlen ? lst.totext(cs[lst.idx]).innerText.substr(0, lst.ftlen).toUpperCase() : "") + String.fromCharCode(kc).toUpperCase();
		var nftlen = nft.length;
		var start = lst.ftlen ? lst.idx : 0;
		var l = 1;
		var cslen = cs.length;
		for (var i = start; l || i != start; l = 0, i + 1 < cslen ? i++ : i = 0) {
			var ct = lst.totext(cs[i]);
			if (ct && ct.innerText.substr(0, nftlen).toUpperCase() == nft) {
				chklstset(lst, i, nftlen);
				break;
			}
		}
		cancel = true; // voorkom scroll bij spatie
	}
	if (cancel) {
		evt.keyCode = 0;
		evt.returnValue = false;
		evt.cancelBubble = true;
	}
}

function chklstkey(evt, lst) {
	var cancel;
	var kc = ((evt.shiftKey ? 1 : 0) + (evt.ctrlKey ? 2 : 0) + (evt.altKey ? 4 : 0)) * 256 + evt.keyCode;
	if (kc == 38) { // up
		for (var i = lst.idx - 1; i >= 0 && chklstset(lst, i); i--) ;
		cancel = true;
	}
	if (kc == 40) { // down
		var cs = lst.children || lst.childNodes
		for (var i = lst.idx + 1; i < cs.length && chklstset(lst, i); i++) ;
		cancel = true;
	}
	if (kc == 33) { // pgup
		var cs = lst.children || lst.childNodes
		var n = Math.floor(lst.offsetHeight / cs[0].offsetHeight) - 1;
		if (lst.idx - n > 0)
			for (var i = lst.idx - n; i >= 0 && chklstset(lst, i); i--) ;
		else
			chklstset(lst, 0);
		cancel = true;
	}
	if (kc == 34) { // pgdn
		var cs = lst.children || lst.childNodes
		var n = Math.floor(lst.offsetHeight / cs[0].offsetHeight) - 1;
		if (lst.idx + n < cs.length)
			for (var i = lst.idx + n; i < cs.length && chklstset(lst, i); i++) ;
		else
			chklstset(lst, cs.length - 1);
		cancel = true;
	}
	if (kc == 36) { // home
		chklstset(lst, 0);
		cancel = true;
	}
	if (kc == 35) { // end
		var cs = lst.children || lst.childNodes
		chklstset(lst, cs.length - 1);
		cancel = true;
	}
	if (kc == 32 && lst.idx != -1 && lst.multi) {
		chkToggle(lst, lst.idx);
		cancel = true;
	}
	if (kc == 8) {
		if (lst.ftlen)
			lst.ftlen--;
		cancel = true;
	}
	if (kc == 115 || kc == 13) {
		chklstHide(lst);
		var ei = document.getElementById('chkne' + lst.id.substr(6)) || document.getElementById(lst.id.substr(6));
		if (ei.select) ei.select();
		if (ei.focus) ei.focus();
		cancel = true;
	}
	if (kc == 9 || kc == 265) {
		chklstHide(lst);
		var ei = document.getElementById(lst.id.substr(6));
		if (ei.focus) ei.focus();
	}
	if (cancel) {
		evt.keyCode = 0;
		evt.returnValue = false;
		evt.cancelBubble = true;
		return false;
	}
}

function chkSetCheckMark(e, newstate) {
	var e = e.firstChild.firstChild.firstChild;
	var n;
	if (newstate) {
		n = document.createElement("IMG");
		n.width = "7";
		n.height = "7";
		n.src = "/9000000/g/chk7x7.gif";
		n.className = "chkun";
	} else {
		n = document.createElement("SPAN");
		n.className = "chkun";
		n.innerHTML = "&nbsp;";
	}
	if (e.tagName == n.tagName)
		return;
	//e.replaceNode(n);
	e.parentNode.replaceChild(n, e);
}

function chkAIndexOf(vs, v) {
	for (var i = 0; i < vs.length; i++)
		if (vs[i] == v)
			return i;
	return -1;
}
function chkAAdd(vs, v) {
	for (var i = 0; i <= vs.length; i++)
		if (!vs[i] || vs[i] > v) {
			vs.splice(i, 0, v);
			break;
		}
}

function chkSetCheckE(lst, ei, e, sep, val) {
	var vs = ei.value ? ei.value.split(sep) : [];
	var opos = chkAIndexOf(vs, e.value);
	var docheck = opos == -1;
	
//alert('ei.v='+ei.value+ '\ne.v=' + e.value + '\ni=' + opos + '\n' + ei.outerHTML + '\n' + 'chkne' + ei.id);

	if (val != -1 && (!val == docheck))
		return;

	chkSetCheckMark(e, docheck)

	if (docheck)
		chkAAdd(vs, e.value);
	else
		vs.splice(opos, 1);
	ei.value = vs.join(sep);
	
	var eine = document.getElementById('chkne' + ei.id);
	if (eine) {
		var vs = eine.value ? eine.value.split(sep) : [];
		var v = lst.totext(e).innerText;
		var i = chkAIndexOf(vs, v);
		if (docheck == (i == -1)) {
			if (docheck)
				chkAAdd(vs, v);
			else
				vs.splice(i, 1);
		}
		eine.value = vs.join(sep);
//alert(vs + '\n\n' + i + ' ' + v + '\n\n' + eine.value + '\n\n' + ei.value + ' ' + e.value);
	}
}

function chkToggleE(lst, ei, e, sep) {
	chkSetCheckE(lst, ei, e, sep, -1);
}

// val: -1 = toggle, 0 = clear, 1 = set
function chkSetCheck(lst, idx, val) {
	var ei = document.getElementById(lst.id.substr(6));
	var cs = lst.children || lst.childNodes
	chkSetCheckE(lst, ei, cs[idx], lst.sep, val);
	if (lst.onchange)
		lst.onchange.call(ei);
}

function chkToggle(lst, idx) {
	chkSetCheck(lst, idx, -1);
}

function chkGetOptions(lst) {
	chklstinit(lst);
	return lst.children || lst.childNodes
}

function chkGetOptionText(lst, option) {
	var t = lst.totext(option);
	return t.textContent || t.innerText;
}

function chkFindByValue(lst, value) {
	var cs = chkGetOptions(lst);
	for (var i = 0; i < cs.length; i++)
		if (cs[i].value == value)
			return i;
	return -1;
}

function chkSetDisabled(lst, disabled) {
	lst.disabled = disabled;
	var e = document.getElementById(lst.id.substr(6));
	if (!e)
		return;
	if (e.tagName == "INPUT") {
		e.disabled = disabled;
	} else {
		e.tabStop = disabled ? "" : "0";
		e.style.color = disabled ? "gray" : "";
	}
}

function chkfind(evt) {
	var e = evt.srcElement || evt.target;
	while (e && (!e.className || e.className.indexOf("chkrow") == -1))
		e = e.parentNode;
	if (!e)
		return;
	var lst = e.parentNode;
	var idx = -1;
	var cs = lst.children || lst.childNodes
	for (var i = 0; i < cs.length; i++)
		if (cs[i] == e) {
			idx = i;
			break;
		}
	return [lst, idx];
}

function chkclk(evt, ein, sep) {
	var ei = document.getElementById(ein);
	var lstidx = chkfind(evt);
	if (!lstidx)
		return;
	var lst = lstidx[0], idx = lstidx[1];
	if (idx != -1)
		chklstset(lst, idx);
	var cs = lst.children || lst.childNodes
	if (lst.multi)
		chkToggleE(lst, ei, cs[idx], sep);
	else
		chklstHide(lst);
}

function chkmo(evt) {
	var lstidx = chkfind(evt || window.event);
	if (!lstidx)
		return;
	var lst = lstidx[0], idx = lstidx[1];
	if (idx != -1)
		chklstset(lst, idx, null, true);
}

function chkattrquote(s) {
	return s.replace(/[<>&"]/g, function(x) { return "&#" + x.charCodeAt(0) + ";"; });
}
function chkhtmlize(s) {
	return s.replace(/[<>&]/g, function(x) { return "&#" + x.charCodeAt(0) + ";"; });
}
function chkjsquote(s) {
	return s.replace(/[\\']/g, "\\$0");
}
function chkgenoneim(txt) {
//tabindex="1"	
//return '<span class="chkpos"><span class="chkchk"><img src="/9000000/g/chk7x7.gif" style="visibility:hidden" width="7" height="7"></span></span><div class="chktxt">' + chkhtmlize(txt) + '</div>';
return '<span class="chkpos"><span class="chkchk"><span class="chkun">&nbsp;</span></span></span><div class="chktxt">' + (chkhtmlize(txt) || '&nbsp;') + '</div>';
}
function chkgenoneis(txt) {
//tabindex="1"	
//return '<span class="chkpos"><span class="chkchk"><img src="/9000000/g/chk7x7.gif" style="visibility:hidden" width="7" height="7"></span></span><div class="chktxt">' + chkhtmlize(txt) + '</div>';
return '<div class="chktxt">' + (txt ? chkhtmlize(txt) : '&nbsp;') + '</div>';
}
function chkgenone(txt,val) {
	return '<div class="chkrow" value="' + chkattrquote(val) + '"><span class="chkpos"><span class="chkchk"><img src="/9000000/g/chk7x7.gif" style="visibility:hidden"></span></span><div class="chktxt" tabindex="1">' + chkhtmlize(txt) + '</div></div>';
}

function chklstHide(lst) {
	lst.style.display = "none";
	if (lst.prevmousedown)
		document.body.onmousedown = lst.prevmousedown;
	if (lst == chklstCurOpen)
		chklstCurOpen = null;
}


function chkkey(evt, ein) {
	var kc = ((evt.shiftKey ? 1 : 0) + (evt.ctrlKey ? 2 : 0) + (evt.altKey ? 4 : 0)) * 256 + evt.keyCode;
	if (kc == 115) {
		chkbclk(evt, ein);
		evt.returnValue = false;
		evt.keyCode = 0;
	}
	if (kc >= 33 && kc <= 40) {
		var lst = document.getElementById("chklst" + ein);
		if (!lst.disabled && (!lst.multi || kc == 38 || kc == 40)) { // for multi only up/down
			chklstinit(lst);
			return chklstkey(evt, lst);
		}
	}
}

function chkkeyp(evt, ein) {
	var ei = document.getElementById(ein);
	var lst = document.getElementById("chklst" + ein);
	if (lst.disabled)
		return;
	chklstinit(lst);
	chklstkeyp(evt, lst);
}

function chklstinit(lst) {
	var gotoidx = -1;
	if (lst.items) {
		var ei = document.getElementById(lst.id.substr(6));
		var ocurs = document.body.style.cursor;
		var ostatus = window.status;
		document.body.style.cursor = "hourglass";
		window.status = "Bezig met voorbereiden van de keuzelijst..."; 
		var items = lst.items;
		var issel = [];
		var chkgenonei = lst.multi ? chkgenoneim : chkgenoneis;
		for (var i = 0; i < items.length; i++) {
			var item = items[i];
			if (!item[0] && i) {
				lst.appendChild(document.createElement("hr")).className = 'chkhr';
				continue;
			}
			var eopt = document.createElement("div");
			eopt.className = "chkrow";
			eopt.value = item[1];
			eopt.innerHTML = chkgenonei(item[0]);
			if (item[2])
				issel[issel.length] = i;
			lst.appendChild(eopt);
		}
		if (ei) {
			ei.value = "";
			if (lst.multi) {
				var cs = lst.children || lst.childNodes
				for (var i = 0; i < issel.length; i++)
					chkToggleE(lst, ei, cs[issel[i]], lst.sep);
			}
		}
		if (issel.length)
			gotoidx = issel[0];
		lst.items = null;
		window.status = ostatus;
		document.body.style.cursor = ocurs;
		if (gotoidx >= 0)
			chklstset(lst, gotoidx, 0, false, true);
	}
	return gotoidx;
}

function chklstShowList(lst, x, y, w) {
	lst.style.left = x + "px";
	lst.style.top = y + "px";
	lst.style.width = w;

	if (chklstCurOpen)
		chklstHide(chklstCurOpen);
	chklstCurOpen = lst;

	lst.style.display = "block";
	//lst.onblur = function (e) { if (!e) e = event; alert(e.fromElement.innerHTML); this.style.display = "none"; }
	//lst.onmousedown = function (e) { if (!e) e = event; var se = e.srcElement; if (se == this || se.parentNode == this || se.parentNode.parentNode == this) { if (se.onclick) se.onclick(e); if (se.parentNode.onclick) se.parentNode.onclick(e); return; } this.releaseCapture(); this.style.display = "none"; }
//status = se.tagName + " " + this.id + " " + new Date().getSeconds(); 	
//status = status + "b" + se.tagName
//status = status + "a"
	//lst.onmousedown = function (e) { if (!e) e = event; var cp = clientPos3(lst); var ecp = new Array(e.clientX  + document.body.scrollLeft, e.clientY + document.body.scrollTop);/* + " " + cp[0] + "," + cp[1] + " " + (cp[0] + lst.offsetWidth) + "," + (cp[1] + lst.offsetHeight) + e.srcElement.tagName; */ if (ecp[0] >= cp[0] && ecp[0] < cp[0] + lst.offsetWidth && ecp[1] >= cp[1] && ecp[1] < cp[1] + lst.offsetHeight) return; var se = e.srcElement; if (se == this || se.offsetParent == this || se.offsetParent.offsetParent == this) { chkclk(e, this.eid, this.sep); return; } this.releaseCapture(); this.style.display = "none";  e.cancelBubble = true; return false; }
	//lst.onmousedown = function (e) { if (!e) e = event; var cp = clientPos3(this), ecp = new Array(e.clientX  + document.body.scrollLeft, e.clientY + document.body.scrollTop), se = e.srcElement; if (ecp[0] >= cp[0] && ecp[0] < cp[0] + lst.offsetWidth && ecp[1] >= cp[1] && ecp[1] < cp[1] + lst.offsetHeight) { if (se.offsetParent == this || se.offsetParent.offsetParent == this) { chkclk(e, this.eid, this.sep); return; } } else { this.releaseCapture(); this.style.display = "none";  e.cancelBubble = true; return false; } }
	lst.prevmousedown = document.body.onmousedown;
	document.body.onmousedown = function(e) {
		if (!e) e = event;
/*
		var cp = clientPos3(lst);
		var ecp = new Array(e.clientX  + document.body.scrollLeft, e.clientY + document.body.scrollTop);
		var se = e.srcElement;
		if (ecp[0] >= cp[0] && ecp[0] < cp[0] + lst.offsetWidth && ecp[1] >= cp[1] && ecp[1] < cp[1] + lst.offsetHeight) {
			//chkclk(e, this.eid, this.sep);
			return;
		}
*/
		chklstHide(lst);
		e.cancelBubble = true;
		return false;
	}
	lst.onmousedown = function(e) { if (!e) e = window.event; chkclk(e, this.eid, this.sep); e.cancelBubble = true }
	if (!lst.multi)
		lst.onmouseover = chkmo;
	//document.body.setCapture(true);
	//lst.onblur = function (e) { if (!e) e = event; alert(e.srcElement.outerHTML); this.style.display = "none";  }
	//lst.onfocus = function (e) { if (!e) e = event; alert(e.srcElement.outerHTML); this.style.display = "block";  }
	//if (lst.focus) lst.focus();

	if (lst.multi) {
		if (lst.idx == -1) {
			if (lst.firstChild)
				chklstset(lst, 0);
		} else {
			var ct = lst.totext((lst.children || lst.childNodes)[lst.idx]);
			if (ct && ct.focus) ct.focus();
		}
	}

	/*
	if (lst.idx > 0 && !lst.scrollTop) {
		var cs = lst.children || lst.childNodes
		lst.scrollTop = cs[lst.idx].offsetTop;
	}
	*/
	if (!lst.ch) {
		lst.ch = (lst.firstChild || {}).offsetHeight;
		lst.oh = lst.offsetHeight;
	}
	if (lst.idx >= 0)
		chklstSetScrollTop(lst, lst.idx);
}

function chkblur(ei) {
	var lst = document.getElementById("chklst" + ei.id.substr(ei.id.indexOf("chkne") == 0 ? 5 : 0));
	chklstHide(lst);
}

function chkbclk(evt, ein) {
	var lst = document.getElementById("chklst" + ein);
	if (lst.disabled)
		return;
	var ei = document.getElementById("chkne" + ein) || document.getElementById(ein);
	//alert(document.getElementById(ein).outerHTML);
	if (lst.style.display == "block") {
		if (ei.focus) ei.focus();
		chklstHide(lst);
		return;
	}

	var gotoidx = chklstinit(lst);

//alert("chkbclk ein=" + ein + " ei=" + ei);
//alert(ei.parentElement.parentElement.offsetLeft);
	var ei1 = ei.parentNode.parentNode;

	var cpIE = navigator.userAgent.indexOf("MSIE ") >= 0;
	function clientPos4(p) {
		function pxw(s) { return s.charCodeAt(s.length - 1) == 120 ? parseInt(s) : 0; }
		var x = 0, y = 0;
		while (p && p.tagName.toLowerCase() != "body") {
			x += p.offsetLeft - p.scrollLeft;
			y += p.offsetTop - p.scrollTop;
			if (cpIE) { //  && p.tagName == "TD"
				x += pxw(p.currentStyle.borderLeftWidth);
				y += pxw(p.currentStyle.borderTopWidth);
			}
			p = p.offsetParent;
		}
		return new Array(x, y);
	}

	var c = clientPos4(ei1);
	//c[0] += ei1.offsetLeft;
	//c[1] += ei1.offsetTop;
//alert("ei1=" + ei1.tagName + " " + ei1.offsetLeft);

	chklstShowList(lst, c[0], c[1] + ei1.offsetHeight, ei1.offsetWidth);
}

/*
var grdlastri=-1,grdlastci=-1,grdelm;
function chklstEnter(grdid,ci,ri){
 var grid=pnElGet(grdid);
 var cell=grid.rows[ri].cells[ci];
 var txte=cell.childNodes[0],txt=txte.innerHTML;
 if(txte.offsetWidth <= cell.offsetWidth){if(grdelm)pnElShow(grdelm,0);return}
 if(!grdelm){grdelm=pnElCreate(350);grdelm.style.zIndex=999}
 grdelm.style.pixelWidth = Math.min(txte.offsetWidth + 6, 350);
 grdelm.altParent=cell
 grdelm.oncontextmenu=grid.oncontextmenu
 pnElSet(grdelm, '<div class="grdtool" onmouseout="pnElShow(grdelm,1)">'+txt+'</div>');
 var xy = clientPos(cell)
 pnElMove(grdelm,xy[0],xy[1]);
 pnElShow(grdelm,1);
}
function chklstLeave(grdid){if(chklstElm)chklstElm.style.visibility="hidden";}
function gridmin(ev,grdid){
 if(document.readyState&&document.readyState!="complete")return
 var e=ev.srcElement;while(e&&e.tagName!="TD"&&e.tagName!="TH")e=e.parentElement;
 var ri=-1;ci=-1;
 if(e){ri=e.parentElement.rowIndex;ci=e.cellIndex}
 if(ri!=grdlastri||ci!=grdlastci){if(ri==-1)gridleave(grdid);else gridenter(grdid,ci,ri);grdlastri=ri;grdlastci=ci}
}
function gridmout(ev,grdid){
 if(document.readyState&&document.readyState!="complete")return
	var fe=ev.fromElement;
	if(fe.tagName=="NOBR"||(fe.parentElement&&fe.parentElement.tagName=="NOBR")||fe.tagName=="TD")return;
 if(grdlastri!=-1){gridleave(grdid);grdlastri=-1;grdlastci=-1}
}
*/

function chklstNewList(eid, items, multiple, disabled, onchange, noedit) {
	var elst = document.createElement("DIV");
	elst.className = "chklst";
	elst.style.display = "none";
	elst.id = "chklst" + eid;
	var sep = noedit ? "; " : ";";
	//elst.onmousedown = function(event) { chkclk(event || window.event, eid, sep); }
	elst.sep = sep;
	elst.eid = eid;
	elst.items = items;
	elst.multi = multiple;
	elst.disabled = disabled;
	elst.onchange = onchange;
	elst.noedit = noedit;
	elst.totext = elst.multi ? function(e) { return e.childNodes[1]; } : function(e) { return e; };
	/*
	var os = e.options;
	var issel = [];
	for (var i = 0; i < os.length; i++) {
		var eopt = document.createElement("DIV");
		eopt.className = "chkrow";
		eopt.value = os[i].value;
		eopt.innerHTML = chkgenonei(os[i].text);
		if (os[i].selected)
			issel[issel.length] = eopt;
		elst.appendChild(eopt);
	}
	*/
	elst.onkeydown = function(e) { return chklstkey(e || event, this); };
	elst.onkeypress = function(e) { chklstkeyp(e || event, this); };
	elst.onselectstart = function() { return false; }
	elst.idx = -1;
	var cs = elst.children || elst.childNodes
	if (cs.length)
		chklstset(elst, 0);
	document.body.appendChild(elst);
	//document.body.insertBefore(elst, document.body.firstChild);
	return elst;
}

function chkGetList(name) {
	return document.getElementById("chklstchklst_" + name);
}

function chkFromSelect(e) {
	if (!document.all) return;
	//window.status = "converting " + e.name + ": creating edit";
	var noedit = /\bchknoedit\b/.test(e.className);

	var eid = "chklst_" + e.name;
	var w = e.offsetWidth;
	if (!w)
		w = 300;
/*
	var ein = document.createElement("INPUT");
	ein.className = "inn";
	ein.id = eid;
	ein.name = eid;
	ein.style.width = (w - 2) + "px";
*/
	//ein.style.height = (h - 2) + "px";

/*

	var ebutimg = document.createElement("IMG");
	ebutimg.src = "/9000000/g/chk7x7.gif";
	ebutimg.width = 7;
	ebutimg.height = 7;
	ebutimg.align = "absmiddle";
	//var ebut = document.createElement("BUTTON");
	//ebut.className = "incb";
	var ebut = document.createElement("SPAN");
	ebut.className = "incbi";
	ebut.onmousedown = function(e) { if(!e)e=window.event;chkbclk(e, eid); e.cancelBubble = true; };
	ebut.appendChild(ebutimg);
	
	//var eb2 = document.createElement("SPAN");
	//eb2.onmousedown = function(event) { chkbclk(event || window.event, eid); };
	//eb2.appendChild(ebut);

	var ebo2 = document.createElement("SPAN");
	ebo2.className = "inb2";
	ebo2.appendChild(ein);
	ebo2.appendChild(ebut);
*/

	w -= 16;
	w -= 4;

	var ebo1 = document.createElement("SPAN");
	ebo1.className = "inb1";
	var imgsrc = e.multiple ? "/9000000/g/chk7x7.gif" : "/9000000/g/arwd7x7.gif";
	var eidne = noedit ? 'chkne' + eid : eid;
	//var eidnex = e.multiple && !noedit ? eidne : 'chkx' + eidne;
//alert(eidne);
	var inputtag = !chkIsCompat || e.multiple || true ? 
		'<input class="inn"' +
		(noedit ? ' readonly' : '') +
		(e.disabled ? ' disabled' : '') +
		' onblur="chkblur(this)" onkeydown="chkkey(event,\'' + eid + '\')"' +
		(e.multiple ? '' :
			' onkeypress="chkkeyp(event,\'' + eid + '\')" onmousedown="chkbclk(event,\'' +
			eid + '\');event.cancelBubble=true" value="' +
			chkattrquote(e.selectedIndex<0?'':e.options[e.selectedIndex].text) + '"') +
		' id="' + eidne + (noedit || !e.multiple ? '' : '" name="' + eidne) + 
		'" style="width:' + (w - 2) + 'px' + (e.multiple ? '' : ';cursor:default') + '">' : 
		'<span' +
		(e.disabled ? '' : ' tabindex="0"') + ' onkeydown="chkkey(event,\'' + eid + '\')" id="' +
		eid + '" onkeypress="chkkeyp(event,\'' + eid + '\')" onmousedown="chkbclk(event,\'' +
		eid + '\');event.cancelBubble=true" style="width:' +
		(w - 2) + 'px;x-padding-top:2px;white-space:nowrap;cursor:default;overflow:hidden' +
		(e.disabled ? ';color:gray' : '') + '" class="inn">'+
		chkhtmlize(e.selectedIndex<0?'':e.options[e.selectedIndex].text)+'</span>';
	if (!e.multiple)
		inputtag += '<input type="hidden" id="' +
			e.name + '" name="' + e.name + '" value="' + chkattrquote(e.value) + '">';
	else if (noedit)
		inputtag += '<input type="hidden" id="' +
			eid + '" name="' + eid + '" value="">';
	//ab352:var inputtag = e.multiple ? '<input class="inn"' + (e.disabled ? ' disabled' : '') + ' onkeydown="chkkey(event,\'' + eid + '\')" id="' + eid + '" name="' + eid + '" style="width:86%">' : '<span' + (e.disabled ? '' : ' tabindex="0" onkeydown="chkkey(event,\'' + eid + '\')" id="' + eid + '" onkeypress="chkkeyp(event,\'' + eid + '\')" onmousedown="chkbclk(event,\'' + eid + '\');event.cancelBubble=true"') + ' style="width: 86%;x-padding-top:2px;white-space:nowrap;overflow:hidden' + (e.disabled ? ';color:gray' : '') + '" class="inn">'+chkhtmlize(e.options[e.selectedIndex].text)+'</span><input type="hidden" id="' + e.name + '" name="' + e.name + '" value="' + chkattrquote(e.value) + '">';	
	var button = '<span class="incbi1" onmousedown="chkbclk(event,\'' + eid + '\'); event.cancelBubble = true;"><span class="incbi2"><img unselectable onselectstart="return false" src="' + imgsrc + '" width="7" height="7" align="absmiddle"><span style="overflow:hidden;width:0px">&nbsp;</span></span></span>';
	var butimgvarname = e.multiple ? "chklstImgM" : "chklstImgS";
	var butimg = window[butimgvarname];
	if (butimg)
		button = '<span class="incbimspan"><img class="incbim" src="' + butimg + '" width=' + window.chklstImgW + ' height=' + window.chklstImgH + ' onmousedown="chkbclk(event,\'' + eid + '\');event.cancelBubble = true"></span>';
	ebo1.innerHTML = '<span class="inb2">' + inputtag + button + '</span>';
	//ab352:ebo1.innerHTML = '<div style="white-space: nowrap;"><img src="/9352000/g/aanleg.gif" width="21" height="14" alt="" /><span class="inb2">' + inputtag + button + '</span><img src="/9352000/g/aanleg.gif" width="1" height="14" alt="" /></div>';

//	ebo1.appendChild(ebo2);


/*
	var os = e.options;
	for (var i = 0; i < os.length; i++) {
		var net = document.createTextNode(os[i].text);
		ne.appendChild(net);
	}
*/

	//window.status = "converting " + e.name + ": reading " + e.options.length + " options";

	var os = e.options;
	var items = new Array(os.length);
	var vs = [], svs = [];
	for (var i = 0; i < os.length; i++) {
		var o = os[i];
		var sel = o.selected;
		items[i] = [o.text, o.value, sel];
		if (sel) {
			vs[vs.length] = o.value;
			if (noedit)
				svs[svs.length] = o.text;
		}
	}
	vs.sort();
	if (e.multiple) {
		ebo1.firstChild.firstChild.value = (noedit ? svs : vs).join(noedit ? "; " : ";");
		if (noedit)
			ebo1.firstChild.firstChild.nextSibling.value = vs.join("; ");
	}

	//window.status = "converting " + e.name + ": creating list";

	var elst = chklstNewList(eid, items, e.multiple, e.disabled, e.onchange, noedit);
	//if (e.currentStyle)
		//elst.style.fontSize = e.currentStyle.fontSize;

	//e.style.display = "none";
	//e.parentNode.insertBefore(ebo1, e);
	//window.status = "converting " + e.name + ": replacing item";

	//e.replaceNode(ebo1);
	e.parentNode.replaceChild(ebo1, e);
//alert(ebo1.outerHTML + '\n\n' + document.getElementById(eid).outerHTML);
	//ein.id = eid;
	//ein.name = eid;

	/*
	var ei = document.getElementById(eid);
	for (var i = 0; i < issel.length; i++)
		chkToggleE(elst, ei, issel[i], sep);
	*/
	//window.status = "";
}

var chkFromSelectQueue = window.chkFromSelectQueue || [];
var chkFromSelectTimerEnabled;

function chkFromSelectRun() {
	//alert("chkFromSelectRun " + chkFromSelectQueue.length);
	if (chkFromSelectQueue.length && !chkFromSelectQueue[0].offsetWidth) {
		setTimeout(chkFromSelectRun, 100);
		return;
	}
	var ostatus = window.status;
	for (var i = 0; i < chkFromSelectQueue.length; i++) {
		window.status = "Bezig met aanmaken keuzelijsten: " + (i + 1) + "/" + chkFromSelectQueue.length;
		chkFromSelect(chkFromSelectQueue[i]);
	}
	window.status = ostatus;
	chkFromSelectQueue = [];
}
/*
function chkFromSelectCheck() {
	if (document.readyState == "complete") {
		chkFromSelectTimerEnabled = false;
		chkFromSelectRun();
	} else {
		setTimeout(chkFromSelectCheck, 100);
		chkFromSelectTimerEnabled = true;
	}
}
*/
function chkFromSelect2(e) {
	chkFromSelectQueue[chkFromSelectQueue.length] = e;
	if (!chkFromSelectTimerEnabled) {
		if (window.attachEvent) {
			if ("onreadystatechange" in document)
				document.attachEvent("onreadystatechange", function() { if (document.readyState == "complete") chkFromSelectRun(); });
			else
				window.attachEvent("onload", chkFromSelectRun);
			chkFromSelectTimerEnabled = true;
		} else if (0&&window.addEventListener) {
			window.addEventListener("load", chkFromSelectRun, false);
			chkFromSelectTimerEnabled = true;
		}
	}
}

