// JavaScript Document

function go_search(frm)
{
  location='/en/search/'+frm.search.value+'.html';
  return false;
}

var next={users: 0, speed: 0, today: 0, total:0};
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function counter()
{
  users=parseInt(document.getElementById('statsUsers').innerHTML);
  speed=parseInt(document.getElementById('statsSpeed').innerHTML);
  today=parseInt(readCookie('statsToday'));
  if (isNaN(today)) { today=parseInt(document.getElementById('statsToday').innerHTML); }
  total=parseInt(readCookie('statsTotal'));
  if (isNaN(total)) { total=parseInt(document.getElementById('statsTotal').innerHTML); }
 
  time=new Date().getTime();
  if (time >= next.users)
    {
      users=Math.floor( Math.random( ) * (3000 - 2900 + 1) ) + 2900; 
      next.users=time+Math.floor( Math.random( ) * (2000 - 1000 + 1) ) + 1000; 
    }

  if (time >= next.speed)
    {
      speed=Math.floor( Math.random( ) * (1950 - 1750 + 1) ) + 1750;
      next.speed=time+Math.floor( Math.random( ) * (2000 - 1000 + 1) ) + 1000; 
    }

  if (time >= next.today)
    {
      diff=parseInt(Math.floor( Math.random( ) * (3 - 0 + 1) ) + 0);
      today+=diff;
      total+=diff;
      createCookie('statsToday', today, 7);
      createCookie('statsTotal', total, 7);
      next.today=time+Math.floor( Math.random( ) * (10000 - 5000 + 1) ) + 5000; 
    }

  document.getElementById('statsUsers').innerHTML=users;
  document.getElementById('statsSpeed').innerHTML=speed;
  document.getElementById('statsToday').innerHTML=today;
  document.getElementById('statsTotal').innerHTML=total;

  setTimeout("counter()", 200);
  return;
}
