    var BoardDiv = null;
    var BoardTargetId = null;
    var BoardMemberName = null;
    var BoardMemberProfileUrl = null;
    var BoardMemberImageUrl=null;

    var TheBoard = [];
    var BoardIndex = 0;
    var BoardStatus = "";
    var BoardMessage = "";
    var BoardRender = false;
    var BoardAjaxService = JobCrank.Web.Job.API.AJAXService;

    //Event Page Text Input Methods
    function NewElement(element, isComment) 
    {
        var comment = "";
        
        if (isComment)
        {
            var EventID = TheBoard[element][4];
            BoardMessage = document.getElementById("bita" + element).value;
            
            //Post to the server
            BoardAjaxService.AddBoardComment(EventID, BoardMessage, AjaxBoardSucceededCallback, AjaxBoardFailedCallback, element, null);  
        } else {
            BoardMessage = document.getElementById(element).value;

            //Post to the server
            if (BoardTargetId.substring(0,1) == "M")
                BoardAjaxService.AddBoardMessageToMember(BoardTargetId.substring(1,BoardTargetId.length), BoardMessage, AjaxBoardSucceededCallback, AjaxBoardFailedCallback);  

            //Post to the server
            if (BoardTargetId.substring(0,1) == "P")
                BoardAjaxService.AddBoardMessageToProject(BoardTargetId.substring(1,BoardTargetId.length), BoardMessage, AjaxBoardSucceededCallback, AjaxBoardFailedCallback);  
        }

        $('textarea.expanding').autogrow();
    }

    function NewStatus(element) 
    {
            BoardStatus = document.getElementById(element).value;

            //Post to the server
            if (BoardTargetId.substring(0,1) == "M")
                BoardAjaxService.AddBoardStatusToMember(BoardStatus, AjaxBoardStatusCallback, AjaxBoardFailedCallback);  
            if (BoardTargetId.substring(0,1) == "P")
                BoardAjaxService.AddBoardStatusToProject(BoardTargetId.substring(1,BoardTargetId.length), BoardStatus, AjaxBoardStatusCallback, AjaxBoardFailedCallback);  
    }

    function RemoveElement(eventId) 
    {
        var ElementIndex = -1;
        for(i=0; i < BoardIndex; i++)
            if (TheBoard[i][4]==eventId)
            {
                ElementIndex = i;
                break;
            }

        BoardAjaxService.RemoveBoardEvent(eventId, AjaxBoardDeleteMessageCallback, AjaxBoardFailedCallback, ElementIndex, null);  
    }

    function RemoveComment(eventId, commentId) 
    {
        var ElementIndex = -1;
        var CommentIndex = -1;
        
        for(i1=0; i1 < BoardIndex; i1++)
            if (TheBoard[i1][4]==eventId)
            {
                ElementIndex = i1;
                for(i2=0; i2 < TheBoard[i1][1].length; i2++)
                    if (TheBoard[i1][1][i2][0]==commentId)
                    {
                        CommentIndex = i2;
                        break;
                    }
                break;
            }

        BoardAjaxService.RemoveBoardComment(commentId, AjaxBoardDeleteCommentCallback, AjaxBoardFailedCallback, ElementIndex + "," + CommentIndex, null);  
    }

    function ShowCommentForm(element) 
    {
        try 
        {
            document.getElementById("bff" + element).style.display = "none";
        } 
        catch(e)
        {
            //Ignore
        }
        document.getElementById("bif" + element).style.display = "block";
        document.getElementById("bita" + element).focus();
    }
    
    function OnTextAreaBlur(element, behavior) 
    {
        if (behavior == 0) 
        {
            if (document.getElementById("bita" + element).value.length == 0) 
            {
                document.getElementById("bff" + element).style.display = "block";
                document.getElementById("bif" + element).style.display = "none";
            }
        }

        if (behavior == 1) 
        {
            if (document.getElementById("bita" + element).value.length == 0) 
                document.getElementById("bif" + element).style.display = "none";
        }
    }

    //Event Page Event Types
    function WriteMessage(eventId, name, profileUrl, imageUrl, commentDate, commentText, canEdit)
    {
        var printDate = dateFormat(commentDate, "h:MM tt mmmm dS yyyy");
        
        var HtmlBlock = "<table class=\"BoardItemMessage\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><div class=\"Image\" style=\"background-image: url(" + imageUrl + "&w=50);\"><div class=\"Mask\"></div></div></td>"
            + "<td class=\"ContentCell\">"
            + "<div class=\"Name\"><a href=\"" + profileUrl + "\">" + name + "</a> <strong>wrote</strong> at " + printDate + "</div>"
            + "<div class=\"Text\">" + commentText + "</div>"
            + "</td>";
            
        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";
            
        WriteRawEvent(eventId, commentDate, HtmlBlock, true);
    }

    function WriteStatusUpdate(eventId, eventDate, byProfileUrl, byName, imageUrl, statusText, canEdit)
    {
        var printDate = dateFormat(eventDate, "h:MM tt mmmm dS yyyy");
    
        var HtmlBlock = "<table class=\"BoardItemStatus\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><div class=\"Image\" style=\"background-image: url(" + imageUrl + "&w=50);\"><div class=\"Mask\"></div></div></td>"
            + "<td class=\"ContentCell\"><div class=\"Text\"><a href=\"" + byProfileUrl + "\">" + byName + "</a> says " + statusText + "</div>"
            + "<div class=\"Info\">" + printDate;

        if  (BoardMemberName == null)
            HtmlBlock = HtmlBlock + "</div></td>";
        else 
            HtmlBlock = HtmlBlock + " - <a href=\"Javascript: ShowCommentForm([EID]);\">Comment</a></div></td>";
            
        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";
            
        WriteRawEvent(eventId, eventDate, HtmlBlock, false);
    }

    function WriteGeneralAction(eventId, eventDate, iconUrl, byProfileUrl, byName, action, aboutUrl, aboutTitle, suffixText, canEdit)
    {
        var printDate = dateFormat(eventDate, "h:MM tt mmmm dS yyyy");
    
        var HtmlBlock = "<table class=\"BoardItemGeneric\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><img src=\"" + iconUrl + "\" width=\"20\" /></td>"
            + "<td class=\"ContentCell\"><div class=\"Text\"><a href=\"" + byProfileUrl + "\">" + byName + "</a> <strong>" + action + "</strong> <a href=\"" + aboutUrl + "\">" + aboutTitle + "</a>" + suffixText + "</div>"
            + "<div class=\"Info\">" + printDate;
            
        if  (BoardMemberName == null)
            HtmlBlock = HtmlBlock + "</div></td>";
        else 
            HtmlBlock = HtmlBlock + " - <a href=\"Javascript: ShowCommentForm([EID]);\">Comment</a></div></td>";
            
        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";
            
        WriteRawEvent(eventId, eventDate, HtmlBlock, false);
    }


    function WriteGeneral(eventId, eventDate, iconUrl, byProfileUrl, byName, message, canEdit)
    {
        var printDate = dateFormat(eventDate, "h:MM tt mmmm dS yyyy");
    
        var HtmlBlock = "<table class=\"BoardItemGeneric\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><img src=\"" + iconUrl + "\" width=\"20\" /></td>"
            + "<td class=\"ContentCell\"><div class=\"Text\"><a href=\"" + byProfileUrl + "\">" + byName + "</a> " + message + "</div>"
            + "<div class=\"Info\">" + printDate;

        if  (BoardMemberName == null)
            HtmlBlock = HtmlBlock + "</div></td>";
        else 
            HtmlBlock = HtmlBlock + " - <a href=\"Javascript: ShowCommentForm([EID]);\">Comment</a></div></td>";
            
        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";
            
        WriteRawEvent(eventId, eventDate, HtmlBlock, false);
    }

    function WriteAudio(eventId, eventDate, byProfileUrl, byName, canEdit)
    {
        var printDate = dateFormat(eventDate, "h:MM tt mmmm dS yyyy");
        
        var HtmlBlock = "<table class=\"BoardItemAudio\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><img src=\"/content/images/common/memberboard/audioupdate_20x20.png\" width=\"20\" /></td>"
            + "<td class=\"ContentCell\">";

        HtmlBlock = HtmlBlock + "<div class=\"Info\"><a href=\"" + byProfileUrl + "\">" + byName + "</a> <strong>added audio</strong> on " + printDate;
        if  (BoardMemberName == null)
            HtmlBlock = HtmlBlock + "</div>";
        else 
            HtmlBlock = HtmlBlock + " - <a href=\"Javascript: ShowCommentForm([EID]);\">Comment</a></div>";

        HtmlBlock = HtmlBlock + "<div id=\"aTrack" + eventId + "\" class=\"Track\"></div></td>";

        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";

        WriteRawEvent(eventId, eventDate, HtmlBlock, false, 1);
    }

    function WriteImage(eventId, eventDate, byProfileUrl, byName, image1Url, image1Link, image2Url, image2Link, image3Url, image3Link, image4Url, image4Link, canEdit)
    {
        var printDate = dateFormat(eventDate, "h:MM tt mmmm dS yyyy");
    
        var HtmlBlock = "<table class=\"BoardItemImage\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><img src=\"/content/images/common/memberboard/photoupdate_20x20.png\" width=\"20\" /></td>"
            + "<td class=\"ContentCell\">";

        HtmlBlock = HtmlBlock + "<div class=\"Info\"><a href=\"" + byProfileUrl + "\">" + byName + "</a> <strong>added images</strong> on " + printDate;
        if  (BoardMemberName == null)
            HtmlBlock = HtmlBlock + "</div>";
        else 
            HtmlBlock = HtmlBlock + " - <a href=\"Javascript: ShowCommentForm([EID]);\">Comment</a></div>";

        if (image4Url != null)
        {
            //Super sized image! (Cause we have 4)
            HtmlBlock = HtmlBlock + "<table cellspacing=\"0\" cellpadding=\"1\">";
            HtmlBlock = HtmlBlock + "<tr><td colspan=\"3\" align=\"center\"><a href=\"" + image1Link + "\"><img src=\"" + image1Url + "&w=310\" width=\"310\" border=\"0\" /></a></td></tr>";
            HtmlBlock = HtmlBlock + "<tr>";
            HtmlBlock = HtmlBlock + "<td align=\"left\" width=\"105\"><a href=\"" + image2Link + "\"><img src=\"" + image2Url + "&w=100&s=1\" width=\"100\" border=\"0\" /></a></td>";
            HtmlBlock = HtmlBlock + "<td align=\"center\" width=\"100\"><a href=\"" + image3Link + "\"><img src=\"" + image3Url + "&w=100&s=1\" width=\"100\" border=\"0\" /></a></td>";
            HtmlBlock = HtmlBlock + "<td align=\"right\" width=\"105\"><a href=\"" + image4Link + "\"><img src=\"" + image4Url + "&w=100&s=1\" width=\"100\" border=\"0\" /></a></td>";
            HtmlBlock = HtmlBlock + "</tr>";
            HtmlBlock = HtmlBlock + "</table></td>";
        } 
        else if (image2Url == null)
        {
            //Super sized image! (Cause only 1)
            HtmlBlock = HtmlBlock + "<table cellspacing=\"0\" cellpadding=\"1\">";
            HtmlBlock = HtmlBlock + "<tr><td align=\"center\"><a href=\"" + image1Link + "\"><img src=\"" + image1Url + "&w=310\" width=\"310\" border=\"0\" /></a></td></tr>";
            HtmlBlock = HtmlBlock + "</table></td>";
        } 
        else 
        {
            //Three up only!
            HtmlBlock = HtmlBlock + "<table cellspacing=\"0\" cellpadding=\"1\">";
            HtmlBlock = HtmlBlock + "<tr>";
            HtmlBlock = HtmlBlock + "<td align=\"left\" width=\"105\"><a href=\"" + image1Link + "\"><img src=\"" + image1Url + "&w=100\" width=\"100\" border=\"0\" /></a></td>";

            if (image2Url != null)
                HtmlBlock = HtmlBlock + "<td align=\"center\" width=\"100\"><a href=\"" + image2Link + "\"><img src=\"" + image2Url + "&w=100\" width=\"100\" border=\"0\" /></a></td>";
            else
                HtmlBlock = HtmlBlock + "<td align=\"center\" width=\"100\">&nbsp;</td>";

            if (image3Url != null)
                HtmlBlock = HtmlBlock + "<td align=\"right\" width=\"105\"><a href=\"" + image3Link + "\"><img src=\"" + image3Url + "&w=100\" width=\"100\" border=\"0\" /></a></td>";
            else
                HtmlBlock = HtmlBlock + "<td align=\"right\" width=\"105\">&nbsp;</td>";
            HtmlBlock = HtmlBlock + "</tr>";

            HtmlBlock = HtmlBlock + "</table></td>";
                
        }

        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveElement(" + eventId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";

            
        WriteRawEvent(eventId, eventDate, HtmlBlock, false);
    }

    function WriteRawEvent(eventId, eventDate, htmlBlock, canComment, postRunFlag) 
    {
        TheBoard[BoardIndex]=[];
        TheBoard[BoardIndex][0]= htmlBlock;
        TheBoard[BoardIndex][1]=[];
        TheBoard[BoardIndex][2]=canComment;
        TheBoard[BoardIndex][3]=eventDate;
        TheBoard[BoardIndex][4]=eventId;
        TheBoard[BoardIndex][5]=postRunFlag;
        BoardIndex++;

        BuildEventPage();
    }

    //Event Page Comments
    function WriteComment(commentId, elementIndex, name, profileUrl, imageUrl, commentDate, commentText, canEdit)
    {
        var CommentIndex = TheBoard[elementIndex][1].length;

        var printDate = dateFormat(commentDate, "h:MM tt mmmm dS yyyy");
    
        var HtmlBlock = "<table class=\"BoardItemComment\" cellspacing=\"0\" cellpadding=\"0\"><tr>"
            + "<td class=\"ImageCell\"><div class=\"Image\" style=\"background-image: url(" + imageUrl + "&w=35);\"><div class=\"Mask\"></div></div></td>"
            + "<td class=\"ContentCell\">"
            + "<div class=\"Name\"><a href=\"" + profileUrl + "\">" + name + "</a> at " + printDate + "</div>"
            + "<div class=\"Text\">" + commentText + "</div>"
            + "</td>";

        if (canEdit) 
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"><img src=\"/content/images/common/memberboard/delete_13x13.png\" onclick=\"RemoveComment(" + TheBoard[elementIndex][4] + "," + commentId + ");\" alt=\"Delete\" border=\"0\"></a></td>";
        else
            HtmlBlock = HtmlBlock + "<td class=\"IconCell\"></td>";

        HtmlBlock = HtmlBlock + "</tr></table>";
            
        TheBoard[elementIndex][1][CommentIndex]=[];
        TheBoard[elementIndex][1][CommentIndex][0]=commentId;
        TheBoard[elementIndex][1][CommentIndex][1]=HtmlBlock;
        BuildEventPage();
    }

    function WriteCommentOnLast(commentId, name, profileUrl, imageUrl, commentDate, commentText, canEdit)
    {
        WriteComment(commentId, BoardIndex-1, name, profileUrl, imageUrl, commentDate, commentText, canEdit)
    }
    
    function RenderBoard()
    {
        BoardRender = true;
        BuildEventPage();
    }
    
    //Event Page Render
    function BuildEventPage()
    {
        if (!BoardRender) return;
    
        var HtmlBlock = "";
        var ShowCommentForm = false;
        var LastPrintDate = "";

        for (i1=BoardIndex-1; i1 >= 0; i1--) 
        {
            ShowCommentForm = TheBoard[i1][2];

            var PrintDate = "";

            var Today = new Date();
            if (Today.toDateString() == TheBoard[i1][3].toDateString()) 
                PrintDate = "Today";
            else if (Today.getFullYear() == TheBoard[i1][3].getFullYear())
                PrintDate = dateFormat(TheBoard[i1][3], "mmm dS");
            else 
                PrintDate = dateFormat(TheBoard[i1][3], "mmm dS yyyy");

            
            if (LastPrintDate != PrintDate)
            {
                HtmlBlock = HtmlBlock + "<div class=\"BoardDay\"><font class=\"BoardDayText\">" + PrintDate + "</font></div>";
                LastPrintDate = PrintDate;
            }
            else
                if (i1 < BoardIndex-1)
                    HtmlBlock = HtmlBlock + "<div class=\"BoardItemDivider\"></div>";

            
            HtmlBlock = HtmlBlock + "<div class=\"BoardItem\">" + TheBoard[i1][0].replace("[EID]", i1); + "</div>";
            for (i2=0; i2 < TheBoard[i1][1].length; i2++) 
            {
                HtmlBlock = HtmlBlock + TheBoard[i1][1][i2][1];
                ShowCommentForm = true;
            }

            if (BoardMemberName != null)
            {
                if (ShowCommentForm) 
                {
                    HtmlBlock = HtmlBlock + "<div class=\"BoardFormFake\" id=\"bff" + i1 + "\" onclick=\"ShowCommentForm(" + i1 + ");\">" 
                        + "<div class=\"FormText\">Write a comment...</div>"
                        + "</div>";

                    HtmlBlock = HtmlBlock + "<div class=\"BoardForm\" id=\"bif" + i1 + "\" style=\"display:none\">" 
                        + "<div class=\"FormText\"><textarea id=\"bita" + i1 + "\" onblur=\"OnTextAreaBlur(" + i1 + ", 0);\" class=\"expanding\"></textarea></div>"
                        + "<div class=\"FormButton\"><input type=\"button\" id=\"bibt" + i1 + "\" value=\"Comment\" onclick=\"NewElement(" + i1 + ", true)\" /></div>"
                        + "</div>";
                } 
                else 
                {
                    HtmlBlock = HtmlBlock + "<div class=\"BoardForm\" id=\"bif" + i1 + "\" style=\"display:none\">"
                        + "<div class=\"FormText\"><textarea id=\"bita" + i1 + "\" onblur=\"OnTextAreaBlur(" + i1 + ", 1);\" class=\"expanding\"></textarea></div>"
                        + "<div class=\"FormButton\"><input type=\"button\" id=\"bibt" + i1 + "\" value=\"Comment\" onclick=\"NewElement(" + i1 + ", true)\" /></div>"
                        + "</div>";
                }
            }
            
        }

        BoardDiv.innerHTML = HtmlBlock;

		var flashVersionFound = false;
        try 
        {
		    var flashVersionFound = DetectFlashVer(7, 0, 0);
        } 
        catch (e)
        {
            //Ignore
        }

        //Run post generation events
        for (i1=0; i1 < BoardIndex; i1++) 
        {
            //Does an audio player need to be intialized?
            if (TheBoard[i1][5] == 1) 
            {
		        if (flashVersionFound) {
		            //Display player
                    var so = new SWFObject("/content/swf/mp3player/playerMultipleList.swf", "track" + TheBoard[i1][4], "310", "150", "7", "#FFFFFF");  
                    so.addVariable("autoPlay","no")
                    so.addVariable("playlistPath","/API/AudioTrackList.aspx?me=" + TheBoard[i1][4])
                    so.write("aTrack" + TheBoard[i1][4]);
		        } else {
		            //Display error
			        var errorHtml = "<a href=\"http://www.adobe.com/products/flashplayer/\"><img src=\"/content/swf/mp3player/mp3player.png\" width=\"192\" height=\"67\" border=\"0\" /></a>";
			        InsertFlashObject(document.getElementById("aTrack" + TheBoard[i1][4]), errorHtml);
		        }
            }
        }
    }
    
    function AjaxBoardSucceededCallback(result, userContext, methodName)
    {
        if (result > (-1)) 
        {
            if (userContext != null)
                WriteComment(result, userContext, BoardMemberName, BoardMemberProfileUrl, BoardMemberImageUrl, new Date(), BoardMessage, true); 
            else            
                WriteMessage(result, BoardMemberName, BoardMemberProfileUrl, BoardMemberImageUrl, new Date(), BoardMessage, true); 
        } 
        else
            alert("An error occurred while posting your comment.");
    }

    function AjaxBoardStatusCallback(result, userContext, methodName)
    {
        if (result > (-1)) 
        {
            WriteStatusUpdate(result, new Date(), BoardMemberProfileUrl,  BoardMemberName, BoardMemberImageUrl, BoardStatus, true)
        } 
        else
            alert("An error occurred while posting your comment.");
    }

    function AjaxBoardDeleteMessageCallback(result, userContext, methodName)
    {
        if (result==true)
        {
            for (i1=parseInt(userContext); i1<(TheBoard.length - 1); i1++)
                TheBoard[i1] = TheBoard[i1+1];

            TheBoard.length = TheBoard.length - 1;
            BoardIndex = BoardIndex - 1;

            BuildEventPage();
            $('textarea.expanding').autogrow();
        } 
        else
            alert("An error occurred while removing your comment.");
    }


    function AjaxBoardDeleteCommentCallback(result, userContext, methodName)
    {
        if (result==true)
        {
            var IndexArray = userContext.split(',');
        
            for (i1=parseInt(IndexArray[1]); i1<(TheBoard[parseInt(IndexArray[0])][1].length - 1); i1++)
                TheBoard[IndexArray[0]][1][i1] = TheBoard[IndexArray[0]][1][i1+1];

            TheBoard[IndexArray[0]][1].length = TheBoard[IndexArray[0]][1].length - 1;

            BuildEventPage();
            $('textarea.expanding').autogrow();
        } 
        else
            alert("An error occurred while removing your comment.");
    }

    function AjaxBoardFailedCallback(error)
    {
        alert("A system error occurred while posting your comment.  Please try again later.");
    }


