WSGLoginFormValidator.prototype = new Object();
WSGLoginFormValidator.prototype.constructor = WSGLoginFormValidator;
WSGLoginFormValidator.superclass = null;

function WSGLoginFormValidator(moduleNamespace, formId) {	
	this.moduleNamespace = moduleNamespace;
	this.formId = formId;
};
WSGLoginFormValidator.prototype.validateLogin = function() {
	bundle = new LoginMirraBundle();
	field = document.getElementById(this.formId).elements['username'];
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace, field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_USERNAME)) return false;		
	field = document.getElementById(this.formId).elements['password'];
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace, field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_PASSWORD)) return false;		
	if (_wsgUtils.fieldIsTooShortSetMsgToField(this.moduleNamespace, field, WSG_MESSAGE_TYPE_ERROR, bundle.PASSWORD_TOO_SHORD, 6)) return false;		
	_wsgUtils.submitForm(this.formId);		
	return true;
};
WSGLoginFormValidator.prototype.validateRegistration = function() {
	_wsgUtils.hideSystemMessage(this.moduleNamespace + '_window');
	bundle = new LoginMirraBundle();
	field = document.getElementById('firstName_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_FIRSTNAME)) return false;		
	field = document.getElementById('lastName_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_LASTNAME)) return false;		
	field = document.getElementById('phone_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_PHONE)) return false;
	field = document.getElementById('email_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_EMAIL)) return false;
	if (_wsgUtils.fieldIsEmailInvalid(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_VALID_EMAIL)) return false;
	field = document.getElementById('userName_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_USERNAME)) return false;
	field = document.getElementById('password_' + this.moduleNamespace);
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_PASSWORD)) return false;
	if (_wsgUtils.fieldIsTooShortSetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PASSWORD_TOO_SHORD, 6)) return false;
	field = document.getElementById('retypePassword_' + this.moduleNamespace);	
	if (_wsgUtils.fieldIsEmptySetMsgToField(this.moduleNamespace + '_window', field, WSG_MESSAGE_TYPE_ERROR, bundle.PLEASE_ENTER_RETYPE_PASSWORD)) return false;
	if (_wsgUtils.fieldsNotMatchSetMsgToField(this.moduleNamespace + '_window', document.getElementById('password_' + this.moduleNamespace), field, WSG_MESSAGE_TYPE_ERROR, bundle.PASSWORD_AND_RETYPE_PASSWORD_NOT_MATCH)) return false;
	return true;
};
