function ajax_checkGiftcardBalance(cardnumber,security)
{
    dhtml_hideGiftcardFeedback();

    var ajax = new sack();
    ajax.requestFile = "./giftcard.php";
    ajax.method = "post";
    ajax.setVar("action","ajax-check-balance");
    ajax.setVar("cardnumber",document.getElementById("cardnumber").value);
    ajax.setVar("security",document.getElementById("security").value);
    ajax.execute = true;
    ajax.onLoading = function() { dhtml_setGiftcardFeedback("Please wait...","none"); };
    ajax.onCompletion = function()
                        {
                            if (success) {
                                dhtml_setGiftcardFeedback("Your current balance is $" + balance,'success');
				if (document.getElementById('giftcardBalance'))
				{
					document.getElementById('giftcardBalance').value=balance;
					if (giftcardsData){
						giftcardsData[currentGC][2]=balance;
						updateCharge(currentGC);
					}
				}
                            } else {
                                dhtml_setGiftcardFeedback(message,'error');
                            }
                        };

    ajax.runAJAX();
}

function dhtml_setGiftcardFeedback(message,className)
{
    obj = document.getElementById("giftcardFeedback");
    obj.innerHTML = message;
    obj.style.display = "block";
    obj.className = className;
}

function dhtml_hideGiftcardFeedback()
{
    obj = document.getElementById("giftcardFeedback");
    obj.innerHTML = "";
    obj.style.display = "none";
}
