/*
 * WordFilter.js
 * check nick.com database if "word" is valid.
 * response is JSON
 */

var WordFilter = new Class ({
	Implements: [Options,Events],
	
	options: {
		/*onGoodWord: $empty,
		  onBadWord: $empty,
		 */
	},
	
	initialize: function(options) {
		this.setOptions(options);
	},
	
	send: function(word) {
		SBCOM.utils.doLog('WordFilter: send: ' + word);
		var jsonp = new MooJsonP(
			'http://' + SBCOM.utils.getNickDomain() + '/common/wordfilter/json.jhtml',
			{
				data:{word:word},
				onComplete:this.handleResult.bind(this)
			}).request();
	},
	
	handleResult: function(response, callerFunc) {
		SBCOM.utils.doLog('WordFilter: handleResult: ' + response);
		//generic logout event
		if (response.status == "good") 
			this.fireEvent('goodWord', response);
		//generic logout failed event
		else if (response.status == "bad")
			this.fireEvent('badWord', response);
	}
	
});
