var IE = document.all?true:false
var UserOK

//All fields with id filled in are required fields.
function cOn(td, color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	  td.style.cursor = 'pointer';
	}
}
function cOut(td,color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	}
}

function nav(obj,show) {
	if(show){
		if(obj.src.indexOf('_o.gif')==-1){
			obj.src=obj.src.replace('.gif','_o.gif')
		}
	}else{
		obj.src=obj.src.replace('_o.gif','.gif')
	}
}

//Smooth Resize
var timeoutLength = 10;
var pixelsPerTick = 20;
var originalHeight = 90;

function resize(stritem,list) {
	//status = document.getElementById('content1').offsetHeight;
	var style = document.getElementById(stritem).style;
	if (style.display != 'none') {
		if (document.getElementById(stritem).innerHTML.length>0){ 
		  smoothResize1(stritem);
		}
	} else {	  		
		document.getElementById(stritem).style.display = 'block';
		var arr = document.getElementById(list).value.split(',')
		for(var cnt=0;cnt<arr.length;cnt++){		
      if (arr[cnt] != '' &&(arr[cnt] != stritem)){
        if (document.getElementById(arr[cnt]).style.display == 'block'){
		      smoothResize1(arr[cnt]); //Dichtklappen
		    }
		  }
		}
		if (document.getElementById(stritem).innerHTML.length>0){	
		  smoothResize2(stritem,originalHeight);	//Openklappen
		}
	}
	//status = document.getElementById('content1').offsetHeight;
}
function smoothResize1(stritem) //Dichtklappen
{
	if ( (parseInt(document.getElementById(stritem).offsetHeight)-pixelsPerTick) <= 0 )
	{		
		document.getElementById(stritem).style.display = 'none';			
	}
	else
	{
		document.getElementById(stritem).style.height = parseInt(document.getElementById(stritem).offsetHeight-pixelsPerTick) + 'px' ;
		setTimeout("smoothResize1('"+stritem+"')",timeoutLength);			
	}
}
function smoothResize2(stritem,max) //Openklappen
{ 
	if ( (document.getElementById(stritem).offsetHeight+pixelsPerTick) >= max )
	{ 
		document.getElementById(stritem).style.height = max+'px';				
	}
	else
	{	  
	  document.getElementById(stritem).style.height = document.getElementById(stritem).offsetHeight+pixelsPerTick+'px';		
	  setTimeout("smoothResize2('"+stritem+"',"+max+")",timeoutLength);
	}
}
//End smooth Resize

function getCheckboxValue(id) {
	var allInputTags = document.getElementById(id+'_group').getElementsByTagName('INPUT');
	for (var c=0; c<allInputTags.length; c++) {
		if (allInputTags[c].checked) {
			return allInputTags[c].value;
			break;
		}
	}
	return ""
}

function SetSumAvg(arr, idSum, idAvg) {
	var objSum = document.getElementById(idSum)
	var objAvg = document.getElementById(idAvg)
	for(i=0;i<arr.length;i++){
		document.getElementById(arr[i]).onkeyup=function(){
			var total = 0
			for(j=0;j<arr.length;j++){
				if(!isNaN(parseInt(document.getElementById(arr[j]).value))){
					if(parseInt(document.getElementById(arr[j]).value)>parseInt(document.getElementById('maxSlagen').value)) {
						alert('Niet hoger dan aantal slagen')
						document.getElementById(arr[j]).value = document.getElementById(arr[j]).value.substr(0,document.getElementById(arr[j]).value.length-1)
					}
					total += parseInt(document.getElementById(arr[j]).value)
				}
			}
			objSum.value = total
			objAvg.value = (total/arr.length)
		}
	}
}

function printme() {
	var objOut = document.getElementById("output");
	var out = objOut.innerHTML;
		
	var wh = window.open("","wh","width=640px,height=480px,scrollbars=yes");
	wh.document.open();
	var output = '<link href="css/print.css" rel="stylesheet" type="text/css">';
	output = '<html><head>'+output+'</head><body>'+out.replace('<object','<!--object').replace('/object>','/object-->')+'</body></html>';
	output += '<'+'script type="text/javascript">';
	output += 'setTimeout("window.print()",2000);';	
	output += '</'+'script>';
	wh.document.writeln(output);
	wh.document.close();
}