﻿function AddToCart(url, productId) {
    jQuery(document).ready(function ($) {
        if (this.timer) clearTimeout(this.timer);
        this.timer = setTimeout(function () {
            $.ajax({
                type: 'POST',
                contentType: "application/json; charset=utf-8",
                dataType: 'json',
                url: '/Default.aspx/AddToCart',
                data: "{\"productID\": \"" + productId + "\" }",
                success: function (data) {
                    alert('Sản phẩm của bạn đã được đưa vào giỏ hàng');
                    UpdateMiniCart();
                    //document.location.href = url;
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    //alert(xhr.status);
                    //alert(thrownError);
                }
            });
        }, 1000);
    });
}

function UpdateMiniCart() {
    jQuery(document).ready(function ($) {
        //alert($('#mini-cart strong').html());
        var item = $('#mini-cart strong');
        var count = parseInt(item.html()) + 1;
        item.html(count);
    });
}
$(function () {
    $(".slider").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        visible: 7,
        circular: true,
        speed: 1000,
        // auto:2000,
        scroll: 7
        // pauseOnHover: true
    });
});
$(document).ready(function () {
    $("#list_price_detail li:even").addClass('li_even');
});
//$(function () {
//    //===================================================================
//    // Special price strike-out text
//    // Usage:
//    //   Normally:    <span class='price'>$59</span>
//    //   On special:  <span class='price' special='$29'>$59</span>
//    //===================================================================
//    $(".price[special]").each(function () {
//        var originalPrice = $(this).text();
//        $(this).html('<strike><span>' + originalPrice + '</span></strike> ' + $(this).attr('special'))
//           .removeAttr('special')
//           .addClass('special');
//    });
//});
