$(document).ready(function(){
    $.get('/hdapp/bas/d.php?ac=getlimit',function(all){
        var reobj = eval('(' + all + ')');
        if(reobj.type == 'success'){
            location.href = "../../403.htm";
        }
    })
    $.get('/hdapp/bas/d.php?ac=all',function(all){
        var reobj = eval('(' + all + ')');
        var ttip = reobj.sysvisit.ttip;
        var ttvp = reobj.sysvisit.ttvp
        $("#umenu").html(reobj.umenu);
        $("#sys_count_ttip").html('UV/'+ttip);
        $("#sys_count_ttvp").html('PV/'+ttvp);
    })
    $.get('/hdapp/bas/d.php?ac=pdc_cart',function(all){
        var reobj = eval('(' + all + ')');
        var cart_list = reobj.cart_list;
        var total_fee = reobj.cart_price_info.total_fee;
        var goods_num = reobj.cart_price_info.goods_num;
        $('#cart_quantity').empty().html(goods_num);
        $('#cart_total_fee').empty().html(total_fee.toFixed(2));
        var carliststr = '';
        for (var i = 0; i < cart_list.length; i++) {
            var goods_price = (cart_list[i].tpc_price * cart_list[i].goods_num).toFixed(2);
            carliststr += '<a href="#"><img src="assets/images/demo/people/300x300/4-min.jpg" width="45" height="45" alt=""><h6><span>'+cart_list[i].goods_num+'x</span> '+cart_list[i].tpc_topic+'</h6><small>￥'+goods_price+'</small></a>';
        }
        $('.quick-cart-wrapper').empty().html(carliststr);
    })
});
function LimitAccess(){
    $.ajax({
        type : "POST",
        url:"../../hdapp/bas/e.php?ac=getlimit",//,
        dataType:'json',
        success: function(data){
            if(data.type == 'success'){
                location.href = "../../403.htm";
            }
        }
    });
}

var _arr    = {};
function loadScript(scriptName, callback) {

    if (!_arr[scriptName]) {
        _arr[scriptName] = true;

        var body        = document.getElementsByTagName('body')[0];
        var script      = document.createElement('script');
        script.type     = 'text/javascript';
        script.src      = scriptName;

        // then bind the event to the callback function
        // there are several events for cross browser compatibility
        // script.onreadystatechange = callback;
        script.onload = callback;

        // fire the loading
        body.appendChild(script);

    } else if (callback) {

        callback();

    }

};

function _toastr(_message,_position,_notifyType,_onclick) {
    var _btn    = jQuery(".toastr-notify");

    if(_btn.length > 0 || _message != false) {

        loadScript(plugin_path + 'toastr/toastr.js', function() {
            // toastr.clear();

            /** BUTTON CLICK
             ********************* **/
            _btn.bind("click", function(e) {
                e.preventDefault();


                var _message            = jQuery(this).attr('data-message'),
                    _notifyType         = jQuery(this).attr('data-notifyType')          || "default",
                    _position           = jQuery(this).attr('data-position')            || "top-right",
                    _progressBar        = jQuery(this).attr('data-progressBar')         == "true" ? true : false,
                    _closeButton        = jQuery(this).attr('data-closeButton')         == "true" ? true : false,
                    _debug              = jQuery(this).attr('data-debug')               == "true" ? true : false,
                    _newestOnTop        = jQuery(this).attr('data-newestOnTop')         == "true" ? true : false,
                    _preventDuplicates  = jQuery(this).attr('data-preventDuplicates')   == "true" ? true : false,
                    _showDuration       = jQuery(this).attr('data-showDuration')        || "300",
                    _hideDuration       = jQuery(this).attr('data-hideDuration')        || "1000",
                    _timeOut            = jQuery(this).attr('data-timeOut')             || "5000",
                    _extendedTimeOut    = jQuery(this).attr('data-extendedTimeOut')     || "1000",
                    _showEasing         = jQuery(this).attr('data-showEasing')          || "swing",
                    _hideEasing         = jQuery(this).attr('data-hideEasing')          || "linear",
                    _showMethod         = jQuery(this).attr('data-showMethod')          || "fadeIn",
                    _hideMethod         = jQuery(this).attr('data-hideMethod')          || "fadeOut";

                    toastr.options = {
                        "closeButton":          _closeButton,
                        "debug":                _debug,
                        "newestOnTop":          _newestOnTop,
                        "progressBar":          _progressBar,
                        "positionClass":        "toast-" + _position,
                        "preventDuplicates":    _preventDuplicates,
                        "onclick":              null,
                        "showDuration":         _showDuration,
                        "hideDuration":         _hideDuration,
                        "timeOut":              _timeOut,
                        "extendedTimeOut":      _extendedTimeOut,
                        "showEasing":           _showEasing,
                        "hideEasing":           _hideEasing,
                        "showMethod":           _showMethod,
                        "hideMethod":           _hideMethod
                    }

                toastr[_notifyType](_message);
            });


            /** JAVSCRIPT / ON LOAD
             ************************* **/
            if(_message != false) {

                if(_onclick != false) {
                    onclick = function() {
                        window.location = _onclick;
                    }
                } else {
                    onclick = null
                }

                toastr.options = {
                    "closeButton":          true,
                    "debug":                false,
                    "newestOnTop":          false,
                    "progressBar":          true,
                    "positionClass":        "toast-" + _position,
                    "preventDuplicates":    false,
                    "onclick":              onclick,
                    "showDuration":         "300",
                    "hideDuration":         "1000",
                    "timeOut":              "5000",
                    "extendedTimeOut":      "1000",
                    "showEasing":           "swing",
                    "hideEasing":           "linear",
                    "showMethod":           "fadeIn",
                    "hideMethod":           "fadeOut"
                }

                setTimeout(function(){
                    toastr[_notifyType](_message);
                }, 100); // delay 0.1s
            }
        });

    }

}