/*****************************************************************************************************/
/*                                                                                                   */
/*                                   'COMMENT PANEL' CLASS                                           */          
/*                                                                                                   */
/*****************************************************************************************************/

function COMMENT_GINFO(parent){
	var JSObject = this;
	this.type = "Comment"; 
	this.arr_inputs = ["_inp_Message"];
	this.form = document.getElementById("comments_form");
	this.ajax = false;
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                         FUNCTION INIT INPUTS                                      */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.init = function(){
		/*****************************************************************************************************/
		/*                                                                                                   */
		/*                                          INFORMATION                                              */          
		/*                                                                                                   */
		/*****************************************************************************************************/
		this._inp_Message = new INPUTFIELD(this, document.getElementById('comment'));
	}
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                    FUNCTION CREATE COMMENT PANEL                                  */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.initCreate = function(){
		/*****************************************************************************************************/
		/*                                                                                                   */
		/*                                      INPUT 'MESSAGE' ACTIONS                                      */          
		/*                                                                                                   */
		/*****************************************************************************************************/
		var input = this._inp_Message.input;
		this._inp_Message.setRequired("yes"); 
		this._inp_Message.setReadySubmit(true);
		this._inp_Message.setValidationType("alphanumeric_extended");
		var errors = ["Champ obligatoire.",
			          "Caractères invalides."];
		var extentedChars = String(" :;',./?!@#$%^*()[]{}|-+À?Â?ÆÇ?ÉÊËÌÍÎàáâãäæçèéêëìíîïòóôõöùûüý»").split("");
			
		this._inp_Message.addExtendedChars(extentedChars);
		this._inp_Message.addErrors(errors);
		this._inp_Message.setErrorsContainer("comment_container");
		this._inp_Message.initActions();
		/*this._inp_Message.input.onblur = function(){
			var chars = "<>&";
			if (this.value.hasInvalidChars(chars)){
				JSObject._inp_Message.displayError(JSObject._inp_Message.errors[1]);
				JSObject._inp_Message.setReadySubmit(false);
			}
			else{
				JSObject._inp_Message.setReadySubmit(true);	
			}
		}*/
	}
	
	
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                 FUNCTION VALIDATE INFORMATION                                     */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.validate = function(){
		var countErrors = 0;
		// aflam cate erori sunt in formular
		for (var i=0; i<this.arr_inputs.length; i++){
			var obj = this[this.arr_inputs[i]];
			if (obj.submit_ready == false && obj.data.length == 0 && obj.required=="yes"){
				obj.displayError(obj.errors[0]);
				obj.setReadySubmit(false);
				countErrors++;
			}
			else if (obj.submit_ready == true && obj.data.length == 0 && obj.required=="yes"){
				obj.displayError(obj.errors[0]);
				obj.setReadySubmit(false);
				countErrors++;
			}
			else if (obj.submit_ready == false){ 
				countErrors++;
			}
		}
		
		
		if (countErrors==0){ 
			this.form.submit();	
		}
		else{ 
			return false;
		}
		
	}
	
}