Type.registerNamespace('MySpace.ProfileDisplay');

MySpace.ProfileDisplay.CommentModule = function() {
	MySpace.ProfileDisplay.CommentModule.initializeBase(this);
};

MySpace.ProfileDisplay.CommentModule.prototype = {
	/// comments
	_MIN_COMMENT_LENGTH: 2,

	/// Fields
	_formElement: null,
	_txtElement: null,
	_previewElement: null,
	_submitBtnElement: null,
	_feedbackElement: null,
	_uid: null,

	/// Properties
	get_uid: function() { return this._uid; },
	set_uid: function(value) { this._uid =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
	/// Events	
	initialize : function() {
		// todo: debug -- console.log("comment Module initialize" );
		this._wire();
		this._attachEvents();
	},
	
	dispose : function() {
		this._formElement = null;
		this._previewElement = null;
		this._submitBtnElement = null;
		this._txtElement = null;
		this._feedbackElement = null;
	},
	
	/// Private Methods
	_wire: function() {
		this._formElement = $get("commentEntryForm");
		this._previewElement = $get("commentPreview");
		this._submitBtnElement = $get("friendCommentBtn");
		this._txtElement = $get("friendCommentText");
		this._feedbackElement = $get("friendCommentFeedback");
	},
	
	_attachEvents: function() {
		var x = this;
		$addHandlers( x._submitBtnElement, { click: function(e) { x.submit(); } }, x );
	},
	
	/// Public Methods
	submit: function() {
		if (this.isValid()){
			alert("So far you've typed \""+ _proxy_jslib_handle(this._txtElement, 'value', '', 0, 0)+"\"");
		}
	},

	isValid: function() {
		var s =  _proxy_jslib_handle(this._txtElement, 'value', '', 0, 0);
		if (s.trim().length < this._MIN_COMMENT_LENGTH){
			 _proxy_jslib_assign('', this._feedbackElement, 'innerHTML', '=', ( String.format("Your message is too short. The minimum comment length is {0} characters.", this._MIN_COMMENT_LENGTH)));
			this._feedbackElement.style.display = "block";
			return false;
		}
		 _proxy_jslib_assign('', this._feedbackElement, 'innerHTML', '=', ( ""));
		this._feedbackElement.style.display = "none";
		return true;
	}

};
// MySpace.ProfileDisplay.UIElement );
MySpace.ProfileDisplay.CommentModule.registerClass('MySpace.ProfileDisplay', Sys.Component );
 ;
_proxy_jslib_flush_write_buffers() ;