function CheckFieldsIFrame(formID) {
	if(formID == null) {
		formID = 'mainForm';
	}
	
	return RunCheckFields(parent.frames[0].document.getElementById(formID).elements);
}

function CheckFields(formID) {
	if(formID == null) {
		formID = 'mainForm';
	}
	
	return RunCheckFields(document.getElementById(formID).elements);
}

function RunCheckFields(elem) {
	for(var a = 0; a < elem.length; a++) {
		if(!elem[a].getAttribute("checkMandatory")) {
			continue;
		}

		if(elem[a].value == '' || elem[a].value == ' ') {
			alert('Please complete the ' + elem[a].getAttribute("checkMandatory") + ' before continuing.');
			elem[a].focus();
			return false;
		}
	}
	return true;
}

function ToggleEvent(primaryURL, id, action) {
	var payload = primaryURL + '?action=' + action;
	payload += '&id=' + id;
	payload += '&KeepThis=true&TB_iframe=true';
	
	tb_show(null, payload, false);
}

