function isNumber(x) {
  return ( (typeof x === typeof 1) && (null !== x) && isFinite(x) );
}

function getComments( articleid, serverid ) {
	var commentsarea = returnObjById( "comments_" + articleid + "_" + serverid );

	if ( commentsarea != null ) {
	    style = $("div#comments_" + articleid + "_" + serverid).attr("style");
		if ( ( style.toLowerCase().indexOf( "display: none" ) != -1 ) || ( style.toLowerCase().indexOf( "display:none" ) != -1 ) ) {
			lastid = -1;
			// async false, we want to wait until we have the stuff
			$.ajax(
               {  type: "get",
                   url: "/ajax.php",
                  data: "req=comments&article_id=" + articleid + "&article_serverid=" + serverid,
               success:
					function( data, status ) {
						// we should be getting a json object
						output = JSON.parse( data );
						if ( output != null ) {
							commentsarea = returnObjById( "comments_" + output.article_id + "_" + output.article_serverid );
							if ( commentsarea != null ) {
								commentcount = returnObjById( "commentlink_" + output.articleid + "_" + output.article_serverid );
								if ( commentcount != null ) {
									if ( isNumber( output.commentcount ) ) {
										commentcount.innerHTML = "comments: " + output.commentcount;
									}
								}
								// todo: don't copy html straight out of the json object
								commentsarea.innerHTML = output.html;
//								commentsarea.style.visibility = "";
								$("div#comments_" + output.article_id + "_" + output.article_serverid).show( "slow" );
							}
						}
					}
               }
			);
		} else {
			$("div#comments_" + articleid + "_" + serverid).hide( "slow" );
		}
	}
}
