/*
 * Modernizr v2.0.6
 * http://www.modernizr.com
 *
 * Copyright (c) 2009-2011 Faruk Ates, Paul Irish, Alex Sexton
 * Dual-licensed under the BSD or MIT licenses: www.modernizr.com/license/
 */
window.Modernizr=(function(A,c,i){var I="2.0.6",w={},y=true,L=c.documentElement,s=c.head||c.getElementsByTagName("head")[0],a="modernizr",H=c.createElement(a),E=H.style,K=c.createElement("input"),B=":)",b=Object.prototype.toString,k=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),J="Webkit Moz O ms Khtml".split(" "),G={svg:"http://www.w3.org/2000/svg"},l={},p={},f={},d=[],r,m=function(R,T,M,O){var P,N,Q,S=c.createElement("div");if(parseInt(M,10)){while(M--){Q=c.createElement("div");Q.id=O?O[M]:a+(M+1);S.appendChild(Q)}}P=["&shy;","<style>",R,"</style>"].join("");S.id=a;S.innerHTML+=P;L.appendChild(S);N=T(S,R);S.parentNode.removeChild(S);return !!N},F=function(N){if(A.matchMedia){return matchMedia(N).matches}var M;m("@media "+N+" { #"+a+" { position: absolute; } }",function(O){M=(A.getComputedStyle?getComputedStyle(O,null):O.currentStyle)["position"]=="absolute"});return M},o=(function(){var N={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};function M(O,Q){Q=Q||c.createElement(N[O]||"div");O="on"+O;var P=O in Q;if(!P){if(!Q.setAttribute){Q=c.createElement("div")}if(Q.setAttribute&&Q.removeAttribute){Q.setAttribute(O,"");P=q(Q[O],"function");if(!q(Q[O],i)){Q[O]=i}Q.removeAttribute(O)}}Q=null;return P}return M})();var j=({}).hasOwnProperty,e;if(!q(j,i)&&!q(j.call,i)){e=function(M,N){return j.call(M,N)}}else{e=function(M,N){return((N in M)&&q(M.constructor.prototype[N],i))}}function D(M){E.cssText=M}function u(N,M){return D(k.join(N+";")+(M||""))}function q(N,M){return typeof N===M}function t(N,M){return !!~(""+N).indexOf(M)}function z(O,M){for(var N in O){if(E[O[N]]!==i){return M=="pfx"?O[N]:true}}return false}function n(P,M){var N=P.charAt(0).toUpperCase()+P.substr(1),O=(P+" "+J.join(N+" ")+N).split(" ");return z(O,M)}var x=(function(P,O){var N=P.join(""),M=O.length;m(N,function(T,V){var S=c.styleSheets[c.styleSheets.length-1],R=S.cssRules&&S.cssRules[0]?S.cssRules[0].cssText:S.cssText||"",Q=T.childNodes,U={};while(M--){U[Q[M].id]=Q[M]}w.touch=("ontouchstart" in A)||U.touch.offsetTop===9;w.csstransforms3d=U.csstransforms3d.offsetLeft===9;w.generatedcontent=U.generatedcontent.offsetHeight>=1;w.fontface=/src/i.test(R)&&R.indexOf(V.split(" ")[0])===0},M,O)})(['@font-face {font-family:"font";src:url("https://")}',["@media (",k.join("touch-enabled),("),a,")","{#touch{top:9px;position:absolute}}"].join(""),["@media (",k.join("transform-3d),("),a,")","{#csstransforms3d{left:9px;position:absolute}}"].join(""),['#generatedcontent:after{content:"',B,'";visibility:hidden}'].join("")],["fontface","touch","csstransforms3d","generatedcontent"]);l.flexbox=function(){function O(S,U,T,R){U+=":";S.style.cssText=(U+k.join(T+";"+U)).slice(0,-U.length)+(R||"")}function M(S,U,T,R){S.style.cssText=k.join(U+":"+T+";")+(R||"")}var Q=c.createElement("div"),P=c.createElement("div");O(Q,"display","box","width:42px;padding:0;");M(P,"box-flex","1","width:10px;");Q.appendChild(P);L.appendChild(Q);var N=P.offsetWidth===42;Q.removeChild(P);L.removeChild(Q);return N};l.canvas=function(){var M=c.createElement("canvas");return !!(M.getContext&&M.getContext("2d"))};l.canvastext=function(){return !!(w.canvas&&q(c.createElement("canvas").getContext("2d").fillText,"function"))};l.webgl=function(){return !!A.WebGLRenderingContext};l.touch=function(){return w.touch};l.geolocation=function(){return !!navigator.geolocation};l.postmessage=function(){return !!A.postMessage};l.websqldatabase=function(){var M=!!A.openDatabase;return M};l.indexedDB=function(){for(var N=-1,M=J.length;++N<M;){if(A[J[N].toLowerCase()+"IndexedDB"]){return true}}return !!A.indexedDB};l.hashchange=function(){return o("hashchange",A)&&(c.documentMode===i||c.documentMode>7)};l.history=function(){return !!(A.history&&history.pushState)};l.draganddrop=function(){return o("dragstart")&&o("drop")};l.websockets=function(){for(var N=-1,M=J.length;++N<M;){if(A[J[N]+"WebSocket"]){return true}}return"WebSocket" in A};l.rgba=function(){D("background-color:rgba(150,255,150,.5)");return t(E.backgroundColor,"rgba")};l.hsla=function(){D("background-color:hsla(120,40%,100%,.5)");return t(E.backgroundColor,"rgba")||t(E.backgroundColor,"hsla")};l.multiplebgs=function(){D("background:url(https://),url(https://),red url(https://)");return/(url\s*\(.*?){3}/.test(E.background)};l.backgroundsize=function(){return n("backgroundSize")};l.borderimage=function(){return n("borderImage")};l.borderradius=function(){return n("borderRadius")};l.boxshadow=function(){return n("boxShadow")};l.textshadow=function(){return c.createElement("div").style.textShadow===""};l.opacity=function(){u("opacity:.55");return/^0.55$/.test(E.opacity)};l.cssanimations=function(){return n("animationName")};l.csscolumns=function(){return n("columnCount")};l.cssgradients=function(){var O="background-image:",N="gradient(linear,left top,right bottom,from(#9f9),to(white));",M="linear-gradient(left top,#9f9, white);";D((O+k.join(N+O)+k.join(M+O)).slice(0,-O.length));return t(E.backgroundImage,"gradient")};l.cssreflections=function(){return n("boxReflect")};l.csstransforms=function(){return !!z(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};l.csstransforms3d=function(){var M=!!z(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);if(M&&"webkitPerspective" in L.style){M=w.csstransforms3d}return M};l.csstransitions=function(){return n("transitionProperty")};l.fontface=function(){return w.fontface};l.generatedcontent=function(){return w.generatedcontent};l.video=function(){var O=c.createElement("video"),M=false;try{if(M=!!O.canPlayType){M=new Boolean(M);M.ogg=O.canPlayType('video/ogg; codecs="theora"');var N='video/mp4; codecs="avc1.42E01E';M.h264=O.canPlayType(N+'"')||O.canPlayType(N+', mp4a.40.2"');M.webm=O.canPlayType('video/webm; codecs="vp8, vorbis"')}}catch(P){}return M};l.audio=function(){var N=c.createElement("audio"),M=false;try{if(M=!!N.canPlayType){M=new Boolean(M);M.ogg=N.canPlayType('audio/ogg; codecs="vorbis"');M.mp3=N.canPlayType("audio/mpeg;");M.wav=N.canPlayType('audio/wav; codecs="1"');M.m4a=N.canPlayType("audio/x-m4a;")||N.canPlayType("audio/aac;")}}catch(O){}return M};l.localstorage=function(){try{return !!localStorage.getItem}catch(M){return false}};l.sessionstorage=function(){try{return !!sessionStorage.getItem}catch(M){return false}};l.webworkers=function(){return !!A.Worker};l.applicationcache=function(){return !!A.applicationCache};l.svg=function(){return !!c.createElementNS&&!!c.createElementNS(G.svg,"svg").createSVGRect};l.inlinesvg=function(){var M=c.createElement("div");M.innerHTML="<svg/>";return(M.firstChild&&M.firstChild.namespaceURI)==G.svg};l.smil=function(){return !!c.createElementNS&&/SVG/.test(b.call(c.createElementNS(G.svg,"animate")))};l.svgclippaths=function(){return !!c.createElementNS&&/SVG/.test(b.call(c.createElementNS(G.svg,"clipPath")))};function C(){w.input=(function(O){for(var N=0,M=O.length;N<M;N++){f[O[N]]=!!(O[N] in K)}return f})("autocomplete autofocus list placeholder max min multiple pattern required step".split(" "));w.inputtypes=(function(P){for(var O=0,N,R,Q,M=P.length;O<M;O++){K.setAttribute("type",R=P[O]);N=K.type!=="text";if(N){K.value=B;K.style.cssText="position:absolute;visibility:hidden;";if(/^range$/.test(R)&&K.style.WebkitAppearance!==i){L.appendChild(K);Q=c.defaultView;N=Q.getComputedStyle&&Q.getComputedStyle(K,null).WebkitAppearance!=="textfield"&&(K.offsetHeight!==0);L.removeChild(K)}else{if(/^(search|tel)$/.test(R)){}else{if(/^(url|email)$/.test(R)){N=K.checkValidity&&K.checkValidity()===false}else{if(/^color$/.test(R)){L.appendChild(K);L.offsetWidth;N=K.value!=B;L.removeChild(K)}else{N=K.value!=B}}}}}p[P[O]]=!!N}return p})("search tel url email datetime date month week time datetime-local number range color".split(" "))}for(var v in l){if(e(l,v)){r=v.toLowerCase();w[r]=l[v]();d.push((w[r]?"":"no-")+r)}}w.input||C();w.addTest=function(N,O){if(typeof N=="object"){for(var M in N){if(e(N,M)){w.addTest(M,N[M])}}}else{N=N.toLowerCase();if(w[N]!==i){return}O=typeof O=="boolean"?O:!!O();L.className+=" "+(O?"":"no-")+N;w[N]=O}return w};D("");H=K=null;if(A.attachEvent&&(function(){var M=c.createElement("div");M.innerHTML="<elem></elem>";return M.childNodes.length!==1})()){(function(S,ad){S.iepp=S.iepp||{};var T=S.iepp,ac=T.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",N=ac.split("|"),ab=N.length,aa=new RegExp("(^|\\s)("+ac+")","gi"),Z=new RegExp("<(/*)("+ac+")","gi"),R=/^\s*[\{\}]\s*$/,M=new RegExp("(^|[^\\n]*?\\s)("+ac+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),P=ad.createDocumentFragment(),X=ad.documentElement,U=X.firstChild,V=ad.createElement("body"),Q=ad.createElement("style"),Y=/print|all/,W;function O(af){var ae=-1;while(++ae<ab){af.createElement(N[ae])}}T.getCSS=function(ai,ag){if(ai+""===i){return""}var af=-1,ae=ai.length,aj,ah=[];while(++af<ae){aj=ai[af];if(aj.disabled){continue}ag=aj.media||ag;if(Y.test(ag)){ah.push(T.getCSS(aj.imports,ag),aj.cssText)}ag="all"}return ah.join("")};T.parseCSS=function(af){var ae=[],ag;while((ag=M.exec(af))!=null){ae.push(((R.exec(ag[1])?"\n":ag[1])+ag[2]+ag[3]).replace(aa,"$1.iepp_$2")+ag[4])}return ae.join("\n")};T.writeHTML=function(){var af=-1;W=W||ad.body;while(++af<ab){var ag=ad.getElementsByTagName(N[af]),ah=ag.length,ae=-1;while(++ae<ah){if(ag[ae].className.indexOf("iepp_")<0){ag[ae].className+=" iepp_"+N[af]}}}P.appendChild(W);X.appendChild(V);V.className=W.className;V.id=W.id;V.innerHTML=W.innerHTML.replace(Z,"<$1font")};T._beforePrint=function(){Q.styleSheet.cssText=T.parseCSS(T.getCSS(ad.styleSheets,"all"));T.writeHTML()};T.restoreHTML=function(){V.innerHTML="";X.removeChild(V);X.appendChild(W)};T._afterPrint=function(){T.restoreHTML();Q.styleSheet.cssText=""};O(ad);O(P);if(T.disablePP){return}U.insertBefore(Q,U.firstChild);Q.media="print";Q.className="iepp-printshim";S.attachEvent("onbeforeprint",T._beforePrint);S.attachEvent("onafterprint",T._afterPrint)})(A,c)}w._version=I;w._prefixes=k;w._domPrefixes=J;w.mq=F;w.hasEvent=o;w.testProp=function(M){return z([M])};w.testAllProps=n;w.testStyles=m;w.prefixed=function(M){return n(M,"pfx")};L.className=L.className.replace(/\bno-js\b/,"")+(y?" js "+d.join(" "):"");return w})(this,this.document);(function(){if("position" in document.createElement("progress")){return}var c=Object.defineProperty,b=true;if(!c){if("__defineSetter__" in document.body){c=function(m,i,e){m.__defineGetter__(i,e.get);if(e.set){m.__defineSetter__(i,e.set)}}}else{c=function(m,i,e){m[i]=e.get()},b=false}}try{[].slice.apply(document.images);var a=function(e){return[].slice.apply(e)}}catch(k){var a=function(o){var m=[],e=o.length;for(var n=0;n<e;n++){m[n]=o[n]}return m}}var j=(function(){var i=document.createElement("div");i.foo="bar";return i.getAttribute("foo")==="bar"})();var d=window.ProgressPolyfill={DOMInterface:{max:{get:function(){return parseFloat(this.getAttribute("aria-valuemax"))||1},set:function(e){this.setAttribute("aria-valuemax",e);if(!j){this.setAttribute("max",e)}d.redraw(this)}},value:{get:function(){return parseFloat(this.getAttribute("aria-valuenow"))||0},set:function(e){this.setAttribute("aria-valuenow",e);if(!j){this.setAttribute("value",e)}d.redraw(this)}},position:{get:function(){return this.hasAttribute("aria-valuenow")?this.value/this.max:-1}},labels:{get:function(){var e=this.parentNode;while(e&&e.nodeName!=="LABEL"){e=e.parentNode}var m=e?[e]:[];if(this.id&&document.querySelectorAll){var i=a(document.querySelectorAll('label[for="'+this.id+'"]'));if(i.length){m=m.concat(i)}}return m}}},redraw:function l(e){if(d.isInited(e)){d.init(e)}else{if(!j){e.setAttribute("aria-valuemax",parseFloat(e.getAttribute("max"))||1);if(e.hasAttribute("value")){e.setAttribute("aria-valuenow",parseFloat(e.getAttribute("value"))||0)}else{e.removeAttribute("aria-valuenow")}}}if(e.position!==-1){e.style.paddingRight=e.offsetWidth*(1-e.position)+"px"}},isInited:function(e){return e.getAttribute("role")==="progressbar"},init:function(e){if(d.isInited(e)){return}e.setAttribute("role","progressbar");e.setAttribute("aria-valuemin","0");e.setAttribute("aria-valuemax",parseFloat(e.getAttribute("max"))||1);if(e.hasAttribute("value")){e.setAttribute("aria-valuenow",parseFloat(e.getAttribute("value"))||0)}for(var i in d.DOMInterface){c(e,i,{get:d.DOMInterface[i].get,set:d.DOMInterface[i].set})}d.redraw(e)},progresses:document.getElementsByTagName("progress")};for(var f=d.progresses.length-1;f>=0;f--){d.init(d.progresses[f])}if(document.addEventListener){document.addEventListener("DOMAttrModified",function(e){var m=e.target,i=e.attrName;if(m.nodeName==="PROGRESS"&&(i==="max"||i==="value")){d.redraw(m)}},false);document.addEventListener("DOMNodeInserted",function(e){var i=e.target;if(i.nodeName==="PROGRESS"){d.init(i)}},false)}})();var upload={};upload.file_was_selected=function(){if($("#id_epub")[0].files){$.each($("#id_epub")[0].files,function(b,c){if(c){var a=0;if(c.size>1024*1024){a=(Math.round(c.size*100/(1024*1024))/100).toString()+"MB"}else{a=(Math.round(c.size*100/1024)/100).toString()+"KB"}}})}};upload.handle_drag_enter=function(a){a.stopPropagation();a.preventDefault();greybox.hide("file-upload-window");greybox.show("drag-upload-window");var b=$("#epub-drag-upload")[0];b.addEventListener("drop",upload.prep_dropped_files_for_upload,false);b.addEventListener("dragover",function(c){c.stopPropagation();c.preventDefault()},false)};upload.prep_dropped_files_for_upload=function(a){a.stopPropagation();a.preventDefault();var b=a.dataTransfer.files;upload.upload_files(a,b);return false};upload.upload_files=function(a,d){var c=d||$("#id_epub")[0].files;if(c&&FormData){var b=new FormData();$.each(c,function(f,i){b.append("epub",i)});if(d){$("#epub-drag-upload-label").css("opacity","0.2");$("#epub-drag-upload-status").text("Uploading...");$("#drag-upload-window img").show().addClass("loading")}else{$("#epub-file-upload-label").css("opacity","0.2");$(".upload-add-button").val("Uploading...")}var e=new XMLHttpRequest();e.upload.addEventListener("progress",upload.progress,false);e.addEventListener("load",upload.complete,false);e.addEventListener("error",upload.failed,false);e.addEventListener("abort",upload.cancelled,false);e.open("POST","/library/upload/");e.setRequestHeader("X_REQUESTED_WITH","XMLHttpRequest");e.send(b);return false}};upload.progress=function(a){if(a.lengthComputable){var b=Math.round(a.loaded*100/a.total);$("progress").attr("value",b.toString());if(b>=99){$(".upload-add-button").val("Adding to library...");$("#epub-drag-upload-status").html("Adding to library...")}}};upload.complete=function(a){var b=a.currentTarget;if(b.status===201||b.status===200){window.location="/library/"}else{upload.show_error_message(b.responseText)}};upload.failed=function(a){upload.show_error_message(a.toString())};upload.show_error_message=function(b){var a="<p>There was an error attempting to upload the file(s):</p><blockquote>"+b+"</blockquote>";if($("#epub-drag-upload-status:visible").exists()){$("#epub-drag-upload-status").html(a+"<p>You can try dragging in a different file, or click outside this window to close it.</p>");$("#drag-upload-window img").hide()}else{$("#epub-file-upload-status").html(a);$(".upload-add-button").val("Add")}$("progress").attr("value",0);$("#GB_overlay").click(function(){window.location="/library/"})};upload.cancelled=function(a){h.debug("The upload has been canceled by the user or the browser dropped the connection.")};$("#id_epub").bind("change",upload.file_was_selected);$("#epub-upload").bind("submit",upload.upload_files);if("FileReader" in window&&Modernizr.draganddrop){$("#epub-upload p").show();var drag_zone=$(".wrap1")[0];drag_zone.addEventListener("dragenter",upload.handle_drag_enter,false);var body=$("body")[0];body.addEventListener("dragover",function(a){a.stopPropagation();a.preventDefault();return false},false);body.addEventListener("drop",function(a){a.stopPropagation();a.preventDefault();return false},false)}if(!g.DEBUG){g.DEBUG=false}if(!g.TESTING){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_ios=g.is_iphone||g.is_ipad;g.is_android=navigator.appVersion.indexOf("Android")!==-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=false;g.is_online=null;g.screen={};g.pagination_implementations={};g.position_implementations={};g.PAGINATION_IMPLEMENTATION="columns";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.7";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.LOADING_DELAY=2000;g.MAX_NUM_ITEMS_IN_BOOK_LIST=25;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('"+MEDIA_URL+"images/paper-grain.png')";g.HREF_SEPARATOR=";";g.PAGINATION_HINT_DISPLAY_MS=500;g.IS_WEB_INTERFACE=false;g.WEB_LIBRARY_LABEL=gettext("Online Bookshelf");g.POSITION_UPDATE_INTERVAL=30*1000;g.SHORT_DATE_FORMAT="%b %e";g.LONG_DATE_FORMAT="%B %e %Y";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)};h.date_from_iso=function(a){return new Date(a.replace(/-/g,"/").replace(/[TZ]/g," "))};jQuery.fn.exists=function(){return jQuery(this).length>0};jQuery.fn.reverse=[].reverse;g.NO_QUOTES_R=/^["'](.+)["']$/;g.noquotes=function(a){return a.replace(g.NO_QUOTES_R,"$1")};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);g.pagination.change_orientation();g.MAX_IMAGE_HEIGHT=Math.floor(g.VIEWPORT_HEIGHT*0.8);$("#book").css("height",g.VIEWPORT_HEIGHT+"px");$("#body-container").css("width",g.VIEWPORT_WIDTH);$("#body-container").css("height",g.VIEWPORT_HEIGHT);$("#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)})}
/*
 * 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};
/*
 * Copyright (c) 2010 Nick Galbreath
 * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */
var base64={};base64.PADCHAR="=";base64.ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";base64.makeDOMException=function(){var c,b;try{return new DOMException(DOMException.INVALID_CHARACTER_ERR)}catch(b){var a=new Error("DOM Exception 5");a.code=a.number=5;a.name=a.description="INVALID_CHARACTER_ERR";a.toString=function(){return"Error: "+a.name+": "+a.message};return a}};base64.getbyte64=function(c,b){var a=base64.ALPHA.indexOf(c.charAt(b));if(a===-1){throw base64.makeDOMException()}return a};base64.decode=function(d){d=""+d;var j=base64.getbyte64;var f,c,e;var b=d.length;if(b===0){return d}if(b%4!==0){throw base64.makeDOMException()}f=0;if(d.charAt(b-1)===base64.PADCHAR){f=1;if(d.charAt(b-2)===base64.PADCHAR){f=2}b-=4}var a=[];for(c=0;c<b;c+=4){e=(j(d,c)<<18)|(j(d,c+1)<<12)|(j(d,c+2)<<6)|j(d,c+3);a.push(String.fromCharCode(e>>16,(e>>8)&255,e&255))}switch(f){case 1:e=(j(d,c)<<18)|(j(d,c+1)<<12)|(j(d,c+2)<<6);a.push(String.fromCharCode(e>>16,(e>>8)&255));break;case 2:e=(j(d,c)<<18)|(j(d,c+1)<<12);a.push(String.fromCharCode(e>>16));break}return a.join("")};base64.getbyte=function(c,b){var a=c.charCodeAt(b);if(a>255){throw base64.makeDOMException()}return a};base64.encode=function(e){if(arguments.length!==1){throw new SyntaxError("Not enough arguments")}var b=base64.PADCHAR;var j=base64.ALPHA;var f=base64.getbyte;var d,k;var a=[];e=""+e;var c=e.length-e.length%3;if(e.length===0){return e}for(d=0;d<c;d+=3){k=(f(e,d)<<16)|(f(e,d+1)<<8)|f(e,d+2);a.push(j.charAt(k>>18));a.push(j.charAt((k>>12)&63));a.push(j.charAt((k>>6)&63));a.push(j.charAt(k&63))}switch(e.length-c){case 1:k=f(e,d)<<16;a.push(j.charAt(k>>18)+j.charAt((k>>12)&63)+b+b);break;case 2:k=(f(e,d)<<16)|(f(e,d+1)<<8);a.push(j.charAt(k>>18)+j.charAt((k>>12)&63)+j.charAt((k>>6)&63)+b);break}return a.join("")}
/* Thanks John Resig et al: http://ejohn.org/blog/javascript-array-remove/ 
 * Array Remove - By John Resig (MIT Licensed)
 */
;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:gettext("January February March April May June July August September October November December").split(" "),ABBR_MONTHNAMES:gettext("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec").split(" "),DAYNAMES:gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" "),ABBR_DAYNAMES:gettext("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;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_epub_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(gettext("Search..."))}if(b){$("#results-header").text(g.WEB_LIBRARY_LABEL).show();$("#results-subheader").text(gettext("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(gettext("No items were found in this catalog.")).show();$("#results-subheader").empty()}jQuery.each(a.items,function(k,q){var o="";if(q.epub){o="#acquire:"+q.epub}else{if(q.subcatalog){o="#opds:"+q.subcatalog}}var j=$('<li class="catalog-item"/>');var u=q.title;var p=$('<a class="catalog-item"/>');var e=q.thumbnail;if(u.length>g.ELIDE_TITLE_THRESHOLD){p.addClass("small-title");p.text(u.substring(0,60));$('<span class="elide">').text(". . .").appendTo(p)}else{if(u.length>g.SHRINK_TITLE_THRESHOLD){p.text(u);p.addClass("small-title")}else{p.text(u)}}if(e){var n=$('<a class="catalog-item">').addClass("img-holder");if(q.epub||q.subcatalog){n.attr("href",o)}else{n.click(function(){alert(gettext("Sorry! This book cannot be opened because it does not have an EPUB version available."))})}if(e.substring(0,5)==="data:"){$('<img class="feed-thumbnail" width="'+g.ICON_WIDTH+'">').attr("src",e).appendTo(n)}else{var s="/nest/image-proxy/?image="+encodeURIComponent(q.thumbnail);$('<img class="feed-thumbnail" width="'+g.ICON_WIDTH+'">').attr("src",s).appendTo(n)}n.appendTo(j)}else{p.addClass("no-icon")}if(q.author){$('<span class="author">').text(q.author).appendTo(p)}if(b){var r={updated:h.date_from_iso(q.updated).strftime(g.LONG_DATE_FORMAT)};$('<span class="date">').text(interpolate(gettext("Added on %(updated)s"),r,true)).appendTo(p)}if(g.is_ipad){if(q.date){var f=interpolate(gettext("Published: %(date)s"),q,true);$('<span class="date">').text(f).appendTo(p)}if(q.publisher){$('<span class="publisher">').text(q.publisher).appendTo(p)}if(q.description){var m=q.description;if(m.length>g.ELIDE_DESCRIPTION_THRESHOLD){m=m.substring(0,g.ELIDE_DESCRIPTION_THRESHOLD)+" . . . "}$('<span class="summary">').text(m).appendTo(p)}}if(q.epub||q.subcatalog){p.attr("href",o)}else{p.click(function(){alert(gettext("Sorry! This book cannot be opened because it does not have an EPUB version available."))})}p.appendTo(j);j.appendTo("#results")});var c={length:$("#results li").length,search_results:a.search_results};var d;if(c.search_results>c.length){d=interpolate(gettext("Showing the first %(length)s results out of %(search_results)s."),c,true);$("#results-header").text(d).show()}else{if(c.search_results!==""&&c.search_results>1){d=interpolate(gettext("%(length)s items were found for your search."),c,true);$("#results-header").text(d).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");var b="/nest/catalogs/list/";var a=api.user_email();if(a){b=api.user_catalogs_api_url(a)}jQuery.ajax({url:b,success:catalogs.get_catalog_list_handler,error:function(e,c,d){alert(gettext("Unable to retrieve the list of catalogs."));h.debug("Could not load catalog:"+d)},type:"GET",dataType:"json"})};catalogs.JFeedItem=function(a,b){this.create(a,b)};catalogs.JFeedItem.prototype={title:"",link:"",description:"",updated:"",id:"",subcatalog:"",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/image/thumbnail"]').attr("href");this.cover=a.find('link[rel="http://opds-spec.org/image"]').attr("href");this.description=a.find("summary").text();if(!this.description){this.description=a.find('content[type="text"]').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.subcatalog=a.find('link[type^="application/atom+xml"][rel!="alternate"]').attr("href");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("summary: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(gettext("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(c,a){h.debug("updating hash with "+c+" and "+a);var b;if(!c){b=""}else{if(!a){b=c}else{b=c+":"+a}}document.location.hash=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 greybox={};greybox.maximum_width_percentage=0.8;greybox.maxium_height_percentage=0.8;greybox.initialized=false;greybox.hide=function(){$(".greybox, #GB_overlay").hide()};greybox.show=function(b){var a=$(document).height();var c=$(document).width();if(!greybox.initialized){$(document.body).append("<div id='GB_overlay'></div>");$("#GB_overlay").click(greybox.hide);greybox.initialized=true}$("#GB_overlay").css("height",a+"px").show();$("#"+b).show()};var ibis={};ibis.add_load_from_url_button=function(){};$(document).ready(function(){if(navigator.appVersion.indexOf("MSIE")===-1){$("a.lightbox").click(function(){greybox.show("file-upload-window");return false})}});$(".close-toc").click(function(){$(".bookNav").fadeOut();$("#mobile-toc").show()});$("#mobile-toc").click(function(){$(".bookNav").fadeIn();$(this).hide()});
