/* This javascript code uses cookies to keep track of comments the
user has viewed so far, in order to show which comments are new.
This code is free for use/modification, whatever tickles your funnybone. :-D
Have a blast - Jtoxification. Google me for info. */

/*------------------------------------------------------*/
hs_MAXSIZE=3072;

/*Shows when there's only one comment and it hasn't been read yet.*/
hs_sameCountSingle = '<span class="newcommentflag"># new comment<\/span>';

/*Shows when there's more than one comment and they haven't been read yet.*/
hs_sameCountText = '<span class="newcommentflag"># new comments<\/span>';

/*Shows when there are new comments mixed in with old comments.*/
hs_newCountText = ' <span class="newcommentflag">(# new)<\/span>';

/*------------------------------------------------------*/

hs_begin_seperator="+"; hs_seperator="&";  hs_divider="/";  hs_cookie_jar="";  hs_cookie = new Array();  hs_cookie_size=0;  hs_cookie_name = "haloscan_comments";  hs_expire_date =";expires=Fri, 01-Jan-2070 00:00:00 GMT";  hs_search = new RegExp('\\W','gi');
function hs_cookies_enabled_func() {   if (document.cookie == "")   {   document.cookie = "cookies=true";   if (document.cookie.indexOf("cookies=true") == -1)   return false;   }   return true;   }
function hs_enabled_func() {  try  {  if (hs) return true;   else return false;  }   catch(exception)  { return false; }  }
function hs_createArrayFromCookie() {   hs_cookie_jar = hs_cookie_name+"=";   var i;   var tmp = null;  var ray = null;  var str;   var ray3=null;   if (document.cookie == "") return;   ray = (""+document.cookie).split(";");   for (i = 0; i < ray.length; i++)   {   if (ray[i].indexOf(hs_cookie_name) != -1)   {   hs_cookie_jar = ray[i] + hs_divider;   str = (ray[i].split("="))[1];   ray3 = str.split(hs_divider);   if (ray3.length == 1)   {   tmp = str.split(hs_seperator);   hs_cookie[tmp[0].substr(1)] = parseInt(tmp[1]);   hs_cookie_size = 1;  return;   }   hs_cookie_size = ray3.length;   break;   }   }   if (!(i < ray.length)) return;   for(i = 0;i < hs_cookie_size;i++)   {   tmp = ray3[i].split(hs_seperator);   hs_cookie[tmp[0].substr(1)] = parseInt(tmp[1]);   }   }
function hs_newCount(id) {   var tmp = "";   var hs_ct = 0;   var cookie_ct = 0;   var ct = 0;   if (hs[id]) hs_ct = hs[id];   if (hs_cookie[id]) cookie_ct = hs_cookie[id];   ct = hs_ct-cookie_ct;   if (ct < 0) ct = 0;   if (ct==0) postCount(id);   else if ( ct==hs_ct)  {  if (ct > 1) tmp = hs_sameCountText.replace("#",ct);  else tmp = hs_sameCountSingle.replace("#",ct);  }  else   {  postCount(id);  tmp = hs_newCountText.replace("#",ct);   }  return tmp;  }
function hs_postCount(id) {    if (hs_enabled)    {    id = id.replace(hs_search,"_");    if (hs_cookies_enabled)   {   var tmp = hs_newCount(id);    if (tmp.length > 1) document.write(tmp);   }   else postCount(id); }    else document.write("Comments are down temporarily.");   }
function hs_updateCookie(postID,pCount) {   var i = hs_cookie_jar.indexOf(hs_begin_seperator+postID+hs_seperator);   if (i != -1)   {   var tmp_jar = hs_cookie_jar.substring(0,i) + hs_cookie_jar.substr(hs_cookie_jar.indexOf(hs_divider,i)+1);   hs_cookie_jar = tmp_jar;   }   hs_cookie_jar += hs_begin_seperator + postID + hs_seperator + pCount;   while ((hs_cookie_jar.length+hs_expire_date.length) > hs_MAXSIZE)   {   hs_cookie_jar = hs_cookie_name+"="+hs_cookie_jar.substr(hs_cookie_jar.indexOf(hs_divider)+1);  }   document.cookie = hs_cookie_jar + hs_expire_date; hs_cookie_jar += hs_divider;   }
function hs_HaloScan(id) {  if (hs_enabled)   {   id = id.replace(hs_search,"_");   if (hs_cookies_enabled)   {  if (hs[id]) hs_updateCookie(id,hs[id]);   else hs_updateCookie(id,0);  }   HaloScan(id);   }   }

/*Initialization Section:------------------------------------------------*/
hs_cookies_enabled = hs_cookies_enabled_func();
hs_enabled = hs_enabled_func();
if (hs_cookies_enabled) { hs_createArrayFromCookie(); }
