﻿//Used: Sponsored.aspx | Find.aspx
function statAjax(p_url,p_params) {
    var l_url = p_url, l_params = p_params;
    if (l_params == null) l_params = '';
    $.ajax({
        type: "GET",
        url: l_url,
	    data: unescape(l_params),
	    dataType: 'html'
    });
}
// Stat para eventos de click - advertise id, event id
function statEventAjax(aid, eid) {
    statAjax('/estatisticas/ClickAjax', 'aid=' + aid + '&eid=' + eid + '&' + 'rnd=' + Math.floor(Math.random() * 10000000));
}
// Stat para lista de anúncios statAdvertiseIdList = new Array(1,2,3,4); - advertise ids, title id, state id, city id
function statViewListAjax(aids, tid, sid, cid, neighborhood, gid) {
    if (aids == null || aids == undefined) aids = new Array(); 
    if (tid == null || tid == undefined) tid = '';
    if (sid == null || sid == undefined) sid = '';
    if (cid == null || cid == undefined) cid = '';
    if (gid == null || gid == undefined) gid = '';
    if (neighborhood == null || neighborhood == undefined) neighborhood = '';
    if (aids.length > 0) {
        var params = '';
        for (i = 0; i < aids.length; i++) {
            params += 'aid=' + aids[i] + '&';
        }
        params += 'tid=' + tid + '&sid=' + sid + '&cid=' + cid + '&neighborhood=' + encodeURIComponent(escape(neighborhood)) + '&gid=' + gid + '&rnd=' + Math.floor(Math.random() * 10000000);
    }
    statAjax('/estatisticas/ViewListAjax', params);
}
