YAHOO.namespace("Netallica.Comment");YAHOO.Netallica.Comment=function(){this.sort;this.order;this.offset;this.reach;this.isendpage;this.currentpage;this.nextpage;this.prevpage;this.annexuri;this.resourceuri;this.registuri;this.tgturi;this.tgtdoneuri;this.crm;this.item_id;this.jsonobj};YAHOO.Netallica.Comment.prototype={trimComment:function(A){return String(A).replace(/^[ 　\r\n]*|[ 　\r\n]*$/gim,"")},save:function(pos){var obj=eval("document.f"+pos);if(this.trimComment(obj.body.value)==""){alert("コメントを入力してください。");obj.body.value="";obj.body.focus();return }if(obj.agreement[0].checked==false){alert("利用規約に同意していただかなければコメントは書き込めません。");obj.body.focus();return }if(obj.body.value.length>800){alert("コメントは最大800文字まででお願いいたします。");obj.body.focus();return }var xhr_handler={success:function(){obj.submit()},send:function(){YAHOO.util.Connect.asyncRequest("POST",g_ycomment.registuri+g_ycomment.item_id+"/1?uri="+g_ycomment.tgturi,callback)}};var callback={success:xhr_handler.success,scope:xhr_handler};xhr_handler.send()},init:function(){g_ycomment.sort="created_at";g_ycomment.order="desc";var B="item_id="+g_ycomment.item_id+"&sort="+g_ycomment.sort+"&order="+g_ycomment.order+"&tgtUri="+g_ycomment.tgturi+"&tgtDoneUri="+g_ycomment.tgtdoneuri+"&crm="+g_ycomment.crm+"&length="+g_ycomment.reach;var A={success:function(D){g_ycomment.showListHtml(D)},send:function(){YAHOO.util.Connect.asyncRequest("POST",g_ycomment.resourceuri,C,encodeURI(B))}};var C={success:A.success,scope:A};A.send()},showListHtml:function(o){var isdetailPage=0;if(g_ycomment.reach>5){isdetailPage=1}var commentList=document.getElementById("comment_List");if(o.responseText==""){return }comObj=eval("("+o.responseText+")");if(isdetailPage){document.getElementById("commentTotal").innerHTML="(合計：<b>"+comObj.total+"</b>件)"}else{document.getElementById("commentTotal").innerHTML='(合計：<a href="'+g_ycomment.annexuri+"comment/list/"+g_ycomment.item_id+'"><b>'+comObj.total+"</b></a>件)"}var listhtml="";if(comObj.sort=="created_at"){listhtml+='<div class="comment_selectitem">[ ';if(comObj.order=="asc"){listhtml+='<a href="#commentSort" onClick="javascript:g_ycomment.changeSort(\'created_at\', \'desc\');"><img src="http://i.yimg.jp/images/search/up.gif" width="13" height="13" border="0" align="absmiddle" alt="昇順"></a>'}else{listhtml+='<a href="#commentSort" onClick="javascript:g_ycomment.changeSort(\'created_at\', \'asc\');"><img src="http://i.yimg.jp/images/search/down.gif" width="13" height="13" border="0" align="absmiddle" alt="降順"></a>'}listhtml+="<b>投稿順</b> | <a href=\"#commentSort\" onClick=\"javascript:g_ycomment.changeSort('points', '"+comObj.order+"');\">評価順</a> ]</div>"}else{listhtml+='<div class="comment_selectitem">[ <a href="#commentSort" onClick="javascript:g_ycomment.changeSort(\'created_at\', \''+comObj.order+"');\">投稿順</a> | ";if(comObj.order=="asc"){listhtml+='<a href="#commentSort" onClick="javascript:g_ycomment.changeSort(\'points\', \'desc\');"><img src="http://i.yimg.jp/images/search/up.gif" width="13" height="13" border="0" align="absmiddle" alt="昇順"></a>'}else{listhtml+='<a href="#commentSort" onClick="g_ycomment.changeSort(\'points\', \'asc\');"><img src="http://i.yimg.jp/images/search/down.gif" width="13" height="13" border="0" align="absmiddle" alt="降順"></a>'}listhtml+="<b>評価順</b> ]"}listhtml+="</div>";if(isdetailPage){listhtml+=g_ycomment.getPagingHtml("pagingComment")}listhtml+='<div id="commentset clearfix">';for(var i=0;i<comObj.list.length;i++){var istokumei=0;if(comObj.list[i].user=="匿名"){istokumei=1}markhtml="";if(comObj.list[i].mark_count>0&&!istokumei){markhtml='<span class="mark_icon"><a href="/personal/'+comObj.list[i].user_id_enc+'/"><img src="http://i.yimg.jp/images/netallica/icon_mark.gif" alt="マーク('+comObj.list[i].mark_count+')" width="16" height="16" hspace=2 border="0" align=absmiddle></a></span>'}if(comObj.list[i].mark_count>0&&!istokumei){listhtml+='<a href="'+g_ycomment.annexuri+"personal/"+comObj.list[i].user_id_enc+'/"><div class="commentleft"><img src="http://avtimg.yahoo.co.jp/yap/'+comObj.list[i].decrypted+'.png?prop=netallica width="48" height="48" alt="アバター" /></a>'}else{listhtml+='<div class="commentleft"><img src="http://avtimg.yahoo.co.jp/yap/'+comObj.list[i].decrypted+'.png?prop=netallica width="48" height="48" alt="アバター" />'}listhtml+='<div class="bt_nice1"><a href="#commentNiceBtn" onClick="g_ycomment.addPoints(\''+comObj.list[i].id+"','"+comObj.list[i].seq_num+"','"+comObj.list[i].points+"','"+comObj.list[i].crm+'\');" id="nicebutton-'+comObj.list[i].seq_num+'"><p class="nice_point"><span id="nicebuttonpoint-'+comObj.list[i].seq_num+'">'+comObj.list[i].points+'</span></p></a></div></div><div class="commentright"><p class="comment_fukitop"></p><div class="comment_fukimiddle"><table cellpadding="2" cellspacing="0" border="0" width="100%" class="comment_text"><tr><td class="comment_com">'+comObj.list[i].body+'</td><table cellpadding="2" cellspacing="0" border="0" width="100%" class="comment_info"></tr></table><table cellpadding="2" cellspacing="0" border="0" width="100%" class="comment_info"><tr><td class="comment_date">'+comObj.list[i].ptime+" [ ";if(istokumei){listhtml+=comObj.list[i].user}else{if(comObj.list[i].mark_count>0){listhtml+='<a href="'+g_ycomment.annexuri+"personal/"+comObj.list[i].user_id_enc+'/">'+comObj.list[i].user+"</a> "}else{listhtml+=comObj.list[i].user}}listhtml+=markhtml+' ]</td><td class="comment_bt_vio"><a href="'+g_ycomment.deluri+"/camp/v1/deleterequest/?prop="+g_ycomment.prop+"&turi="+comObj.list[i].uri+"&done="+comObj.list[i].tgtDoneUri+"&id="+comObj.list[i].id+"&crm="+comObj.list[i].crm+'"><img src="http://i.yimg.jp/images/netallica/bt_vio.gif" width="73" height="17" border="0" alt="削除/違反報告"></a></td></tr></table></div><p class="comment_fukibottom"></p></div></div><div class="comment_clear"></div>'}if(isdetailPage){listhtml+=g_ycomment.getPagingHtml("comment_List")}if(isdetailPage){listhtml+='<div class="comment_naviright"><a href="#commentInputHeader" onClick="g_yannex.toggle_comment_button(\'commentInputBox\',\'commentButton\',\'write_comment\');">▲コメント入力欄に戻る</a></div><div class="comment_clear"></div>'}else{listhtml+='<div class="comment_naviright"><a href="'+g_ycomment.annexuri+"comment/list/"+g_ycomment.item_id+'">すべてのコメントを見る</a></div><div class="comment_clear"></div>'}commentList.innerHTML=listhtml},getPagingHtml:function(C){var D="";g_ycomment.isendpage=0;if(g_ycomment.reach>=(comObj.total-g_ycomment.reach*g_ycomment.currentpage)){g_ycomment.isendpage=1}var B=g_ycomment.currentpage*g_ycomment.reach+1;var A=(g_ycomment.currentpage+1)*g_ycomment.reach;if(g_ycomment.isendpage){A=B+(comObj.total-B)}D+='<div class="articleListNavi">';D+='<p class="listNum">'+comObj.total+"件中 <strong>"+B+"～"+A+'件</strong> を表示しています。</p><p class="listLink">[ ';if(g_ycomment.currentpage==0&&g_ycomment.isendpage==1){D+='<span style="color:#999;">前の20件</span> | <span style="color:#999;">次の20件</span>'}else{if(g_ycomment.currentpage==0){g_ycomment.nextpage=1;D+='<span style="color:#999;">前の20件</span> | <a href="#'+C+'" onClick="javascript:g_ycomment.getPagingData('+g_ycomment.nextpage+');">次の20件</a>'}else{if(g_ycomment.isendpage==1){g_ycomment.prevpage=g_ycomment.currentpage-1;D+='<a href="#i'+C+'" onClick="javascript:g_ycomment.getPagingData('+g_ycomment.prevpage+');">前の20件</a> | <span style="color:#999;">次の20件</span>'}else{g_ycomment.prevpage=g_ycomment.currentpage-1;g_ycomment.nextpage=g_ycomment.currentpage+1;D+='<a href="#'+C+'" onClick="javascript:g_ycomment.getPagingData('+g_ycomment.prevpage+');">前の20件</a> | <a href="#'+C+'" onClick="javascript:g_ycomment.getPagingData('+g_ycomment.nextpage+');">次の20件</a>'}}}D+=" ] </p></div>";return D},getPagingData:function(C){g_ycomment.currentpage=C;g_ycomment.offset=C*g_ycomment.reach;var B="item_id="+g_ycomment.item_id+"&sort="+g_ycomment.sort+"&order="+g_ycomment.order+"&tgtUri="+g_ycomment.tgturi+"&tgtDoneUri="+g_ycomment.tgtdoneuri+"&crm="+g_ycomment.crm+"&offset="+g_ycomment.offset+"&length="+g_ycomment.reach;var A={success:function(E){g_ycomment.showListHtml(E)},send:function(){YAHOO.util.Connect.asyncRequest("POST",g_ycomment.resourceuri,D,encodeURI(B))}};var D={success:A.success,scope:A};A.send()},changeSort:function(B,A){g_ycomment.sort=B;g_ycomment.order=A;g_ycomment.getPagingData(0)},addPoints:function(C,B,A,D){url=g_ycomment.pointuri+"?prop="+g_ycomment.prop+"&turi="+g_ycomment.tgturi+"&id="+C+"&seq="+B+"&crm="+D+"&fmt=jsonp";g_ycomment.jsonobj=new JSONscriptRequest(url);g_ycomment.jsonobj.buildScriptTag();g_ycomment.jsonobj.addScriptTag()}}
