 /**
 * sldisplay.js
 *
 * This script contains all of the necessary fucntions to actually
 * write HTML to the page.  This file should be entirely overwritten
 * by WPNI as they make the user experience, look and feel, and
 * style, their own.
 * 
 * The general integration strategy is that an HTML div element must
 * exist somewhere on the page and have a given name.  Each of these
 * methods is "hooked" back into a DAAPI call and executed when the
 * data is actually returned from SiteLife.
 */

function SiteLifeDisplay () {

    this.commentsPageDivId = "CommentsPageDisplay"
    this.CommentsPagePlaceHolder = function() {
        document.write("<div id=\"" + this.commentsPageDivId + "\"><div class=\"loading\"><img alt=\"Loading...\" src=\"/wp-srv/community/images/wait.gif\" align=\"middle\" class=\"loadingicon\" /><br />Loading...</div></div>");
    }

    this.commentCountDivId = "CommentCount"
    this.commentCountClassName = "comment-count"
    this.commentCountTextClassName = "comment-count-text"
    this.CommentCountPlaceHolder = function() {
        document.write("<span id=\"" + this.commentCountDivId + "\"></span>");
    }
    this.CommentCountPlaceHolderByClass = function() {
        document.write("<span class=\"" + this.commentCountClassName + "\"></span>");
    }

    this.DrawHeadlineCommentCount = function(art) {
	// do id to support old way
		if ( document.getElementById(slDisplay.commentCountDivId) ) {
        	var where = document.getElementById(slDisplay.commentCountDivId);
        	// where.innerHTML = (typeof art == 'undefined' || art == null ) ? 0 : art.Comments.NumberOfComments ;
        	var text = (typeof art == 'undefined' || art == null ) ? 0 : art.Comments.NumberOfComments ;
			var note = document.createTextNode(text);
			where.appendChild(note) ;
		}

	// but also do it by class name
        if ( document.getElementsByClassName ) {
        	var elements = document.getElementsByClassName(slDisplay.commentCountClassName) ;
			for ( var i=0; i<elements.length; i++ ) {
			var e = elements[i] ;
        		// e.innerHTML = (typeof art == 'undefined' || art == null ) ? 0 : art.Comments.NumberOfComments ;
        		var text = (typeof art == 'undefined' || art == null ) ? 0 : art.Comments.NumberOfComments ;
				var note = document.createTextNode(text);
				e.appendChild(note) ;
			}
        }

	// for more than just the number
        if ( document.getElementsByClassName ) {
        	var elements = document.getElementsByClassName(slDisplay.commentCountTextClassName) ;
		for ( var i=0; i<elements.length; i++ ) {
			var e = elements[i] ;

        		var comment_count = (typeof art == 'undefined' || art == null ) ? 0 : art.Comments.NumberOfComments ;
        		var has_comments = ( comment_count > 0 ) ;
				var comments_period = ( typeof wp_article != "undefined" && typeof wp_article.comments_period != "undefined" && ( wp_article.comments_period != "" || wp_article.comments_period == "0" ) && wp_article.comments_period >= 0 ) ? wp_article.comments_period : 3 ;
				var comments_open = !checkDaysOld(comments_period) ;
        		var has_pullquote = false ;

        		var word = 'comment' ;
        		if ( comment_count > 1 )
        			word += 's' ;

			var note = document.createElement("div");
			note.className="comment-text";

        		if ( !COMMENTS_ACTIVE ) {
				
				if ( has_comments ) {
					note = getViewAllNote(note);
        			} else {
        				var text = 'No comments have been posted about this item.' ;
					var tn = document.createTextNode(text);
        				note.appendChild(tn) ;
				}
        		} else {
        			if ( !has_comments ) {
        				var text = 'No comments have been posted yet about this item. Be the first!' ;
					var tn = document.createTextNode(text);
        				note.appendChild(tn) ;
        			} else {
        				if ( !has_pullquote ) {
						note = getViewAllNote(note);
        				} else {
        				}
       				}
       			}

        		e.appendChild(note) ;
		}
	}
    	function getViewAllNote(parent) {
		var text1 = 'washingtonpost.com readers have posted ' ;
		var tn1 = document.createTextNode(text1);

		var strong = document.createElement("strong");
		var strong_text = comment_count+' '+word ;
		var strong_tn = document.createTextNode(strong_text);
		strong.appendChild(strong_tn);

		var text2 = ' about this item.'
		var tn2 = document.createTextNode(text2);

		var br = document.createElement("br");

		var a = document.createElement("a");
		a.setAttribute("href",wp_article.comments_url);
		var a_text = 'View All Comments \u00BB' ;
		var a_tn = document.createTextNode(a_text);
		a.appendChild(a_tn);

		parent.appendChild(tn1) ;
		parent.appendChild(strong) ;
		parent.appendChild(tn2) ;
		parent.appendChild(br) ;
		parent.appendChild(a) ;

		return parent ;
    	}
    }

	this.DrawDiscoveredCommentedArticles = function(art) {
		this.DrawDiscoveredArticles(art,"divArticlesMostCommented");
	}
	this.DrawDiscoveredRecommendedArticles = function(art) {
		this.DrawDiscoveredArticles(art,"divArticlesMostRecommended");
	}
	this.DrawDiscoveredArticles = function(art,elemId) {
		// draw the pertinante info for discovered articles
		var parent = document.getElementById(elemId);
		for (var i=0;i < art.DiscoveredArticles.length; i++) {
			parent.appendChild(this.DrawArticleInfo(art.DiscoveredArticles[i]));
		}
	}
	this.DrawArticleInfo = function(disc) {
		var div = document.createElement("div");
			div.id = "DiscoveredArticle";
		var pageTitle = document.createElement("div");
			pageTitle.innerHTML = "Page Title : "+disc.PageTitle;
		var pageUrl = document.createElement("div");
			pageUrl.innerHTML = "Page Url : "+disc.PageUrl;
		var Comments = document.createElement("div");
			Comments.innerHTML = "Number of Comments : "+disc.Comments.NumberOfComments;
		var Recommendations = document.createElement("div");
			Recommendations.innerHTML = "Number of Recommendations : "+disc.Recommendations.NumberOfRecommendations;
		var Seperator = document.createElement("hr");

		div.appendChild(pageTitle);
		div.appendChild(pageUrl);
		div.appendChild(Comments);
		div.appendChild(Recommendations);
		div.appendChild(Seperator);
		return div;
	}
}

// Instantiate the SiteLifeDisplay object for use on the page.
var slDisplay = new SiteLifeDisplay();

function CommentPretty(loc,myComment,author) {
	var divComment = document.createElement("div");
	divComment.className="Article_Comment";
	divComment.id="articleComment_" + myComment.CommentKey.Key;

	// <<user>> wrote:
	var divAuthor = document.createElement("div");
	divAuthor.className="Comments_From";
	var a=document.createElement("a");
	
	var directory = "";
	
	
	if(document.domain=="digitalink.com"){
		directory = "/wp-dyn/content/custom/2006/09/25/CU2006092500203.html?newspaperUserId=";
	} else {
		var directory = "/wp-srv/community/mypost/index.html?newspaperUserId=";
	}
			a.href = directory+author.DisplayName+'&plckUserId='+author.DisplayName;
		a.innerHTML = author.DisplayName;
	var span=document.createElement("span");
		span.innerHTML = "&nbsp;wrote:";
	divAuthor.appendChild(a);
	divAuthor.appendChild(span);

	// comment
	var divCmt = document.createElement("div");
		divCmt.className="Comments_CommentText";
		divCmt.innerHTML = myComment.CommentBody;

	// date
	var divDate = document.createElement("div");
		divDate.className="Comments_NestedDate";
		divDate.innerHTML = myComment.PostedAtTime;

	divComment.appendChild(divAuthor);
	divComment.appendChild(divCmt);
	divComment.appendChild(divDate);
	CommentTools(divComment,myComment);

	var PermaLinkEl = document.createElement("div");
	PermaLinkEl.id = "articleComment_" + myComment.CommentKey.Key + "_link";
	PermaLinkEl.className="Comments_PermaLink";
	loc.appendChild(PermaLinkEl);
	cmt.CommentPermaLinkButton(myComment,PermaLinkEl);
	divComment.appendChild(PermaLinkEl);

	var StaffRecEl = document.createElement("div");
	StaffRecEl.id = "articleComment_" + myComment.CommentKey.Key + "_staffrec";
	StaffRecEl.className="Comments_StaffRec";
	loc.appendChild(StaffRecEl);
	cmt.CommentStaffRecommendsButton(myComment, StaffRecEl);
	divComment.appendChild(StaffRecEl);

	loc.appendChild(divComment);
}
function CommentTools(parent,cmt) {
	var table = document.createElement("table");
		table.className="Comments_NestedTable";
		table.setAttribute("cellspacing","0");
		table.setAttribute("cellpadding","0");
	var tbody = document.createElement("tbody");
	var tr = document.createElement("tr");
	var td1 = document.createElement("td");
		td1.className="Comments_NestedRecommend";
		RecommendLink(td1,cmt);
	var td2 = document.createElement("td");
		td2.className="Comments_NestedReport";
		AbuseLink(td2,cmt);

	tr.appendChild(td1);
	tr.appendChild(td2);
	tbody.appendChild(tr);
	table.appendChild(tbody);
	parent.appendChild(table);
}
function PolicyLink(parent) {
	var span = document.createElement("span");
		span.className = "Comments_AbusePolicyLink";
	var a = document.createElement("a");
		a.setAttribute("href","http://www.washingtonpost.com/wp-srv/liveonline/delphi/delphirules.htm");
		a.innerHTML="Discussion Policy";
	span.appendChild(a);
	parent.appendChild(span);
}
function RecommendLink(parent,cmmt) {
	var divname="recommend_"
	var key = cmmt.CommentKey.Key;
	var RecommendDiv = document.createElement("div");
		RecommendDiv.id = divname+key;
		if (cmmt.CurrentUserHasRecommended == "False") {
			var RecommendA = document.createElement("a");
			RecommendA.className = "SiteLife_Recommend";
			RecommendA.onclick = function() {cmt.Recommend(key,Recommended(RecommendDiv.id));};
			RecommendA.setAttribute("href","javascript:void(0)");
			RecommendA.innerHTML = "Recommend ("+parseInt(cmmt.NumberOfRecommendations)+")";
			RecommendDiv.appendChild(RecommendA);
		}
		else {  // already recommended
			var RecommendSpan = document.createElement("span");
			RecommendSpan.className = "SiteLife_Recommended";
			RecommendSpan.innerHTML = "Recommended ("+parseInt(cmmt.NumberOfRecommendations)+")";
			RecommendDiv.appendChild(RecommendSpan);
		}
		parent.appendChild(RecommendDiv);
}
function AbuseLink(parent,cmt) {
	var divname="abuse_"
	var key = cmt.CommentKey.Key;
	var ReportAbuseDiv = document.createElement("div");
	ReportAbuseDiv.id = divname+key;

	var ReportAbuseA = document.createElement("a");
	if (cmt.CurrentUserHasReportedAbuse == "False") {
		ReportAbuseA.className = "SiteLife_ReportAbuse";
		ReportAbuseA.onclick =  function (event) { wpShowReportAbuse(event||window.event, key);};
		ReportAbuseA.setAttribute("href","javascript:void(0)");
		ReportAbuseA.innerHTML = "Report Abuse";
	} else {  // already reported
		ReportAbuseA.className = "SiteLife_Reported";
		ReportAbuseA.setAttribute("href","javascript:void(0)");
		ReportAbuseA.setAttribute("style","text-decoration:none;");
		ReportAbuseA.innerHTML = "Reported";
	}
	ReportAbuseDiv.appendChild(ReportAbuseA);

		var space = document.createTextNode("\u00a0");
		ReportAbuseDiv.appendChild(space);
		PolicyLink(ReportAbuseDiv);
		parent.appendChild(ReportAbuseDiv);
}
function Recommended(id) {
		var divname="recommend_"
        var elem = document.getElementById(id);
        elem.className = "SiteLife_Recommended";
        elem.innerHTML = "Recommended ("+parseInt(1+cmt.RecommendedCount(id.substring(divname.length)))+")";
}
function Abusive(id) {
	var elem = document.getElementById(id);
	children = elem.childNodes;
	for (var i=0; i<children.length;i++) {
		var child = children[i];
		if (child.className == "SiteLife_ReportAbuse") {
			child.className = "SiteLife_Reported";
			child.setAttribute("style","text-decoration:none;");
			// child.onclick =  void(0) ;
			child.innerHTML = "Reported";
		}
	}
}

function DrawComments(myComments) {
	var where = document.getElementById(slDisplay.commentsPageDivId);

    // REVISIT - get rid of the loading icon
    where.innerHTML = "";
	// wpPagination(where);
/*
	for (var c=0;c < myComments.length;c++) {

        // BLOCK BLOCKED USERS
        if (myComments[c].Author.IsBlocked != "True") {

		    CommentPretty(where,myComments[c],myComments[c].Author);
        }
	}
*/

      for (var c=0;c < myComments.length;c++) {

                CommentPretty(where,myComments[c],myComments[c].Author);

            }


	
//	var newDiv = document.createElement('div');
//	newDiv.innerHTML = "done!";
	//document.body.insertBefore(newDiv,where);

//	where.appendChild(newDiv);


	//document.body.insertBefore(tbl,where);
   // where.insertBefore(tbl);
	
	wpPagination(where);
	
}
function countChars(field,countfield, maxlimit){
	if ( document.getElementById(field) ) {
		if (document.getElementById(field).value.length > maxlimit) { // trim if too long
			document.getElementById(field).value = document.getElementById(field).value.substring(0, maxlimit);
		}
		else if ( document.getElementById(countfield)) {
			document.getElementById(countfield).innerHTML = maxlimit - document.getElementById(field).value.length  ;
		}
	}
}
function trim(s) {
	if ( s != null ) {
		s = s.replace(/^\s+/,'') ;
		s = s.replace(/\s+$/,'') ;
	}
	return s
}
function ValidateComment(field,key) {
	var theComment = document.getElementById(field).value;
	if ( (theComment == null) || (trim(theComment).length == 0) ) {
		var er = document.getElementById('clearboth');
		er.style.display = "block";
		er.innerHTML= 'You must make a comment';
		return;
	}
	cmt.AddComment(key,theComment);
}
function DrawCommentsInput(parent,key,values) {


        // init values
        var rows = 6 ;
        var cols = 42 ;
        var button_text = "Post" ;
        var show_directions = true ;
        var directions = "Add a comment" ;
        var count = 5000 ;
        var show_count = true ;
        var default_comment_text = "" ;
        var submit_button = "" ;

        if ( values ) {
                if ( values.rows )
                        rows = values.rows ;
                if ( values.cols )
                        cols = values.cols ;
                if ( values.button_text )
                        button_text = values.button_text ;
                if ( typeof values.show_directions != "undefined" )
                        show_directions = values.show_directions ;
                if ( values.directions )
                        directions = values.directions ;
                if ( values.count )
                        count = values.count ;
                if ( typeof values.show_count != "undefined" )
                        show_count = values.show_count ;
                if ( values.default_comment_text )
                        default_comment_text = values.default_comment_text ;
                if ( values.submit_button )
                        submit_button = values.submit_button ;
        }

        var display_count = "compact" ;

        if (! show_count )
                display_count = "none" ;
        var form = document.createElement("form");
                form.name = "wp_Comments";
        var textarea = document.createElement("textarea");
                textarea.rows = rows ;
                textarea.cols = cols ;
                textarea.id = "wp_comments_comment";
                textarea.name ="wp_comments_comment";
                if ( show_count ) {
                	textarea.onkeydown = function() {countChars('wp_comments_comment','charCountDisplayComment',5000);};
                	textarea.onkeyup = function() {countChars('wp_comments_comment','charCountDisplayComment',5000);};
                	textarea.onclick = function() {countChars('wp_comments_comment','charCountDisplayComment',5000);};
                }
                if ( default_comment_text ) {
                	textarea.onfocus = activate_comment_form;
                	textarea.onblur = deactivate_comment_form;
                	textarea.value = default_comment_text ;
                	textarea.style.color = "#999;";
                }
                textarea.maxLength = 5000;
				
				if (document.cookie.indexOf("wpniuser") == -1) {
					textarea.disabled = true;
				}
				
				
        var br = document.createElement("br");
        var input = document.createElement("input");
	if ( 0&&submit_button ) {
		input.type = "image";
		input.src = submit_button ;
	} else {
		input.type = "button";
		input.value = button_text ;
	}
		input.onclick = function() {ValidateComment('wp_comments_comment',key);};
		input.id ="wp_comments_submit";
		input.name = "wp_comments_submit";
		input.title = button_text ;
		
			if (document.cookie.indexOf("wpniuser") == -1) {
				input.disabled = true ;
			}
		
		
        var label = document.createElement("label") ;
                label.setAttribute("for","commentText") ;
                label.innerHTML = '<b>'+directions+'</b>' ;
                label.innerHTML += " <em style=\"font-weight:normal;\">(Limit 5000 characters<span style=\"display:"+display_count+";\"> / <span id=\"charCountDisplayComment\">5000</span> characters remaining</span>)</em>" ;

        form.appendChild(textarea);
        form.appendChild(br);
        form.appendChild(input);

        if ( show_directions ) {
                parent.appendChild(label);
	}
        parent.appendChild(form);
	
}
function wpPostCommentSuccess(url) {
        sendEventToOmniture("Submit Comment","event3");
        setTimeout( function() { window.location = url }, 100 );
}
// customize the Errors returned from pluck
function wpPostCommentFailure(err) {
	var elem = document.getElementById("comments_error");
	var msg = "Your comment contains content that violates our discussion policy. Please edit and resubmit. ";
	var msg2 = "You must be logged in to leave a comment.";
	var msg3 = "The comment contains words not acceptable by our acceptable use policy";
	var msg4 = "We restrict rapid posting of multiple comments for quality reasons. You have already posted a comment within the last three minutes. Please try again later.";
	// elem.innerHTML = msg;

	
	if (err.indexOf("authentication") != -1) { elem.innerHTML = msg2; }
	else if (err.indexOf("language") != -1) { elem.innerHTML = msg; }
	else if (err.indexOf("request") != -1) { elem.innerHTML = msg3; }
	else if (err.indexOf("multiple") != -1) { elem.innerHTML = msg4; }
	 else { elem.innerHTML = err;}
	 

	 
}
function mouseX(evt) {
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)
       return evt.clientX + (document.documentElement.scrollLeft ?
       document.documentElement.scrollLeft :
       document.body.scrollLeft);
    else return null;
}
function mouseY(evt) {
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
       return evt.clientY + (document.documentElement.scrollTop ?
       document.documentElement.scrollTop :
       document.body.scrollTop);
    else return null;
}
function HideDiv(id){
    document.getElementById(id).style.display = "none";
}

function ShowDivAtMouse(evt, id) {
    posx = mouseX(evt) - 170;    
    posy = mouseY(evt);
    //normalize to make sure we at least appear on the screen
    if(posx < 0) posx = 10;
    if(posy < 0) posy = 10;
    
    document.getElementById(id).style.left = posx + "px";
	document.getElementById(id).style.top = posy + "px";
	document.getElementById(id).style.display = "block";
}

function wpShowReportAbuse(evt, commentKey)
{
//    var commentKey = commentKey.split("abuse_");
//    var commentPrimaryKey = commentKey[1];
    document.getElementById("ReportAbuse_Key").value = commentKey;
    ShowDivAtMouse(evt, "ReportAbuse_Menu");
}
function wpReportAbuse()
{
	var key = document.getElementById("ReportAbuse_Key").value; 
	var reason = document.getElementById("ReportAbuse_Reason").value;
	var text = document.getElementById("ReportAbuse_CommentText").value;
	document.getElementById("ReportAbuse_Menu").style.display='none';
	cmt.ReportAbuse(key,reason,text,Abusive("abuse_"+key));
}
function clearReportAbuseForms()
{
    var reportAbuseReasonForm = document.getElementById("ReportAbuse_Form");
    reportAbuseReasonForm.reset();//reset is a clean, scalable way to handle the form clearing but will not reset the character counter
    var charCount = document.getElementById("charCountDisplayRemoval");
    charCount.innerHTML = "500"; //not ideal but need this element update because a form clear will not update the char count text
}
function CreateTextPageLink(parent,text,pageNumber) {
	var link = document.createElement("a");
		link.id = "Comment_PageLinkText"+pageNumber;
		link.setAttribute("href","#");
		link.className = "SiteLifePageLink";
		link.style.padding = "1px 6px 1px 6px"
		link.innerHTML = text;
		link.display = "block";
//		link.setAttribute("onClick","cmt.GetCommentsPage("+(1+parseInt(pageNumber))+");");
		link.onclick = function() {cmt.GetCommentsPage(1+parseInt(pageNumber)) };
	parent.appendChild(link);
}
function CreateNumberPageLink(parent,pageNumber) {
	var link = document.createElement("a");
		link.id = "Comment_PageLinkNumber"+pageNumber;
		//link.setAttribute("href","javascript:void(0)");
		link.setAttribute("href","#");
		
		link.className = "SiteLifePageLink";
		link.style.padding = "1px 6px 1px 6px"
		link.innerHTML = 1+parseInt(pageNumber);
		link.display = "block";
//		link.setAttribute("onClick","cmt.GetCommentsPage("+(1+parseInt(pageNumber))+");");
		link.onclick = function() {cmt.GetCommentsPage(1+parseInt(pageNumber)) };
	parent.appendChild(link);
}
function CreateNumberPageNonLink(parent,pageNumber) {
	var link = document.createElement("span");
		link.id = "Comment_PageLinkNumber"+pageNumber;
//		link.setAttribute("href","javascript:void(0)");
		link.className = "SiteLifePageLink";
		link.style.padding = "1px 6px 1px 6px";
		link.style.fontWeight = "bold";
		link.innerHTML = 1+parseInt(pageNumber);
		link.display = "block";
//		link.setAttribute("onClick","cmt.GetCommentsPage("+(1+parseInt(pageNumber))+");");
	parent.appendChild(link);
}

// function that draws the pagination links 
// pageNumber is zero
function wpCreatePageLink(parent,pageNumber,pageStart,pageCount,pageDisplay) {

	var link = document.createElement("a");
		link.id = "Page"+pageNumber;
		link.className = "SiteLifePageLink";
		link.setAttribute("href","#");

//		link.setAttribute("onClick","cmt.GetCommentsPage("+(1+parseInt(pageNumber))+");");
		link.onclick = function() {cmt.GetCommentsPage(1+parseInt(pageNumber)) };
	parent.appendChild(link);
}

function wpPagination(parent) {
	// this assumes that we already have cmt. object full of data
	var pageCount = parseInt(cmt.GetPageCount());
	if (parseInt(pageCount) > 1) {
		var paginationDiv = document.createElement("div");
			paginationDiv.name = "SitelifePagination";
			paginationDiv.id = "SitelifePagination";

		var pageNumber = cmt.GetCurrentPageNumber(); 

		// show the previous/first page if we are not on the first page
		if (parseInt(pageNumber)!=1) {
			CreateTextPageLink(paginationDiv,"<< First Page",0);
			CreateTextPageLink(paginationDiv,"< Previous Page",parseInt(pageNumber)-2);
		}

		// show the pages in the middle
		var start = 0;
		if (parseInt(pageNumber) > 10) {
			start = (parseInt(parseInt(pageNumber)/10) *10)-1;
		}
		var stop = 10;
		if (parseInt(cmt.GetPageCount()) < parseInt(stop) ) {
			stop = parseInt(cmt.GetPageCount());
		} else if (parseInt(cmt.GetPageCount()) > parseInt(stop) && (parseInt(cmt.GetPageCount()-parseInt(start)) <= 10) ) {
			stop =Math.round(parseInt(cmt.GetPageCount()) - (Math.floor(parseInt(cmt.GetPageCount())/10)*10))+1;
		}

		for (i=parseInt(start);i<(start+stop);i++) {
			if ((parseInt(i)+1) == parseInt(pageNumber)) {
				CreateNumberPageNonLink(paginationDiv,parseInt(i));
			}
			else {
				CreateNumberPageLink(paginationDiv,parseInt(i));
			}
		}
		// show the next/last page if we are not on the last page
		if (parseInt(pageNumber)!= parseInt(pageCount)) {
			CreateTextPageLink(paginationDiv,"Next Page >",(parseInt(pageNumber)));
			CreateTextPageLink(paginationDiv,"Last Page >>",(parseInt(pageCount)-1));
		}
		parent.appendChild(paginationDiv);
	}
}

function DrawAbuseReportDialog(parent) {
	var divReportAbuse_Container = document.createElement("div");
		divReportAbuse_Container.className = "ReportAbuse_Container";
		divReportAbuse_Container.id   = "ReportAbuse_Menu";
		divReportAbuse_Container.style.display = "none";
		divReportAbuse_Container.style.left = "763px";
		divReportAbuse_Container.style.top = "370px";
	var formReportAbuse = document.createElement("form");
		formReportAbuse.id = "ReportAbuse_Form";
		formReportAbuse.action = "";
	var inputReportAbuse_Key = document.createElement("input");
		inputReportAbuse_Key.id = "ReportAbuse_Key";
		inputReportAbuse_Key.type ="hidden";
 	var divReportAbuse_SectionHead = document.createElement("div");
		divReportAbuse_SectionHead.className = "ReportAbuse_SectionHead";
	var span1 = document.createElement("span");
		span1.style.cssFloat = "right";
	var span1a = document.createElement("span");
		span1a.style.cssFloat = "left";
		span1a.innerHTML = "Report item as: (required)";
	var a1 = document.createElement("a");
		a1.setAttribute("href","#none");
//		a1.setAttribute("onclick","HideDiv('ReportAbuse_Menu');clearReportAbuseForms()");
		a1.onclick = function() { HideDiv('ReportAbuse_Menu');clearReportAbuseForms(); };
		a1.style.display = "block";
		a1.style.padding = "1px 6px 1px 6px"
		a1.innerHTML = "X";
	var divReportAbuse_Interior = document.createElement("div");
		divReportAbuse_Interior.className = "ReportAbuse_Interior";
	var selectReportAbuse_Reason = document.createElement("select");
		selectReportAbuse_Reason.id = "ReportAbuse_Reason";
	var option1 = document.createElement("option");
		option1.value = "Obscenity or vulgarity";
		option1.innerHTML = "Obscenity/vulgarity";
	var option2 = document.createElement("option");
		option2.value = "Hate speech";
		option2.innerHTML = "Hate speech";
	var option3 = document.createElement("option");
		option3.value = "Personal attack";
		option3.innerHTML = "Personal attack";
	var option4 = document.createElement("option");
		option4.value = "Advertising or Spam";
		option4.innerHTML = "Advertising/Spam";
	var option5 = document.createElement("option");
		option5.value = "Copyright or Plagiarism";
		option5.innerHTML = "Copyright/Plagiarism";
	var option6 = document.createElement("option");
		option6.value = "Other";
		option6.innerHTML = "Other";
	var divReportAbuse_SectionHead2 = document.createElement("div");
		divReportAbuse_SectionHead2.className ="ReportAbuse_SectionHead";
		divReportAbuse_SectionHead2.style.margin = "5px 0px 0px 0px";
		divReportAbuse_SectionHead2.innerHTML = "Comment: (optional)";
	var divReportAbuse_Comment = document.createElement("div");
		divReportAbuse_Comment.className = "ReportAbuse_Comment";
	var textArea = document.createElement("textarea");
		textArea.id = "ReportAbuse_CommentText";
		textArea.className = "ReportAbuse_CommentText";
//		textArea.setAttribute("onkeypress","return countChars('ReportAbuse_CommentText','charCountDisplayRemoval',500)");
		textArea.onkeypress = function() { return countChars('ReportAbuse_CommentText','charCountDisplayRemoval',500) }; 
//		textArea.setAttribute("onkeyup","return countChars('ReportAbuse_CommentText','charCountDisplayRemoval',500)");
		textArea.onkeyup = function() { return countChars('ReportAbuse_CommentText','charCountDisplayRemoval',500) };
		textArea.maxLength = "500";
	var span2 = document.createElement("span");
		span2.style.marginLeft = "5px";
		span2.style.fontSize = "75%";
		span2.style.fontWeight = "normal";
		span2.style.color = "#666";
		span2.innerHTML = "500 char. limit / ";
		span2.style.display = "inline";

	var span3 = document.createElement("span");
		span3.id ="charCountDisplayRemoval";
		span3.style.color = "#000";
		span3.innerHTML = "500";
		span3.style.display = "inline";
		span2.appendChild(span3);

	var span4 = document.createElement("span");
		span4.id ="remaining";
		span4.style.color = "#666";
		span4.innerHTML = "left ";
		span4.style.display = "inline";
		span2.appendChild(span4);


	var input = document.createElement("button");
//		input.setAttribute("onclick","wpReportAbuse(); return false;");
		input.onclick = function() {wpReportAbuse(); return false; };
//		input.type = "button";
		input.value = "Report";
		input.innerHTML = "Report";

		formReportAbuse.appendChild(inputReportAbuse_Key);
		span1.appendChild(a1);
		divReportAbuse_SectionHead.appendChild(span1);
		divReportAbuse_SectionHead.appendChild(span1a);
		formReportAbuse.appendChild(divReportAbuse_SectionHead);
		formReportAbuse.appendChild(divReportAbuse_Interior);
		selectReportAbuse_Reason.appendChild(option1);
		selectReportAbuse_Reason.appendChild(option2);
		selectReportAbuse_Reason.appendChild(option3);
		selectReportAbuse_Reason.appendChild(option4);
		selectReportAbuse_Reason.appendChild(option5);
		selectReportAbuse_Reason.appendChild(option6);
		divReportAbuse_Interior.appendChild(selectReportAbuse_Reason);

		formReportAbuse.appendChild(divReportAbuse_Interior);
		formReportAbuse.appendChild(divReportAbuse_SectionHead2);

		divReportAbuse_Comment.appendChild(textArea);
		divReportAbuse_Comment.appendChild(span2);
		divReportAbuse_Comment.appendChild(span3);
		divReportAbuse_Comment.appendChild(input);
		formReportAbuse.appendChild(divReportAbuse_Comment);
		divReportAbuse_Container.appendChild(formReportAbuse);
		parent.appendChild(divReportAbuse_Container);
}

function DrawPair(label,value) {
	var pair = document.createElement("div");
	var label1a = document.createElement("label");
		label1a.id = "heading";
		label1a.innerHTML = label
		label1a.style.fontWeight ="bold";
		label1a.style.padding = "1px 6px 1px 6px"
	var label1 = document.createElement("div");
		label1.name = "label1";
		label1.id = "label1";
		label1.innerHTML = value;
		label1.style.display = "inline";
		label1.style.padding = "1px 6px 1px 6px"
	var seperator = document.createElement("br");
	pair.appendChild(label1a);
	pair.appendChild(label1);
	pair.appendChild(seperator);
	return pair;
}
function DrawLink(label,value) {
	var pair = document.createElement("div");
	var label1a = document.createElement("label");
		label1a.id = "heading";
		label1a.innerHTML = label
		label1a.style.fontWeight ="bold";
		label1a.style.padding = "1px 6px 1px 6px"
	var label1 = document.createElement("a");
		label1.setAttribute("href",value);
		label1.name = "label1";
		label1.id = "label1";
		label1.innerHTML = "Comment Link";
		label1.style.display = "inline";
		label1.style.padding = "1px 6px 1px 6px"
	var seperator = document.createElement("br");
	pair.appendChild(label1a);
	pair.appendChild(label1);
	pair.appendChild(seperator);
	return pair;
}

function DrawRecommended(review) {
	var recommend = document.createElement("div");
		recommend.id = "EditorRecommended";
		recommend.appendChild(DrawPair("Title",review.ReviewTitle));
		recommend.appendChild(DrawPair("Comment",review.ReviewBody));
		recommend.appendChild(DrawPair("JSON",review.ReviewPros));
		var packedJSON = eval("(" + review.ReviewCons + ")");
		recommend.appendChild(DrawLink("ArticleLink",packedJSON.articleURL));
		recommend.appendChild(DrawLink("CommentLink",packedJSON.commentPermaLink));
		recommend.appendChild(DrawPair("commentUserDisplayName",packedJSON.commentUserDisplayName));
		recommend.appendChild(DrawPair("commentDate",packedJSON.commentDate));
		recommend.appendChild(DrawPair("commentUserKey",packedJSON.commentUserKey));
	var sep = document.createElement("hr");
	recommend.appendChild(sep);
	return recommend;
}
function DrawEditorRecommendedComments(revPage) {
	var parent = document.getElementById("divRecommendations");
	for (var i=0;i < revPage.Reviews.length; i++) {
		parent.appendChild(DrawRecommended(revPage.Reviews[i]));
	}
}
