var OB={};OB.Suggest={myInterval:300,myId:"search",myTimeout:0,myXhrId:0,myDisplayedXhrId:0,myUrl:"/topics/tools/suggest",KeyPress:function(){if(OB.Suggest.myTimeout){clearTimeout(OB.Suggest.myTimeout)}OB.Suggest.myTimeout=setTimeout(OB.Suggest.Timeout,OB.Suggest.myInterval)},Timeout:function(){var a=$("#"+OB.Suggest.myId).val();if(a==""){$("#suggest").html("")}else{var b=$.get(OB.Suggest.myUrl,{q:a},function(d,e,c){if(!d){d={result:""}}if(c.myId>=OB.Suggest.myDisplayedXhrId){$("#suggest").html(d.result)}},"json");OB.Suggest.myXhrId++;b.myId=OB.Suggest.myXhrId}}};OB.Verse={previewUrl:"/topics/tools/verse",Preview:function(a){a.preventDefault();$.getJSON(OB.Verse.previewUrl,{verse:$("#preview").val()},OB.Verse.PreviewResponse)},PreviewResponse:function(a){if(a.content&&a.id&&a.reference){$("#preview-text").html("<h3>"+a.reference+"</h3><p>"+a.content+'</p><p><input type="submit" value="Suggest This Verse" /></p>');$("#verse").val(a.id)}else{$("#preview-text").html('<p class="error">Sorry, we couldn&rsquo;t find a passage matching the verse you suggest. Please double-check your spelling and try again.</p>')}}};OB.Vote={myUrl:"/topics/tools/vote",Vote:function(a){a.preventDefault();$.post(OB.Vote.myUrl,{word:document.URL.replace(/\/+$/,"").split(/\//).pop(),id:$(this).attr("id")});$(this).parent().html("Thank you for your vote.")},Over:function(){$(this).addClass("visible")},Out:function(){$(this).removeClass("visible")}};$(document).ready(function(){$("body").addClass("script");if($("#search").length){$("#search").keypress(OB.Suggest.KeyPress);OB.Suggest.Timeout()}$("form#vote button").click(OB.Vote.Vote);$("div.verse").hover(OB.Vote.Over,OB.Vote.Out);$("#preview-button").click(OB.Verse.Preview)});
