
﻿
function zzk_go(){var keystr=encodeURIComponent(document.getElementById('q').value);window.location="http://zzk.cnblogs.com/s?w="+keystr;}
function zzk_go_enter(event){if(event.keyCode==13){zzk_go();return false;}}
function google_search(){var keystr=encodeURIComponent(document.getElementById('google_keyword').value);window.location="/search.aspx?keyword="+keystr;}
function google_search_enter(event){if(event.keyCode==13){google_search();return false;}}
function blogger_search(){var keystr=$("#txt_blogger_search").val();if(keystr==''){alert('请输入关键字');return false;}
$("#pager_block").html("");$("#headline_block").html("<div>搜索“"+keystr+"”中...</div>");$("#btnBloggerSearch").val("搜索中...");$("#btnBloggerSearch").attr("disabled","true");$("#post_list").html('<div id="tips_block"><img src="http://static.cnblogs.com/images/searching.gif" alt=""></div>');keystr=keystr.replace(/\'/g,"\\'");$.ajax({url:"/WS/SearchService.asmx/SearchBlogger",data:'{keyword:"'+keystr+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){$("#post_list").html(data.d);$("#btnBloggerSearch").val("搜索博主");$("#btnBloggerSearch").removeAttr("disabled");$("#headline_block").html("<div>搜索“"+keystr+"”的结果：</div>");}},error:function(xhr){alert("提交出错，请重试。错误信息："+xhr.responseText);$("#btnBloggerSearch").removeAttr("disabled");}});}
function blogger_search_enter(event){if(event.keyCode==13){blogger_search();return false;}}
var currentDiggType;var currentDiggEntryId;function DiggIt(entryId,blogId,diggType){currentDiggEntryId=entryId;ShowDiggMsg('提交中...');currentDiggType=diggType;$.ajax({url:'/ws/digg.asmx/digg',data:'{entryId:'+entryId+',blogId:'+blogId+',diggType:'+diggType+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){ShowDiggMsg('');if(data.d==-1){location.href="http://passport.cnblogs.com/login.aspx?ReturnUrl="+location.href;}
else if(data.d==-2){if(confirm("您已经评价过该文章！要取消评价吗？")){CancelDigg(entryId);}}
else if(data.d==0){alert('操作失败，请与管理员联系！');}
else{if(diggType==1){$("#digg_count_"+entryId).html(parseInt($("#digg_count_"+entryId).html())+1);}
else if(diggType==2){$("#bury_count_"+entryId).html(parseInt($("#bury_count_"+entryId).html())+1);}
ShowDiggMsg('提交成功');}},error:function(xhr){alert("提交出错，请重试。错误信息："+xhr.responseText);}});}
function CancelDigg(entryId){ShowDiggMsg('操作中...');$.ajax({url:'/ws/digg.asmx/CancelDigg2',data:'{entryId:'+entryId+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){if(data.d==1){$("#digg_count_"+entryId).html(parseInt($("#digg_count_"+entryId).html())-1);}
else if(data.d==2){$("#bury_count_"+entryId).html(parseInt($("#bury_count_"+entryId).html())-1);}
ShowDiggMsg('取消成功');}},error:function(xhr){alert("提交出错，请重试。错误信息："+xhr.responseText);}});}
function ShowDiggMsg(msg){$("#digg_tip_"+currentDiggEntryId).css("color","red");$("#digg_tip_"+currentDiggEntryId).html(msg);}
function AjaxPost(url,postData,successFunc){$.ajax({url:url,data:postData,type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){successFunc(data.d);}}});}
function GetUserInfo(){try{$.ajax({url:'/ws/PublicUserService.asmx/GetLoginInfo',data:'{url:"'+location.href+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#span_userinfo").html(data.d);if(data.d.indexOf("注册")<0){GetNewMsgCount($("#current_spaceId").html());}}});}catch(e){}}
function GetNewMsgCount(spacerUserId){$.ajax({url:'/ws/PublicUserService.asmx/GetNewMsgCount',data:'{spaceUserId:'+spacerUserId+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){$("#site_msg").append('<span class="new_msg">('+data.d+')</span>');}}});}
function GetHeadline(){try{$.ajax({url:'/ws/BlogPost.asmx/GetHeadline',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){$("#headline_block").html(data.d);}}});}catch(e){}}
function GetDiggCount(){var entryIdList=$("#span_entryid_list").html();$.ajax({url:'/wcf/DiggService.svc/GetDiggCountList',data:'{"entryIdList":"'+entryIdList+'"}',type:'post',dataType:'json',contentType:'text/json',success:function(data){if(data.d){var entryIdArray=entryIdList.split(',');var diggCountArray=data.d.split(',');for(var i=0;i<diggCountArray.length;i++){$("#digg_count_"+entryIdArray[i]).html(diggCountArray[i]);}}}});}
function GetFeedbackCount(){var entryIdList=$("#span_entryid_list").html();$.ajax({url:'/ws/BlogPost.asmx/GetFeedbackCountList',data:'{entryIdList:"'+entryIdList+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){var entryIdArray=entryIdList.split(',');var feedbackCountArray=data.d.split(',');for(var i=0;i<entryIdArray.length;i++){$("#feedback_count_"+entryIdArray[i]).html(feedbackCountArray[i]);}}}});}
function GetViewCount(){var entryIdList=$("#span_entryid_list").html();$.ajax({url:'/ws/BlogPost.asmx/GetViewCountList',data:'{entryIdList:"'+entryIdList+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){var entryIdArray=entryIdList.split(',');var viewCountArray=data.d.split(',');for(var i=0;i<entryIdArray.length;i++){$("#viewcount_"+entryIdArray[i]).html(viewCountArray[i]);}}}});}
function setTab(name,content_name,current,count){for(i=1;i<=count;i++){var title=document.getElementById(name+i);var content=document.getElementById(content_name+i);title.className=i==current?"current":"";content.className=i==current?"block_show":"block_hidden";}}
function showOrderLink(){document.getElementById("order_link").style.borderColor="#ccc";document.getElementById("order_link_content").style.display="";}
function hideOrderLink(){document.getElementById("order_link").style.borderColor="white";document.getElementById("order_link_content").style.display="none";}
function cateShow(index){if(document.getElementById("cate_content_block_"+index)){document.getElementById("cate_content_block_"+index).style.display='block';document.getElementById("cate_item_"+index).className='cate_item_hover';}}
function cateHidden(index){if(document.getElementById("cate_content_block_"+index)){document.getElementById("cate_content_block_"+index).style.display='none';document.getElementById("cate_item_"+index).className='';}}
function GetAggStats(){try{$.ajax({url:'/ws/SiteHomeService.asmx/GetAggStats',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#site_stats").html(data.d);}});}catch(e){}}
function GetTopBlogger(){try{$.ajax({url:'/ws/SiteHomeService.asmx/GetTopBloggers',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#blogger_list").html(data.d);}});}catch(e){}}
function GetCategoryList(cateId){try{$.ajax({url:'/ws/SiteHomeService.asmx/GetCategoryList',data:'{cateId:"'+cateId+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#cate_sub_block").html(data.d);}});}catch(e){}}
var waitingTips='<div id="tips_block"><img src="http://static.cnblogs.com/images/waiting.gif" alt=""/></div>';function UpateSiteHomePosts(siteCategoryType,pageIndex,pageSize){window.scrollTo(0,0);$("#nav_tab_"+siteCategoryType).attr("class","current_nav");$("#nav_tab_"+(3-siteCategoryType)).removeAttr("class");$("#nav_tab_3").removeAttr("class");$("#posts_refresh").hide();$("#headline_block").html('');$("#posts_refresh_tips").css("color","green");$("#posts_refresh_tips").html("更新中...");GetHeadline();ShowProgress();$.ajax({url:'/ws/BlogPost.asmx/GetSiteHomePosts',data:'{siteCategoryType:'+siteCategoryType+',pageIndex:'+pageIndex+',pageSize:'+pageSize+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){var startDate=new Date();document.getElementById("post_list").innerHTML=data.d;$("#posts_refresh_tips").html("");$("#posts_refresh").show();},error:function(xhr){$("#post_list").html("更新数据失败！请重试！");}});var urlFormat;if(siteCategoryType==2){urlFormat='/candidate/page{0}';}
else{urlFormat='/page{0}';}
ShowPager(4000,pageIndex,pageSize,urlFormat,'UpateSiteHomePosts('+siteCategoryType+',');}
function ShowProgress(){$("#post_list").html('<div id="tips_block"><img src="/images/loading.gif" alt=""/></div>');}
function ShowPager(totalCount,pageIndex,pageSize,urlFormat,func){var showPageCount=5;$.ajax({url:'/ws/BlogPost.asmx/GetPager',data:'{totalCount:'+totalCount+',pageIndex:'+pageIndex+',pageSize:'+pageSize+',showPageCount:'+showPageCount+',urlFormat:"'+urlFormat+'",func:"'+func+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(pageIndex>1){$("#pager_top").html(data.d);$("#pager_top").show();}
else{$("#pager_top").html('');$("#pager_top").hide();}
$("#pager_block").html(data.d);}});}
function ShowHeadlineList(pageIndex,pageSize){window.scrollTo(0,0);$("#posts_refresh").hide();$("#headline_block").html('编辑推荐：');$("#headline_block").css('padding-left','25px');$("#posts_refresh_tips").css("color","green");$("#posts_refresh_tips").html("更新中...");ShowProgress();$.ajax({url:'/ws/BlogPost.asmx/GetHeadlineHtml',data:'{pageIndex:'+pageIndex+',pageSize:'+pageSize+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#post_list").html(data.d);$("#posts_refresh_tips").html("");},error:function(xhr){$("#post_list").html("更新数据失败！请重试！");}});$.ajax({url:'/ws/BlogPost.asmx/GetHeadlineCount',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){ShowPager(data.d,pageIndex,pageSize,"#",'ShowHeadlineList(');}});}
function GetNewsList(pageIndex,pageSize){window.scrollTo(0,0);var news_click=eval("(function(){GetNewsList(1,30);return false;});");$("#posts_refresh").attr("onclick","").click(news_click);$("#posts_refresh").attr("title","刷新新闻列表");$("#nav_tab_3").attr("class","current_nav");$("#nav_tab_1").removeAttr("class");$("#nav_tab_2").removeAttr("class");$("#posts_refresh").hide();$("#posts_refresh_tips").css("color","green");$("#posts_refresh_tips").html("更新中...");$("#headline_block").html('');$("#post_list").css("padding-top","20px");ShowProgress();$.ajax({url:'/ws/SiteHomeService.asmx/GetNewsLis',data:'{pageIndex:'+pageIndex+',pageSize:'+pageSize+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#post_list").html(data.d);$("#posts_refresh_tips").html("");$("#posts_refresh").show();},error:function(xhr){$("#post_list").html("更新数据失败！请重试！");}});var urlFormat="#";ShowPager(1500,pageIndex,pageSize,urlFormat,'GetNewsList(');}
function GetDayTopDiggPosts(pageIndex,pageSize){$("#post_list_tips").html('24小时推荐排行：');$("#post_list_tips").show();ShowProgress();$.ajax({url:'/ws/BlogPost.asmx/GetTopDiggPostList',data:'{pageIndex:'+pageIndex+',pageSize:'+pageSize+'}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#post_list").html(data.d);},error:function(xhr){$("#post_list").html("更新数据失败！请重试！");}});}
function GetTopViewPosts(){try{$("#top_views_posts").html('<ul><li>数据加载中...</li></ul>');$.ajax({url:'/ws/SiteHomeService.asmx/GetTopViewPosts',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#top_views_posts").html(data.d);}});}catch(e){}}
function GetTopDiggPosts(){try{$("#top_digg_posts").html('<ul><li>数据加载中...</li></ul>');$.ajax({url:'/ws/SiteHomeService.asmx/GetTopDiggPosts',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#top_digg_posts").html(data.d);}});}catch(e){}}
function GetJobList(){try{$("#job_list").html('<ul><li>数据加载中...</li></ul>');$.ajax({url:'/ws/SiteHomeService.asmx/GetJobList',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#job_list").html(data.d);}});}catch(e){}}
function GetTeamPosts(){try{$("#team_posts").html('<ul><li>数据加载中...</li></ul>');$.ajax({url:'/ws/SiteHomeService.asmx/GetTeamPosts',data:'{}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){$("#team_posts").html(data.d);}});}catch(e){}}
function GetEditorPick(url,element){try{$.ajax({url:'/ws/SiteHomeService.asmx/GetEditorPickCount',data:'{url:"'+url+'"}',type:'post',dataType:'json',contentType:'application/json; charset=utf8',success:function(data){if(data.d){$(element).append('<span class="editor_pick_count"> ('+data.d+")</span>");}}});}catch(e){}}
var c_enable_dfp=true;function ShowTopBloggers(){$.ajax({url:'/mvc/SiteHome/UserStats.aspx',type:'get',dataType:'text',success:function(data){$("#user_stats").html(data);}});}
function google_cse_load(){try{var cses=document.createElement('script');cses.type='text/javascript';cses.src='http://www.google.com.hk/coop/cse/brand?form=cse-search-box&amp;lang=zh-Hans';var node=document.getElementById('google_cse_holder');node.parentNode.insertBefore(cses,node);}catch(e){}}
function close_side_right(){$("#side_right").css("display","none");$("#main").css("margin-right","10px");$("#rss_block").css("right","10px");}
function set_a_title(a){var text=$.trim($(a).text());if(text&&!$(a).attr("title")){$(a).attr("title",text);}}
