var accountNum = "t0102";
//var accountNum = "";

function SetACCookie (name, value) {
  var argv = SetACCookie.arguments;
  var argc = SetACCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  
  document.cookie = name + "=" + escape (value) + 
      ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
      ((path == null) ? "" : ("; path=" + path)) + 
      ((domain == null) ? "" : ("; domain=" + domain)) + 
      ((secure == true) ? "; secure" : "");
}

function GetACCookie(special) {
  var cookieName = (special + "=");
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + cookieName.length;
    if (document.cookie.substring(i, j) == cookieName) return GetACCookieValue(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
}

function GetACCookieValue(offset) {
  var endString = document.cookie.indexOf (";", offset);
  if (endString) endString = document.cookie.length;
  return unescape(document.cookie.substring(offset, endString));
}

function acgo()
{
  var acCookie = GetACCookie(accountNum);
  
  if (acCookie == null) {
    var expDays = 365; // number of days the cookie should last
    var expDate = new Date();
    expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays));
    
    var r = Math.round(Math.random() * 100000000);
    
    acCookie = accountNum + '-' + r;
    SetACCookie(accountNum, acCookie, expDate);
  }
  
  
  var browserNS4 = (document.layers) ? true : false;
  var browserIE = (document.all) ? true : false;
  var browserNS7 = (document.getElementById) ? true : false;
  
  if (browserIE) browserNS7 = false;
  var browserMAC = (navigator.platform) && (navigator.platform.toUpperCase().indexOf("MAC") >= 0);
  if (browserNS4) browserMAC = false;
  if (browserNS7) browserNS4 = false;
  
  
  var s = "onClick=\"window.open('http://www.answerchat.com/cgi-bin/answerchat.exe?action=js" +
      "&cPage=" + escape(document.URL) + 
      "&account=" + accountNum + 
      "&getInfo=true" +
      "&cookie=" + escape(acCookie) +
      "&browser=" + escape(navigator.appName) +
      "&bVersion=" + escape(navigator.appVersion) +
      "','" + accountNum + "','";
  
  if (browserIE)
    s = s + "width=430,height=300,resizable');return false;\">";
  else
    s = s + "width=402,height=300,resizable');return false;\">";
  
  document.write("<a href=\"answerChat\" " + s); // href for AnswerChat button
}

if (true) acgo();
