var accountNum = "t0133";
//var accountNum = "";

function SetACCookie(name, value, expires, path, domain, secure) {
  document.cookie= name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; 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 acAccountUrl = GetHostNameURL();
  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, '/', '.' + acAccountUrl, 0);
  }
  
  
  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 + "','";
  
  s = s + "width=590,height=356,resizable=no');return false;\">";
  
  document.write("<a href=\"answerChat\" " + s); // href for AnswerChat button
}

function GetHostNameURL() {
  var tempUrl = document.location.hostname;
  
  if (tempUrl.substr(0, 4) == "www.")
    tempUrl = tempUrl.substring(4);
  
  return tempUrl;
}

if (true) acgo();

