/////////////////////////////////////////////////
// getCookieVal - retrieves the value within the
//                document's cookie, which for us
//                is the number of comments this
//                post had the last time you
//                clicked to go view them.
//      
function getCookieVal(cookieName)
{
 thisCookie = document.cookie.split("; ")

 //iterate through the cookie array
 for(i=0; i < thisCookie.length; i++)
 {
   //is this our cookie?
   if(cookieName == thisCookie[i].split("=")[0])
   {
     //return this cookie's value
     return thisCookie[i].split("=")[1]
   }
 }
 return 0
}

////////////////////////////////////////////////
// setCookieVal - called when the link to the
//                comments section for a post
//                is clicked on, it will store
//                the current number of posts
//                in a cookie on your system.
//
function setCookieVal(postID)
{
 //write the cookie name (postID) and value (hs[ID])
 document.cookie = postID + "=" + hs[postID]
                              + "; expires=Fri, 01-Jan-2070 00:00:00 GMT";
}

/////////////////////////////////////////////////
// newCheck - writes out the text telling the
//            reader how many comments are new
//            since they last looked at the them.
//
function newCheck(postID)
{
 numberOfCommentsLastTime = getCookieVal(postID)
 numberOfCommentsThisTime = hs[postID]

var startspan = "<span style=\"color:#666666;\">"
document.write(startspan)

 if (numberOfCommentsThisTime - numberOfCommentsLastTime == 1)
{
  document.write("(1 new)")
}
 else if (numberOfCommentsThisTime > numberOfCommentsLastTime)
 {
   numberOfNewComments = numberOfCommentsThisTime - numberOfCommentsLastTime
   document.write("(" + numberOfNewComments + " new)")
 }
 else
 {
   document.write("(None new)")
 }

var endspan = "</span>"
document.write(endspan)

}
