function FormInspector(formName)
{
	this.formName = formName;
	this.filters = {};
	this.errorClassName = 'error';
	
	// ustawia filtr sprawdzający
	this.setFilter = function(fieldName, filter)
	{
		this.filters[fieldName] = filter;
	}
	
	// sprawdza formularz
	this.check = function()
	{
		var result = true;
		for(i in this.filters)
		{
			if(!this.checkField(i))
			{
				result = false;
			}
		}
		return result;
	}
	
	// sprawdza konkretne pole
	this.checkField = function(fieldName)
	{
		var value = document.forms[this.formName][fieldName].value;
		var ok = true;
		
		// wyrażenie regularne
		if(this.filters[fieldName].re)
		{
			// Re
			var re = new RegExp(this.filters[fieldName].re);
			if(!value.match(re))
			{
				ok = false;
			}
		}
		
		// min
		if(this.filters[fieldName].min)
		{
			if(value < this.filters[fieldName].min)
			{
				ok = false;
			}
		}
		
		//max
		if(this.filters[fieldName].max)
		{
			if(value > this.filters[fieldName].max)
			{
				ok = false;
			}
		}

		this.changeStatus(fieldName, ok);
		return ok;
	}
	
	// zmienia podświetlenie pola na podstawie wartości logicznej
	this.changeStatus = function(fieldName, status)
	{
		var f = document.forms[this.formName][fieldName];
		//
		// uwaga! w tej wersji poniższe polecenia usuwają wszelkie inne niż 'error' klasy
		//
		if(status)
		{
			f.className = '';
		}
		else
		{
			f.className = 'error';
		}
	}
}
