// The function for check forms by the client side
// Required jquery



function chckFrm(form, attrName, preText, postText, errStyle){
var underfined;
var This = this;
var errorsNone = true;
attrName = (attrName === underfined) ? 'required' : attrName;
preText = (preText === underfined) ? '' : preText;
postText = (postText === underfined) ? ' поле не заполненно ' : postText;
errStyle = (errStyle === underfined) ? 'errStyleInput' : errStyle;

$('input',form).removeClass(errStyle);
$('span.errPreText',form).remove();
$('span.errPostText',form).remove();

$('input',form).each(function(){
//console.log($(this).attr('name')+' - |'+attrName+'-'+$(this).attr(attrName)+'\r\n');
	if($(this).attr(attrName)=='1'){
		if ($(this).val()==''){
			$(this).addClass(errStyle).before(preText ? '<span class="errPreText">' + preText + '</span>' : '').after(postText ? '<span class="errPostText">' + postText + '</span>' : '');
			errorsNone=false;
		} 
	}
});

$('textarea',form).each(function(){
	if($(this).attr(attrName)!=''){
		if ($(this).val()==''){
			$(this).addClass(errStyle).before(preText ? '<span class="errPreText">' + preText + '</span>' : '').after(postText ? '<span class="errPostText">' + postText + '</span>' : '');
			errorsNone=false;
		} 
	}
});

return errorsNone;
}