function getPaymentPlanByCode(theCode) {
	var ppArray = this.paymentPlanArr;
	for(var i=0; i< ppArray.length; i++) {
		if(ppArray[i].code == theCode)
			return ppArray[i];
	}
	return null;
}

function getDonationUsageByCode(theCode) {
	var usageArray = this.donationUsageArr;
	for(var i=0; i< usageArray.length; i++) {
		if(usageArray[i].code == theCode) {
			return usageArray[i];
		}
	}
	return null;
}

function getFDClassByCode(theCode) {
	var classArray = this.fdClassArr;
	for(var i=0; i< classArray.length; i++) {
		if(classArray[i].code == theCode) {
			return classArray[i];
		}
	}
	return null;
}

function getFundDriveByCode(theCode) {
	for(var i=0; i< fundDriveList.length; i++) {
		if(fundDriveList[i].code == theCode) {
			return fundDriveList[i];
		}
	}
	return null;
}

function getFundDriveById(theId) {
	for(var i=0; i< fundDriveList.length; i++) {
		if(fundDriveList[i].id == theId) {
			return fundDriveList[i];
		}
	}
	return null;
}

function getPledgeByCode(theCode) {
	for(var i=0; i< donorPledgeList.length; i++) {
		if(donorPledgeList[i].code == theCode) {
			return donorPledgeList[i];
		}
	}
	return null;
}

function getPledgeUsageByCode(theCode) {
	var usageArray = this.pledgeUsageAllocationArr;
	for(var i=0; i< usageArray.length; i++) {
		if(usageArray[i].code == theCode) {
			return usageArray[i];
		}
	}
	return null;
}

function fundDrive(id, code, status, name, desc, startTimeStamp, endTimeStamp, defaultPaymentCd, defaultUsageCd, precedingFundDriveCd, precedingPayoffRequired, suggestedPledgeAmount, allowMultiple, availableOnline) {
	this.id = id,
	this.code = code;
	this.status = status;
	this.name = name;
	this.desc = desc;
	this.startTimeStamp = startTimeStamp;
	this.endTimeStamp = endTimeStamp;
	this.defaultPaymentCd = defaultPaymentCd;
	this.defaultUsageCd = defaultUsageCd;
	this.precedingFundDriveCd = precedingFundDriveCd;
	this.precedingPayoffRequired= precedingPayoffRequired;
	this.suggestedPledgeAmount = suggestedPledgeAmount;
	this.allowMultiple = allowMultiple;
	this.fdClassArr = new Array;
	this.paymentPlanArr = new Array;
	this.donationUsageArr = new Array;
	this.getPaymentPlanByCode = getPaymentPlanByCode;
	this.getDonationUsageByCode = getDonationUsageByCode;
	this.getFDClassByCode = getFDClassByCode;
	this.availableOnline = availableOnline;
}

function fdClass(id, code, name, desc, minPledge, minInitialPayment, suggestedPledgeAmount, benefitValue) {
	this.id = id;
	this.code = code;
	this.name = name;
	this.desc = desc;
	this.minPledge = minPledge;
	this.suggestedPledgeAmount = suggestedPledgeAmount;
	this.benefitValue = benefitValue;
	this.minInitialPayment = minInitialPayment;
	this.fdClassBenefitArr = new Array;
}

function fdClassBenefit(fdClassId, benefit) {
	this.fdClassId = fdClassId;
	this.benefit = benefit;
}

function donationUsage(code, desc, readonly) {
	this.code = code;
	this.desc = desc;
	this.readonly = readonly;
}

function paymentPlan(code, numInstallments, desc) {
	this.code = code;
	this.numInstallments = numInstallments;
	this.desc = desc;
}

function pledge(id, code, fundDriveId, classCode, paymentPlanCode, pledgeAmount, balance, paymentDue, paymentDueDate, pledgeDate, historical) {
	this.id = id;
	this.code = code;
	this.fundDrive = getFundDriveById(fundDriveId);
	if(this.fundDrive != null) {
		this.pledgeClass = this.fundDrive.getFDClassByCode(classCode);
		this.paymentPlan = this.fundDrive.getPaymentPlanByCode(paymentPlanCode);
	}
	this.pledgeAmount = pledgeAmount;
	this.balance = balance;
	this.paymentDue = paymentDue;
	this.paymentDueDate = paymentDueDate;
	this.pledgePaymentArr = new Array;
	this.pledgeUsageAllocationArr = new Array;
	this.pledgeDate = pledgeDate;
	this.getPledgeUsageByCode = getPledgeUsageByCode;
	this.historical = historical;
}

function pledgePayment(amount, date, paymentMethod, reference) {
	this.amount = amount;
	this.date = date;
	this.paymentMethod = paymentMethod;
	this.reference = reference;
}

function pledgeUsageAllocation(code, amount) {
	this.code = code;
	this.amount = amount;
}

function pledgeRenewal(id, fundDriveId, pledgeCode, minPledgeAmount, suggestedPledgeAmount, allowDecrease) {
	this.id = id;
	this.fundDrive = getFundDriveById(fundDriveId);
	this.pledgeCode = pledgeCode;
	this.minPledgeAmount = minPledgeAmount;
	this.suggestedPledgeAmount = suggestedPledgeAmount;
	this.allowDecrease = allowDecrease;
	this.pledge = getPledgeByCode(pledgeCode);
}


