﻿
function CheckAddQty(cartid, qty) {
}

function CheckAddQtyValidate(qty) {
}

function CheckCoupon(CouponValue) {
    var CouponValid = false;
    if (CouponValue.toString().length > 0) {
        if (CouponValue.toString().length != 19) {
            tdCouponValid.innerHTML = '<img src="images/cross.gif" alt="Coupon is invalid" title="Coupon is invalid" />';
            //trCouponDiscount.style.display = 'table-row';
        } else {
            var xhr;
            xhr = null;
            if (window.XMLHttpRequest) {// code for Firefox, Opera, etc.
                xhr = new XMLHttpRequest();
            } else if (window.ActiveXObject) {// code for IE7 IE6, IE5
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        if (xhr.responseText == "1") {
                            tdCouponValid.innerHTML = '<img src="images/tick2.gif" alt="Coupon is valid" title="Coupon is valid" />';
                            //trCouponDiscount.style.display = 'table-row';
                            //alert(xhr.responseText);
                        } else {
                            tdCouponValid.innerHTML = '<img src="images/cross.gif" alt="Coupon is invalid" title="Coupon is invalid" />';
                            //alert(xhr.responseText); //trCouponDiscount.style.display = 'table-row';
                        }
                    } else {
                        alert(xhr.responseText);
                    }
                }
            };
            xhr.open('GET', 'check_coupon.asp?Coupon=' + CouponValue, true);
            xhr.send(null);
        }
    } else {
        tdCouponValid.innerHTML = '';
        //trCouponDiscount.style.display = 'table-row';
    }
};

function ddlDeliveryCountry_Changed(ddlDeliveryCountry, NetBasketValue, DeliverySurcharge) {
    frmDeliveryCountry.submit();
};

function ApplyDiscountCode() {
    var CouponValue = document.getElementById('txtCouponValue').value;

    var CouponValid = false;
    if (CouponValue.toString().length > 0) {
        if (CouponValue.toString().length != 19) {
            tdCouponValid.innerHTML = '<img src="images/cross.gif" alt="Coupon is invalid" title="Coupon is invalid" />';
            //trCouponDiscount.style.display = 'table-row';
        } else {
            var xhr;
            xhr = null;
            if (window.XMLHttpRequest) {// code for Firefox, Opera, etc.
                xhr = new XMLHttpRequest();
            } else if (window.ActiveXObject) {// code for IE7 IE6, IE5
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        if (xhr.responseText == "1") {
                            tdCouponValid.innerHTML = '<img src="images/tick2.gif" alt="Coupon is valid" title="Coupon is valid" />';
                            //trCouponDiscount.style.display = 'table-row';
                            window.location = 'Apply_Discount_coupon.asp?Coupon=' + CouponValue
                        } else {
                            tdCouponValid.innerHTML = '<img src="images/cross.gif" alt="Coupon is invalid" title="Coupon is invalid" />';
                            //trCouponDiscount.style.display = 'table-row';
                        }
                    } else {
                        alert(xhr.responseText);
                    }
                }
            };
            xhr.open('GET', 'check_coupon.asp?Coupon=' + CouponValue, true);
            xhr.send(null);
        }
    } else {
        tdCouponValid.innerHTML = '';
        //trCouponDiscount.style.display = 'table-row';
    }

};
    
