﻿function addToFavorite(iTopicId)
{
	viewPopuper('Выполняется добавление в избранные', 1);
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
        	if (req.responseJS.topic_points)
        	{
        		document.getElementById('topic_'+iTopicId+'_favorite').src = cfg_path_web + '/themes/' + cfg_site_theme + '/images/favorites_gray.gif';
        	}
       
        if (req.responseJS.aMessages) {
        		printMessages(req.responseJS.aMessages);
        }
        setTimeout('hidePopuper()', 1000);
         }	
    }
    
    req.caching = false;
    req.open('POST', cfg_path_web+'/modules/blog/loaders/add_to_favorites.loader.php', true);
    req.send( { topic_id: iTopicId } );
}