function addTorgRew(sess_md5, target, target_id, parent_id){
	$('div.reply').html('').hide();
    $("#rew_addentry"+parent_id).html("<div>Загрузка формы...</div>");
	$("#rew_addentry"+parent_id).load("/components/rew/addform.php", {cd: sess_md5, target: target, target_id: target_id, parent_id: parent_id}, cmLoaded());
	$("#rew_addentry"+parent_id).slideDown("fast");
}

function editTorgRew(sess_md5, comment_id){
	$('div.reply').html('').hide();
    var entry = $("#rew_addentry"+comment_id);
    entry.parent('div').find('.rew_entry').hide();
    entry.show();
    entry.html("<div>Загрузка формы...</div>");
	entry.load("/components/rew/addform.php", {cd: sess_md5, action: 'edit', id: comment_id}, cmLoaded());	
}

function cmLoaded() {
    //$("#content").autogrow();
}

function cancelTorgRew(parent_id){
    $("#rew_addentry"+parent_id).parent('div').find('.rew_entry').show();
	$("#rew_addentry"+parent_id).hide();
}

function expandTorgRew(id){
	$('a#expandlink'+id).hide();
	$('div#expandblock'+id).show();
}

function addSmile(tag, field_id){
	var txtarea = document.getElementById(field_id);
	txtarea.value += ' :' + tag + ': ';
	$('#smilespanel').hide();
}

function loadTorgRews(target, target_id, anchor){

    $('div.rew_ajax_list').html('<p style="margin:30px; margin-left:0px; padding-left:50px; background:url(/images/ajax-loader.gif) no-repeat">загрузка отзывов...</p>');

    $.ajax({
			type: "POST",
			url: "/components/rew/comments.php",
			data: "target="+target+"&target_id="+target_id,
			success: function(data){
				$('div.rew_ajax_list').html(data);
                $('td.loading').html('');
                if (anchor){
                    window.location.hash = anchor.substr(1, 100);
                    $('a[href='+anchor+']').css('color', 'red').attr('title', 'Вы пришли на страницу по этой ссылке');
                }
			}
    });

}

function goPage(dir, field, target, target_id){

	var p = Number($('#'+field).attr('value')) + dir;
    loadComments(target, target_id, p);

}

function voteTorgRew(comment_id, vote){

    $('span#votes'+comment_id).html('<img src="/images/ajax-loader.gif" border="0"/>');
    $.ajax({
			type: "POST",
			url: "/components/rew/vote.php",
			data: "comment_id="+comment_id+"&vote="+vote,
			success: function(data){
				$('span#votes'+comment_id).html(data);
			}
    });

}