function inviteeDataAvailable(currentInvitee) {
	var dataAvailable = false;
	dataAvailable = (findObject('ep'+currentInvitee+'[eventpaymentFirstName]').value != '' ? true : dataAvailable);
	dataAvailable = (findObject('ep'+currentInvitee+'[eventpaymentLastName]').value != '' ? true : dataAvailable);
	dataAvailable = (findObject('ep'+currentInvitee+'[eventpaymentCompany]').value != '' ? true : dataAvailable);
	dataAvailable = (findObject('ep'+currentInvitee+'[eventpaymentEmail]').value != '' ? true : dataAvailable);

	return dataAvailable;
}

function checkFormEventpayment(elForm) {
	var elInviteesCheckbox = findObject('addInvitees');

	for (var i=1; i<=maxPeople; i++) {
		var elIsMemberCheckbox = findObject('isMemberCheckbox'+i);

		// Only do check for first and if invitees are added and if there is anything filled for a given invitee
		if (i==1 || (inviteeDataAvailable(i))) {
			// Do check for the relevant fields.
			if (elIsMemberCheckbox && elIsMemberCheckbox.checked) { // Only do this check 
				// Person is a member
				var isComplete = checkForm(elForm, 'eventId', 'ep'+i+'[eventpaymentFirstName]', 'ep'+i+'[eventpaymentLastName]', 'ep'+i+'[eventpaymentCompany]', 'ep'+i+'[eventpaymentEmail]', 'ep'+i+'[eventpaymentMemberId]');
				if (!isComplete) {return false};
			} else {
				// Person is not a member
				var isComplete = checkForm(elForm, 'eventId', 'ep'+i+'[eventpaymentFirstName]', 'ep'+i+'[eventpaymentLastName]', 'ep'+i+'[eventpaymentCompany]', 'ep'+i+'[eventpaymentEmail]');
				if (!isComplete) {return false};
			}
		}
		if (!checkValidEmail('ep'+i+'[eventpaymentEmail]')) {
			return false;
		}
		
	}

	return true;

}

function toggleVisibility(elCheckbox, target) {
	var elTarget = findObject(target);
	elTarget.style.display = (elCheckbox.checked ? '' : 'none');
}

function confirmDelete() {
  // Check whether the user really intended to perform a delete action
  if (typeof(langDeleteWarning) == 'undefined') {
    langDeleteWarning = 'Are you sure you wish to delete this item?';
  }
  return(confirm(langDeleteWarning));
}

function confirmArchive() {
  // Check whether the user really intended to perform a delete action
  if (typeof(langArchiveWarning) == 'undefined') {
    langArchiveWarning = 'Are you sure you wish to archive this item?';
  }
  return(confirm(langArchiveWarning));
}

function confirmUnarchive() {
  // Check whether the user really intended to perform a delete action
  if (typeof(langUnarchiveWarning) == 'undefined') {
    langUnarchiveWarning = 'Are you sure you wish to activate this item?';
  }
  return(confirm(langUnarchiveWarning));
}

function confirmArchiveAndCheck() {
  // Check whether the current form contains unsaved instructions, AS WELL AS
  // whether the user really indended to activate a link to a delete action
  if (checkForUnsavedChanges()) {
    formChanged = false;
    return confirmArchive();
  } else {
    return false;
  }
}

function confirmUnarchiveAndCheck() {
  // Check whether the current form contains unsaved instructions, AS WELL AS
  // whether the user really indended to activate a link to a delete action
  if (checkForUnsavedChanges()) {
    formChanged = false;
    return confirmUnarchive();
  } else {
    return false;
  }
}
