function ebill_notification_submit()
{
	ebill_notification_form_disable();
	ebill_notification_request_send();

	return true;
}

function ebill_notification_form_disable()
{
	$("#ebill_notification_button_submit").attr('disabled', 'disabled');
	$("#ebill_notification_button_submit").val('Processing...');
	$("#ebill_notification_email").attr('disabled', 'disabled');

	return true;
}

function ebill_notification_form_enable()
{
	$("#ebill_notification_button_submit").removeAttr('disabled');
	$("#ebill_notification_button_submit").val('Submit');
	$("#ebill_notification_email").removeAttr('disabled');

	return true;
}

function ebill_notification_request_send()
{
	var params = Object();
	params.email = $("#ebill_notification_email").val();

	$.getJSON('ebill_notification/ebill_notification_ajax.php', params, function (json) { ebill_notification_request_complete(json); });

	return true;
}

function ebill_notification_request_complete(json)
{
	var errors;
	var i;

	if(json.code == '0')
	{
		alert("Your request to be notified when E-BillPay is available has been received.");
		$("#ebill_notification_email").val("");
	}
	else
	{
		errors = "The following errors were found with your submission:";
		for(i = 0; i < json.error_count; i++)
		{
			errors += "\n- "+json.error_strings[i];
		}

		alert(errors);
	}

	ebill_notification_form_enable();
	
	return true;
}