/* taken from: http://www.shopdev.co.uk/blog/text-resizing-with-jquery/#comment-1044 */
 
var sitefunctions = {
  textresize : function(){
    // show text resizing links
    var cookie_name = "yudkowsky-font-size";
    var originalFontSize = $("html body #content").css("font-size");
    // if exists load saved value, otherwise store it
    if($.cookie(cookie_name)) {
      var getSize = $.cookie(cookie_name);
      $("html body #content").css({fontSize : getSize + (getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
    } else {
      $.cookie(cookie_name, originalFontSize, {path: '/'});
    }
    // reset link
    $("#text-size-reset").click(function(e) {
      e.preventDefault();
      $("html body #content").css("font-size", originalFontSize);
      $.cookie(cookie_name, originalFontSize, {path: '/'});
    });
    
    function change_font_size_by(factor) {
      var currentFontSize = $("html body #content").css("font-size");
      var currentFontSizeNum = parseFloat(currentFontSize, 10);
      var newFontSize = currentFontSizeNum+factor;
      $("html body #content").css("font-size", newFontSize);
      $.cookie(cookie_name, newFontSize, {path: '/'});
    }
    // text "+" link
    $("#text-size-inc").click(function(e) {
      e.preventDefault();
      change_font_size_by(2);
    });
    // text "-" link
    $("#text-size-dec").click(function(e) {
      e.preventDefault();
      change_font_size_by(-2);
    });
  }
}
 
$(document).ready(function(){
    sitefunctions.textresize();
    $("#search input[name=q]").defaultvalue('Search…');
    $.each(location.search.replace(/\^?/,'').split('&'), function() {
      term = this.split('=')
      if (term[0] == 'q') { $("#search input[name=q]").val(unescape(term[1].replace(/\+/g,' '))); }
    });
})