if(document.all){ // IE
	tr_style_visible='block';
} else {
	tr_style_visible='table-row';
}

post_login_mode = 0;

function switch_post_login_mode(l){
	if(l){
		post_login_mode = 1;
		document.getElementById('name_input_tr').style.display = 'none';
		document.getElementById('email_input_tr').style.display = 'none';
		document.getElementById('turing_input_tr').style.display = 'none';
		document.getElementById('login_input_tr').style.display = tr_style_visible;
	} else {
		post_login_mode = 0;
		document.getElementById('name_input_tr').style.display = tr_style_visible;
		document.getElementById('email_input_tr').style.display = tr_style_visible;
		document.getElementById('turing_input_tr').style.display = tr_style_visible;
		document.getElementById('login_input_tr').style.display = 'none';
	}
}


function form_check(theForm){
	if(!post_login_mode){
		if (theForm.code.value==""){
			alert("Не заполнено поле «Буквенный код»");
			theForm.code.focus();
			return(false);
		}
		if (theForm.author_name.value==""){
			alert("Не заполнено поле «Имя»");
			theForm.author_name.focus();
			return(false);
		}
	
		re = /(^)[\-0-9A-Z_-z~\.]+@[\-0-9A-Z_-z~\.]+\.[\-0-9A-Z_-z~\.]+($)/;
		found = theForm.author_email.value.match(re); 
		if (!found) {
			alert("Неправильный формат e-mail!");
			return(false);
		}
	} else {
		if (theForm.login.value==""){
			alert("Не заполнено поле «Логин»");
			theForm.login.focus();
			return(false);
		}
		if (theForm.password.value==""){
			alert("Не заполнено поле «Пароль»");
			theForm.password.focus();
			return(false);
		}
	}

	if (theForm.body.value==""){
		alert("Не заполнено поле «Текст комментария»");
		theForm.body.focus();
		return(false);
	}

	return(true);
}