function ControlReply(w) {
	w.style.width = w.parentNode.offsetWidth;
	window.status = w.scrollHeight;
	if (w.scrollHeight < 100) {
		w.style.height = 100;
	} else {
		w.style.height = w.scrollHeight + 2;
	}
}
function ShowReplyForm(o, c, i, id) {
	// o - reply link
	// c - in reply
	// i - item name
	// id - item id
	o.style.display = 'none';
	ReplyForm = document.createElement('form');
	ReplyForm.action = '/addcomment/';
	ReplyForm.method = 'post';
	o.parentNode.appendChild(ReplyForm);
	//
	if (i == 'forum' && c == 0) {
		ReplyFormCaptionTitleSpan = document.createElement('span');
		ReplyFormCaptionTitleSpan.className = 'ReplyCaption';
		ReplyForm.appendChild(ReplyFormCaptionTitleSpan);
		ReplyFormCaptionTitle = document.createTextNode('Заголовок');
		ReplyFormCaptionTitleSpan.appendChild(ReplyFormCaptionTitle);
		//
		ReplyFormTopic = document.createElement('input');
		ReplyFormTopic.type = 'text';
		ReplyFormTopic.name = 'topic';
		ReplyFormTopic.className = 'ReplyFormTitle';
		ReplyForm.appendChild(ReplyFormTopic);
	}
	ReplyFormCaptionSpan = document.createElement('span');
	ReplyFormCaptionSpan.className = 'ReplyCaption';
	ReplyForm.appendChild(ReplyFormCaptionSpan);
	if (i == 'forum' && c == 0) {
		ReplyFormCaption = document.createTextNode('Сообщение');
	} else {
		ReplyFormCaption = document.createTextNode('Ответить');
	}
	ReplyFormCaptionSpan.appendChild(ReplyFormCaption);
	//
	ReplyFormAction = document.createElement('input');
	ReplyFormAction.type = 'hidden';
	ReplyFormAction.name = 'action';
	ReplyFormAction.value = 'comment';
	ReplyForm.appendChild(ReplyFormAction);
	ReplyFormBack = document.createElement('input');
	ReplyFormBack.type = 'hidden';
	ReplyFormBack.name = 'back_url';
	ReplyFormBack.value = document.location;
	ReplyForm.appendChild(ReplyFormBack);
	ReplyFormItem = document.createElement('input');
	ReplyFormItem.type = 'hidden';
	ReplyFormItem.name = 'item';
	ReplyFormItem.value = i;
	ReplyForm.appendChild(ReplyFormItem);
	ReplyFormNewsId = document.createElement('input');
	ReplyFormNewsId.type = 'hidden';
	ReplyFormNewsId.name = 'itemid';
	ReplyFormNewsId.value = id;
	ReplyForm.appendChild(ReplyFormNewsId);
	ReplyFormInReply = document.createElement('input');
	ReplyFormInReply.type = 'hidden';
	ReplyFormInReply.name = 'inreply';
	ReplyFormInReply.value = c;
	ReplyForm.appendChild(ReplyFormInReply);
	//
	ReplyFormBody = document.createElement('textarea');
	ReplyFormBody.name = 'comment';
	ReplyFormBody.cols = 45;
	ReplyFormBody.className = 'ReplyFormBody';
	ReplyFormBody.rows = 8;
	ReplyFormBody.style.width = '100%';
	ReplyFormBody.style.height = 100;
	ReplyForm.appendChild(ReplyFormBody);
	ReplyFormBody.onchange = function() {
		ControlReply(ReplyFormBody);
	}
	ReplyFormBody.onclick = function() {
		ControlReply(ReplyFormBody);
	}
	ReplyFormBody.onkeypress = function() {
		ControlReply(ReplyFormBody);
	}
	
	ReplyFormSubSpan = document.createElement('span');
	ReplyFormSubSpan.className = 'ReplyFormSubSpan';
	ReplyForm.appendChild(ReplyFormSubSpan);
	
	ReplyFormSubCheck = document.createElement('input');
	ReplyFormSubCheck.type = 'checkbox';
	ReplyFormSubCheck.name = 'subscribe';
	ReplyFormSubCheck.tabIndex = '-1';
	ReplyFormSubCheck.id = 'subscribe' + c;
	ReplyFormSubCheck.value = 1;
	ReplyFormSubSpan.appendChild(ReplyFormSubCheck);
	ReplyFormSubCheck.checked = true;
	
	ReplyFormSubCheckLabel = document.createElement('label');
	ReplyFormSubCheckLabel.tabIndex = '-1';
	ReplyFormSubCheckLabel.htmlFor = 'subscribe' + c;
	ReplyFormSubSpan.appendChild(ReplyFormSubCheckLabel);
	
	ReplyFormSubCaption = document.createTextNode('Следить за обсуждением');
	ReplyFormSubCheckLabel.appendChild(ReplyFormSubCaption);
	//
	ReplyFormBody.focus();
	ReplyFormSubmit = document.createElement('input');
	ReplyFormSubmit.type = 'submit';
	ReplyFormSubmit.value = 'Добавить ответ';
	ReplyFormSubmit.className = 'ReplyFormButton';
	ReplyForm.appendChild(ReplyFormSubmit);
	return false;
}