/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing & EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith &
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/
jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(B,C,A,E,D){return jQuery.easing[jQuery.easing.def](B,C,A,E,D);},easeInSine:function(B,C,A,E,D){return -E*Math.cos(C/D*(Math.PI/2))+E+A;},easeInOutExpo:function(B,C,A,E,D){if(C==0){return A;}if(C==D){return A+E;}if((C/=D/2)<1){return E/2*Math.pow(2,10*(C-1))+A;}return E/2*(-Math.pow(2,-10*--C)+2)+A;},easeOutElastic:function(B,D,A,H,G){var E=1.70158;var F=0;var C=H;if(D==0){return A;}if((D/=G)==1){return A+H;}if(!F){F=G*0.3;}if(C<Math.abs(H)){C=H;var E=F/4;}else{var E=F/(2*Math.PI)*Math.asin(H/C);}return C*Math.pow(2,-10*D)*Math.sin((D*G-E)*(2*Math.PI)/F)+H+A;},easeOutBounce:function(B,C,A,E,D){if((C/=D)<(1/2.75)){return E*(7.5625*C*C)+A;}else{if(C<(2/2.75)){return E*(7.5625*(C-=(1.5/2.75))*C+0.75)+A;}else{if(C<(2.5/2.75)){return E*(7.5625*(C-=(2.25/2.75))*C+0.9375)+A;}else{return E*(7.5625*(C-=(2.625/2.75))*C+0.984375)+A;}}}}});
/*
 * One Bit Wonder
 * Copyright © 2009 Leon Hong & Camile Orillaneda
 * All rights reserved
*/
var site=new WonderSite();var search=new WonderSearch();var comments;$(document).ready(function(){site.setup();search.setup();if(PAGE_ID=="post"){comments=new WonderComments();comments.setup();}});jQuery.preloadImages=function(){for(var A=0;A<arguments.length;A++){jQuery("<img>").attr("src",arguments[A]);}};jQuery.fn.log=function(A){console.log("%s: %o",A,this);return this;};function WonderComments(){this.sending=false;this.nameInput=$("#comname");this.emailInput=$("#comemail");this.phoneInput=$("#comphone");this.textArea=$("#comtext");this.ssnInput=$("#comssn");this.form=$("#comform");this.tip=$(".tip");}WonderComments.prototype.setup=function(){comments.nameInput.data("label","Your Name");comments.emailInput.data("label","Your Email");comments.textArea.data("label","Your comment goes here (markup tags are removed, 1000 character limit)");comments.nameInput.val(comments.nameInput.data("label"));comments.emailInput.val(comments.emailInput.data("label"));comments.textArea.val(comments.textArea.data("label"));comments.tip.addClass("tipon").focus(function(){$(this).removeClass("tipon");$("#comerror").hide();if($(this).val()==$(this).data("label")){$(this).val("");}}).blur(function(){if($(this).val()==""){$(this).addClass("tipon").val($(this).data("label"));}});comments.emailInput.keyup(function(){if(isValidEmailAddress($(this).val())){$(this).removeClass("invalid");}else{$(this).addClass("invalid");}});comments.form.submit(function(A){if(comments.sending){A.preventDefault();}else{comments.sending=true;if(!comments.isValid()||comments.phoneInput.val()!=""){if($("#comerror").length==0){$("#comments h3").after('<div id="comerror"></div>');}$("#comerror").hide().html("An error occured. Make sure all fields are filled and try again.").fadeIn(400);A.preventDefault();comments.sending=false;return false;}}});};WonderComments.prototype.isValid=function(){return comments.nameInput.val()!=""&&comments.nameInput.val()!=comments.nameInput.data("label")&&comments.emailInput.val()!=""&&comments.emailInput.val()!=comments.emailInput.data("label")&&comments.textArea.val()!=""&&comments.textArea.val()!=comments.textArea.data("label");};function WonderSearch(){this.selectedIndex=-1;this.indexLength=0;this.lastSearch="";this.mouseOver=false;this.lastHash="";}WonderSearch.prototype.moveIndex=function(A){switch(A){case -1:search.selectedIndex=search.selectedIndex<=1?0:search.selectedIndex-1;break;case 1:search.selectedIndex=search.selectedIndex+1>(search.indexLength+2)-1?(search.indexLength+2)-1:search.selectedIndex+1;break;case 0:search.selectedIndex=-1;break;}$("#results li.selected").removeClass("selected");$(".i-"+search.selectedIndex).addClass("selected");};WonderSearch.prototype.filter=function(){var A=$.trim($(this).val().toLowerCase());if(A==""){search.lastSearch="";search.clear();return false;}if(search.lastSearch!=A){$("#results li.selected").removeClass("selected");search.moveIndex(0);search.lastSearch=A;$("#search").addClass("load");$.getJSON("/view.results.rpc",{query:search.lastSearch},function(C){if(search.lastSearch==C.query){if(C.total==0){search.lastHash=C.hash;$("#data").empty();$("#google").addClass("i-0").html('<a href="http://www.google.com/search?as_sitesearch=onebitwonder.com&as_q='+search.lastSearch+'">Search with Google</a>');$("#wonder").addClass("i-1").html('<a href="/view.results?phrase='+search.lastSearch+'">Show all results</a>');}else{if(C.hash!=search.lastHash){$("#results li").removeClass();search.indexLength=C.total;search.lastHash=C.hash;$("#data").empty();var B=0;if(C.total>0){$.each(C.results,function(D,E){switch(E.type){case"article":$("#data").append("<li class='t-"+E.type+" w-"+E.weight+" i-"+D+"'><a href='/view.post/"+E.slug+"'><span>Article</span>"+E.name+"</a></li>");break;case"mammal":$("#data").append("<li class='t-"+E.type+" w-"+E.weight+" i-"+D+"'><a href='/view.page/mammals'><span>Mammal</span>"+E.name+"</a></li>");break;case"page":$("#data").append("<li class='t-"+E.type+" w-"+E.weight+" i-"+D+"'><a href='/view.page/"+E.name.toLowerCase()+"'><span>Page</span>"+E.name+"</a></li>");break;}B=D+1;});}$("#google").addClass("i-"+B).html('<a href="http://www.google.com/search?as_sitesearch=onebitwonder.com&as_q='+search.lastSearch+'">Search with Google</a>');B++;$("#wonder").addClass("i-"+B).html('<a href="/view.results?phrase='+search.lastSearch+'">Show all results</a>');}}if(site.userIE){$("#results").stop().show();}else{$("#results").stop().show().focus();}$("#search").removeClass("load");}});}else{search.lastHash="";$("#search").removeClass("load");}};WonderSearch.prototype.clear=function(){$("#results").stop().hide();$("#data").empty();search.mouseOver=false;search.indexLength=0;search.selectedIndex=-1;search.lastHash="";$("#search").val("");};WonderSearch.prototype.setup=function(){search.clear();$("#search").keyup(this.filter).blur(function(){$("#search").removeClass("load");if(!search.mouseOver){search.clear();}}).parents("form").submit(function(){return false;});$("#results").hover(function(){search.mouseOver=true;},function(){search.mouseOver=false;});$(window).keydown(function(A){switch(A.keyCode){case 38:search.moveIndex(-1);return false;break;case 40:search.moveIndex(1);return false;break;case 13:if($("#results").is(":visible")){if(search.selectedIndex!=-1){window.location.href=$("#results li.selected").children("a").attr("href");}else{window.location.href="/view.results?phrase="+$("#search").val();}}break;}});};function WonderSite(){this.gutterOpen=false;this.currentSubpage="";this.userAgent=navigator.userAgent.toLowerCase();this.userIE=0;if(navigator.appName=="Microsoft Internet Explorer"){var A=new RegExp("msie ([0-9]{1,}[.0-9]{0,})","i");if(A.exec(this.userAgent)!=null){this.userIE=parseFloat(RegExp.$1);}}}WonderSite.prototype.setup=function(){$.preloadImages("/static/images/loader.gif");jQuery.easing.def="easeInOutExpo";$("#mainwrap").prepend("<h5 id='tag'><span>Tag</span></h5>").prepend('<div id="subpage"><div id="close">close</div><h4>Title</h4><div id="subcontent"></div></div>');$("#about").html("About");$("#mammals").html("Mammals");$("#contact").html("Contact");$("#tag span").click(function(){if(this.gutterOpen){$("#mainwrap").stop().animate({marginLeft:"0px"},800);$("#gutter").stop().css("z-index","-1").fadeOut(800,function(){$(this).removeClass("close").addClass("open");});this.gutterOpen=false;}else{$("#mainwrap").stop().animate({marginLeft:"170px"},800);$("#gutter").stop().fadeIn(800,function(){$(this).css({zIndex:"1"}).removeClass("open").addClass("close");});this.gutterOpen=true;}}).hover(function(){$(this).stop().animate({marginLeft:"-10px"},500,"easeOutElastic");if(this.gutterOpen){$(this).removeClass("open").addClass("close");}else{$(this).removeClass("close").addClass("open");}},function(){$(this).stop().animate({marginLeft:"-20px"},300,"easeOutBounce");$(this).removeClass("close").removeClass("open");});$("#close").click(function(){site.currentSubpage="";site.slideSubpage(0);$("#nav li.subon").removeClass("subon");});$("#about").click(function(){if(site.currentSubpage!="about"){$("#subcontent").html('<img src="/static/images/loader.gif" alt="Loading">');$("#nav li.subon").removeClass("subon");site.currentSubpage="about";$("#subpage").removeClass().addClass("subabout");$("#subpage h4").html("About");site.slideSubpage(170);$.getJSON("/view.page/about.rpc",function(A){if(site.currentSubpage=="about"){$("#subcontent").html(A.summary);}});$(this).addClass("subon");}return false;});$("#mammals").click(function(){if(site.currentSubpage!="mammals"){$("#subcontent").html('<img src="/static/images/loader.gif" alt="Loading">');$("#nav li.subon").removeClass("subon");site.currentSubpage="mammals";$("#subpage").removeClass().addClass("submammals");$("#subpage h4").html("Mammals");site.slideSubpage(280);$.getJSON("/view.page/mammals.rpc",function(B){if(site.currentSubpage=="mammals"){$("#subcontent").html("");for(var A=B.length-1;A>=0;A--){$("#subcontent").prepend("<em>"+B[A].name+"</em> "+B[A].summary);}}});$(this).addClass("subon");}return false;});$("#contact").click(function(){if(site.currentSubpage!="contact"){$("#subcontent").html('<img src="/static/images/loader.gif" alt="Loading">');$("#nav li.subon").removeClass("subon");site.currentSubpage="contact";$("#subpage").removeClass().addClass("subcontact");$("#subpage h4").html("Contact");site.slideSubpage(130);$.getJSON("/view.page/contact.rpc",function(A){if(site.currentSubpage=="contact"){$("#subcontent").html(A.summary);}});$(this).addClass("subon");}return false;});$(".setwrap .image img").hover(function(){var A=$(this).attr("alt");if(A.replace(" ","")==""){$(this).parents(".setwrap").find("div.caption").stop().html("");}else{$(this).parents(".setwrap").find("div.caption").stop().html("<em>Figure:</em> "+A).fadeTo(700,1,"easeInSine");}});if(PAGE_ID=="post"){$(".top .image img").hover(function(){var A=$(this).attr("alt");$(".setcap").stop().html("<em>Figure:</em> "+A).fadeTo(700,1,"easeInSine");});}$("#logo").click(function(){if(window.location.pathname=="/"){return false;}});if(PAGE_ID!="list"){$("#gridmeta, ol.grid .post a span, #relatedlist span").css({display:"block",opacity:"0.0"});$("ol.grid .post a, #relatedlist a").hover(function(){$(this).children("span").stop().animate({opacity:1},400);if(PAGE_ID=="grid"){$("#gridmeta").stop().html($(this).parent(".post").children(".gmeta").html()).animate({opacity:1},400);}},function(){$(this).children("span").stop().animate({opacity:0},400);if(PAGE_ID=="grid"){$("#gridmeta").stop().animate({opacity:0},400);}}).children("span").hyphenate();if(PAGE_ID=="grid"){$(window).scroll(function(){var A=$(window).scrollTop();if(A>48){$("#gridmeta").stop().animate({marginTop:A-48},400);}else{$("#gridmeta").stop().css("marginTop",48);}});}}site.enableSmoothScroll();};WonderSite.prototype.slideSubpage=function(A){$("#subpage").stop().animate({height:A},800);if(!site.userIE||site.userIE>=8){$("#tag").stop().animate({marginTop:A+100},800);}$("#gutter").stop().animate({marginTop:A},800);};WonderSite.prototype.enableSmoothScroll=function(){var A="html, body";$("html, body").each(function(){var B=$(this).attr("scrollTop");$(this).attr("scrollTop",B+1);if($(this).attr("scrollTop")==B+1){A=this.nodeName.toLowerCase();$(this).attr("scrollTop",B);return false;}});$("a[href^='#']").click(function(B){var D=$(this.hash).offset().top;var C=this.hash;B.preventDefault();$(A).animate({scrollTop:D},500,function(){location.hash=C;});return false;});};function isValidEmailAddress(B){var A=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return A.test(B);}jQuery.fn.hyphenate=function(B){settings=$.extend({oWidth:this.width()},B);return this.each(function(){var C="";$.each($(this).text().split(" "),function(E,D){C+=A(D)+" ";});$(this).html(C);});function A(E){if($("<span></span>").text(E).hide().appendTo(document.body).width()>settings.oWidth){var D="";var C=0;while(C<E.length){D+=(E.slice(C,++C)+"&shy;");}return D;}else{return E;}}};
