function getKeynum(e) { var kn;
// IE
if(window.event) { kn = e.keyCode; }
// Netscape/Firefox/Opera
else if(e.which) { kn = e.which; }
return kn;
}

function isControlChar(keynum) {if (!keynum || keynum < 32) { return true; } else {return false;}}

// do not allow numbers (onkeypress event)
function noNumbers(e) {
var keynum; var keychar; var numcheck;
keynum = getKeynum(e) ;
if (isControlChar(keynum)) { return false; }
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return !numcheck.test(keychar);
}

// do not allow characters (onkeypress event)
function noChars(e) {
var keynum; var keychar; var numcheck;

keynum = getKeynum(e) ;
if (isControlChar(keynum)) { return false; }
keychar = String.fromCharCode(keynum);
numcheck = /[\d]/;
return numcheck.test(keychar);
}

// Check whether an integer does not exceed lmax digits (onkeypress event)
function maxIntLength(e, ref, lmax) {
// always allow delete
if (isControlChar(getKeynum(e)) == true) {return true;}

if (noChars(e) == true) {
	if (ref.value.length >= lmax) {
		return false;
	} else {
		return true;
	}
} else {
	return false;
}
}

// Check whether a number is within a range (onblur event) => does not work!!!
function inRange(ref, lmin, lmax) {
	if (ref.value < lmin || ref.value > lmax) {
		alert("Zahl muss zwischen "+lmin+" und "+lmax+" liegen.");
		ref.focus();
	}
}

// Count the number of checked items in multicheck
function selectCount(item) {
	var count = 0;
	for(var i=0; i<itemList[item].length; i++){
		var ref = document.getElementById(itemList[item][i]);
		if (ref && ref.checked) {count++;}
	}
return count;
}

// Select only a maximum number of items in multicheck (onclick event)
function selectMaxItems(ref,item,count) {
// always allow uncheck
if (!ref.checked) { return true; }
// forbid checking if this is greater than allowed, otherwise allow
if (selectCount(item) > count) { return false; } else { return true; }
}

function open_blitzumfrage(w,h,x,y,l) {
	if (!y) {l = x; x="40"; y="40"; }
	params = "width="+w+",height="+h+",scrollbars,resizable,left="+x+",top="+y;
	l = "http://80.190.229.18/ctx/know?look1="+l;
	wblitzumfrage = window.open(l,"Blitzumfrage",params);
}


