//<![CDATA[   

	$(document).ready( 

		function() {

			if (chptIdArg > 0) {
				var chptId = chptIdArg;
			} else {
				var chptId = $("#chpt").val();
			}

			if (dsfdIdArg > 0) {
				var dsfdId = dsfdIdArg;
			} else {
				var dsfdId = null;
			}

			// if on a screen that displays the donation form, update the form fields
			if ($("#donation_form").length) {
				updateDsfd(chptId,dsfdId,Math.random(),false);
			}

		}
	);
	

	function updateDsfd(chptId,dsfdId,_nc,hideError) {
		$.ajax({
			type: "POST",
			cache: false,
			url: "/qry/sd_dsfd.taf",
			data: "chpt=" + chptId + "&dsfd=" + dsfdId + "&_nc=" + _nc,
			error : function(XMLHttpRequest, textStatus, errorThrown ) {
				alert('We\'re sorry, there was an error retrieving information for this church.\n\nWe have been notified and will correct this issue as soon as possible.');
				$.ajax({
					type: "GET",
					url: "/qry/sd_donate.taf",
					data: "_function=error&chpt=" + chptId + "&dsfd=" + dsfdId + "&_nc=" + _nc
				})

				eval('$("#dsfd").html("")');

			},
			success: function(data, textStatus) {

				// search the results returned by sd_dsfd.taf for the string 'Success'
				var dataIndex = data.search('Success');

				// if found success string, the records were retrieved successfully
				if(dataIndex != -1) {

					if (hideError == true) {$("#WarningMessage").hide();}

					// get option list string from results
					var options = data.slice(dataIndex + 8);

					eval('$("#dsfd").html(options)');

				} else {
					alert('We\'re sorry, there was an error retrieving information for this church.\n\nWe have been notified and will correct this issue as soon as possible.');
					eval('$("#dsfd").html("")');
				}
			}

		});
	}	

	function swapDsfd(dsfdId,hideError) {
		// the function to display the designation description does not apply to the case where we are drawing funds from multiple databases, as we can't prepopulate all the descriptions
	}

 //]]>