//-------------------------------------------------------------------//
/* Article Handler */
//-------------------------------------------------------------------//

var articleHandler = Class.create();
articleHandler.prototype = {

	//-------------------------------------------------------------------//

	initialize: function(name) {
		this.comment_id = 0;
	},

	//-------------------------------------------------------------------//

	ajaxAddToFavorite: function(article_id) {
		var ajax = new Ajax.Request(
											'/index.php?action=ajax',
											{
												method: 'post',
												parameters: '&aid='+article_id+'&add_fav=1',
												onComplete: this.ajaxAddToFavoriteComplete.bindAsEventListener(this)
											}
											);
	},

	//-------------------------------------------------------------------//

	ajaxAddToFavoriteComplete: function(o) {
		if(o.responseText == 1) {
			$('add-to-favorite').update(TrimPath.processDOMTemplate('t_label_success_favorite', null));
			dialogHND.showSuccessAddToFavoriteDialog();
		}
		else  dialogHND.showErrorAddToFavoriteDialog();
	},

	//-------------------------------------------------------------------//

	ajaxReportArticle: function(article_id) {
		var ajax = new Ajax.Request(
											'/index.php?action=ajax',
											{
												method: 'post',
												parameters: '&aid='+article_id+'&areport=1',
												onComplete: this.ajaxReportArticleComplete.bindAsEventListener(this)
											}
											);
	},

	//-------------------------------------------------------------------//

	ajaxReportArticleComplete: function(o) {
		if(o.responseText == 1) {
			dialogHND.showSuccessReportDialog();
		}
		else dialogHND.showErrorReportDialog();
	},

	//-------------------------------------------------------------------//

	ajaxReportComment: function(comment_id) {
		var ajax = new Ajax.Request(
											'/index.php?action=ajax',
											{
												method: 'post',
												parameters: '&cid='+comment_id+'&creport=1',
												onComplete: this.ajaxReportCommentComplete.bindAsEventListener(this)
											}
											);
	},

	//-------------------------------------------------------------------//

	ajaxReportCommentComplete: function(o) {
		if(o.responseText == 1) {
			dialogHND.showSuccessReportDialog();
		}
		else dialogHND.showErrorReportDialog();
	},

	//-------------------------------------------------------------------//

	ajaxSuggestComment: function(comment_id) {
		this.comment_id = comment_id;

		var ajax = new Ajax.Request(
											'/index.php?action=ajax',
											{
												method: 'post',
												parameters: '&cid='+comment_id+'&csuggest=1',
												onComplete: this.ajaxSuggestCommentComplete.bindAsEventListener(this)
											}
											);
	},

	//-------------------------------------------------------------------//

	ajaxSuggestCommentComplete: function(o) {
		if(o.responseText == 1) {
			$('c-sugg-num-'+this.comment_id).update(parseInt($('c-sugg-num-'+this.comment_id).innerHTML) + 1);
			dialogHND.showSuccessSuggestDialog();
		}
		else dialogHND.showErrorSuggestDialog();
	},

	//-------------------------------------------------------------------//

	addToBrowserFavorite: function(title) {
		if (window.sidebar) {
			window.sidebar.addPanel(window.document.title+' - '+title, window.document.location,"");
		} 
		else if( window.external ) {
			window.external.AddFavorite( window.document.location, window.document.title+' - '+title); 
		}
		else if(window.opera && window.print) {
			return true;
		}
	}
	
	//-------------------------------------------------------------------//

}

//-------------------------------------------------------------------//
