var fodderCommentEvent={initHtml:"你想说什么？",repeatFlag:false,blurTimerFlag:null,urlpara:"",fodderCounter:{maxlength:140,isMax:function(c,b){b=b||fodderCommentEvent.fodderCounter.maxlength;var a=parseInt(c);if(a>b){return true}return false},setCounterContent:function(a,b){b=b||fodderCommentEvent.fodderCounter.maxlength;if((b-a)>=0){var c=(b-a);return("还可以输入"+c+"个字")}else{var c=(a-b);return("已超出"+c+"个字")}}},initCommentEvent:function(b){var a=this.getCommentCounterObject();fodderCommentEvent.setCommentCounterText(a,0);$("textarea[name='commentinput']").unbind().val(fodderCommentEvent.initHtml).focus(function(){fodderCommentEvent.commentInputChangeEvent($(this))}).keyup(function(){fodderCommentEvent.commentInputChangeEvent($(this))}).keydown(function(c){if(c.ctrlKey&&c.keyCode==13){fodderCommentEvent.submitAction($(this),b);return false}fodderCommentEvent.commentInputChangeEvent($(this))}).blur(function(c){var d=$(this);fodderCommentEvent.blurTimerFlag=setTimeout(function(){if(d.val()==""){fodderCommentEvent.reSet(d)}},200)});$("input[name='commentsubmit']").click(function(){clearTimeout(fodderCommentEvent.blurTimerFlag);fodderCommentEvent.submitAction($("textarea[name='commentinput']"),b)})},commentInputChangeEvent:function(b){var a=this.getCommentCounterObject();if(b.val()==fodderCommentEvent.initHtml){b.val("")}if(fodderCommentEvent.fodderCounter.isMax(b.val().length)){fodderCommentEvent.setCommentCounterColor(a,"rgb(255, 0, 0)")}else{fodderCommentEvent.setCommentCounterColor(a,"")}setTimeout(function(){fodderCommentEvent.setCommentCounterText(a,b.val().length)},400)},submitAction:function(e,d){e.blur();if(e.val()==fodderCommentEvent.initHtml){e.val("")}if($.trim(e.val())==""){e.val(fodderCommentEvent.initHtml);return}else{if(!this.isLogin()){fodderCommentEvent.HDAlert("你尚未登录，请<a onclick=\"var date=new Date();date.setTime(date.getTime()+24*3600*1000);document.cookie='nextURL='+encodeURIComponent(document.location.href)+';expire='+date.toGMTString()+';path=/;domain=.hudong.com;'\" href='http://i.hudong.com/user/login/userLogin.jsp'>登录</a>后再评论",0);return}var c=$.trim(e.val());e.val(c);if(fodderCommentEvent.repeatFlag){return}if(fodderCommentEvent.fodderCounter.isMax(e.val().length)){var a=6;var b=setInterval(function(){if(a>0){a--;e.toggleClass("textarea-alert")}else{clearInterval(b);e.removeClass("textarea-alert").focus()}},100);return}fodderCommentEvent.HDAlert("正在发布....",3000);fodderCommentEvent.repeatFlag=true;$.getJSON("http://i.hudong.com/fodderComment.do?commentContent="+encodeURIComponent(c)+fodderCommentEvent.urlpara+"&t="+Math.random()+"&callback=?",function(g){fodderCommentEvent.repeatFlag=false;var f=g.flag;if(f==1){var h=g.resultInfo;fodderCommentEvent.closeHDAlert();fodderCommentEvent.submitSuccess(d,h);fodderCommentEvent.reSet($("textarea[name='commentinput']"))}else{if(f==0){var h=g.resultInfo;fodderCommentEvent.HDAlert(h,0)}else{var h="系统异常，请稍候再试，或与管理员联系";fodderCommentEvent.HDAlert(h,0)}}return true})}return false},submitSuccess:function(j,i){var p=j[0].contentWindow;var o="";var k=p.curUserInfo.nick;var f=p.curUserInfo.url;var b=p.curUserInfo.img;var l=p.curUserInfo.iden;var n=i;var a="刚刚更新";var d="";var g="";var q=1;var h="";var c="";var m=p.snsTemplet.feedTemplet.clone(true);p.snsTemplet.setFeedTemplet(m,o,k,l,f,b,n,a,d,g,q,h,c);var r=j.contents().find("#sns-footprint-profile");var e=r.children("div");if(e.length>0){e.eq(0).removeClass().addClass("footlist-new");e.eq(0).before(m);m.removeClass().addClass("footlist-new bac_no")}else{r.append(m);m.removeClass().addClass("footlist-new bac_no")}m.find(".sns-time a").eq(0).replaceWith('<span class="l link_gray9">刚刚更新</span>');m.find(".showReplyhref").replaceWith("回复 ")},reSet:function(b){b.val(fodderCommentEvent.initHtml);var a=this.getCommentCounterObject();this.setCommentCounterText(a,0);this.setCommentCounterColor(a,"")},closeHDAlert:function(){$.dialog.close("commentAlert")},setCommentCounterText:function(a,b){a.text(fodderCommentEvent.fodderCounter.setCounterContent(b))},setCommentCounterColor:function(b,a){b.css("color",a)},getCommentCounterObject:function(){return $("input[name='commentsubmit'] ~ span")},getCookie:function(c){var d=document.cookie.indexOf(c+"=");var a=d+c.length+1;if((!d)&&(c!=document.cookie.substring(0,c.length))){return null}if(d==-1){return null}var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))},isLogin:function(){return(this.getCookie("hduser")!=null)},HDAlert:function(b,a){$.dialog({id:"commentAlert",overlay:false,autoClose:typeof(a)=="undefined"?2000:a,title:"提示",height:100,width:230,content:'<div style="height:80px;line-height:80px;">'+b+"</div>",skin:"bluebox",resetTime:-1})},autoHeight:function(c,b,a){if(b){c.height(c.contents().find("body").height())}if(a){c.width(c.contents().find("body").width())}},checkHTML:function(b){var a=/<(\w*)[^>]*>[^<]*<\/\1>|<(\w*)[^>]*\/>/;if(b.search(a)>-1){return true}return false}};
