"use strict";function loadingGraphic(A){A.w.append("<div class='loading initial' id='loading'><img src='/images/oneclick/processing.gif' class='processing' alt='processing'><h3>please stand by...</h3></div>");A.w.fadeIn("1000")}function rearrangeMargins(B){var C=parseInt($(B).parents("div.bookModule").width(),10),D=parseInt($(B).width(),10),A=Math.round((C-D)/2);$(B).parents("div.ds1").hide().css("marginLeft",(A-4)).fadeIn(50)}function showTab(){if(document.getElementById&&document.createElement){if($("#featured").get(0)){$("#featured li a").click(function(){var C,A=$(this).parents("li").attr("id"),B=A.substring(8);$("#featured a").removeClass("selected");$(this).addClass("selected");$("#featuredReviews div.featuredBook").addClass("noshow");B="#featuredBook"+B;$(B).removeClass("noshow");C=$(B+" img.shadow");rearrangeMargins(C);return false})}}}$(function(){showTab()});function isClicked(){$("#continue").click(function(){$("a.dlmCheck").unbind();$("#dlm").hide();$(".jqmOverlay").hide();$("#eMusicRemote").hide();$("#whyDlm").hide()})}function subscribeBook(){if(document.getElementById("upsellModal")!==null){$("#upsellTitle").hide();$("#upsellContainer").hide();$("#upsellClose").hide();$("#upsellLoading").show()}var A=1;$.ajax({async:false,type:"POST",url:"/remote/upsellBook.html",data:"mode=subscribe&r="+Math.random(),success:function(D){var B=D.split(","),F="credit ",C=" &amp; ",E="";if(A===1){A=2;$("#upsellClose").show();$("#upsellLoading").hide();if(parseInt(B[0],10)===1){$("#newBookDownloads").append(B[1]);$("#newBookPlanName").append(B[2]);$("#upsellSuccess").show();if(parseInt(B[1],10)!==1){F="credits "}if($("#downloadCount").html()===null){C="";E=" remaining"}$("span.downloadHeaderUpdate").after(C+"<span id='bookDownloadCount'>"+B[1]+"</span> audiobook "+F+E);$("#bookDownloadCount").css({color:"yellow",fontSize:12,fontWeight:"bold"});$("img.freeAudiobook").attr({src:"/images/audiobooks/btn-download_audiobook.png",height:"19",width:"118",className:"downloadAudiobook"})}else{if(parseInt(B[0],10)===2){$("#upsellError").show()}else{$("#ccError").show()}}}},error:function(C,D,B){$("#upsellClose").show();$("#upsellLoading").hide();$("#upsellError").show()}})}function subscribe(A){$("#subscribeBook input").click(function(){subscribeBook();return false})}function checkAS(){if($("span.credits").html()==="1"){var B,D=window.location.href.substring(1+window.location.href.lastIndexOf("/"),window.location.href.lastIndexOf(".")),A={type:"POST",dataType:"text",async:false,url:"/remote/checkdlb.html?bookID="+D,data:Math.random()},C=$.ajax(A).responseText;if(C==="red"){B="/remote/upsellBook.html?r="+Math.random();$("body").append("<div id='upsellModal' class='upsellWindow' style='display:none;'></div>");$("#upsellModal").jqm({onShow:loadingGraphic,ajax:B,modal:true,onLoad:subscribe}).jqmShow();return false}}return true};