// -------------------------------------------------------------------------- //
// -------------------------------- Form ------------------------------------ //
// -------------------------------------------------------------------------- //

Form = function( target ) {
	Form.superClass.apply( this, arguments );

	this.Id = 'Form';
	this.element = target;
	this.inputs = new Array();
	this.status = false;
}
Form.inheritsFrom( HTMLGlif );

// -------------------------------------------------------------------------- //

Form.prototype.check = function() {
	var oS = this.status;
	
	this.status = true;
	for( var c in this.inputs ) {
		if ( this.inputs[ c ].required ){
			if( !this.inputs[ c ].status ) {
				this.status = false;
				break;
			}
		}
	}
	
	if( !( oS === this.status ) ) this.notify( 'formStatusChange', this );
	return this.status;
}

Form.prototype.checkToSubmit = function() {
	var oS = this.status;
	
	this.status = true;
	for( var c in this.inputs ) {
		if( !this.inputs[ c ].checkToSubmit() ) {
			this.status = false;
		}
	}
	
	if( !( oS === this.status ) ) this.notify( 'formStatusChange', this );
	return this.status;
}

/*Form.prototype.setEmpty = function(){
	for( var c in this.inputs ) {
		var cI = this.inputs[ c ];
		//this.onInputBlured( null, cI );
		var status = cI.check();
		if (!status) {
			if (cI.blur) {
				cI.blur();
			}
			else if (cI.type == 'select') {
				cI.setClassName('error', true);
			}
		}
	}
}*/
