﻿//var RSUrl = 'http://server-it.imrworldwide.com/cgi-bin/count?cid=';
//var cid = 'it_Matrix-it_0';
var RSUrl = '//secure-it.imrworldwide.com/cgi-bin/m?ci=';
var cid = 'matrix-it';

// Stefano Chiari 10/2/2010
// Indicazione di Nielsen (a seguito di una telefonata): non encordare tutto ma solo i : per fare in modo che 
// non venga interpretato come url
var channelName = (document.location.href).replace('http:', 'http%3A');

/* Ricarica Red Sheriff */
function callRS(channelParam) {
    var param = '';
    if (channelParam) {
        param = channelParam;
    }
    var rnd = Math.floor(Math.random() * 10000000);
    //var url = RSUrl + cid + '&url=' + channelName + param + '&rnd=' + rnd;
	var url = RSUrl + cid + '&cg=0' + '&si=' + channelName + param + '&rnd=' + rnd;
    var imgRS = document.getElementById('imgRS');
    if (!imgRS) {
        imgRS = document.createElement('IMG');
        imgRS.id = 'imgRS';
        document.body.appendChild(imgRS);
    }
    imgRS.src = url;
}

/* Ricarica Red Sheriff */
function reloadRSSpecificId(strIdImg, strIdContainer, channelParam) {
    if (document.getElementById(strIdImg) == null || document.getElementById(strIdImg) == undefined) {
        var returns = function () {return callRSSpecificId(strIdImg, strIdContainer, channelParam);};
	this.curTimeout = setTimeout(returns, (this.timeout * 1000));
        return false;
    }
    callRSSpecificId(strIdImg, strIdContainer, channelParam);
}

function callRSSpecificId(strIdImg, strIdContainer, channelParam) {
    var param = '';
    if (channelParam) {
        param = channelParam;
    }
    var rnd = Math.floor(Math.random() * 10000000);
    var url = RSUrl + cid + '&url=' + channelName + param + '&rnd=' + rnd;
    var imgRSSpecificId = document.getElementById(strIdImg);
    if (imgRSSpecificId == null || imgRSSpecificId == undefined) {
        var imgRSCreate = document.createElement('IMG');
        imgRSCreate.id = strIdImg;
        document.getElementById(strIdContainer).appendChild(imgRSCreate);
    }
    imgRSSpecificId = null;
    imgRSSpecificId = document.getElementById(strIdImg);
    imgRSSpecificId.src = url;
}

function callRSSpecificUrl(strUrl){
	 channelName=strUrl;
	 callRS();
}
