﻿
function	tcArticleLoader()	{
	this.isLoading		=	0;
	this.onloadusercallback	=	null;
}

tcArticleLoader.prototype.init	=	function()	{
	this.isLoading	=	false;
}

/* =========================================================== */

tcArticleLoader.prototype.loadArticle		=	function( id, thumbtype, imgtype  )	{
	this._beginLoad(id, thumbtype, imgtype );
}

tcArticleLoader.prototype.setOnLoadCallback				=	function( cb )			{	this.onloadusercallback	=	cb;		}
tcArticleLoader.prototype.showLoading					=	function()				{	this.isLoading		=	true;		}
tcArticleLoader.prototype.hideLoading					=	function()				{	this.isLoading		=	false;		}

/* =========================================================== */

tcArticleLoader.prototype._beginLoad	=	function( id, thumbtype, imgtype )	{

	this.showLoading();
	var	aurl	=	'/code/ajaxcall.php?module=article&action=getarticlebyid&id=' + id + "&thumbtype=" + thumbtype + "&imgtype=" + imgtype;
	var myloader = function( jsonObj ) {
		this._onloadcallback( jsonObj );
	}.create({bind : this});

	var request = new Request.JSON({
		url: aurl,
		onComplete: function( jsonObj ) {
			myloader( jsonObj.TC_ARTICLE );
		}
	}).send();
}

// e = tcArticle

tcArticleLoader.prototype._onloadcallback	=	function	(e)	{

	if( this.onloadusercallback )	{
		this.onloadusercallback(e);
	}

	this.hideLoading();
}