// User name to color comments for.
var ownerName = "Wind Li";

function getCookie (name) {
    var dc = document.cookie;
    var cname = name + "=";

    if (dc.length > 0) {
      begin = dc.indexOf(cname);
      if (begin != -1) {
        begin += cname.length;
        end = dc.indexOf("", begin);
        if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
        }
      }
    return null;
}

function onContentLoad(event) {

	var currentUser = getCookie("commentAuthor");

//	alert(currentUser);
        // Find all the "comment-detail" class entries.
        var allCommentDetails = document.evaluate(
            "//p[@class='comment-details']//b",
            document,
            null,
            XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
            null);


        // If any of the comments are from the given user, adjust their CSS
        // to make them more prominent.
	var snaplength = 0;
	if (document.addEventListener) {
		snaplength = allCommentDetails.snapshotLength;
	}
	else
	{
		snaplength = allCommentDetails.getSnapshotLength();
	}
        for (var i = 0; i < snaplength; i++) {
             thisComment = allCommentDetails.snapshotItem(i);
             if (thisComment.textContent == ownerName || thisComment.textContent == currentUser) {
                 // Find the first parent <div> element.
                 div = thisComment.parentNode;
                 while (div.tagName != "DIV") {
                     div = div.parentNode;
                 }

                 // Set its style to be more prominent.
		 if (currentUser == thisComment.textContent )
                   div.style.backgroundColor = "EEEBEB";
		 else
                   div.style.backgroundColor = "CEEBEB";
                 div.style.color = "black";
            }
        }
    
}


/* for Mozilla */
   if (document.addEventListener) {
       document.addEventListener("DOMContentLoaded", onContentLoad, false);
   }
