if( typeof formHandlerSingleInput == 'undefined' ) 
{
	var formHandlerSingleInput = function( options ) 
	{
		this.name = 'formHandler';
		this.options = {};
		this.options.form = {};
		this.options.form.id = null;
		this.options.form.onSubmitErrorMessage;
		this.options.input = {};
		this.options.input.id = null;
		this.options.input.textAlign = 'left';
		this.options.input.minLen = null;
		this.options.input.checkFunction = null;
		this.options.input.defaultValue = {};
		this.options.input.defaultValue.value = null;
		this.options.input.defaultValue.textAlign = 'left';
		this.formEl = null;
		this.inputEl = null;
		this.init( options || {} );
	};
	formHandlerSingleInput.prototype.init = function( options ) 
	{
		this.extend( this.options , options );
		this.formEl = this.$( this.options.form.id );
		this.inputEl = this.$( this.options.input.id );
		if ( this.formEl == null ) 
		{
			alert( '1. The element with the "' + this.options.formId + '" ID do not exist in HTML source.' );
		}
		if ( this.inputEl == null ) 
		{
			alert( '2. The element with the "' + this.inputId + '" ID do not exist in HTML source.' );
		}
		if ( this.formEl && this.inputEl ) 
		{
			var obj = this;
			this.formEl.onsubmit = function () 
			{
				return obj.formOnSubmit();
			};
			this.inputEl.onfocus = function () 
			{
				obj.inputOnFocus();
			};
			this.inputEl.onblur = function () 
			{
				obj.inputOnBlur();
			};
			this.inputOnBlur();
		}
	};
	formHandlerSingleInput.prototype.$ = function( id ) 
	{
		return document.getElementById( id );
	}
	formHandlerSingleInput.prototype.extend = function ( original , extended ) 
	{
		for ( var key in ( extended || {} ) ) 
		{
			if( typeof extended[key] == "object" && typeof original[key] == "object" ) 
			{
				original[key] = this.extend( original[key] , extended[key] );
			}
			else 
			{
				original[key] = extended[key];
			}
		}
		return original;
	};
	formHandlerSingleInput.prototype.formOnSubmit = function () 
	{
		this.inputEl.value = this.inputEl.value.trim();
		if ( this.inputEl.value.length < this.options.input.minLen 
				 || this.inputEl.value == this.options.input.defaultValue.value 
				 || !eval( this.options.input.checkFunction + '(\'' + this.inputEl.value + '\')' ) ) 
		{
			alert( this.options.form.onSubmitErrorMessage );
			this.inputEl.focus();
			return false;
		}
		return true;
	};
	formHandlerSingleInput.prototype.inputOnFocus = function () 
	{
		if ( this.options.input.defaultValue.value.length ) 
		{
			if ( this.inputEl.value == this.options.input.defaultValue.value ) 
			{
				this.inputEl.value = '';
			}
			this.inputEl.style.textAlign = this.options.input.textAlign;
		}
	};
	formHandlerSingleInput.prototype.inputOnBlur = function () 
	{
		this.inputEl.value = this.inputEl.value.trim();
		if( this.options.input.defaultValue.value.length ) 
		{
			if( this.inputEl.value.length == 0 || this.inputEl.value == this.options.input.defaultValue.value ) 
			{
				this.inputEl.style.textAlign = this.options.input.defaultValue.textAlign;
				this.inputEl.value = this.options.input.defaultValue.value;
			}
		}
	};
}
