// -----------------------------------------------------------------------
// TINAMI Comike Map System Ver 2010/07/20
// (c) 2006-2010 TINAMI. All rights reserved.
// favorite.js: お気に入り
// -----------------------------------------------------------------------
function clickFavorite(id)
{
    var url = '/comike/favorite/click/' + id;
    var myAjax = new Ajax.Request( url, {
        method: 'post', onComplete: function(req) {
            var data;
            try {
                data = eval('(' + req.responseText + ')');
            } catch(e) {
                _MapInternalErrorMsg("データ解析時に異常が発生しました", e, req.responseText, 'clickFavorite');
                return ;
            }
            // アイコンを差し換え
//            Element.setStyle('favorite_star', { 'background-position':'0 ' + data.top + 'px' });
            $('favorite_star').style.backgroundPosition = '0 ' + data.top + 'px';
            // 件数を差し換え
            Element.update('favorite_count', data.favorite_count);
            var classname = (data.favorite_count > 0 ? 'favorite_count_on' : 'favorite_count_off');
            $('favorite_count').setAttribute("class", classname);
            // title属性を状態によって変更
            var title = 'このサークルを' + (data.top == -24 ? 'お気に入りから外す':'お気に入りに追加');
            $('favorite_star').setAttribute('title', title);
        }
    });
}

function clickFavoriteList(id)
{
    var url = '/comike/favorite/click/' + id;
    var myAjax = new Ajax.Request( url, {
        method: 'post', onComplete: function(req) {
            var data;
            try {
                data = eval('(' + req.responseText + ')');
            } catch(e) {
                _MapInternalErrorMsg("データ解析時に異常が発生しました", e, req.responseText, 'clickFavorite');
                return ;
            }
            // アイコンを差し換え
//            Element.setStyle('favorite_star' + id, { 'background-position':'0 ' + data.top + 'px' });
            $('favorite_star' + id).style.backgroundPosition = '0 ' + data.top + 'px';
            // title属性を状態によって変更
            var title = 'このサークルを' + (data.top == -24 ? 'お気に入りから外す':'お気に入りに追加');
            $('favorite_star' + id).setAttribute('title', title);
        }
    });
}

