
	if ( !qFlux )
		var qFlux = {};
	qFlux.community = {};
	
	//####################################################################################################

	qFlux.community.sendMessage = function(action, type, topic)
		{
			document.getElementById('message_error').innerHTML = '';
			document.getElementById('message_error').style.display = 'none';
			var title = document.getElementById('message_title').value;
			if ( !title || title.replace(/ /g, "").length < 3 || title.length > 64 )
				{
					qFlux.community.showError('title');
					return;
				}
			var text = document.getElementById('message_text').value;
			if ( !text || text.replace(/\n| /g, "").length < 3 || text.length > 8000 )
				{
					qFlux.community.showError('message');
					return;
				}
			qFlux.xmlHttpRequest('community.php', 'action=' + action + '&type=' + type + '&topic=' + topic + '&title=' + title + '&text=' + text, 'qFlux.community.receiveMessage');
		}
	
	//####################################################################################################

	qFlux.community.sendReport = function(index)
		{
			document.getElementById('message_error').innerHTML = '';
			document.getElementById('message_error').style.display = 'none';

			var text = document.getElementById('message_text').value;
			if ( !text || text.replace(/\n| /g, "").length < 3 || text.length > 255 )
				{
					qFlux.community.showError('report');
					return;
				}
			qFlux.xmlHttpRequest('community.php', 'action=report&topic=' + index + '&text=' + text, 'qFlux.community.receiveMessage');
		}

	//####################################################################################################

	qFlux.community.receiveMessage = function()
		{
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			if ( xmlHttp.responseText == 'database' )
				{ qFlux.comment.showError('database'); }
			else if ( xmlHttp.responseText.match('community') )
				{ window.location.href = xmlHttp.responseText; }
			else
				{ qFlux.community.showError(xmlHttp.responseText); }
			qFlux.xmlHttpSend();
		}
	
	//####################################################################################################
	
	qFlux.community.showError = function(status) 
		{
			var text;
			if ( status == 'title' )
				{ text = 'Your entered subject is not valid - it has to be between 3 and 64 characters long!'; }
			else if ( status == 'message' )
				{ text = 'Your entered message is not valid - it has to be between 3 and 8000 characters long!'; }
			else if ( status == 'report' )
				{ text = 'Your entered statement is not valid - it has to be between 3 and 255 characters long!'; }
			else if ( status == 'database' )
				{ text = 'No database connection - please try again later!'; }
			else
				{ text = status; }
			document.getElementById('message_error').innerHTML = text;
			document.getElementById('message_error').style.display = 'block';
			window.setTimeout("document.getElementById('message_error').style.display = 'none'", 10000);
		}

