var hasChangedOnce = false;
var keyCount = 0;

$(document).ready(function() {

    $(".quantity-textbox").bind("keyup",
        function() {
            var curKeyCount = ++keyCount;
            window.setTimeout(function() {
                RunKeyUp(curKeyCount);
            }, 1200);
        }
     );

    $(".related-acc-item-container").hover(
        function() { $("img", this).css('border', '2px solid #000'); },
        function() { $("img", this).css('border', '2px solid #fff'); });

    $(".related-acc-item-container img").css('border', '2px solid #fff');

});

function RunKeyUp(oldVal) {
    if (oldVal == keyCount) {
        GetProductPrice();
    }
}

function GetProductPrice() {

    var quantity = parseInt($(".quantity-textbox").val(), 10);

    if (!isNaN(quantity) && quantity > 0 && quantity < 10001) {
        $.ajax({
            type: "POST",
            url: "/WebServices/PricingService.asmx/GetProductPrice",
            data: "{'productID':" + productID + ",'quantity':" + quantity + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                $(".big-green-price").fadeOut(200, function() { $(".big-green-price").text(msg.d).fadeIn(200); });
            }
        });
    }
}