
d3.select("#clink").on("click",function(){
  var newWindow = window.open('/candy','_blank');
});

checkChat();

function checkChat(){
  d3.json("/json/candy/isOn",function(d){
    if(d != undefined){
      if (d.a=="connection error"){ 
        d3.select("#clink").style("visibility","hidden");}
      else if (d.a=="1") { d3.select("#clink").style("visibility","visible");}
      else if (d.a=="0") { d3.select("#clink").style("visibility","hidden");}
    }
  else {
    d3.select("#clink").style("visibility","hidden");
    console.error("json/candy/candy_loader/candyInterface.pl&v=isOn");}
  d3.select("#clink").transition().on("end",checkChat).delay(30000);
  });
}

