function isEmpty(str)
{
	for (var intLoop = 0; intLoop < str.length; intLoop++)
		if (" " != str.charAt(intLoop))
			return false;
		return true;
}

function check_reqfields(f_id) {
	f = document.getElementById(f_id);
	var strError = "";
	for  (var intLoop = 0; intLoop<f.elements.length; intLoop++)
		if (null!=f.elements[intLoop].getAttribute("req"))
			if (isEmpty(f.elements[intLoop].value))
				strError +="  " + f.elements[intLoop].name + "\n";

	if ("" != strError)
	{
		//alert ("Ошибка, заполните пожалуйста все обязательные поля");
		return false;
	}
	else
	{
		return true;
	}
}

function test_form(fid,butselector)
{	if(check_reqfields(fid)) $(butselector).removeAttr("disabled");	else $(butselector).attr({disabled:"disabled"});
}
