var article_offset = 0;

function article_tabelize(rows, offset) {

	ac_ui_api_callback();
	ac_dom_remove_children($("articles"));

	var article_html = "";

	var ul = Builder.node("ul");
	$("articles").appendChild(ul);

	if (rows.length > 0)
	{
		for (var i = 0; i < rows.length; i++) {

			article_html = "";
			var stars = ac_stars(rows[i].rating);

			if (rows[i].icon == "") {
				var icon_image = "articleicon.gif";
			}
			else {
				var icon_image = "article_icons/" + ac_str_htmlescape(rows[i].icon);
			}

			var preview = ac_str_replace("&amp;nbsp;", " ", rows[i].preview);

			article_html += "<img src='" + ac_js_site["p_link"] + "/images/" + icon_image + "' />";
			article_html += "<a href='" + rows[i].url + "'>" + ac_str_htmlescape(rows[i].title) + "</a>";
			article_html += "<div>";
			article_html += ac_str_shorten(preview, 50);
			article_html += "<br />";

			article_html += stars;

			if (ac_js_site["articles_display_mdate"]) {
				article_html += " - " + sql2date(rows[i]['mdate']).format(dateformat);
			}

			if (ac_js_site["articles_display_mostsimilar"] > 0) {
				article_html += " - <a href='index.php?action=article_similar&id=" + rows[i].id + "'>" + jsSimilarArticles + "</a>";
			}

			article_html += "</div>";
			var li = Builder.node("li");
			li.innerHTML = article_html;
			ul.appendChild(li);
		}

		article_html += "</ul>";
	}
	else
	{
		$("articles").innerHTML = "There are currently no articles for this category.";
		$("articles_pagination").className = "ac_hidden";
	}

	//$("articles").innerHTML = article_html;
}

function article_paginate(offset) {

	if (!ac_loader_visible() && !ac_result_visible() && !ac_error_visible())
		ac_ui_api_call(jsLoading);

	article_offset = parseInt(offset, 10);

	ac_ajax_call_cb(this.ajaxURL, this.ajaxAction, paginateCB, this.id, "01", article_offset, ac_js_site["articles_display_perpage"], category_filterid);
}

