$(document).ready(function(){$.dialog.setConfig("base","http://www.huimg.cn/lib/dialog")});var textCounter={maxlength:140,setCounterContent:function(a,b){b=b||textCounter.maxlength;var c=(b-a)>0?(b-a):0;return("你还可以输入"+c+"个字")},isMax:function(c,b){b=b||textCounter.maxlength;var a=parseInt(c);if(a>b){return true}return false}};var shareForSNS={};shareForSNS.repeatflag=false;shareForSNS.HDAlert=function(b,a){$.dialog({id:"snsShareDialog",overlay:false,title:"提示",autoClose:typeof(a)=="undefined"?2000:a,effects:"fade",height:100,width:230,content:b,skin:"bluebox",styleDialog:{border:"5px solid #666666"},resetTime:-1})};shareForSNS.showCommentAlert=function(){try{StatVirtualTraffic(document.referrer,window.location,"sns_fenxiang_click")}catch(c){}var a=getHdCookie(hdCookieName);if(a!=null){var b="<div style='width:300px; padding:10px 10px 15px; text-align:left; word-wrap:break-word; word-break:break-all; overflow:hidden'><p style='display:block; line-height:25px'>分享理由：（选填）</p><textarea style='width:290px; overflow-y:auto; vertical-align:top; border:1px solid #e1e1e1; padding:3px 4px; height:60px; background:#fff' id='share_comment_info'></textarea><span id='share_comment_count_info' style='color: rgb(153, 153, 153);'>你还可以输入140个字</span><p style='text-align:center; margin-top:10px'><input style='white-space:nowrap; cursor:pointer;background:url(http://www.huimg.cn/sns/sns_img100601.gif) no-repeat; vertical-align:middle; color:#0268CD; width:47px; height:27px; background-position:-350px -39px; border:none' id='share_submit' type='button' value='确定' /> 或  <a id='share_close' href='#'>取消</a></p></div>";shareForSNS.HDAlert(b,0);$("#share_comment_info").keyup(function(){shareForSNS.textareaEvent()}).keydown(function(){shareForSNS.textareaEvent()});$("#share_close").bind("click",function(){$.dialog.close("snsShareDialog");return false});if(shareForSNS.type==1||shareForSNS.type==2){$("#share_submit").bind("click",function(){shareForSNS.fromSNSsubmit();return false})}else{if(shareForSNS.type==0){$("#share_submit").bind("click",function(){shareForSNS.fromOutsubmit();return false})}else{if(shareForSNS.type==3){$("#share_submit").bind("click",function(){shareForSNS.fromOutsubmit();return false})}}}}else{linkToLogin(shareForSNS.shareURL)}};shareForSNS.textareaEvent=function(){if(textCounter.isMax($("#share_comment_info").val().length)){$("#share_comment_info").val($("#share_comment_info").val().substring(0,textCounter.maxlength));$("#share_comment_count_info").attr("style","color: rgb(255, 0, 0)")}else{$("#share_comment_count_info").attr("style","color: rgb(153, 153, 153)")}setTimeout(function(){$("#share_comment_count_info").text(textCounter.setCounterContent($("#share_comment_info").val().length))},500)};shareForSNS.init=function(g,d,c){var e=window.location.href;var b=new RegExp("#.*");var f=b.exec(e);shareForSNS.shareURL=e.replace(f,"");shareForSNS.type=c;if(shareForSNS.type==1){var a=getHdCookie(hdCookieName);if(a!=null){shareForSNS.shareId=d;shareForSNS.showCommentAlert()}else{linkToLogin(shareForSNS.shareURL)}}else{if(shareForSNS.type==0){shareForSNS.shareTitle=$("#"+d).val();$("#"+g).bind("click",function(){shareForSNS.showCommentAlert();return false})}else{if(shareForSNS.type==2){shareForSNS.feedId=d;shareForSNS.showCommentAlert()}else{if(shareForSNS.type==3){shareForSNS.shareURL=g;shareForSNS.shareTitle=d;shareForSNS.showCommentAlert()}}}}};shareForSNS.fromOutsubmit=function(){var c=getHdCookie(hdCookieName);if(c!=null){if(shareForSNS.repeatflag){return}var a=$("#share_comment_info").val();var b=new RegExp("#");while(b.exec(a)!=null){var d=b.exec(a);a=a.replace(d,"")}this.shareComment=a;$("#share_submit").attr("disabled","disabled");shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">正在分享请等待....</div>',0);shareForSNS.repeatflag=true;$.getJSON("http://i.hudong.com/userShare.do?action=shareFromOwner&shareTitle="+encodeURI(shareForSNS.shareTitle)+"&shareComment="+encodeURI(shareForSNS.shareComment)+"&shareURL="+shareForSNS.shareURL+"&callback=?",function(g){var f=g.flag;if(f==1){var h="分享成功";shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");shareForSNS.repeatflag=false;try{StatVirtualTraffic(document.referrer,window.location,"sns_fenxiang_success")}catch(i){}return true}else{if(f==-1){var h="分享失败，请登录";h=g.resultInfo;shareForSNS.repeatflag=false;linkToLogin(shareForSNS.shareURL);return true}else{if(f==0){var h="分享失败";h=g.resultInfo;shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");shareForSNS.repeatflag=false;return true}else{var h="系统异常，请稍候再试！";h=g.resultInfo;shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");shareForSNS.repeatflag=false;return true}}try{StatVirtualTraffic(document.referrer,window.location,"sns_fenxiang_fail")}catch(i){}return true}shareForSNS.repeatflag=false})}else{linkToLogin(shareForSNS.shareURL)}};shareForSNS.fromSNSsubmit=function(){var b=$("#share_comment_info").val();var c=new RegExp("#");var d=c.exec(b);this.shareComment=b.replace(d,"");var a="shareId";var e=shareForSNS.shareId;$("#share_submit").attr("disabled","disabled");if(shareForSNS.type==2){a="feedId";e=shareForSNS.feedId}else{if(shareForSNS.type==1){a="shareId";e=shareForSNS.shareId}}shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">正在分享请等待....</div>',0);$.getJSON("http://i.hudong.com/userShare.do?action=shareFromSNS&"+a+"="+e+"&shareComment="+encodeURI(shareForSNS.shareComment)+"&callback=?",function(g){var f=g.flag;if(f==1){var h="分享成功";shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");return true}else{if(f==-1){var h="分享失败，请登录";h=g.resultInfo;linkToLogin(shareForSNS.shareURL);return true}else{if(f==0){var h="分享失败";h=g.resultInfo;shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");return true}else{var h="系统异常，请稍候再试！";h=g.resultInfo;shareForSNS.HDAlert('<div style="height:80px;line-height:80px;">'+h+"</div>");return true}}}})};function linkToLogin(b){var a=new Date();a.setTime(a.getTime()+24*3600*1000);document.cookie="nextURL="+b+";expire="+a.toGMTString()+";path=/;domain=.hudong.com;";location.href="http://wiki.hudong.com/user/login/userLogin.jsp"}var hdCookieName="hduser";function getHdCookie(b){try{var a=document.cookie.match(new RegExp("(^| )"+b+"=([^;]*)(;|$)"));if(a!=null){return unescape(a[2])}}catch(c){return null}return null};
