// ====================================
// = FUNCTIONS FOR ADMIN TRANSACTIONS =
// ====================================

var lookup_count = 0;

function lookupInvoice(event){
	event.preventDefault();
	
	if (lookup_count > 5) {
		$('pay_invoice_form').update('<div class="error">You have exceeded the maximum number of invoice lookups. You must log into your account to continue.</div>');
		return;
	}
	
	if ( $("invoice_number").value == '' ) {
		alert("Please enter an Invoice Number.");
		return;
	}
	if (( $("invoice_number").value != '' ) && ( isNaN($("invoice_number").value ) ) ) {
		alert("You entered an valid Invoice Number.\nPlease enter a valid Invoice Number.");
		return;
	}
	var lookup = new Ajax.Updater(
		{ success: "invoice_response", failure: "invoice_reponse"},
		"ajax/ajax_transaction_lookup.php",
		{
			parameters: { transaction_id: $("invoice_number").value },
			onCreate: function() {
				$("ajax_progress").show();
			},
			onComplete: function() {
				$("ajax_progress").hide();
			}
		}
	);
	
	lookup_count++
	
}

