function refreshCaptcha(id) {

  document.getElementById(id).src = '/captcha/image.php?r='+Math.random();

}

function checkAllBoxes(name, flag) {
  var checks = document.getElementsByName(name);
  for (i=0; i < checks.length; i++) {
    checks[i].checked = flag;
  }
  if(document.getElementById('checkall'+name)) 
  document.getElementById('checkall'+name)[0].checked = flag;
}

function checkTotal(name) {
  var checks = document.getElementsByName(name);
  var total = 0;
  for (i=0; i < checks.length; i++) {
    if(checks[i].checked) total++;
  }
  return total;
}

function updateTopOut(id) {
  if(document.getElementById('topsite_out_'+id)) {
    var topOut = document.getElementById('topsite_out_'+id).innerHTML;
	topOut++;
	document.getElementById('topsite_out_'+id).innerHTML = topOut;
  }
  return;
}

function clickOut(id) {
  var xmlhttp;
  if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }else{ // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
	  if(document.getElementById('topsite_out_'+id)) {
		var topOut = document.getElementById('topsite_out_'+id).innerHTML;
		topOut++;
		document.getElementById('topsite_out_'+id).innerHTML = topOut;
	  }
    }
  }
  xmlhttp.open('GET', '/js/out.php?id='+id, true);
  xmlhttp.send();
}

