﻿function CheckAll (checkedBox,FormName,FieldName)
{
	
	if(checkedBox.checked)
	{
	SetAllCheckBoxes(FormName,FieldName, true);
	}
	else {
	SetAllCheckBoxes(FormName, FieldName, false);
	}
}


function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function enableLink(FormName, FieldName)
{	
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
		// set the check value for all check boxes
		
	if (countCheckBoxes == undefined) { countCheckBoxes = 1; }
		
	if (countCheckBoxes == 1) {
		return true;
	}
	
	for(var i = 0; i < countCheckBoxes; i++) {
		if(objCheckBoxes[i].checked) {
			return true;
		}
	}
	return false;
}

function checkTemplateForm() {
	if(document.forms['templateChoice'].template_id.value.length < 1) {
		document.getElementById('popUpTemplateChoice').style.visibility = 'visible';
		return false;
		//alert("Selecteer eerst een template");
		
		
	}
}

function checkAboForm() {
	var objCheckBoxes = document.forms["select_adress"].elements["groepvolgnr"];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)	
		document.getElementById('popUpTemplateChoice').style.visibility = 'visible';
	//objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			if(objCheckBoxes[i].checked ) {
			return true;	
		}
	document.getElementById('popUpTemplateChoice').style.visibility = 'visible';
	return false;
}
