var diggs=new Array();$(document).ready(function(){if(isLoggedIn==true){$("a.digg-it").click(function(){var id=$(this).attr("id").substring(1);
if(diggs[id]!=undefined){return false}$.ajax({url:"/ajax/digg/perform",type:"POST",dataType:"json",data:{itemid:id,location:"9",type:"s",row:$("#r"+id).val(),digcheck:$("#dc"+id).val()},success:function(json){if(json.success==true){$("#diggs-strong-"+id).fadeOut("normal",function(){$(this).text(json.count).fadeIn("normal");
$("#di"+id).attr("src","/img/dugg-it.gif")});$("#favorite-div").fadeIn()}},error:function(xml){var json=eval("("+xml.responseText+")");
$("#diggs-strong-"+id).text("ERR!");alert(json.error?json.error:json.message)}});return false})}$("#username, #password").focus(function(){$("#"+$(this).attr("id")+"-label").hide()
});$("#loadComments").click(function(event){event.preventDefault();$("#loadingCommentSpinner").html('<img src="/img/c-spinner.gif" id="spinnerImg" alt="" />');
$("#loadComments").css("display","none");var commentCount=$(".comments > ul > li").length;var page=(Math.floor(commentCount/5)+1);
var count=5;var commentsLeft=(totalCommentCount-commentCount);if(commentsLeft>5){count=5}else{if(commentsLeft<=0){return false
}else{count=commentsLeft}}$.ajax({url:"/ajax/comments/loadPage",async:true,type:"POST",dataType:"json",data:{id:storyID,sort:5,page:page,count:count,token:tokens.comments.loadPage},success:function(json){var i=0;
$.each(json.comments,function(){i++;var digCountPrefix="";if(this.dig_count>0){digCountPrefix="+"}var commentHTML="<li><h5><em>"+digCountPrefix+this.dig_count+'</em><a href="/users/'+this.user+'">'+this.user+"</a> "+this.age+"</h5><div>"+this.comments+"</div></li>";
$(".comments > ul").append(commentHTML)});$(".comments > h4").html("Top "+(commentCount+i)+" of "+totalCommentCount+" Comments");
$("#loadingCommentSpinner").html("");if(i==5){$("#loadComments").css("display","block")}return false},error:function(){$("#loadingCommentSpinner").html("");
$("#loadComments").css("display","block")}});return false});$(".favorite").click(function(event){$.ajax({url:"/ajax/favorites/fave",async:true,type:"POST",dataType:"json",data:{item:this.id,token:tokens.favorites.fave},success:function(json){$(".favorite").parent().html("Favorite!")
}});return false});$("#redirectCookie").click(function(e){var wl=window.location;var domain=wl.host.replace("m.","");
$.cookie("mobileRedirect","noRedirect",{expires:365,path:"/",domain:domain});var url="http://"+domain;
if(wl.pathname){url+=wl.pathname}if(wl.search){url+=wl.search}if(wl.hash){url+=wl.hash}window.location=url;
e.preventDefault()})});$(".submitButton").click(function(){$(this).parent().parent().submit()});function doLogout(A){var B='<form id="newpost" action="/logout" method="post">';
B+='<input type="hidden" name="logout_check" value="'+A+'" />';B+="</form>";$("#post-form").html(B);$("#newpost").submit()
};
