ischecked = new Object();
function formtool_count_chars(textField, countField, maxlen,show_alert) {
    if(textField != null && textField.value != null) {
	    if (textField.value.length > maxlen){
            if(show_alert)
               alert('Это поле не может превышать ' +  maxlen + ' символов.');
            textField.value = textField.value.substring(0, maxlen);
	    } else {
            countField.value = maxlen - textField.value.length;
	    }
    }
}

function CheckForm(UserForm)
{
    var is_ok = true;

	if (document.contact.code.value.length < 1 || UserForm.message.value == '' || UserForm.email.value == '')
	{
		is_ok = false;
    	alert("Пожалуйста, заполните все поля, отмеченные *");
    	UserForm.code.focus();
	}

	p_email = document.contact.email.value.toString();
	t = p_email.indexOf("@");
	if((p_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > p_email.length - 5) || (p_email.charAt(t - 1) == '.') || (p_email.charAt(t + 1) == '.'))
	{
    	is_ok = false;
		alert('Указан некорректный e-mail.');
    	UserForm.email.focus();
	}

return is_ok;
}

