var g={};g.DEBUG=false;g.TESTING=false;g.BASE_API_URL="/nest/api";g.BASE_API_PATH="/nest/api";g.userAgent=navigator.userAgent;g.book_id=function(a){return Base64.encode(a||"")};g.book_uri=null;g.catalog=null;g.chapter=null;g.label=null;g.bookmark_selectors={};g.book_uri_to_be_acquired=null;g.db=null;g.db_initialized=false;g.is_app=window.navigator.standalone;g.login_cookie_name="ibis_reader";g.api_cookie_name="ibis_api";g.is_iphone=navigator.appVersion.indexOf("iPhone OS ")!==-1;g.is_ipad=navigator.appVersion.indexOf("iPad")!==-1;g.is_android=navigator.appVersion.indexOf("Android")!==-1;g.is_nexus_one=navigator.appVersion.indexOf("Nexus")!==-1;g.is_droid=navigator.appVersion.indexOf("Droid")!==-1;g.is_webkit=navigator.appVersion.indexOf("WebKit")!==-1&&!g.is_iphone&&!g.is_android&&!g.is_ipad;g.is_mobile_html5_compatible=g.is_iphone||g.is_android;g.is_mobile=g.is_mobile_html5_compatible;g.supports_touch_events=g.is_android;g.is_online=null;g.screen={};g.pagination={};g.magic_horizontal_scrollbar_height_landscape=30;g.magic_horizontal_scrollbar_height_portrait=10;g.parse_xml=function(b){if(window.DOMParser){var c=new DOMParser();return c.parseFromString(b,"text/xml")}else{var a=new ActiveXObject("Microsoft.XMLDOM");a.async="false";a.loadXML(b)}};g.DB_DISPLAY_NAME="Ibis Reader offline storage";g.DB_NAME="ibisreader_1.0.1";g.DB_VERSION="1.0.4";g.IPHONE_DB_SIZE=52428800;g.ANDROID_DB_SIZE=5242880;g.DB_MAX_SIZE=g.is_iphone||g.is_ipad?g.IPHONE_DB_SIZE:g.ANDROID_DB_SIZE;g.MAX_CONTENT_LENGTH=300000;g.IBIS_BOOK_CLASS="#content";g.font_preference_style=null;g.font_preference_style_cache=null;g.FONT_NAME_DEFAULT="Georgia";g.FONT_SIZE_DEFAULT="16px";g.FONT_SIZE_STEP_VALUE=2;g.FONT_SIZE_MIN=4;g.FONT_SIZE_MAX=144;g.ORIENTATION="portrait";g.SHRINK_TITLE_THRESHOLD=60;g.ELIDE_TITLE_THRESHOLD=120;g.ELIDE_DESCRIPTION_THRESHOLD=500;g.ICON_WIDTH=g.is_ipad?75:30;g.COVER_INFO_PAGE_HEIGHT=120;g.TOP_NAV_HEIGHT=10;g.TOP_NAV_EXPANDED_HEIGHT=40;g.BOOKMARK_WIDTH=40;g.BOOKMARK_HEIGHT=40;g.TOC_NESTING_MARGIN=10;g.TOP_MARGIN=15+g.TOP_NAV_HEIGHT;g.BOTTOM_MARGIN=10;g.LAST_SELECTOR="#ibis-final-content";g.FIRST_SELECTOR=g.IBIS_BOOK_CLASS+" *:first";g.BRIGHTNESS_STEP_VALUE=25;g.BRIGHTNESS_MIN=50;g.BRIGHTNESS_MAX=255;g.DEFAULT_BOOK_BACKGROUND_IMAGE="-webkit-gradient(linear, 100% 0, 0 0, from(rgba(237,218,181,0.2)), color-stop(0.1, rgba(255,255,255,0)), color-stop(0.9, rgba(255,255,255,0)), to(rgba(237,218,181,0.2))), url('../images/paper-grain.png')";g.HREF_SEPARATOR=";";g.PAGINATION_HINT_DISPLAY_MS=500;g.IS_WEB_INTERFACE=false;g.WEB_LIBRARY_LABEL="My Online Bookshelf";g.POSITION_UPDATE_INTERVAL=30*1000;var h={};h.last_debug_time=null;h.utc_milliseconds=function(a){var b=a.getTime()+(a.getTimezoneOffset()*60000);return b};h.db_datetime_to_date=function(c){var a=c.replace(/[TZ]/g," ").replace(/\..*/,"").replace(/-/g,"/");var b=new Date(a);return b};h.utc_iso8601_to_date=function(d){var a=d.replace(/[TZ]/g," ").replace(/\..*/,"");var c=new Date();var b=a.split(" ");var e=b[0].split("-");var f=b[1].split(":");c.setUTCFullYear(e[0]);c.setUTCMonth(e[1]-1);c.setUTCDate(e[2]);c.setUTCHours(f[0]);c.setUTCMinutes(f[1]);c.setUTCSeconds(f[2]);return c};h.debug=function(a){if(g.DEBUG){h.last_debug_time=new Date().getTime();a="["+h.last_debug_time+"] "+a;if(window.console&&console.log){console.log(a)}jQuery.post("/debug/",{message:a})}};h.test=function(a){if(g.TESTING){jQuery.post("/debug/",{message:a})}};h.debug_data=function(b){var a=null;jQuery.each(b,function(c,d){if(d!==null&&d.substring!==null){a+=d.substring(1,25)+" |  "}});return a};h.debug_item=function(a){var b;jQuery.each(window.getComputedStyle(a),function(c,d){b+=d+" = "+window.getComputedStyle(a).getPropertyValue(d)+"\n"});jQuery.each(a,function(c,d){b+=c+" = "+d+"\n"});return b};h.current_datetime=function(){return new Date().strftime(Date.ISO)};jQuery.fn.exists=function(){return jQuery(this).length>0};jQuery.fn.reverse=[].reverse;g.set_orientation=function(){if(window.orientation){g.ORIENTATION=Math.abs(window.orientation)===90?"landscape":"portrait"}else{g.ORIENTATION="portrait"}$("body").attr("class",g.ORIENTATION);if(g.is_iphone&&g.ORIENTATION==="landscape"){g.VIEWPORT_HEIGHT=g.screen.width-g.magic_horizontal_scrollbar_height_landscape;h.debug("Setting special VIEWPORT_HEIGHT for iPhone in landscape to "+g.VIEWPORT_HEIGHT)}else{g.VIEWPORT_HEIGHT=g.ORIENTATION==="portrait"?g.screen.height:g.screen.width}if(g.is_ipad){g.VIEWPORT_WIDTH=window.innerWidth;g.VIEWPORT_HEIGHT=window.innerHeight;if(g.ORIENTATION==="portrait"){g.VIEWPORT_HEIGHT-=g.magic_horizontal_scrollbar_height_portrait}else{g.VIEWPORT_HEIGHT-=g.magic_horizontal_scrollbar_height_portrait}}else{g.VIEWPORT_WIDTH=g.ORIENTATION==="portrait"?g.screen.width:g.screen.height}g.MAX_IMAGE_HEIGHT=Math.floor(g.VIEWPORT_HEIGHT*0.8);$("#book").css("height",g.VIEWPORT_HEIGHT+"px");$("#turning-previous").css("height",g.VIEWPORT_HEIGHT+"px");$("#turning-next").css("height",g.VIEWPORT_HEIGHT+"px");$("#state").css("height",g.VIEWPORT_HEIGHT+g.magic_horizontal_scrollbar_height_portrait+"px");$("#state-overlay").css("height",g.VIEWPORT_HEIGHT+g.magic_horizontal_scrollbar_height_portrait+"px");g.MAX_IMAGE_WIDTH=Math.floor(g.VIEWPORT_WIDTH*0.9);$(g.IBIS_BOOK_CLASS).css("width",g.VIEWPORT_WIDTH-40+"px");h.debug("viewport height="+g.VIEWPORT_HEIGHT+" viewport width="+g.VIEWPORT_WIDTH+" body class="+$("body").attr("class")+" CSS #book width="+$("#book").width()+" CSS #content width="+$("#content").width())};g.update_orientation=function(){g.set_orientation();if(hash.parse_hash().protocol==="epub"){g.pagination.reset_pagination()}};if(g.supports_touch_events){$("#book").live("touchend click",function(a){return ibis.delegate_touch_events("#book",a,ibis.register_book_events)})}else{$("#book").bind("click",function(a){ibis.register_book_events(a)})}
/*
 * JavaScript Pretty Date
 * Copyright (c) 2008 John Resig (jquery.com)
 * Licensed under the MIT license.
 */
function prettyDate(f){var d=new Date((f||"").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\..*/,""));var c=new Date();var b=c.getTime()+(c.getTimezoneOffset()*60000);var e=((b-d.getTime())/1000);var a=Math.floor(e/86400);if(isNaN(a)||a<0){return"who knows how long ago"}else{if(a==0){return(e<60&&"just now"||e<120&&"1 minute ago"||e<3600&&Math.floor(e/60)+" minutes ago"||e<7200&&"1 hour ago"||e<86400&&Math.floor(e/3600)+" hours ago")}else{if(a==1){return"yesterday"}else{if(a<7){return a+" days ago"}else{return Math.ceil(a/7)+" weeks ago"}}}}}
/*
 * jQuery hashchange event - v1.0 - 1/9/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,i){var f=i.location,j,k=$.event.special,b="hashchange",d=$.browser,e=d.msie&&d.version<8,c="on"+b in i&&!e;function a(l){l=l||f.href;return l.replace(/^[^#]*#?(.*)$/,"$1")}$[b+"Delay"]=100;k[b]=$.extend(k[b],{setup:function(){if(c){return false}j.start()},teardown:function(){if(c){return false}j.stop()}});j=(function(){var l={},q,m,n,p;function o(){n=p=function(r){return r};if(e){m=$('<iframe src="javascript:0"/>').hide().appendTo("body")[0].contentWindow;p=function(){return a(m.document.location.href)};n=function(t,r){if(t!==r){var s=m.document;s.open().close();s.location.hash="#"+t}};n(a())}}l.start=function(){if(q){return}var s=a();n||o();(function r(){var u=a(),t=p(s);if(u!==s){n(s=u,t);$(i).trigger(b)}else{if(t!==s){f.href=f.href.replace(/#.*/,"")+"#"+t}}q=setTimeout(r,$[b+"Delay"])})()};l.stop=function(){if(!m){q&&clearTimeout(q);q=0}};return l})()})(jQuery,this);(function(c){c.fn.getPath=function(i){var i=c.extend({full:false,limit:false},i);if(typeof this.get(0).tagName==="undefined"){return false}var j=c(this).get(0),k=[],o=o?o:0,m=0,l=0,e=c(j).closest("body").length?true:false,n=false;do{if(typeof j.tagName==="undefined"){break}m++;if(i.limit&&l==i.limit){continue}l++;var f=b.apply(j);if(f){k[k.length]=f;if(!i.full){break}continue}else{f=a.apply(j)+d.apply(j)}k[k.length]=f}while(j=c(j).parent().get(0));if(!e&&m===l&&k[k.length-1]==="div"){k.splice(k.length-1,1)}return k.reverse().join(" > ")};function b(){var e=c(this).attr("id");if(e){e="#"+e}return e||""}function a(){return this.tagName.toLowerCase()}function d(){if(!this.parentNode){return""}var e=c(this.parentNode).children(this.tagName);if(e.length===1){return""}return":eq("+e.index(this)+")"}})(jQuery);jQuery.cookie=function(b,l,o){if(typeof l!="undefined"){o=o||{};if(l===null){l="";o.expires=-1}var e="";if(o.expires&&(typeof o.expires=="number"||o.expires.toUTCString)){var f;if(typeof o.expires=="number"){f=new Date();f.setTime(f.getTime()+(o.expires*24*60*60*1000))}else{f=o.expires}e="; expires="+f.toUTCString()}var n=o.path?"; path="+(o.path):"";var j=o.domain?"; domain="+(o.domain):"";var a=o.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(l),e,n,j,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var m=document.cookie.split(";");for(var k=0;k<m.length;k++){var c=jQuery.trim(m[k]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}return false};var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-=",encode:function(c){var a="";var m,k,f,l,j,e,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){m=c.charCodeAt(b++);k=c.charCodeAt(b++);f=c.charCodeAt(b++);l=m>>2;j=((m&3)<<4)|(k>>4);e=((k&15)<<2)|(f>>6);d=f&63;if(isNaN(k)){e=d=64}else{if(isNaN(f)){d=64}}a=a+this._keyStr.charAt(l)+this._keyStr.charAt(j)+this._keyStr.charAt(e)+this._keyStr.charAt(d)}return a},decode:function(c){var a="";var m,k,f;var l,j,e,d;var b=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(b<c.length){l=this._keyStr.indexOf(c.charAt(b++));j=this._keyStr.indexOf(c.charAt(b++));e=this._keyStr.indexOf(c.charAt(b++));d=this._keyStr.indexOf(c.charAt(b++));m=(l<<2)|(j>>4);k=((j&15)<<4)|(e>>2);f=((e&3)<<6)|d;a=a+String.fromCharCode(m);if(e!=64){a=a+String.fromCharCode(k)}if(d!=64){a=a+String.fromCharCode(f)}}a=Base64._utf8_decode(a);return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var d="";var f=0;var k=0;var j=0;var e=0;var b=0;while(f<a.length){k=a.charCodeAt(f);if(k<128){d+=String.fromCharCode(k);f++}else{if((k>191)&&(k<224)){e=a.charCodeAt(f+1);d+=String.fromCharCode(((k&31)<<6)|(e&63));f+=2}else{e=a.charCodeAt(f+1);b=a.charCodeAt(f+2);d+=String.fromCharCode(((k&15)<<12)|((e&63)<<6)|(b&63));f+=3}}}return d}};Array.prototype.remove=function(b,a){this.splice(b,!a||1+a-b+(!(a<0^b>=0)&&(a<0||-1)*this.length));return this.length};(function(){var a=24*60*60*1000;var e=function(k,l){k=String(k);while(k.length<l){k="0"+k}return k};var j={millisecond:1,second:1000,minute:60*1000,hour:60*60*1000,day:a,week:7*a,month:{add:function(m,k){j.year.add(m,Math[k>0?"floor":"ceil"](k/12));var l=m.getMonth()+(k%12);if(l==12){l=0;m.setYear(m.getFullYear()+1)}else{if(l==-1){l=11;m.setYear(m.getFullYear()-1)}}m.setMonth(l)},diff:function(o,m){var k=o.getFullYear()-m.getFullYear();var l=o.getMonth()-m.getMonth()+(k*12);var n=o.getDate()-m.getDate();return l+(n/30)}},year:{add:function(l,k){l.setYear(l.getFullYear()+Math[k>0?"floor":"ceil"](k))},diff:function(l,k){return j.month.diff(l,k)/12}}};for(var d in j){if(d.substring(d.length-1)!="s"){j[d+"s"]=j[d]}}var i=function(n,m){if(Date.prototype.strftime.formatShortcuts[m]){return n.strftime(Date.prototype.strftime.formatShortcuts[m])}else{var k=(Date.prototype.strftime.formatCodes[m]||"").split(".");var l=n["get"+k[0]]?n["get"+k[0]]():"";if(k[1]){l=e(l,k[1])}return l}};var c={succ:function(k){return this.clone().add(1,k)},add:function(m,l){var k=j[l]||j.day;if(typeof k=="number"){this.setTime(this.getTime()+(k*m))}else{k.add(this,m)}return this},diff:function(l,o,k){l=Date.create(l);if(l===null){return null}var m=j[o]||j.day;if(typeof m=="number"){var n=(this.getTime()-l.getTime())/m}else{var n=m.diff(this,l)}return(k?n:Math[n>0?"floor":"ceil"](n))},strftime:function(l){var n=l||"%Y-%m-%d",k="",m;while(n.length>0){if(m=n.match(Date.prototype.strftime.formatCodes.matcher)){k+=n.slice(0,m.index);k+=(m[1]||"")+i(this,m[2]);n=n.slice(m.index+m[0].length)}else{k+=n,n=""}}return k},getShortYear:function(){return this.getYear()%100},getMonthNumber:function(){return this.getMonth()+1},getMonthName:function(){return Date.MONTHNAMES[this.getMonth()]},getAbbrMonthName:function(){return Date.ABBR_MONTHNAMES[this.getMonth()]},getDayName:function(){return Date.DAYNAMES[this.getDay()]},getAbbrDayName:function(){return Date.ABBR_DAYNAMES[this.getDay()]},getDayOrdinal:function(){return Date.ORDINALNAMES[this.getDate()%10]},getHours12:function(){var k=this.getHours();return k>12?k-12:(k==0?12:k)},getAmPm:function(){return this.getHours()>=12?"PM":"AM"},getUnix:function(){return Math.round(this.getTime()/1000,0)},getGmtOffset:function(){var k=this.getTimezoneOffset()/60;var l=k<0?"+":"-";k=Math.abs(k);return l+e(Math.floor(k),2)+":"+e((k%1)*60,2)},getTimezoneName:function(){var k=/(?:\((.+)\)$| ([A-Z]{3}) )/.exec(this.toString());return k[1]||k[2]||"GMT"+this.getGmtOffset()},toYmdInt:function(){return(this.getFullYear()*10000)+(this.getMonthNumber()*100)+this.getDate()},clone:function(){return new Date(this.getTime())}};for(var b in c){Date.prototype[b]=c[b]}var f={create:function(k){if(k instanceof Date){return k}if(typeof k=="number"){return new Date(k*1000)}var p=String(k).replace(/^\s*(.+)\s*$/,"$1"),l=0,m=Date.create.patterns.length,n;var o=p;while(l<m){ms=Date.parse(o);if(!isNaN(ms)){return new Date(ms)}n=Date.create.patterns[l];if(typeof n=="function"){obj=n(o);if(obj instanceof Date){return obj}}else{o=p.replace(n[0],n[1])}l++}return NaN},MONTHNAMES:"January February March April May June July August September October November December".split(" "),ABBR_MONTHNAMES:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),DAYNAMES:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ABBR_DAYNAMES:"Sun Mon Tue Wed Thu Fri Sat".split(" "),ORDINALNAMES:"th st nd rd th th th th th th".split(" "),ISO:"%Y-%m-%dT%H:%M:%S.%N%G",SQL:"%Y-%m-%d %H:%M:%S",daysInMonth:function(k,l){if(l==2){return new Date(k,1,29).getDate()==29?29:28}return[undefined,31,undefined,31,30,31,30,31,31,30,31,30,31][l]}};for(var b in f){Date[b]=f[b]}Date.prototype.strftime.formatCodes={matcher:/()%(#?(%|[a-z]))/i,Y:"FullYear",y:"ShortYear.2",m:"MonthNumber.2","#m":"MonthNumber",B:"MonthName",b:"AbbrMonthName",d:"Date.2","#d":"Date",e:"Date",A:"DayName",a:"AbbrDayName",w:"Day",o:"DayOrdinal",H:"Hours.2","#H":"Hours",I:"Hours12.2","#I":"Hours12",p:"AmPm",M:"Minutes.2","#M":"Minutes",S:"Seconds.2","#S":"Seconds",s:"Unix",N:"Milliseconds.3","#N":"Milliseconds",O:"TimezoneOffset",Z:"TimezoneName",G:"GmtOffset"};Date.prototype.strftime.formatShortcuts={F:"%Y-%m-%d",T:"%H:%M:%S",X:"%H:%M:%S",x:"%m/%d/%y",D:"%m/%d/%y","#c":"%a %b %e %H:%M:%S %Y",v:"%e-%b-%Y",R:"%H:%M",r:"%I:%M:%S %p",t:"\t",n:"\n","%":"%"};Date.create.patterns=[[/-/g,"/"],[/st|nd|rd|th/g,""],[/(3[01]|[0-2]\d)\s*\.\s*(1[0-2]|0\d)\s*\.\s*([1-9]\d{3})/,"$2/$1/$3"],[/([1-9]\d{3})\s*-\s*(1[0-2]|0\d)\s*-\s*(3[01]|[0-2]\d)/,"$2/$3/$1"],function(n){var l=n.match(/^(?:(.+)\s+)?([1-9]|1[012])(?:\s*\:\s*(\d\d))?(?:\s*\:\s*(\d\d))?\s*(am|pm)\s*$/i);if(l){if(l[1]){var m=Date.create(l[1]);if(isNaN(m)){return}}else{var m=new Date();m.setMilliseconds(0)}var k=parseFloat(l[2]);k=l[5].toLowerCase()=="am"?(k==12?0:k):(k==12?12:k+12);m.setHours(k,parseFloat(l[3]||0),parseFloat(l[4]||0));return m}}]})();var $D=Date.create;g.IS_WEB_INTERFACE=true;g.ICON_WIDTH="inherit";g.ELIDE_DESCRIPTION_THRESHOLD=200;g.USE_CLIENT_Y_FOR_POSITION=navigator.userAgent.indexOf("Firefox")!==-1||navigator.userAgent.indexOf("Explorer")!==-1||navigator.userAgent.indexOf("Chrome")!==-1;if(g.DEBUG){g.POSITION_UPDATE_INTERVAL=1000}var ui={};ui.show_info_for_uri=function(b){$("#results li.catalog-item a").removeClass("clicking-disabled");$("#results li.catalog-item a").unbind("disable_catalog_links");var a=$("#results a[href=#info:"+b+"]");if(a.exists()){var c=a.parent();$(c).find(".summary").hide();$(c).find(".description").show().css("display","block");$(c).find(".add-epub").show()}else{h.debug("Warning: didn't find '#results a[href=#info:"+b+"]");hash.update_hash()}};ui.show_app=function(){};ui.hide_search=function(){};ui.show_global_nav=function(){};ui.hide_global_nav=function(){};ui.hide_results=function(){};ui.clear_results=function(){$("#results li").remove();$("#results-header").empty().hide();$("#results-subheader").empty().hide();$("#book-list-dropdown").hide();ui.hide_results();ui.hide_search()};ui.show_results=function(){$("#book-list-dropdown").hide();$("#results-container").show();$("#results").css("opacity",0).show().fadeTo("fast",1)};ui.show_search=function(){};ui.clear_book=function(){};ui.hide_book=function(){};ui.hide_content=function(){};ui.show_content=function(){};ui.show_book=function(){};ui.show_top_nav=function(){};ui.hide_top_nav=function(){};ui.clear_book_info=function(){};ui.show_overlay=function(a,b){};ui.hide_overlay=function(a,b){};ui.select_nav=function(a){};ui.show_loader=function(){};ui.hide_loader=function(){};ui.show_list_loader=function(){};ui.hide_list_loaders=function(){};ui.hide_welcome=function(){};ui.display_no_books=function(){};ui.display_some_books=function(){};ui.show_options=function(){};ui.show_login=function(){};ui.hide_login=function(){};ui.in_page_previous_area=function(a){};ui.in_page_next_area=function(a){};ui.location_to_percent=function(a){};ui.extent_into_label=function(a,b){};ui.pages_into_label=function(b,a){};ui.clear_nexus_nav=function(){};ui.add_reflection=function(a){};var catalogs={};catalogs.get_selected_catalog_handler=function(a,b){if(a.message){ui.hide_results();$("#error p").text(a.message);alert($("#error p").text());ui.hide_list_loaders();$("#results li.catalog-item a").removeClass("clicking-disabled");$("#results li.catalog-item a").unbind(ibis.disable_links);hash.update_hash("catalogs");return false}$("#load-more").hide();if(!a.previous){ui.clear_results();ui.clear_book_info();ui.show_global_nav();ui.show_search();$("#results-header").empty().hide();$("#results-subheader").empty().hide();$("#searchterm").val("Search...")}if(b){$("#results-header").text(g.WEB_LIBRARY_LABEL).show();$("#results-subheader").text("All the books you've uploaded on Ibis Reader:").show()}if(a.search_description){$("#search-description").val(a.search_description);$("#searchbox").show()}else{$("#searchbox").hide()}if(a.items.length===0){$("#results-header").text("No items were found in this catalog.").show();$("#results-subheader").empty()}jQuery.each(a.items,function(j,e){if(e.epub){var d=$('<li class="catalog-item"/>');var f=e.title;var c=$('<a class="catalog-item"/>');if(f.length>g.ELIDE_TITLE_THRESHOLD){c.addClass("small-title");c.text(f.substring(0,60));$('<span class="elide">').text(". . .").appendTo(c)}else{if(f.length>g.SHRINK_TITLE_THRESHOLD){c.text(f);c.addClass("small-title")}else{c.text(f)}}if(e.thumbnail){var k=$('<a class="catalog-item">').attr("href","#acquire:"+e.epub).addClass("img-holder");$('<img class="feed-thumbnail" width="'+g.ICON_WIDTH+'">').attr("src","/nest/image-proxy/?image="+e.thumbnail).appendTo(k);k.appendTo(d)}else{c.addClass("no-icon")}$('<span class="author">').text(e.author).appendTo(c);if(g.is_ipad){if(e.date){$('<span class="date">').text("Published: "+e.date).appendTo(c)}if(e.publisher){$('<span class="publisher">').text(e.publisher).appendTo(c)}if(e.description){var m=e.description;if(m.length>g.ELIDE_DESCRIPTION_THRESHOLD){m=m.substring(0,g.ELIDE_DESCRIPTION_THRESHOLD)+" . . . "}$('<span class="summary">').html(m).appendTo(c)}}c.attr("href","#acquire:"+e.epub).appendTo(d);d.appendTo("#results")}});if(a.search_results>$("#results li").length){$("#results-header").text("Showing the first "+$("#results li").length+" results out of "+a.search_results+".").show()}else{if(a.search_results!==""&&a.search_results>1){$("#results-header").text($("#results li").length+" items were found for your search.").show()}}ui.show_results();ui.hide_list_loaders();if(a.next){$("#load-more a").removeClass("clicking-disabled");$("#load-more").show()}return false};catalogs.get_selected_catalog=function(a,b){h.debug("Getting catalog "+a+" (my_web_library: "+b+")");$("#catalog-back").attr("href","#opds:"+a);if(b){h.debug("Loading My Web Library without proxy");catalogs.getCatalog({url:a,success:function(c){catalogs.get_selected_catalog_handler(c,b)}})}else{catalogs.getCatalog({url:"/nest/proxy/",data:{feed:a},success:catalogs.get_selected_catalog_handler})}return false};catalogs.get_epub_entry=function(a){catalogs.getCatalog({url:"/nest/entry/",data:{feed:a},first:true,success:function(b){ibis.get_epub_file(b.epub)},error:function(b){if(b.error){$("#error p").html(b.error);$("#error").show()}}});return false};catalogs.get_catalog_list_handler=function(e){ui.clear_results();ui.clear_book();ui.show_global_nav();for(var c in e){if(e.hasOwnProperty(c)){var d=e[c];var b=$('<li class="catalog-item"/>').appendTo("#results");var a=$("<a>");a.attr("href","#opds:"+d.fields.url);if(d.icon){$("<img>").attr("src",d.icon).appendTo(b)}else{a.addClass("no-icon")}a.appendTo(b);a.text(d.fields.name)}}ibis.add_load_from_url_button();ui.show_results()};catalogs.get_catalog_list=function(){ui.select_nav("nav-library");jQuery.ajax({url:"/nest/catalogs/list/",success:catalogs.get_catalog_list_handler,error:function(c,a,b){alert("Unable to retrieve the list of catalogs.");h.debug("Could not load catalog:"+b)},type:"GET",dataType:"json"})};catalogs.JFeedItem=function(a,b){this.create(a,b)};catalogs.JFeedItem.prototype={title:"",link:"",description:"",updated:"",id:"",epub:"",pdf:"",create:function(a,b){this.title=a.find("title:first").text();this.author=a.find("author:first name").text();this.link=a.find("link:first").attr("href");this.thumbnail=a.find('link[rel="http://opds-spec.org/thumbnail"]').attr("href");this.cover=a.find('link[rel="http://opds-spec.org/cover"]').attr("href");this.description=a.find("summary").text();this.language=a.find("language").text();this.publisher=a.find("publisher").text();this.date=a.find("issued").text();this.rights=a.find("rights").text();this.updated=a.find("updated").text();this.id=a.find("id").text();this.epub=a.find('link[type="application/epub+zip"]').attr("href");this.pdf=a.find('link[type="application/pdf"]').attr("href");this.xml=b}};catalogs.ErrorFeed=function(a){this._parse(a)};catalogs.ErrorFeed.prototype={_parse:function(a){this.message=jQuery("error",a).find("message").text()}};catalogs.JAtom=function(a){this._parse(a)};catalogs.JAtom.prototype={_parse:function(a){var b=jQuery("feed",a).eq(0);this.version="1.0";this.title=b.find("title:first").text();this.author=b.find("author:first").text();this.link=b.find("link:first").attr("href");this.self=b.find('link[rel="self"]').attr("href");this.next=b.find('link[rel="next"]').attr("href");this.previous=b.find('link[rel="previous"]').attr("href");this.search_description=b.find('link[type="application/opensearchdescription+xml"]').attr("href");this.search_results=parseInt(b.find("totalResults").text(),10);this.search_start_index=parseInt(b.find("startIndex").text(),10);if(this.self&&this.self.indexOf("http")===-1){this.self=this.base+this.self}this.description=jQuery(b).find("subtitle:first").text();this.language=jQuery(b).attr("xml:lang");this.updated=jQuery(b).find("updated:first").text();this.items=[];this.entries=[];var c=this;jQuery("entry",a).each(function(){var d=jQuery(this);var e=new catalogs.JFeedItem(d,this);c.items.push(e);c.entries[e.epub]=e})}};catalogs.Catalog=function(a){if(a){this.parse(a)}};catalogs.Catalog.prototype={type:"",version:"",title:"",link:"",next:"",description:"",epub:"",pdf:"",self:"",search_description:"",search_total:"",search_start_index:"",icon:"",parse:function(a){var b=null;if(jQuery("error",a).length===1){b=new catalogs.ErrorFeed(a)}else{if(jQuery("feed",a).length===1){b=new catalogs.JAtom(a)}else{if(jQuery("entry",a).length===1){b=new catalogs.Book(a)}}}jQuery.extend(this,b)}};catalogs.getCatalog=function(a){a=jQuery.extend({url:null,data:null,success:null,error:null},a);if(a.url){$.ajax({type:"GET",url:a.url,data:a.data,dataType:"xml",success:function(b){g.catalog=new catalogs.Catalog(b);if(jQuery.isFunction(a.success)){a.success(g.catalog,a.first)}},error:function(d,b,c){h.debug("Got error retrieving catalog: xhr was="+d.status+" status was="+b+" error was="+c.message);alert("There was a problem loading this catalog.")}})}};catalogs.catalog_item_handler=function(){$("#results li a.catalog-item").addClass("clicking-disabled");$("#results ll a.catalog-item").bind("click",ibis.disable_links);ui.show_list_loader($(this).parent());return true};$("#results li.catalog-item a").live("click",catalogs.catalog_item_handler);var hash={};hash.update_hash=function(b,a){h.debug("updating hash with "+b+" and "+a);if(b!==undefined){document.location.hash=""}document.location.hash=a!==undefined?b+":"+a:b};hash.parse_hash=function(){var a={};var b=document.location.hash.replace("#","").split(":");a.protocol=b[0];a.uri=document.location.hash.replace("#"+a.protocol+":","");return a};var GB_DONE=false;function GB_show(b,c,a,d){if(!GB_DONE){$(document.body).append("<div id='GB_overlay'></div>");$("#GB_window img").click(GB_hide);$("#GB_overlay").click(GB_hide);GB_DONE=true}$("#GB_overlay").show();if(GB_ANIMATION){$("#GB_window").slideDown("fast")}else{$("#GB_window").show()}}function GB_hide(){$("#GB_window,#GB_overlay").hide()}function GB_position(){}var ibis={};var GB_ANIMATION=true;ibis.add_load_from_url_button=function(){};jQuery(document).ready(function(){if(navigator.appVersion.indexOf("MSIE")===-1){$("a.lightbox").click(function(){var a=this.title||$(this).text()||this.href;var b=new GB_show(a,this.href,370,600);return false})}});$(".close-toc").click(function(){$(".bookNav").fadeOut();$("#mobile-toc").show()});$("#mobile-toc").click(function(){$(".bookNav").fadeIn();$(this).hide()});