/* Js for , Version=1781511514 */
 if(typeof(v) != "object") v = {};v.lang = {"confirmDelete":"\u60a8\u78ba\u5b9a\u8981\u57f7\u884c\u522a\u9664\u64cd\u4f5c\u55ce\uff1f","deleteing":"\u522a\u9664\u4e2d","doing":"\u8655\u7406\u4e2d","loading":"\u52a0\u8f09\u4e2d","updating":"\u66f4\u65b0\u4e2d...","timeout":"\u7db2\u7d61\u8d85\u6642,\u8acb\u91cd\u8a66","errorThrown":"<h4>\u57f7\u884c\u51fa\u932f\uff1a<\/h4>","continueShopping":"\u7e7c\u7e8c\u8cfc\u7269","required":"\u5fc5\u586b","back":"\u8fd4\u56de","continue":"\u7e7c\u7e8c","bindWechatTip":"\u767c\u5e16\u529f\u80fd\u8a2d\u7f6e\u4e86\u7d81\u5b9a\u5fae\u4fe1\u7684\u9650\u5236\uff0c\u8acb\u5148\u7d81\u5b9a\u5fae\u4fe1\u6703\u54e1\u3002","importTip":"\u53ea\u5c0e\u5165\u4e3b\u984c\u7684\u98a8\u683c\u548c\u6a23\u5f0f","fullImportTip":"\u5c07\u6703\u5c0e\u5165\u6e2c\u8a66\u6578\u64da\u4ee5\u53ca\u66ff\u63db\u7ad9\u9ede\u6587\u7ae0\u3001\u7522\u54c1\u7b49\u6578\u64da"};;v.theme = {"template":"mobile","theme":"default","device":"mobile"};;v.currencySymbol = "\uffe5";;
+(function($){
    'use strict';

    var minDelta = 20;

    $.fn.numberInput = function(){
        return $(this).each(function(){
            var $input = $(this);
            $input.on('click', '.btn-minus, .btn-plus', function(){
                var $val = $input.find('.btn-number, [type="number"]');
                var val = parseInt($val.val());
                val = Math.max(1, $(this).hasClass('btn-minus') ? (val - 1) : (val + 1));
                $val.val(val).trigger('change');
            });
        });
    };

    $(function(){$('.input-number').numberInput();});
}(Zepto));

$(function()
{
    var caculateTotal = function()
    {
        statAll();
    };

    $('.btn-number').on('change', function()
    {
        caculateTotal();
    });

    $('#checkAll').on('click', function()
    {
        $('.check-product').each(function()
        {
            $(this).prop("checked", $('#checkAll').prop("checked"));
        });
        statAll();
    });

    $('.check-product').on('click', function()
    {
        var status = true;
        $('.check-product').each(function()
        {
            if(!$(this).prop("checked"))
            {
                $('#checkAll').prop("checked", false);
                status = false;
            }
        })
        if(status)
        {
            $('#checkAll').prop("checked", true);
        }
        statAll();
    });

    $('.opt.admin').on('click', function()
    {
        $(this).siblings().show();
        $(this).hide();
        $('.total').find('span').hide();
        $('.btn-order-submit').hide();
        $('.btn-order-delete').show();
    });

    $('.opt.complete').on('click', function()
    {
        $(this).siblings().show();
        $(this).hide();
        $('.total').find('span').show();
        $('.btn-order-submit').show();
        $('.btn-order-delete').hide();
    });

    $('.btn-order-delete').on('click', function()
    {
        var products = '';
        $('.check-product:checked').each(function()
        {
            products += $(this).attr('cartID') + ',';
        });
        $.getJSON(createLink('cart', 'batchdelete', 'products=' + products), function(data) 
        {
            window.location.reload();
        });
    });
});

statAll();
function statAll()
{
    var amount = 0;
    var total = 0;
    $('.check-product').each(function()
    {
        var price = $(this).parent().parent().find('.btn-number').data('price');
        var number = $(this).parent().parent().find('.btn-number').val();
        $(this).parent().parent().find('.product-amount').text(parseFloat(price*number).toFixed(2)); 
        if($(this).prop("checked"))
        {
            amount += 1;
            total += parseFloat($(this).parent().parent().find('.product-amount').html()); 
        }
    });
    total = total.toFixed(2);
    $('#amount').prev().html(amount);
    $('#amount').html($('#amount').html().substr(0,1) + total);

}
;
$(function()
{
    var countLink  = '/index.php/tw/cart-count.mhtml';
    var browseLink = '/index.php/tw/cart-browse.mhtml';
    
    $.refreshCart = function(twinkle)
    {
        $.getJSON(countLink, function(data)
        {
            if($.isPlainObject(data) && data.result === 'success')
            {
                var $count = $('.cart-count').text(data.count).toggleClass('hide', data.count < 1);
                if(data.count > 0 && twinkle)
                {
                    $count.addClass('twinkle');
                    setTimeout(function(){$count.removeClass('twinkle')}, 200);
                    if(window.v && window.v.addToCartSuccess) $.messager.success(window.v.addToCartSuccess + "<div><a class='btn success dismiss' href=" + browseLink + ">" + window.v.gotoCart + " <i class='icon-arrow-right'></i></a><div class='msger-cart-count'><i class='icon icon-shopping-cart icon-s3'></i><strong class='cart-count badge'>" + data.count + "</strong></div></div>", {time: 10000, cssClass: 'msger-cart'});
                }
            }
        });
    };
    
    $.refreshCart();
});
;
  var logLink = "/index.php/tw/log-record.mhtml";
  var browserLanguage = navigator.language || navigator.userLanguage; 
  var resolution      = screen.availWidth + ' X ' + screen.availHeight;
  $.get(logLink, {browserLanguage:browserLanguage, resolution:resolution});
  