
function SystemNews()
{
	this.oAjax = new sack();
	this.resetAjax();
}


SystemNews.prototype = {

	init : function(sContainerID, sBoxFuncContainer) {
		this.sContainerID = sContainerID;
		this.sBoxFuncContainer = sBoxFuncContainer;
	},

	loadContent : function(sEvent, sFormName) {
		this.resetAjax();
		this.oAjax.setVar('event', sEvent);
		this.oAjax.setVar( 'iSNPage', this.iSNPage );
		this.oAjax.setVar( 'iSNID', this.iSNID );
		if ( sFormName != undefined && sFormName != '' ) {
			this.submitForm(sFormName);
		}
		this.oAjax.runAJAX();
		oThis = this;
		onCompletionAJAX = function () {
			oThis.writeOutput(oAJAX.responseText, oThis.sContainerID);
		};
	},


	resetAjax : function() {
		this.oAjax.reset();
		this.oAjax.requestFile	= "index.php";
		this.oAjax.method		= "POST";
		this.oAjax.setVar('module', 'SystemNews');
	},

	//gather data and do stuff
	ActionSwitch : function(sAction, iSNPage, iSNID) {
		this.iSNPage = iSNPage;
		this.iSNID = iSNID
		this.sEvent = "";
		//action switch baby
		switch (sAction) {
			case 'list':
				//show list stuff
				this.loadContent('on_showSystemNewsList');
				break;
			case 'detail':
				//show detail stuff
				this.loadContent('on_showSystemNewsDetail');
				break;
		}
	},

	//all those things we can do
	SystemNewsList : function( iSNPage ) { this.ActionSwitch( 'list', iSNPage, 0 ); },
	SystemNewsDetail : function( iSNPage, iSNID ) {
//		this.oListDetailButton = _gel( this.sBoxFuncContainer );
		this.sListDetailClass = "detailbox";
//		this.oListDetailButton.className = this.oListDetailButton.className.replace(/listbox/, this.sListDetailClass);
		this.ActionSwitch( 'detail', iSNPage, iSNID );
	},

	writeOutput : function(sResponse, sID) {
		var oResponse = eval(sResponse);
		try {
			if (oResponse.sErrors != "" && oResponse.sErrors != undefined) {
				if (document.popup == null) document.popup = new isPopup();
				document.popup.show("OK", oResponse.sHeadline, 300, 130, oResponse.sErrors);
			}
		} catch (e) {
		}
		try {
			if (oResponse.sContent != "" && oResponse.sContent != undefined) {
				oModuleContent = _gel(sID);
				if (oModuleContent) {
					oModuleContent.innerHTML = oResponse.sContent;
				}
			}
		} catch (e) {
		}
	},

	loadErrorMessage : function (sError) {
		this.resetAjax();
		this.oAjax.setVar('event', 'on_AdminNoLanguageSelected');
		this.oAjax.setVar('LangError', sError);
		this.oAjax.runAJAX();
		oThis = this;
		onCompletionAJAX = function () {
			var oResponse = eval(oAJAX.responseText);
			if (document.popup == null) document.popup = new isPopup();
			document.popup.show("OK", oResponse.sHeadline, 300, 200, oResponse.sContent, oThis);
		};
	}
}