$(document).ready(function () {
	var form = $('#f-comment > form');
	var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: proccessAddCommentResponse};
	form.ajaxForm(options);
	form.find('input[@name=author]').focus(function () {
		$(this).toggleDefaultText('Ваше имя');
	});
	form.find('input[@name=author]').blur(function () {
		$(this).toggleDefaultText('Ваше имя');
	});
	form.find('textarea').focus(function () {
		$(this).toggleDefaultText('Добавить комментарий');
	});
	form.find('textarea').blur(function () {
		$(this).toggleDefaultText('Добавить комментарий');
	});
});

function proccessAddCommentResponse(responseText) {
	var form = $('#f-comment > form');
	if (responseText.status == 'success') {
       	form.clearHighlight();
       	refreshScreen();
	} else {
      	$('#code').val('');
      	form.highlightFields(responseText.fields);
    }
	$('#capcha').setNewCapcha();
	form.hideSplash('none');
}
