﻿

function ShowOrHideComments()
    {
        var showAll = document.getElementById("ShowAllCommentsValue").value;
        var commentList = document.getElementById("CommentList");
        
        if(commentList == null)
            return;
            
        if(document.getElementById("ShowAllComments") == null)
            return;
        
        var listItemCount = 1;
        for(var j = 0; j < commentList.childNodes.length; j++)
        {
            var childnode = commentList.childNodes[j];
            if (childnode.nodeName == "LI")
            {
                if(showAll == "true")
                    {commentList.childNodes[j].style.display = "";  }
                else if (listItemCount > 10)
                    { commentList.childNodes[j].style.display = "none"; }
                    
                listItemCount++;
            }
        }
        
        if(showAll == "true")
        {
            document.getElementById("ShowAllCommentsValue").value = "false";
            document.getElementById("ShowAllComments").innerHTML = "Show First 10 Comments";
        }
        else
        {
            document.getElementById("ShowAllCommentsValue").value = "true";
            document.getElementById("ShowAllComments").innerHTML = "Show All Comments";
        }
    }
