/*-----------------------------------------------------------------------------
 * newsing script functions
 *
 * DEPEDENCIES
 * -- prototype.js
 * -- rico.js
 *---------------------------------------------------------------------------*/

/**
 * ベースのURLをグローバル変数gBASE_URLにセット・保持する
 * html header 部で、この関数を呼び、ベースURLをこのJavaScriptで参照可能とする。
 */
var gBASE_URL;
function setBASE_URL(url){
    gBASE_URL = url;
}

var gFlash_Enable;
function isFlashEnable(){
    var enable = false;
    if(navigator.mimeTypes && 
       navigator.mimeTypes["application/x-shockwave-flash"]&&
       navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        if(navigator.plugins && navigator.plugins["Shockwave Flash"]){
            gFlash_Enable = true;
        }
    }else if(navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && navigator.userAgent.indexOf("Win")>=0){
        document.write('<SCR'+'IPT LANGUAGE="VBS'+'cript"\> \n');
        document.write('on error resume next \n');
        document.write('gFlash_Enable = CreateObject("ShockwaveFlash.ShockwaveFlash").FlashVersion \n');
        document.write('</SCR'+'IPT\>\n');
    }
    return gFlash_Enable;
}

/**
 * ヘッダー部の検索ボタン処理
 * 検索フォームにキーワードが入力されている場合に、検索アクションを呼び出す。
 * 
 * @param String type 検索対象の種別。news: ニュース検索、inside: ソーシャル検索
 */
function search_submit(type){
    if(document.searchform.q.value != ''){
        if(type == 'news') { document.searchform.action = gBASE_URL + 'search'; }
        if(type == 'inside') {
               document.searchform.action = gBASE_URL + 'searchentry'; 
               document.searchform.sidesearch.name="q";
               removeHiddenElement(document.searchform,'id');
               removeHiddenElement(document.searchform,'ord');
        }
        if(type == 'site') {
               document.searchform.action = 'http://search.newsing.jp/'; 
               addHiddenElement(document.searchform,'id','300716');
               addHiddenElement(document.searchform,'ord','s');
               document.searchform.sidesearch.name="kw";
        }
        if(type == 'site_mincareer') {
               document.searchform.action = 'http://search.mincareer.com/'; 
               addHiddenElement(document.searchform,'ord','s');
               document.searchform.sidesearch.name="kw";
        }
        document.searchform.submit();
    }
}

// Hidden要素を追加
function addHiddenElement(obj,name,value){
    var element=document.createElement('input');
    element.type="hidden";
    element.name=name;
    element.value=value;
    obj.appendChild(element);
}

// Hidden要素を削除
function removeHiddenElement(obj,name){
    var max=obj.childNodes.length;
    for(var i=0;i<max;i++)
    {
            if(obj.childNodes.item(i) &&
                obj.childNodes.item(i).nodeName=="INPUT" &&
                obj.childNodes.item(i).type=="hidden"  &&
                obj.childNodes.item(i).name==name)
            {
                    obj.removeChild(obj.childNodes.item(i));
            }

    }
}

/**
 * 未ログインでは操作できない場合のalert box 表示
 *
 */
function unlogined(){
    alert('この操作はログインした後に可能です。');
    return false;
}

function jstrlen(str) {
   var len = 0;
   str = escape(str);
   for (var i = 0; i < str.length; i++, len++) {
      if (str.charAt(i) == "%") {
         if (str.charAt(++i) == "u") {
            i += 3;
            len++;
         }
         i++;
      }
   }
   return Math.floor(len/2);
}

function problem_report(entryid, mode){
    var obj = $('pb-'+entryid);
    var s = obj.style;
    
    if(mode=='close') { s.display = 'none'; }
    else if(mode=='open') { s.display = 'block'; }
    else if(s.display == 'block') { s.display = 'none'; }
    else { s.display = 'block'; }
}

function problem_report_go(entryid, entrytitle, type){
    if(confirm("この記事を通報します。よろしいですか？")){
        var url = gBASE_URL + 'api/problemreport?id=' + entryid + '&type=' + type;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: alert('記事「' + entrytitle + '」をサイト運営者へ通報しました')
            }
        );
    }
}

function problem_user_report(userid, mode){
    var obj = $('pb-'+userid);
    var s = obj.style;
    
    if(mode=='close') { s.display = 'none'; }
    else if(mode=='open') { s.display = 'block'; }
    else if(s.display == 'block') { s.display = 'none'; }
    else { s.display = 'block'; }
}

function problem_user_report_go(userid,username, type){
    if(confirm("このユーザを通報します。よろしいですか？")){
        var url = gBASE_URL + 'api/problemuserreport?id=' + userid + '&type=' + type;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: alert('ユーザ「' + username + '」をサイト運営者へ通報しました')
            }
        );
    }
}

//エントリーを削除
function delete_entry(entryId){
    return confirm(entryId);
    return false;
}

//PRnewsing click
/* これはもう使いません 2008-09-02 BY たつや 
function clickcount(jumpurl,clicktype){
    var url_option = '';
    if(clicktype == 'jumptosite'){
        url_option = '&f=pr_jumptosite';
    }
    if(clicktype == 'click'){
        url_option = '&f=pr_click';
    }

    var url = gBASE_URL + 'api/click?n=' + jumpurl + url_option;
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get'
        }
    );
}
*/

// click
var LinkCount = Class.create();
LinkCount.prototype = {
    initialize: function(className, parentElement) {
        var elements = document.getElementsByClassName(className, parentElement);
        for (var i = 0, len = elements.length; i < len; i++) {
            Event.observe(elements[i], 'click', this.addLinkCount.bindAsEventListener(this));
        }
    },
    addLinkCount: function(event) {
        var element = Event.element(event);
        if(element.getAttribute('src') != null){
            //画像のときはelementが<img>になるため対応。
            element = element.parentNode;
        }
        var image = new Image();
        image.src = gBASE_URL + 'api/click?n=' + encodeURIComponent(element.getAttribute('href'));
    }
}; 

Event.observe(window, 'load', function () {
    new LinkCount('click');
});

// AnnounceClick
var LinkAnnounceCount = Class.create();
LinkAnnounceCount.prototype = {
    initialize: function(aid) {
        this.aid = aid;
        var elements = document.getElementById('announce_id_' + aid);
        if(elements){
            Event.observe(elements, 'click', this.addLinkCount.bindAsEventListener(this));
        }
    },
    addLinkCount: function(event) {
        var element = Event.element(event);
        var image = new Image();
        image.src = gBASE_URL + 'api/clickannounce?aid=' + this.aid;
    }
};

//キーワードマッチ広告のクリック数
function clickAd(ad_id,type){
    var url = gBASE_URL + 'api_clickad?ad_id=' + ad_id + '&type=' + type;
    var options = {"method":"get"};
    new Ajax.Request(url,options);
}

/*
    PRnewsingのレポートをAjaxで送信する
    入力
    id   : PRnewsingのエントリーID
    type : レポートのタイプ
           8種類(imp_entry, imp_prframe, click_jumptosite, click_linktext,
                 click_prframe, click_banner, click_middlebanner, click_topbanner)
*/
function prReport(id, type){
    var url = gBASE_URL + 'api_prreport?id=' + id + '&type=' + type;
    var options = {"method":"get"};
    new Ajax.Request(url,options);
}

// PRnewsing VoteButton
var PRnewsingVoteButton = Class.create();
PRnewsingVoteButton.prototype = {
    initialize: function(entryId, entryUrl, point, goodVote, badVote, loginStatus, prButton){
        this.entryId = entryId;
        this.entryUrl = entryUrl;
        this.point = point;
        this.goodVote = goodVote;
        this.badVote = badVote;
        this.loginStatus = loginStatus;

        var idNamePrnewsingPositiveButton = 'prpositivebutton';
        var idNamePrnewsingNegativeButton = 'prnegativebutton';
        var idNamePrPoint = 'point_inner';
        var idNameLoading = 'loading-button';
        var idNameVoteButton = 'vote_button';

        this.objPositiveButton = $(idNamePrnewsingPositiveButton);
        this.objNegativeButton = $(idNamePrnewsingNegativeButton);
        this.objPoint = $(idNamePrPoint);
        this.objLoading = $(idNameLoading);
        this.voteButton = $(idNameVoteButton);

        this.voteButton.isEnabled = true;

        if(this.loginStatus != 'guest'){
            Event.observe(this.objPositiveButton, 'click', this.clickButtonPositive.bindAsEventListener(this), false);
            Event.observe(this.objNegativeButton, 'click', this.clickButtonNegative.bindAsEventListener(this), false);
            if(this.loginStatus == 'commented'){
                this.setUnable();
            }
        }else{
            Event.observe(this.objPositiveButton, 'click', this.clickGuestPositive.bindAsEventListener(this), false);
            Event.observe(this.objNegativeButton, 'click', this.clickGuestNegative. bindAsEventListener(this), false);
        }

    },
    // 投票したときのアニメーション　＆　ポイント数と円グラフの表示更新
    startCountupAnimation: function(res){
        var myObj = this;
        new Rico.Effect.FadeTo($(myObj).objPoint, 0.01, 300, 10, {
            complete:function(){
              $(myObj).objPoint.innerHTML = res; //表示ポイント数値
              new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {
                  complete:function(){
                  //
                  }
              });
            }
        });
    },
    clickButtonPositive: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.startButtonAnimation('p');
            this.AjaxRequest('p');
        }else{
            Event.stop(event);
        }
    },
    clickButtonNegative: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.startButtonAnimation('n');
            this.AjaxRequest('b');
        }else{
            Event.stop(event);
        }
    },
    //未ログインユーザがボタンクリックしたときはログイン画面へ。
    clickGuestPositive: function(){
        var myObj = this;
        new Rico.Effect.FadeTo(this.objPoint, 0.01, 500, 10, {complete:function(){
            window.open(gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=1&w=open', '_top');
            new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {complete:function(){
                //window.open(gBASE_URL + 'add', '_top');
            }});
        }});
    },
    clickGuestNegative: function(){
        var myObj = this;
        new Rico.Effect.FadeTo(this.objPoint, 0.01, 500, 10, {complete:function(){
            window.open(gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=0&w=open', '_top');
            new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {complete:function(){
                //window.open(gBASE_URL + 'add', '_top');
            }});
        }});
    },
    startButtonAnimation: function(btn_flag){
        var myObj = this;

        if(btn_flag == 'p'){
            new Rico.Effect.FadeTo(this.objPositiveButton, 0.01, 300, 10, {
                complete:function(){
                    new Rico.Effect.FadeTo($(myObj).objPositiveButton, 0.3, 5, 2, {
                        complete:function(){
                            // 
                        }
                    });
                }
            });
        }else{
            new Rico.Effect.FadeTo(this.objNegativeButton, 0.01, 300, 10, {
                complete:function(){
                    new Rico.Effect.FadeTo($(myObj).objNegativeButton, 0.3, 5, 2, {
                        complete:function(){
                            //
                        }
                    });
                }
            });
        }
    },
    setEnable: function(){
        this.voteButton.isEnabled = true;
        new Rico.Effect.FadeTo(this.voteButton, 1.0, 5, 2, {});
    },
    setUnable: function(){
        this.voteButton.isEnabled = false;
        new Rico.Effect.FadeTo(this.voteButton, 0.3, 5, 2, {});
    },
    //引数：○のときvoteMode='t', ×のときvoteMode='f'
    AjaxRequest: function(voteMode){
        voteMode = (voteMode == 'p')? 't': 'f';

        var url = gBASE_URL + 'api/vote?t=' + voteMode + '&i=' + this.entryId + '&p=1';
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.AjaxReturned.bind(this)
            }
        );
    },
    AjaxReturned: function(originalRequest){
        var res = originalRequest.responseText;
        res = res.strip() - 0;
        if(res >= 0){ //処理成功の場合（res＝増加後のポイント値）
            this.point = res; //表示増数
            $('graph_point').innerHTML = res;
            this.startCountupAnimation(res);
        }else{
            if(res == -2){
            }else{
            }
        }
    }
}

// GraphAnimation
var GraphAnimation = Class.create();
GraphAnimation.prototype = {
    initialize: function(seq, entryId, entryUrl, point, goodVote, badVote, loginStatus, prButton, prText){
        this.obj = $('graphanimation-' + seq);//親要素
        this.obj.innerHTML = '';
        this.obj.style.color = '#5B5759';
        this.seq = seq;
        this.entryId = entryId;
        this.entryUrl = entryUrl;
        this.point = point;
        this.goodVote = goodVote;
        this.badVote = badVote;
        this.loginStatus = loginStatus;
        if(prText){
          this.prText = prText;        
          this.prFlag = 1;
        }else{
          this.prText = 'このニュースは？';
          this.prFlag = '';
        }

        if(prButton == 1){
          this.btPositive = 'bt_yes.gif'
          this.btNegative = 'bt_no.gif'
        }else{
          this.btPositive = 'bt_circle.gif'
          this.btNegative = 'bt_cross.gif'
        }

        this.voteButton = '';
        var htmlButtonClick = '';
        if(this.loginStatus != 'guest'){
            htmlButtonClick = 'javascript:void(0)';
        }
        else{
            htmlButtonClick = 'javascript:void(0)';
        }
        //DOMをくみたてる
        //円グラフ
        this.divGraph = document.createElement('div');
        this.divGraph.id = 'divgraph-' + seq;
        var gs = this.divGraph.style;
        gs.width = '60px';
        gs.height = '60px';
        gs.margin = '0px 14px 5px 14px';
        gs.padding = '0px';
        gs.textAlign = 'center';
        gs.color = '#ffffff';
        gs.fontWeight = 'bold';
        gs.fontSize = '15px';
        gs.lineHeight = '100%';
        gs.fontFamily = '"arial","Sans-serif"';
        this.setGraphImage();
        //グラフ上の数値
        this.linkToEntryBox = document.createElement('div');
        this.linkToEntry = document.createElement('a');
        if(this.prFlag == 1){
            this.linkToEntry.href = gBASE_URL + 'entry?url=' + encodeURIComponent(this.entryUrl.unescapeHTML())+'&pr=1';
        }else{
            this.linkToEntry.href = gBASE_URL + 'entry?url=' + encodeURIComponent(this.entryUrl.unescapeHTML());
        }
        this.linkToEntryBox.style.padding = '14px 0px 0px 0px';
        this.pointValue = document.createElement('span');
        this.pointValue.id = 'id-' + this.entryId;
        this.pointValue.innerHTML = this.point; //表示ポイント数値
        this.linkToEntry.appendChild(this.pointValue);
        this.textElem = document.createElement('div');
        this.textElem.style.fontSize = '12px';
        this.textElem.innerHTML = 'point';
        this.linkToEntry.appendChild(this.textElem);
        this.linkToEntryBox.appendChild(this.linkToEntry);
        this.divGraph.appendChild(this.linkToEntryBox);
        this.obj.appendChild(this.divGraph);
        this.textElement = document.createElement('span');

        if(prText != 'buttonhide'){
            this.textElement.innerHTML = '<div class="line88"><img src="/common/images/spacer.gif" width="88" height="1" alt=""></div><div class="title">' + this.prText + '</div>';
            this.obj.appendChild(this.textElement);
            //○×ボタン
            this.voteButton = document.createElement('div');
            this.voteButton.id = 'vote-' + this.entryId;
            this.voteButton.isEnabled = true;//クリックできるかどうか
            this.voteButton.style.align = 'center';
            this.voteButton.style.width = '88px';
            this.buttonGood = document.createElement('span');
            this.buttonGood.innerHTML = '<a href="' + htmlButtonClick + '"><img src="/common/images/' + this.btPositive + '" alt="支持する" width="43" height="43" border="0"></a>';

            this.voteButton.appendChild(this.buttonGood);
            this.buttonBad = document.createElement('span');
            this.buttonBad.innerHTML = '<a href="' + htmlButtonClick + '"><img src="/common/images/' + this.btNegative + '" alt="支持しない" width="43" height="43" border="0"></a>';
            this.voteButton.appendChild(this.buttonBad);
            this.obj.appendChild(this.voteButton);
            //処理中アイコン
            this.executingIcon = document.createElement('div');
            this.executingIcon.style.textAlign = 'center';
            this.obj.appendChild(this.executingIcon);

            if(this.loginStatus != 'guest'){
                Event.observe(this.buttonGood, 'click', this.clickButtonGood.bindAsEventListener(this), false);
                Event.observe(this.buttonBad,  'click', this.clickButtonBad. bindAsEventListener(this), false);
                if(this.loginStatus == 'commented'){
                    this.setUnable();
                }
            }
            else{
                Event.observe(this.buttonGood, 'click', this.clickGuestGood.bindAsEventListener(this), false);
                Event.observe(this.buttonBad , 'click', this.clickGuestBad. bindAsEventListener(this), false);
            }
        }
    },
    // グラフ画像をセット
    setGraphImage: function(){
        var num = 50;
        if ((this.goodVote + this.badVote) > 0){
            if(this.goodVote / ((this.goodVote-0) + (this.badVote-0)) == 0.25) { num = 25; }
            else if(this.goodVote / ((this.goodVote-0) + (this.badVote-0)) == 0.75) { num = 75; }
            else {
                num = (Math.round(10 * this.goodVote / ((this.goodVote-0) + (this.badVote-0))) * 10);
            }
        }
        //var graphImageName =  'url(/common/images/graph/graph_' + num + '.gif)'; //円グラフ画像用
        var graphImageName =  'url(/common/images/graph/graph_m_' + num + '.gif)'; //円グラフ画像用
        this.divGraph.style.backgroundImage = graphImageName; //グラフ画像
    },
    // 投票したときのアニメーション　＆　ポイント数と円グラフの表示更新
    voteAnimation: function(){
        var myObj = this;
        new Rico.Effect.FadeTo(this.divGraph, 0.01, 500, 10, {
            complete:function(){
                $(myObj).pointValue.innerHTML = $(myObj).point; //表示ポイント数値
                $(myObj).setGraphImage();
                new Rico.Effect.FadeTo($(myObj).divGraph, 1, 500, 10, {
                    complete:function(){
                        $(myObj).executingIcon.innerHTML = '';
                        $(myObj).openToCommentWindow();
                    }
                });
            }
        });
    },
    clickButtonGood: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.goodVote ++;
            this.showExecutingIcon();
            this.voteButton = 'good';
            this.AjaxRequest('t');
            this.vote = 't';
            this.addUser('t');
        }
        Event.stop(event);
    },
    clickButtonBad: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.badVote ++;
            this.showExecutingIcon();
            this.voteButton = 'bad';
            this.AjaxRequest('f');
            this.vote = 'f';
            this.addUser('f');
        }
        Event.stop(event);
    },
    //マルバツ投票数を増やす
    changeVoteCount: function(){
        var goodCount = this.goodVote;
        var badCount  = this.badVote;

        if(this.vote == 't'){
            //IEのバグでwidthを指定しないとRico.Effect.FadeToがきかない
            //記事詳細ページの場合
            if($('goodCount-Big')){
                $('goodCount-Big').style.width = 40;
                new Rico.Effect.FadeTo('goodCount-Big', 0.01, 500, 10,{
                    complete:function(){
                        $('goodCount-Big').innerHTML = '（' + goodCount + '票）';
                        new Rico.Effect.FadeTo('goodCount-Big', 1, 500, 10);
                    }
                });
            }
        }else{
            //IEのバグでwidthを指定しないとRico.Effect.FadeToがきかない
            //記事詳細ページの場合
            if($('badCount-Big')){
                $('badCount-Big').style.width = 40;
                new Rico.Effect.FadeTo('badCount-Big', 0.01, 500, 10,{
                    complete:function(){
                        $('badCount-Big').innerHTML = '（' + badCount + '票）';
                        new Rico.Effect.FadeTo('badCount-Big', 1, 500, 10);
                    }
                });
            }
        }
    },
    setEnable: function(){
        this.voteButton.isEnabled = true;
        new Rico.Effect.FadeTo(this.voteButton, 1.0, 5, 2, {});
    },
    setUnable: function(){
        this.voteButton.isEnabled = false;
        new Rico.Effect.FadeTo(this.voteButton, 0.3, 5, 2, {});

        //大きいマルバツもクリックできなくする
        if($('big_btn_area')){
            if(this.prText == 'このニュースは？'){
                $('big_btn_area').isEnabled = false;
                $('big_good_btn').innerHTML = '<img src="/common/images/good-off.png" alt="支持しする" width="271" height="66" border="0">' 
                $('big_bad_btn').innerHTML = '<img src="/common/images/bad-off.png" alt="支持しない" width="271" height="66" border="0">'
            }else{
                $('big_btn_area').isEnabled = false;
                $('big_good_btn').innerHTML = '<img src="/common/images/yes-off.png" alt="支持しする" width="271" height="66" border="0">'
                $('big_bad_btn').innerHTML = '<img src="/common/images/no-off.png" alt="支持しない" width="271" height="66" border="0">'
            }
        }
    },
    showExecutingIcon: function(){
        this.executingIcon.innerHTML = '<img src="/common/images/loading_red.gif" />';
    },
    //○×クリックをサーバ側へAjax送信
    //引数：○のときvoteMode='t', ×のときvoteMode='f'
    AjaxRequest: function(voteMode){
        voteMode = (voteMode == 't')? 't': 'f';
        pr_flag = '';

        if(this.prFlag != ''){
            pr_flag = '&p=1';
        }

        var url = gBASE_URL + 'api/vote?t=' + voteMode + '&i=' + this.entryId + pr_flag;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.AjaxReturned.bind(this)
            }
        );
    },
    AjaxReturned: function(originalRequest){
        var res = originalRequest.responseText;
        res = res.strip() - 0;
        if(res >= 0){ //処理成功の場合（res＝増加後のポイント値）
            this.point = res; //表示増数
            this.executingIcon.innerHTML = '';
            this.voteAnimation();
        }else{
            if(res == -2){
                //入力済み
                this.executingIcon.innerHTML = '';
            }else{
                //その他のエラーー
                this.executingIcon.innerHTML = '';
            }
        }
    },
    openToCommentWindow: function(){
        var seq = ("" + this.obj.id).replace('graphanimation-', '');
        if($('commentwindow-' + seq)){
            openCommentWindow(seq);

            //○×の初期値
            if(CommentWindow.instance[seq].setGoodBadButton){
                CommentWindow.instance[seq].setGoodBadButton(this.voteButton);
            }
        }
    },
    //未ログインユーザがボタンクリックしたときはログイン画面へ。
    clickGuestGood: function(){
        var myObj = this;
        this.showExecutingIcon();
        new Rico.Effect.FadeTo(this.divGraph, 0.01, 500, 10, {complete:function(){
            window.open(gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=1&w=open', '_top');
            new Rico.Effect.FadeTo($(myObj).divGraph, 1, 500, 10, {complete:function(){
                //window.open(gBASE_URL + 'add', '_top');
            }});
        }});
    },
    clickGuestBad: function(){
        var myObj = this;
        this.showExecutingIcon();
        new Rico.Effect.FadeTo(this.divGraph, 0.01, 500, 10, {complete:function(){
            window.open(gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=0&w=open', '_top');
            new Rico.Effect.FadeTo($(myObj).divGraph, 1, 500, 10, {complete:function(){
                //window.open(gBASE_URL + 'add', '_top');
            }});
        }});
    },
    addUser: function(flag){
        var url = gBASE_URL + 'api/getuserdata?f=' + flag;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.showuser.bind(this)
            }
        );
    },
    showuser: function(originalRequest){
        var show_value = originalRequest.responseText;
        var obj = eval("("+show_value+")");
        var img_id       = 'img' + obj.userid;
        var userpage_url = gBASE_URL +'user/'+obj.encusername;
        var usericon_url = gBASE_URL + obj.imagepath;
        var iconhtml = '<span id="'+ img_id +'"><a href="'+userpage_url +'"><img src="'+ usericon_url +'" width="60" height="60" border="0" align="absmiddle"></a><br /><a href="' +userpage_url +'">'+ obj.username +'</a></span>';
        if(obj.voteflag == 't'){
            $('good_commenter').innerHTML = iconhtml;
        }else{
            $('bad_commenter').innerHTML = iconhtml;
        }

       //IEのバグでwidthｸA頏指定しないた?Rico.Effect.FadeToがきかない
       $(img_id).style.width = 60;

        var myObj = this;
        //写真を消す
        new Rico.Effect.FadeTo(img_id, 0.01, 1, 1)
        //写真を出す
        new Rico.Effect.FadeTo(img_id, 1, 1000, 10,{
            complete:function(){
                $(myObj).changeVoteCount();
            }
        });
    }
}

// 大きな○×ボタン
var BigVoteBtn = Class.create();
BigVoteBtn.prototype = {
    initialize: function(seq, entryId, entryUrl, point, goodVote, badVote, loginStatus, prFlag){
        this.obj = $('bigvotebtn');//親要素
        this.obj.innerHTML = '';
        this.obj.style.color = '#5B5759';
        this.entryId = entryId;
        this.entryUrl = entryUrl;
        this.point = point;
        this.goodVote = goodVote;
        this.badVote = badVote;
        this.loginStatus = loginStatus;
        this.seq = seq;
        this.voteButton = '';
        this.divGraph = 'divgraph-' + seq;
        this.pointValue = 'id-' + entryId;

        if(prFlag == 1 || prFlag == 0){
          if(prFlag == 1){
              this.bigbtnimg_o_on = 'yes-on.png';
              this.bigbtnimg_o_off = 'yes-off.png';
              this.bigbtnimg_x_on = 'no-on.png';
              this.bigbtnimg_x_off = 'no-off.png';
          }
          if(prFlag == 0){
              this.bigbtnimg_o_on = 'good-on.png';
              this.bigbtnimg_o_off = 'good-off.png';
              this.bigbtnimg_x_on = 'bad-on.png';
              this.bigbtnimg_x_off = 'bad-off.png';
          }
          this.prFlag = prFlag;
        }else{
          this.bigbtnimg_o_on = 'good-on.png';
          this.bigbtnimg_o_off = 'good-off.png';
          this.bigbtnimg_x_on = 'bad-on.png';
          this.bigbtnimg_x_off = 'bad-off.png';
          this.prFlag = '';
        }

        //○×ボタン
        this.voteButton = document.createElement('div');
        this.voteButton.id = 'big_btn_area';
        this.voteButton.isEnabled = true;   //クリックできるかどうか
        this.voteButton.style.align = 'center';
        this.voteButton.style.width = '580px';
        this.buttonGood = document.createElement('span');
        this.buttonGood.id = 'big_good_btn';
        this.buttonGood.style.width = '271px';
        this.buttonGood.style.styleFloat = 'left';
        this.buttonGood.style.cssFloat = 'left';
        this.voteButton.appendChild(this.buttonGood);
        this.buttonBad = document.createElement('span');
        this.buttonBad.id = 'big_bad_btn';
        this.buttonBad.style.width = '271px';
        this.buttonBad.style.styleFloat = 'right';
        this.buttonBad.style.cssFloat = 'right';
        this.voteButton.appendChild(this.buttonBad);
        this.obj.appendChild(this.voteButton);
        //処理中アイコン
        this.executingIcon = document.createElement('div');
        this.executingIcon.style.textAlign = 'center';
        this.obj.appendChild(this.executingIcon);
        this.setEnable();
        if(this.loginStatus != 'guest'){
            Event.observe(this.buttonGood, 'click', this.clickButtonGood.bindAsEventListener(this), false);
            Event.observe(this.buttonBad,  'click', this.clickButtonBad. bindAsEventListener(this), false);
            if(this.loginStatus == 'commented'){
                this.setUnable();
            }
        }
    },
    clickButtonGood: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.goodVote ++;
            this.showExecutingIcon();
            this.voteButton = 'good';
            this.AjaxRequest('t');
            this.addUser('t');
        }
        Event.stop(event);
    },
    clickButtonBad: function(event){
        if(this.voteButton.isEnabled){
            this.setUnable();
            this.badVote ++;
            this.showExecutingIcon();
            this.voteButton = 'bad';
            this.AjaxRequest('f');
            this.addUser('f');
        }
        Event.stop(event);
    },
    setEnable: function(){
        this.voteButton.isEnabled = true;
        if(this.loginStatus == 'guest'){
            var myObj = this;
            this.buttonGood.innerHTML = '<a href="' + gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=1&w=open"><img src="/common/images/' + this.bigbtnimg_o_off + '" onmouseout="this.src=\'/common/images/' + this.bigbtnimg_o_off + '\'" onmouseover="this.src=\'/common/images/' + this.bigbtnimg_o_on + '\'"  alt="支持する" width="271" height="66" border="0"></a>'; 
            this.buttonBad.innerHTML = '<a href="' + gBASE_URL + 'comment?url=' + encodeURIComponent($(myObj).entryUrl.unescapeHTML()) + '&submit=true&thumb=0&w=open"><img src="/common/images/' + this.bigbtnimg_x_off + '" onmouseout="this.src=\'/common/images/' + this.bigbtnimg_x_off +'\'" onmouseover="this.src=\'/common/images/' + this.bigbtnimg_x_on + '\'"  alt="支持しない" width="271" height="66" border="0"></a>'; 
        }else{
            this.buttonGood.innerHTML = '<a href="javascript:void(0);"><img src="/common/images/' + this.bigbtnimg_o_off + '" onmouseout="this.src=\'/common/images/' + this.bigbtnimg_o_off + '\'" onmouseover="this.src=\'/common/images/' + this.bigbtnimg_o_on + '\'"  alt="支持する" width="271" height="66" border="0"></a>'; 
            this.buttonBad.innerHTML = '<a href="javascript:void(0);"><img src="/common/images/' + this.bigbtnimg_x_off + '" onmouseout="this.src=\'/common/images/' + this.bigbtnimg_x_off + '\'" onmouseover="this.src=\'/common/images/' + this.bigbtnimg_x_on + '\'"  alt="支持しない" width="271" height="66" border="0"></a>'; 
        }
    },
    setUnable: function(){
        this.voteButton.isEnabled = false;
        this.buttonBad.innerHTML = '<img src="/common/images/' + this.bigbtnimg_x_off + '" alt="支持しない" width="271" height="66" border="0">';
        this.buttonGood.innerHTML = '<img src="/common/images/' + this.bigbtnimg_o_off + '" alt="支持する" width="271" height="66" border="0">';

        //グラフのほうのマルバツボタンも押せなくする
        $('vote-' + this.entryId).isEnabled = false;
        new Rico.Effect.FadeTo('vote-' + this.entryId, 0.3, 5, 2, {});         
    },
    showExecutingIcon: function(){
        this.executingIcon.innerHTML = '<img src="/common/images/loading_red.gif" />';
    },
    addUser: function(flag){
        var url = gBASE_URL + 'api/getuserdata?f=' + flag;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.showuser.bind(this)
            }
        );
    },
    showuser: function(originalRequest){
        var show_value = originalRequest.responseText;
        var obj = eval("("+show_value+")");
        var img_id       = 'img' + obj.userid;
        var userpage_url = gBASE_URL +'user/'+obj.encusername;
        var usericon_url = gBASE_URL + obj.imagepath;
        var iconhtml = '<span id="'+ img_id +'"><a href="'+userpage_url +'"><img src="'+ usericon_url +'" width="60" height="60" border="0" align="absmiddle"></a><br /><a href="' +userpage_url +'">'+ obj.username +'</a></span>';
        if(obj.voteflag == 't'){
            $('good_commenter').innerHTML = iconhtml;
        }else{
            $('bad_commenter').innerHTML = iconhtml;
        }

       //IEのバグでwidthを指定しないとRico.Effect.FadeToがきかない
       $(img_id).style.width = 60;

        var myObj = this;
        //写真を消す
        new Rico.Effect.FadeTo(img_id, 0.01, 1, 1)
        //写真を出す
        new Rico.Effect.FadeTo(img_id, 1, 1000, 10,{
            complete:function(){
                $(myObj).changeVoteCountBig(obj.voteflag, $(myObj).goodVote, $(myObj).badVote);
            }
        });
    },
    //票数を変える
    changeVoteCountBig: function(flag,good,bad){
        if(flag == 't'){
            //IEのバグでwidthを指定しないとRico.Effect.FadeToがきかない
           // $('goodCount-0').style.width = 40;
            $('goodCount-Big').style.width = 40;
/*
            new Rico.Effect.FadeTo('goodCount-0', 0.01, 500, 10,{
                complete:function(){
                    $('goodCount-0').innerHTML = good + '票';
                    new Rico.Effect.FadeTo('goodCount-0', 1, 500, 10);
                }
            });*/
            new Rico.Effect.FadeTo('goodCount-Big', 0.01, 500, 10,{
                complete:function(){
                    $('goodCount-Big').innerHTML = '（' + good + '票）';
                    new Rico.Effect.FadeTo('goodCount-Big', 1, 500, 10);
                }
            });
        }else{
            //IEのバグでwidthを指定しないとRico.Effect.FadeToがきかない
            //$('badCount-0').style.width = 40;
            $('badCount-Big').style.width = 40;

           /* new Rico.Effect.FadeTo('badCount-0', 0.01, 500, 10,{
                complete:function(){
                    $('badCount-0').innerHTML = bad + '票';
                    new Rico.Effect.FadeTo('badCount-0', 1, 500, 10);
                }
            });*/
            new Rico.Effect.FadeTo('badCount-Big', 0.01, 500, 10,{
                complete:function(){
                    $('badCount-Big').innerHTML = '（' + bad + '票）';
                    new Rico.Effect.FadeTo('badCount-Big', 1, 500, 10);
                }
            });
        }
    },
    //○×クリックをサーバ側へAjax送信
    //引数：○のときvoteMode='t', ×のときvoteMode='f'
    AjaxRequest: function(voteMode){
        voteMode = (voteMode == 't')? 't': 'f';
        if(this.prFlag == 1){
            pr_flag = '&p=1';
        }else{
            pr_flag = '&p=0';
        }
        var url = gBASE_URL + 'api/vote?t=' + voteMode + '&i=' + this.entryId + pr_flag;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.AjaxReturned.bind(this)
            }
        );
    },
    AjaxReturned: function(originalRequest){
        var res = originalRequest.responseText;
        res = res.strip() - 0;
        if(res >= 0){ //処理成功の場合（res＝増加後のポイント値）
            this.point = res; //表示増数
            this.executingIcon.innerHTML = '';
            this.voteAnimation();
        }
        else{
            if(res == -2){
                //入力済み
                this.executingIcon.innerHTML = '';
            }
            else{
                //その他のエラーー
                this.executingIcon.innerHTML = '';
            }
        }
    },
    // 投票したときのアニメーション　＆　ポイント数と円グラフの表示更新
    voteAnimation: function(){
        var myObj = this;
        new Rico.Effect.FadeTo($(myObj).divGraph, 0.01, 500, 10, {
            complete:function(){
                $($(myObj).pointValue).innerHTML = $(myObj).point; //表示ポイント数値
                $(myObj).setGraphImage();
                new Rico.Effect.FadeTo($(myObj).divGraph, 1, 500, 10, {
                    complete:function(){
                        $(myObj).executingIcon.innerHTML = '';
                    }
                });
            }
        });
    },
    // グラフ画像をセット
    setGraphImage: function(){
        var num = 50;
        if ((this.goodVote + this.badVote) > 0){
            if(this.goodVote / ((this.goodVote-0) + (this.badVote-0)) == 0.25) { num = 25; }
            else if(this.goodVote / ((this.goodVote-0) + (this.badVote-0)) == 0.75) { num = 75; }
            else {
                num = (Math.round(10 * this.goodVote / ((this.goodVote-0) + (this.badVote-0))) * 10);
            }
        }
        //var graphImageName =  'url(/common/images/graph/graph_' + num + '.gif)'; //円グラフ画像用
        var graphImageName =  'url(/common/images/graph/graph_m_' + num + '.gif)'; //円グラフ画像用
        $(this.divGraph).style.backgroundImage = graphImageName; //グラフ画像
    }
}

//クラス初期化
function initGraphAnimation() {
    if(document.body){
        var objLabel = Array();
        var cnt = -1;
        while(true){ //IDの連番0から順に探す
            cnt++;
            var e = document.getElementById('graphanimation-' + cnt);
            if(e){
                var inText = e.innerHTML; //記事ID、ポイント数、○票数、×票数、commented/notyet/guestが'! !'区切りで入っていることが前提
                var ret = inText.split('! !');
                objLabel[cnt] = new GraphAnimation(e, ret[0], ret[1], ret[2], ret[3], ret[4]);
            }
            else{
                //見当たらなかったらループ終了
                break;
            }
        }
    }
    else{
        //html読み込みが完了していない場合
        setTimeout("initGraphAnimation()", 190);
    }
}
//Event.observe(window, 'load', function(){
//initGraphAnimation();
//});

// delete comment
var DeleteComment = Class.create();
DeleteComment.prototype = {
    initialize: function(entryurl, parentElement){
        this.entryurl = entryurl;
        this.Request();
    },
    Success: function(originalRequest){
        var res = originalRequest.responseText;
        res = res.strip();
        if(res == 0){
            new Effect.Puff('entry-'+ this.entryurl);
            current = $('comment_num').innerHTML;
            current = current.stripTags();
            current = current - 0 + 1;
            $('comment_num').innerHTML = current;
        }else{
            $('edit-' + this.entryurl).innerHTML = this.comment_original;
        }
    },
    Request: function(){
        this.loadMessage();
        var url = gBASE_URL + 'api/delete?url=' + this.entryurl;
        var MyAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.Success.bind(this)
            }
        );
    },
    loadMessage : function(){
        this.comment_original = $('edit-' + this.entryurl).innerHTML;
        $('edit-' + this.entryurl).innerHTML = '<img src="/common/images/loading_red.gif" />';
    }
};

// EditableTextBox
var EditableTextBox = Class.create();
EditableTextBox.prototype = {
    // @param label テキストまたはブロックエレメント
    initialize: function(label) {
        // テキストラベル表示状態のDOM定義
        this.textHolder = document.createElement('span');
        this.text = document.createElement('span');
        this.textHolder.appendChild(this.text);
        this.dummy1 = document.createElement('span');
        this.dummy1.innerHTML = "&nbsp";
        this.textHolder.appendChild(this.dummy1);
        this.toEdit = document.createElement('a');
        this.toEdit.href = "javascript:void(0);";
        this.toEdit.innerHTML = '[編集]';
        this.toEdit.style.fontSize = "90%";
        this.textHolder.appendChild(this.toEdit);
        Event.observe(this.toEdit, 'click', this.edit.bindAsEventListener(this), false);

        // 編集中状態のDOM定義
        this.form = document.createElement('form');
        this.form.style.margin = '0px';
        this.form.style.padding = '0px';
        this.input = document.createElement('input');
        this.input.type = 'text';
        this.input.style.width = '400px';
        this.form.appendChild(this.input);
        this.submitButton = document.createElement('input');
        this.submitButton.type = 'submit';
        this.submitButton.value = '更新';
        this.form.appendChild(this.submitButton);
        this.dummy2 = document.createElement('span');
        this.dummy2.innerHTML = "&nbsp";
        this.form.appendChild(this.dummy2);
        this.retLink = document.createElement('a');
        this.retLink.href = 'javascript:void(0);';
        this.retLink.innerHTML = '[戻る]';
        this.retLink.style.fontSize = '90%';
        this.form.appendChild(this.retLink);

        Event.observe(this.form, 'submit', this.submit.bindAsEventListener(this), false);
        Event.observe(this.retLink, 'click', this.back.bindAsEventListener(this), false);

        this.setLabel((typeof label == 'string') ? label : label.innerHTML);

        // EditableTextBox 全体のエレメント
        if(typeof label == 'string') {
            this.element = document.createElement('div');
        } else {
            this.element = label;
            this.element.innerHTML = '';
        }
        this.element.appendChild(this.textHolder);
        this.name = label.id;        //name属性を代用（id属性だと重複してしまうので）

    },
    // 書いてある文字のアクセサ
    getLabel: function() {
        return $F(this.input);
    },
    setLabel: function(label) {
        this.text.innerHTML = label;
        this.input.value = label;
    },
    // 編集開始
    edit: function(event) {
        this.element.replaceChild(this.form, this.textHolder);
        this.submitButton.disabled = false;
        Field.activate(this.input);  // フォーカス・選択
    },
    // 保存せずに編集終わり
    back: function(event) {
        this.element.replaceChild(this.textHolder, this.form);
        this.setLabel(this.text.innerHTML);
        Event.stop(event);
    },
    // 編集終わり
    submit: function(event) {
        var myObj = this;
        new Ajax.Request('submitted.php', {
            method:'get',
            parameters: 'id=' + $(this).name + '&q=' + encodeURIComponent($F(this.input)),
            onSuccess: function(transport){
                //Ajaxレスポンスが返ってきたときの処理                
                //alert(transport.responseText);
                $(myObj).element.replaceChild($(myObj).textHolder, $(myObj).form);
                $(myObj).setLabel(transport.responseText);    //Ajaxレスポンスの文字列を新しい画面表示文言にする
            }
        });
        
        //もしあれば this.onSubmit を呼ぶ
        if(this.onSubmit) this.onSubmit.call(this, event);
        
        this.submitButton.disabled = true;    //Ajax処理中はグレー表示
        Event.stop(event);
    }

};

//クラス名が'editabletextbox'のものをすべてEditableTextBox部品に変換する
//Event.observe(window, 'load', function() {
//    var objLabel = Array();
//    var elements = document.getElementsByClassName('editabletextbox');    //対象のclass名
//    if(elements && elements.length){
//        for(var i = 0, len = elements.length; i < len; i++){
//            objLabel[i] = new EditableTextBox($(elements[i]));
//        }
//    }
//}, false);

function openCommentWindow(seq,category,option_mode){
    if(CommentWindow.instance[seq]){
        if(CommentWindow.instance[seq].slideOpen){
            CommentWindow.instance[seq].slideOpen();
        }
    } else {
        CommentWindow.instance[seq] = new CommentWindow(seq,category,option_mode);
    }
}

/*
var CommentWindow = Class.create();
CommentWindow.instance = {};
CommentWindow.prototype = {
    initialize: function(seq,category){
        this.seq = seq;
        this.id = CommentWindow_initialValue[seq].entryid;
        this.parentObj = $('commentwindow-' + seq);
        if(category){
            this.category = category;
        }else{
            this.category = '';
        }
        this.element = document.createElement('div');

        //DOM組み立て
        var html = '<div class="comment_waku"> '
                 + '  <form action="' + gBASE_URL + 'comment" method="post">'
                 + '    <input type="hidden" name="action_comment" value="1" >'
                 + '    <input type="hidden" name="submit" value="submit" >'
                 + '    <input type="hidden" name="url" value="' + CommentWindow_initialValue[seq].entryurl+ '" >'
                 + '    <input type="hidden" name="c" value="' + this.category + '" >'
                 + '    <div class="comment_back"> '
                 + '      <table width="100%" border="0" cellspacing="0" cellpadding="0">'
                 + '        <tr height="20" valign="bottom"> '
                 + '          <td width="15"><img src="/common/images/spacer.gif" width="15" height="1" alt=""></td>'
                 + '          <td align="left" class="main-txt">コメント</td>'
                 + '          <td align="right"><span id="commentwindow-clickclose-' + this.seq + '"><a href="javascript:void(0);" class="medium"><img src="/common/images/icn/icn_close.gif" width="13" height="13" align="absmiddle" border="0">&nbsp;閉じる</a></span></td>'
                 + '          <td width="15"><img src="/common/images/spacer.gif" width="15" height="1" alt=""></td>'
                 + '        </tr>'
                 + '      </table>'
                 + '    </div>'
                 + '    &nbsp;&nbsp;このニュースは？'
                 + '    <table width="100%" border="0" cellspacing="0" cellpadding="0">'
                 + '      <tr>'
                 + '        <td  valign="middle" align="left" nowrap>'
                 + '          &nbsp;&nbsp;<input id="commentwindow-thumbup-' + this.seq + '" type="radio" value="1" name="thumb" checked ><label for="commentwindow-thumbup-' + this.seq + '">&nbsp;<img src="/common/images/icn/icn_circle.gif" alt="支持する" width="20" height="18" align="absmiddle"></label>&nbsp;&nbsp;'
                 + '          <input id="commentwindow-thumbdown-' + this.seq + '" type="radio" value="0" name="thumb" ><label for="commentwindow-thumbdown-' + this.seq + '">&nbsp;<img src="/common/images/icn/icn_cross.gif" alt="支持しない" width="20" height="18" align="absmiddle"></label>'
                 + '        </td>'
                 + '        <td align="right">'
                 + '        </td>'
                 + '      </tr>'
                 + '      <tr> '
                 + '        <td colspan="2">'
                 + '          <textarea name="comment" class="comment_area" id="commentwindow-textarea-' + this.seq + '" wrap="soft">' + CommentWindow_initialValue[seq].comment + '</textarea><br>'
                 + '          <span style="font-size:90%;">&nbsp;&nbsp;&nbsp;&nbsp;全角400字以内で入力してください。<span id="commentcount-' + this.seq + '"></span></span>'
                 + '        </td>'
                 + '      </tr>'
                 + '    </table>'
                 + '    <table border="0" cellspacing="0" cellpadding="0" style="font-size:85%">'
                 + '      <tr>'
                 + '        <td>&nbsp;&nbsp;&nbsp;</td>'
                 + '        <td>';

        //タグ入力UI
        this.tagInputUI = new TagInputInterface(this.seq, ('commentwindow-tag-' + this.seq));
        html += this.tagInputUI.getHtmlInsert();

        html += '        </td>'
             +  '      </tr>'
             +  '    </table>'
             +  '    <table border="0" cellspacing="0" cellpadding="0">'
             +  '      <tr valign="middle">'
             +  '        <td>&nbsp;&nbsp;タグ:&nbsp;</td>'
             +  '        <td><input type="text" maxlength="50" value="' + CommentWindow_initialValue[seq].tag + '" name="tag" class="comment_tag" style="width:300px;" id="commentwindow-tag-' + this.seq + '"></td>'
             +  '      </tr>'
             +  '      <tr valign="middle">'
             +  '        <td>&nbsp;</td>'
             +  '        <td>&nbsp;<span style="font-size:80%;"><span id="alertMaxItemsOver">カテゴリーは2個まで、タグは合計5個まで（空白区切り）</span><br /> （<a href="' + gBASE_URL + 'help/pickup#pickup05" target="_blank">タグとは？</a>）</span></td>'
             +  '      </tr>'
             +  '    </table>'
             +  '    <table width="100%" border="0" cellspacing="0" cellpadding="0">'
             +  '      <tr> '
             +  '        <td align="right" valign="middle">'
             +  '          <input type="hidden" name="fromcommentwindow" value="true">'
             +  '          <input value="" type="image" name="submit" src="/common/images/bt_go.gif" width="41" height="22" alt="送信" align="absmiddle" id="commentwindow-form-' + this.seq + '">'
             +  '        &nbsp;&nbsp;</td>'
             +  '      </tr>'
             +  '    </table>'
             +  '  </form>'
             +  '</div>';
        this.element.innerHTML = html;

        this.parentObj.appendChild(this.element);

        this.closeButton = document.getElementById('commentwindow-clickclose-' + this.seq);
        this.commentArea = document.getElementById('commentwindow-textarea-' + this.seq);

        this.tagInputUI.setEvent();
        this.tagInputUI.refreshTagList();

        this.slideHeight = this.element.offsetHeight; //この行は「一瞬表示させた状態」で取得する

        var s = this.element.style;
        s.visibility = 'visible';
        s.display = 'none';
        s.overflow = 'hidden';
        s.height = '1px';

        Event.observe(this.closeButton,  'click', this.slideClose.bindAsEventListener(this), false);
        Event.observe(this.commentArea,  'keyup', this.setCommentCount.bindAsEventListener(this), false);

        this.setGoodBadButton(CommentWindow_initialValue[this.seq].vote);
        this.slideOpen();
    },
    slideOpen: function(){
        var objTextArea = $('commentwindow-textarea-' + this.seq);
        var objSubmitButton = $('commentwindow-form-' + this.seq);

        this.element.style.display = 'block';
        new Rico.Effect.Size( this.element, null, this.slideHeight, 120, 8, {complete: function(){objSubmitButton.focus();objTextArea.focus();}});
    },
    slideClose: function(){
        var myObj = this.element;
        myObj.style.overflow = "hidden";
        new Rico.Effect.Size( myObj, null, 1, 120, 8, {complete: function(){myObj.style.display = 'none';}});
    },
    setCommentCount: function(){
        var cnt = jstrlen(this.commentArea.value);
        $('commentcount-' + this.seq).innerHTML = '（現在 ' + cnt + ' 文字）';

    },
    setGoodBadButton: function(buttonName){
        if(buttonName == 'good'){
            $('commentwindow-thumbup-' + this.seq).checked = true;
        }
        else if(buttonName == 'bad'){
            $('commentwindow-thumbdown-' + this.seq).checked = true;
        }
    }
}
*/

function comment_waku_open(){
   var waku = $('comment_waku_entry_ver');
   var commentForm = $('comment_form');
   if(waku.style.display == 'none'){
       waku.style.height = 1;
       waku.style.display = 'block';
       wakuHeight = commentForm.offsetHeight + 10;
       new Rico.Effect.Size(waku,null,wakuHeight,300,8);
   }
}

function comment_waku_close(){
   var waku = $('comment_waku_entry_ver');
   new Rico.Effect.Size(waku,null,1,300,8,{complete: function(){waku.style.display = 'none';}});
}

var CommentWindow_initialValue;
function setCommentWindowInitialValue(value){
    CommentWindow_initialValue = value;
}

//ページ内リンクをスムーズにスクロールする
var eventTimer; //タイマー変数
var restScroll=0; //スクロール残量
function Scroll(base,move){
    //移動元(base)要素＆オブジェクトを取得
    var obj_base  = getElemPosition(base);

    //移動先(move)要素＆オブジェクトを取得
    var elem_move = document.getElementById(move);
    var obj_move  = getElemPosition(elem_move);

    scrollPos = document.body.scrollTop  || document.documentElement.scrollTop;
    restScroll = obj_move.y - scrollPos;
    eventTimer = setInterval(setScrollPosition,5);
}
//スクロール処理をする
function setScrollPosition() {
    var moveValue=0;
    //スクロール残量が80以上の場合、スクロール量を変える
    //Math.abs()では値の絶対値を取得
    if(Math.abs(restScroll)>80){
        moveValue = (restScroll>0)?20:-20;
    }else{
        moveValue = Math.round(restScroll/4);
    }

    //スクロールを処理
    parent.scrollBy(0,moveValue);

    //スクロール残量を計算して、残りが無ければタイマー解除
    restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;

    if(moveValue==0){
        clearInterval(eventTimer);
        restScroll=0;
    }
}
//要素の位置を取得し、オブジェクトとして返す
function getElemPosition(elem) {
    var obj = new Object();
    obj.x = elem.offsetLeft;
    obj.y = elem.offsetTop;

    //親要素を取得して位置情報を修正する
    while(elem.offsetParent) {
        elem = elem.offsetParent;
        obj.x += elem.offsetLeft;
        obj.y += elem.offsetTop;
    }
    return obj;
}

function scroll_and_open(base,move){
    Scroll(base,move);
    setTimeout("comment_waku_open()",1000);
}

//タグ入力支援UI
var gTagList = [
    {
        // 表示順の定義
        items: [
            'インターネット',
            '科学',
            'テクノロジー',
            'ビジネス',
            '政治',
            '社会',
            'くらし',
            'マネー',
            'マーケティング',
            'キャリア',
            '医療',
            '健康',
            '教育',
            '子ども',
            'エンタメ',
            'スポーツ',
            '恋愛',
            '結婚',
            '海外',
            '雑学',
            'ネタ',
            '写真',
            '動画',
            '大人向け'
            ]
    }];
var TagInputInterface = Class.create();
TagInputInterface.prototype = {
    initialize: function(seq, tagfieldID){
        //seq: html中で一意な連番、tagfieldID: タグ入力textboxのid
        this.seq = seq;
        this.tagfieldID = tagfieldID;
        this.selectAreaID = 'commentwindow-taglist-' + this.seq; //タグ選択UIのエリア
        this.tagArea = null;
        this.separator = '(　| )+';
    },
    getHtmlInsert: function(){
        var html = '<table border="0" cellpadding="0" cellspacing="0">'
                 + '  <tr><td style="margin:0px;padding:0px;"><div style="margin:5px 0px 0px 0px;padding:0px;width:89px;height:15px;"><img src="/common/images/tab_tagcategory.gif" width="100" height="15" alt="ニュースカテゴリー"></div>'
                 + '  <div style="margin:0px;padding:0px 0px;"><span id="' + this.selectAreaID + '"></span></div></td></tr>'
                 + '  <tr><td style="margin:0px;padding:0px;"><div style="margin:0px;padding:0px;width:30px;height:7px;text-align:right;"><img src="/common/images/tab_tagcategory_down.gif" width="9" height="7" alt=""></div></td></tr>'
                 + '</table>';
        return html;
    },
    setEvent: function(){
        //タグ入力フィールド
        this.tagArea = $(this.tagfieldID);
        Event.observe(this.tagArea, 'keyup', this.refreshTagList.bindAsEventListener(this), false);
        // このid要素がinnerHTMLに反映されたあとに実行させること。
    },
    refreshTagList: function(){
        var target = document.getElementById(this.selectAreaID);
        var checkstr = ' ' + this.tagArea.value + ' ';
        var html = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#F0EDE7"><tr>';

        for(var j = 0; j < gTagList.length; j++){
            //選択中のタブパネルのみを表示
            //タグごとにループ
            this.tagItem = Array();
            for(var i = 0; i < gTagList[j].items.length; i++){
                var strSelected = checkstr.match(new RegExp(this.separator + gTagList[j].items[i] + this.separator, 'ig')) ? ' style="background-color:#999;color:#fff;"' : '';
                if(i % 4 == 0){
                    html += '</tr><tr>';
                }
                html += '<td width="100" height="25" style="font-size: 13px;"><a href="javascript:void(0);" class="tagitem"' + strSelected + ' onclick="CommentWindow.instance[' + this.seq + '].tagInputUI.clickTagItem(\'' + gTagList[j].items[i] + '\')"><img src="/common/images/icn/category/comment_form/'
                // 画像ファイルとひも付ける
                if(gTagList[j].items[i] == 'ビジネス'){
                    html += 'icn_biz.gif';
                }else if(gTagList[j].items[i] == '政治'){
                    html += 'icn_poli.gif';
                }else if(gTagList[j].items[i] == 'インターネット'){
                    html += 'icn_it.gif';
                }else if(gTagList[j].items[i] == 'IT'){
                    html += 'icn_it.gif';
                }else if(gTagList[j].items[i] == 'くらし'){
                    html += 'icn_life.gif';
                }else if(gTagList[j].items[i] == '社会'){
                    html += 'icn_soc.gif';
                }else if(gTagList[j].items[i] == '医療'){
                    html += 'icn_medical.gif';
                }else if(gTagList[j].items[i] == '健康'){
                    html += 'icn_health.gif';
                }else if(gTagList[j].items[i] == '科学'){
                    html += 'icn_science.gif';
                }else if(gTagList[j].items[i] == 'テクノロジー'){
                    html += 'icn_tech.gif';
                }else if(gTagList[j].items[i] == 'キャリア'){
                    html += 'icn_career.gif';
                }else if(gTagList[j].items[i] == '海外'){
                    html += 'icn_global.gif';
                }else if(gTagList[j].items[i] == '芸能'){
                    html += 'icn_entertainment.gif';
                }else if(gTagList[j].items[i] == 'エンタメ'){
                    html += 'icn_entertainment.gif';
                }else if(gTagList[j].items[i] == 'スポーツ'){
                    html += 'icn_sports.gif';
                }else if(gTagList[j].items[i] == '雑学'){
                    html += 'icn_trivia.gif';
                }else if(gTagList[j].items[i] == 'ネタ'){
                    html += 'icn_neta.gif';
                }else if(gTagList[j].items[i] == '動画'){
                    html += 'icn_movie.gif';
                }else if(gTagList[j].items[i] == '写真'){
                    html += 'icn_image.gif';
                }else if(gTagList[j].items[i] == 'マーケティング'){
                    html += 'icn_marketing.gif';
                }else if(gTagList[j].items[i] == 'マネー'){
                    html += 'icn_money.gif';
                }else if(gTagList[j].items[i] == '恋愛'){
                    html += 'icn_love.gif';
                }else if(gTagList[j].items[i] == '結婚'){
                    html += 'icn_marriage.gif';
                }else if(gTagList[j].items[i] == '教育'){
                    html += 'icn_education.gif';
                }else if(gTagList[j].items[i] == '子ども'){
                    html += 'icn_children.gif';
                }else if(gTagList[j].items[i] == '大人向け'){
                    html += 'icn_adult.gif';
                }

                html += '" align="absmiddle">' + gTagList[j].items[i] + '</a></td> ';
                // ↑onclickのなかの関数表記に注意（グローバルアクセス可能な関数であること）
            }
        }
        html += '</tr></table>'
        target.innerHTML = html;
    },
    clickTagItem: function(tag){
        var target = this.tagArea;
        var tmpStr = (' ' + target.value + ' ');
        if(tmpStr.match(new RegExp(this.separator + tag + this.separator, 'ig'))){
            //削除 - 前後の空白を考慮
            if(target.value.match(new RegExp(this.separator + tag, 'ig'))) { 
                target.value = target.value.replace(new RegExp(this.separator + tag, 'ig'), ''); 
            }
            else if(target.value.match(new RegExp(tag + this.separator, 'ig'))) {
                target.value = target.value.replace(new RegExp(tag + this.separator, 'ig'), ''); 
            }
            else { 
                target.value = target.value.replace(tag, ''); 
            }
        }
        else{
            //項目が多いときはアラート表示
            var tmpStr = target.value.replace(new RegExp(this.separator, 'ig'), " ");
            tmpStr = tmpStr.replace(new RegExp("^( +)"), "");
            tmpStr = tmpStr.replace(new RegExp("( +)$"), "");

            var tmpStrArray = tmpStr.split(" ");
            var gTagItemCount = 0;
            for(var i = 0; i < tmpStrArray.length; i++){
                for(var j = 0; j < gTagList.length; j++){
                    for(var k = 0; k < gTagList[j].items.length; k++){
                        if(tmpStrArray[i] == gTagList[j].items[k]){
                            gTagItemCount++;  
                        }
                    }
                }
            }
            
            if(gTagItemCount > 1 || tmpStr.split(" ").length > 4 ){
                fadeYellow2White('alertMaxItemsOver', 40);
            }else {
                //追加
                target.value += (target.value == '') ? tag : ' ' + tag;
            }
        }
        this.refreshTagList();
    }
}

// カレンダー表示サイドバー
function calendar_effect(parentid){
    if($('caleffect') != null) { $('caleffect') = null; }
    var parentobj = $(parentid);
    var linkurl = parentobj.firstChild.href;
    var efobj = document.createElement('div');
    efobj.id = 'caleffect';
    parentobj.style.position = 'relative';
    var s = efobj.style;
    s.position = 'absolute';
    s.whiteSpace = 'nowrap';
    s.top = '0px';
    s.left = '0px';
    s.fontSize = '10px';
    efobj.innerHTML = parentobj.innerHTML.unescapeHTML().escapeHTML();
    parentobj.appendChild(efobj);

    setTimeout('changeeffect();',  50);
    new Rico.Effect.FadeTo(efobj, 0.01, 600, 10);

    if(linkurl == '') { return true; }
    else{
        setTimeout("window.open('" + linkurl + "','_top');",750);
        return false;
    }
}

function changeeffect(){
    var obj = $('caleffect');
    var s = obj.style;

    var presize = ((s.fontSize).slice(0,-2) - 0);
    var newsize = Math.ceil(presize * 1.5);
    s.fontSize = newsize + 'px';

    s.top  = -(obj.offsetHeight - 10) / 2 + 'px';
    s.left = -(obj.offsetWidth - 22) / 2 + 'px';

    if((s.fontSize).slice(0,-2) < 2000) { setTimeout('changeeffect();',  50); }
    else { s.display = 'none'; }
}

var timerIdYellowFade;
function fadeYellow2White(id, color){
    var obj = $(id);
    var s = obj.style;
    if(timerIdYellowFade) { clearTimeout(timerIdYellowFade); }
    s.backgroundColor = 'rgb(100%, 100%, ' + color + '%)';
    if(color == 100) { return; }
    else{ timerIdYellowFade = setTimeout("fadeYellow2White('" + id + "', " + (color + 10) + ");", 100); }
}

// Nice Comment
var NiceCommentButton = Class.create();
NiceCommentButton.prototype = {
    initialize: function(seq, point, entryid, userid,pr){
        this.seq = seq;
        this.entryid = entryid;
        this.userid = userid;
        this.pr = pr;
        this.isClicked = false;
        var idNameHolder = 'nicebuttonholder-' + seq;
        var idNameButton = 'nicebutton-' + seq;
        var idNamePoint  = 'nicebuttonpoint-' + seq;

        var html = '<span style="white-space:nowrap;"> '
                 + '<img src="/common/images/btn_nicecomment.gif" alt="Nice Comment!" width="77" height="13" border="0" align="absmiddle" onmouseover="this.src=\'/common/images/btn_nicecomment_on.gif\'" onmouseout="this.src=\'/common/images/btn_nicecomment.gif\'" id="' + idNameButton + '" style="cursor:pointer;">'
                 + ' <span style="width:38px" id="' + idNameHolder + '">(<span id="' + idNamePoint + '">' + point + '</span>)</span>'
                 + '</span>';

        document.open();
        document.write(html);
        document.close();
        this.objHolder = $(idNameHolder);
        this.objButton = $(idNameButton);
        this.objPoint = $(idNamePoint);


        Event.observe(this.objButton, 'click', this.click.bindAsEventListener(this));
    },
    AjaxRequest: function(voteMode){
        var url = gBASE_URL + 'api/clicknicecomment?e=' + this.entryid + '&u=' + this.userid+'&pr='+this.pr;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.AjaxReturned.bind(this)
            }
        );
    },
    AjaxReturned: function(originalRequest){
        var res = originalRequest.responseText;
        res = res.strip() - 0;
        if(res > 0){ //処理成功の場合（res＝増加後のポイント値）
            this.startCountupAnimation(res);
        }
        else{
            if(res == -2){
                //入力済み
            }
            else{
                //その他のエラーー
            }
        }
    },
    click: function(){
        if(this.isClicked) { return; }
        else{
            this.isClicked = true;
            this.startButtonAnimation();
            this.AjaxRequest();
        }
    },
    startButtonAnimation: function(){
        var myObj = this;
        new Rico.Effect.FadeTo(this.objButton, 0.01, 300, 10, {complete:function(){
            new Rico.Effect.FadeTo($(myObj).objButton, 0.3, 500, 10, {complete:function(){
                //
            }});
        }});
    },
    startCountupAnimation: function(newPoint){
        var myObj = this;
        new Rico.Effect.FadeTo(this.objHolder, 0.01, 500, 10, {complete:function(){
            $(myObj).objPoint.innerHTML = newPoint;
            new Rico.Effect.FadeTo($(myObj).objHolder, 1, 500, 10, {complete:function(){
                //
            }});
        }});
    }
}

var img_niceButtonOnmouseover = new Image();
img_niceButtonOnmouseover.src = "/common/images/btn_nicecomment_on.gif";

/**
 *    ブリーエクセレントボタンの動作
 */
var BuryExcellentButton = Class.create();
BuryExcellentButton.prototype = {
    initialize: function(seq, bury, excellent, entryid, bury_login_state, excellent_login_state){
        this.seq = seq;
        this.entryid = entryid;
        this.bury_login_state = bury_login_state;
        this.excellent_login_state = excellent_login_state;

        var idNameBuryButton = 'burybutton-' + seq;
        var idNameBuryPoint  = 'burybuttonpoint-' + seq;
        var idNameExcellentButton = 'excellentbutton-' + seq;
        var idNameExcellentPoint  = 'excellentbuttonpoint-' + seq;
        var idNameLoading = 'loading-' + seq;

        var html = '<tr>'
                 + '  <td>'
                 + '    <table class="table_w88" border="0" cellspacing="0" cellpadding="0">'
                 + '      <tr>'
                 + '        <td class="td_w44">'
                 + '          <img src="/common/images/btn_osusume.gif" title="おすすめ" alt="おすすめ" border="0" align="absmiddle" onmouseover="this.src=\'/common/images/btn_osusume_on.gif\'" onmouseout="this.src=\'/common/images/btn_osusume.gif\'" id="' + idNameExcellentButton + '" style="cursor:pointer;">'
                 + '        </td>'
                 + '        <td class="td_w44">'
                 + '          <div class="osusume_text">おすすめ</div>'
                 + '          <div class="osusume_int"><span id ="' + idNameExcellentPoint + '">' + excellent + '</span></div>'
                 + '        </td>'
                 + '      </tr>'
                 + '      <tr>'
                 + '        <td colspan="2" height="9"><img src="/common/images/spacer.gif" width="88" height="1"></td>'
                 + '      </tr>'
                 + '      <tr>'
                 + '        <td class="td_w44">'
                 + '          <img src="/common/images/btn_gakkari.gif" title="がっかり" alt="がっかり" border="0" align="absmiddle" onmouseover="this.src=\'/common/images/btn_gakkari_on.gif\'" onmouseout="this.src=\'/common/images/btn_gakkari.gif\'" id="' + idNameBuryButton + '" style="cursor:pointer;">'
                 + '        </td>'
                 + '        <td class="td_w44">'
                 + '          <div class="gakkari_text">がっかり</div>'
                 + '          <div class="gakkari_int"><span id="' + idNameBuryPoint + '">' + bury + '</span></div>'
                 + '        </td>'
                 + '      </tr>'
                 + '    </table>'
                 + '  </td>'
                 + '</tr>';

        document.open();
        document.write(html);
        document.close();

        this.objBuryButton = $(idNameBuryButton);
        this.objBuryPoint = $(idNameBuryPoint);
        this.objExcellentButton = $(idNameExcellentButton);
        this.objExcellentPoint = $(idNameExcellentPoint);
        this.objLoading = $(idNameLoading);
        this.objPoint = $('id-' + this.entryid);

        //IEバグ対策 widthを指定しないとrico.jsが効かない　背景画像を入れないと、文字・数字の枠に黒が入る
        this.objBuryButton.style.width = '37px';
        this.objBuryPoint.style.width = '44px';
        this.objBuryPoint.style.backgroundImage = 'url(/common/images/blank1x1_white.jpg)';
        this.objExcellentButton.style.width = '37px';
        this.objExcellentPoint.style.width = '44px';
        this.objExcellentPoint.style.backgroundImage = 'url(/common/images/blank1x1_white.jpg)';
        this.objLoading.style.width = '16px';
        this.objPoint.style.width = '76px';
        this.objPoint.style.backgroundImage = 'url(/common/images/blank1x1.jpg)';

        Event.observe(this.objBuryButton, 'click', this.buryClick.bindAsEventListener(this));
        if(this.bury_login_state == 'pushed'){
            this.setUnable('b');
        }

         Event.observe(this.objExcellentButton, 'click', this.excellentClick.bindAsEventListener(this));
        if(this.excellent_login_state == 'pushed'){
            this.setUnable('e');
        }
    },
    unlogined: function() {
        alert('この操作はログインした後に可能です。');
        return false;
    },
    AjaxRequest: function(flag){
        //ロード中アイコン表示
        this.objLoading.style.visibility = "visible";
        var url = gBASE_URL + 'api/clickburyexcellent?id=' + this.entryid + '&flag=' + flag;
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                onComplete: this.AjaxReturned.bind(this)
            }
        );
    },
    AjaxReturned: function(originalRequest){
        //ロード中アイコン消す
        this.objLoading.style.visibility = "hidden";

        var res = originalRequest.responseText;
        resdata = res.split(",");
        res = resdata[0];
        btn_flag = resdata[1];
        update_flag = resdata[2];
        if(res >= 0){//処理成功の場合
            this.startCountupAnimation(res,btn_flag,update_flag);
        }else if(res == -4){
            //-4の場合はCookieが無効のエラー
            alert('Cookieを有効にしてください'); 
        }else{
            //マイナスの場合はエラー
            alert('エラーが発生しました'); 
        }
    },
    buryClick: function(){
        if(this.isBuryClicked){
            //何も起こらない 
        }else{
            this.isBuryClicked = true;
            this.startButtonAnimation('b');
            this.AjaxRequest('b');
        }
    },
    excellentClick: function(){
        if(this.isExcellentClicked){
            //何も起こらない
        }else{
            this.isExcellentClicked = true;
            this.startButtonAnimation('e');
            this.AjaxRequest('e');
        }
    },
    setUnable: function(btn_flag){
        var myObj = this;

        if(btn_flag == 'b'){
            this.isBuryClicked = true;
            new Rico.Effect.FadeTo($(myObj).objBuryButton, 0.3, 5, 2, {});
        }else{
            this.isExcellentClicked = true;
            new Rico.Effect.FadeTo($(myObj).objExcellentButton, 0.3, 5, 2, {});
        }
    },
    startButtonAnimation: function(btn_flag){
        var myObj = this;

        if(btn_flag == 'b'){
            new Rico.Effect.FadeTo($(myObj).objBuryButton, 0.01, 300, 10, {
                complete:function(){
                    new Rico.Effect.FadeTo($(myObj).objBuryButton, 0.3, 500, 10, {
                        complete:function(){
                            // 
                        }
                    });
                }
            });
        }else{
            new Rico.Effect.FadeTo($(myObj).objExcellentButton, 0.01, 300, 10, {
                complete:function(){
                    new Rico.Effect.FadeTo($(myObj).objExcellentButton, 0.3, 500, 10, {
                        complete:function(){
                            //
                        }
                    });
                }
            });
        }
    },
    startCountupAnimation: function(res,btn_flag,update_flag){
        var myObj = this;

        if(btn_flag == 'b'){
            new Rico.Effect.FadeTo($(myObj).objBuryPoint, 0.01, 200, 10, {
                complete:function(){
                    $(myObj).objBuryPoint.innerHTML = parseInt($(myObj).objBuryPoint.innerHTML) + 1; 
                    new Rico.Effect.FadeTo($(myObj).objBuryPoint, 1, 200, 10, {
                        complete:function(){
                            if(update_flag == 1){
                                new Rico.Effect.FadeTo($(myObj).objExcellentPoint, 0.01, 200, 10, {
                                    complete:function(){
                                        $(myObj).objExcellentPoint.innerHTML = parseInt($(myObj).objExcellentPoint.innerHTML) - 1;
                                        new Rico.Effect.FadeTo($(myObj).objExcellentPoint, 1, 200, 10, {
                                            complete:function(){
                                                new Rico.Effect.FadeTo($(myObj).objPoint, 0.01, 300, 10, {
                                                    complete:function(){
                                                        $(myObj).objPoint.innerHTML = res; //表示ポイント数値
                                                        //記事詳細ページのマルバツグラフ
                                                        if($('graph_point')){
                                                            $('graph_point').innerHTML = res;
                                                        }
                                                        new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {
                                                            complete:function(){
                                                                //
                                                            }
                                                        });
                                                    }
                                                });
                                            }
                                        });
                                        
                                        
                                    }
                                });
                            }else{
                                new Rico.Effect.FadeTo($(myObj).objPoint, 0.01, 300, 10, {
                                    complete:function(){
                                        $(myObj).objPoint.innerHTML = res; //表示ポイント数値
                                        //記事詳細ページのマルバツグラフ
                                        if($('graph_point')){
                                            $('graph_point').innerHTML = res;
                                        }
                                        new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {
                                            complete:function(){
                                                //
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    });
                }
            });
        
            new Rico.Effect.FadeTo($(myObj).objExcellentButton, 1, 500, 10, {
                complete:function(){
                    //
                }
            });
            this.isExcellentClicked = false;
        }else{
            new Rico.Effect.FadeTo($(myObj).objExcellentPoint, 0.01, 200, 10, {
                complete:function(){
                    $(myObj).objExcellentPoint.innerHTML = parseInt($(myObj).objExcellentPoint.innerHTML) + 1; 
                    new Rico.Effect.FadeTo($(myObj).objExcellentPoint, 1, 200, 10, {
                        complete:function(){
                            if(update_flag == 1){
                                new Rico.Effect.FadeTo($(myObj).objBuryPoint, 0.01, 200, 10, {
                                    complete:function(){
                                        $(myObj).objBuryPoint.innerHTML = parseInt($(myObj).objBuryPoint.innerHTML) - 1;
                                        new Rico.Effect.FadeTo($(myObj).objBuryPoint, 1, 200, 10, {
                                            complete:function(){
                                                new Rico.Effect.FadeTo($(myObj).objPoint, 0.01, 300, 10, {
                                                    complete:function(){
                                                        $(myObj).objPoint.innerHTML = res; //表示ポイント数値
                                                        //記事詳細ページのマルバツグラフ
                                                        if($('graph_point')){
                                                            $('graph_point').innerHTML = res;
                                                        }
                                                        new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {
                                                            complete:function(){
                                                                //
                                                            }
                                                        });
                                                    }
                                                });
                                            }
                                        });
                                    }
                                });
                            }else{
                                new Rico.Effect.FadeTo($(myObj).objPoint, 0.01, 300, 10, {
                                    complete:function(){
                                        $(myObj).objPoint.innerHTML = res; //表示ポイント数値
                                        //記事詳細ページのマルバツグラフ
                                        if($('graph_point')){
                                            $('graph_point').innerHTML = res;
                                        }
                                        new Rico.Effect.FadeTo($(myObj).objPoint, 1, 500, 10, {
                                            complete:function(){
                                                //
                                            }
                                        });
                                    }
                                });
                            }
                        }    
                    });
                }
            });

            new Rico.Effect.FadeTo($(myObj).objBuryButton, 1, 500, 10, {
                complete:function(){
                     //
                }
            });
            this.isBuryClicked = false;
        }
    }
}

var img_niceButtonOnmouseover = new Image();
img_niceButtonOnmouseover.src = "/common/images/bury.gif";

//RSSリーダー登録セレクトボックス
function writeRSSReaderRegist(url, uniqueid){
    var html = '<select name="rssd" size="1" id="' + uniqueid + '" style="font-size:12px;" >' + "\n"
             + '  <option value="http://reader.livedoor.com/subscribe/' + url + '">livedoor Reader</option>' + "\n"
             + '  <option value="http://www.bloglines.com/sub/' + url + '">Bloglines</option>' + "\n"
             + '  <option value="http://feedpath.jp/feedreader/feeds_add?url=' + url + '">feedpath</option>' + "\n"
             + '  <option value="http://r.hatena.ne.jp/append/' + url + '">はてなRSS</option>' + "\n"
             + '  <option value="https://webryreader.sso.biglobe.ne.jp/index.php?fn=grs&apid=bkml&from=grsr&url=' + url + '">ウェブリリーダー</option>' + "\n"
             + '  <option value="http://e.my.yahoo.co.jp/config/jp_promo_content?.module=jp_rss&amp;.url=' + url + '">My Yahoo!</option>' + "\n"
             + '  <option value="http://fusion.google.com/add?feedurl=' + url + '">Google</option>' + "\n"
             + '  <option value="http://reader.goo.ne.jp/web/bookmarklet.html?,,' + url + '">goo RSSリーダー</option>' + "\n"
             + '  <option value="http://reader.excite.co.jp/subscribe/?url=' + encodeURIComponent(url) + '">exciteリーダー</option>' + "\n"
             + '  <option value="http://paipo.jp/bookmarklet/?url=' + url + '">PAIPO READER</option>' + "\n"
             + '  <option value="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=' + url + '">NewsGator</option>' + "\n"
             + '  <option value="http://www.rojo.com/add-subscription?resource=' + url + '">Rojo</option>' + "\n"
             + '</select> '
             + 'に <input value="登録" type="button" onclick="window.open(document.getElementById(\'' + uniqueid + '\').value, \'_blank\');" style="font-size:11px;" />' + "\n";
    document.open();
    document.write(html);
    document.close();
}

//クリックでお気に入り追加
function userAddFavorite(){
    var html;
    var bookmarkTitle = 'newsing(ニューシング) ユーザー参加型ニュースサイト';
    //IE
    if(navigator.userAgent.indexOf("MSIE") >= 0){   
        var html = '<a href="#" onclick="window.external.AddFavorite(\''+ gBASE_URL + '\',\''+ bookmarkTitle +'\');return false;">お気に入りに追加する</a>';
    //Fx
    }else if(navigator.userAgent.indexOf("Firefox")>= 0){
        var html = '<a href="#" onclick="window.sidebar.addPanel(\''+ bookmarkTitle +'\',\''+ gBASE_URL +'\',\'\');return false;">お気に入りに追加する</a>';
     //OPERA
     }else if(navigator.userAgent.indexOf("Opera") >= 0){
        var html = '<a href="'+ gBASE_URL +'" rel="sidebar" title="'+ bookmarkTitle +'">お気に入りに追加する</a>';
     }else{
        var html ='';
     }
     document.open();
     document.write(html);
     document.close;
}

