define(function (require, exports, module) {


    var URL = 'http://zhushou.huihui.cn/log?';
    var LOG_TYPE = 'ARMANI_EXTENSION_PAGE';

    var img = new Image();

    var defaultParams = {
        action: 'click',
        type: LOG_TYPE
    };

    var _sendLog = function (logAction, logType, position) {
        var params = _.clone(defaultParams);
        params.action = logAction;

        if (logType) {
            params.type = logType;
        }

        if (position) {
            params.position = position;
        }

        var url = URL;
        for (var pro in params) {
            if (params.hasOwnProperty(pro)) {
                url = url + pro + '=' + params[pro] + '&';
            }
        }
        url = url.slice(0, url.length - 1);
        img.src = url;
    };


    // 注册点击事件
    $(document).delegate('[clkAction]', 'click', function (e) {
        var logAction = $(this).attr('clkAction');
        var position = $(this).data('position');
        _sendLog(logAction, LOG_TYPE, position);
    });

    // 注册hover事件
    $(document).delegate('[hovAction]', 'hover', function (e) {
        var logAction = $(this).attr('hovAction');
        var position = $(this).data('position');
        _sendLog(logAction, LOG_TYPE, position);
    });


    module.exports = function (logAction, logType, position) {
        _sendLog(logAction, logType, position);
    };

});
