/**
	Dependencias:
		- mootools-1.2.1-core.js
		- mootools-1.2-more.js
		- formcheck.js
*/

var Sugerencias = {
	formActivo: null,
	formName: null,
	acciones: {},
	actions: {},
	messages: {},
	cache: {},
	init: function() {
		Portal.init();
		this.formActivo = document.forms[this.formName];
        new TexAreaMaxLength ($('sugerencia'), 250, $('notifSugerenciaSize'));
        $('lnkEnvio').addEvent('click',function(event) {
			new Event(event).stop();
			Sugerencias.envioFormulario();
		});
        this.crearFormCheck();
	},

    /**
	* Asigna los literales internacionalizados para cada error, crea las funciones especificas de validación
	* e inicializa el objeto formCheck.
	*/
	crearFormCheck: function() {
		//Creo y asigno el validador del formulario.
		this.formCheck = new FormCheck(Sugerencias.formName,{
			display : {
				showErrors: 0,
				addClassErrorToField: 1
			}
		});
	},

	envioFormulario: function (event) {
		InputHelp.clearValues();
    	if(Sugerencias.formCheck.validateFormNow(event)) {
			this.formActivo.action = this.actions.DEF;
			this.formActivo.accion.value = this.acciones.ENVIAR;
			this.formActivo.submit();
		} else {
			InputHelp.setValues();
		}
	}
}

window.addEvent('domready', function(){
	Sugerencias.init();
});