//establecemos el intervalo con el que se actualizara
//el monitor de inteligencia colectiva
var pandaCollectiveIntellingenceUpdateInterval = 1500;	//cada segundo y medio


setInterval("updatePandaCollectiveIntelligence()",pandaCollectiveIntellingenceUpdateInterval);
setInterval("updateVirusAcumuladosHoy()",pandaCollectiveIntellingenceUpdateInterval);


/**
	Funcion que se ejecuta cada x tiempo y actualiza en contador
	del monitor de inteligencia colectiva
*/
function updatePandaCollectiveIntelligence(){ 

	if(secServidorGlobalIC != -1){
	
		secServidorGlobalIC = secServidorGlobalIC + 1;
		
		acumVirusGlobalTotalIC =  acumVirusGlobal + (incVirusGlobal*secServidorGlobalIC);
		
		$('#contadorAnalyzedViruses').html(addCommas(Math.round(acumVirusGlobalTotalIC)));
	}
}

function updateVirusAcumuladosHoy(){

	if(secServidor != -1){

		secServidor = secServidor + 1;
		
		acumVirusHoyTotal = acumVirusHoy + (incVirusHoy * secServidor);
		
		$('#virusAcumuladosHoy').html(addCommas(Math.round(acumVirusHoyTotal)));
	}
}


function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + '.' + '$2');
    }
    return x1 + x2;
}



function checkTime(i){
	if (i<10){
	  i="0" + i;
	}
	return i;
}


