/*
 *  (c) 2000-2013 deviantART, Inc. All rights reserved.
 */
DWait.ready(["jms/lib/jquery/jquery.current.js","jms/lib/browser.js","jms/lib/Base.js","jms/lib/gmi.js",".domready"],function(){(function(t,i){i.GPager2=GMIBase.extend({cache:{},callbacks:{},gmiConstructor:function(){this.cache={},this.callbacks={}},gmiDestructor:function(){this.cache={},this.callbacks={}},update_to_offset:function(t){var i=t+"-"+this.gmi_args.id,o=this;return this.cache[i]?(this._update_pager(this.cache[i],t),void 0):(DiFi.pushPost("Pager","get_updated_pager_html",[t,this.gmi_args],function(n,a){n&&(o.cache[i]=a.response.content,o._update_pager(a.response.content,t))}),DiFi.send(),void 0)},_update_pager:function(i,o){var n=t(i).children();this.$.empty().append(n),t.isEmptyObject(this.callbacks)||(this._bind_clicks(),this.callbacks.on_pager_update&&this.callbacks.on_pager_update.call(this.$[0],o))},register:function(t){this.callbacks=t,this._bind_clicks()},_bind_clicks:function(){this.$.find("a.away").off("click.gpager").on("click.gpager",this._handle_click.bindTo(this))},_handle_click:function(i){return!t.isEmptyObject(this.callbacks)&&this.callbacks.on_page_click?this.callbacks.on_page_click.call(i.currentTarget,i):!0}}),t(".gotobox").hide(),i.PaginationGoto={boxesOnDisplay:{},eventHandlersSet:{},clearSuperbrowsableData:function(){i.PaginationGoto.boxesOnDisplay={},i.PaginationGoto.eventHandlersSet={}},hideGotoBox:function(o){o in i.PaginationGoto.boxesOnDisplay&&t("#"+o).fadeOut("fast",function(){delete i.PaginationGoto.boxesOnDisplay[o]})},clickDotDotDot:function(o,n){var a=t("#"+o),e=t("#"+n),c=t("#"+n+"-input"),s=a.position().left-Math.floor((e.innerWidth()-a.innerWidth())/2);n in i.PaginationGoto.boxesOnDisplay?i.PaginationGoto.boxesOnDisplay[n]===o?i.PaginationGoto.hideGotoBox(n):e.animate({left:s+"px"},"fast",function(){i.PaginationGoto.boxesOnDisplay[n]=o,c.focus()}):(e.css({left:s+"px"}),e.fadeIn("fast",function(){i.PaginationGoto.boxesOnDisplay[n]=o,c.focus()}))},calculateOffsetFromPageNumber:function(t,i,o,n){var a=!1;return!isNaN(t)&&t>0&&Math.floor(t)==t&&parseInt(o,10)>=parseInt(t,10)&&t!==i&&(a=(t-1)*n),a},errorAlert:function(){i.alert("Please enter a valid page number")},handleDotDotDotClick:function(o,n,a,e,c,s){var r=t("#"+o),l=t("#"+n),u=t("#"+n+"-input"),g=t("#"+n+"-go");if(1>g.length&&(g=t("#"+n+"-input").next()),!(n in i.PaginationGoto.eventHandlersSet)){var d="pagination-"+n;if(t(document).unbind("click."+d),t(document).bind("click."+d,function(t){t.target!=r[0]&&t.target!=l[0]&&i.PaginationGoto.hideGotoBox(n)}),l.click(function(t){t.target.id!==n+"-go"&&t.stopPropagation()}),null===g.attr("onclick")||g.attr("onclick")===void 0){var f=function(){var t=!1,o=u.val(),n=i.PaginationGoto.calculateOffsetFromPageNumber(o,a,e,s);return n!==!1&&(t=g.attr("href"),t=t.replace(RegExp(c+"="+c),c+"="+n),g.attr("href",t)),t};g.bind("mousedown.gotoboxgo, focus.gotoboxgo",function(){f()}),g.bind("click.gotoboxgo",function(t){var o=f();o===!1&&(Browser.isGecko&&u.blur(),i.PaginationGoto.errorAlert(),t.preventDefault())})}u.focus(function(){"#"==t(this).val()&&t(this).val("")}),u.blur(function(){""===t(this).val()&&t(this).val("#")}),u.keyup(function(t){var o=t.keyCode?t.keyCode:t.which;"13"==o&&g.get(0).click(),"27"==o&&i.PaginationGoto.hideGotoBox(n)}),i.PaginationGoto.eventHandlersSet[n]=!0}return o in i.PaginationGoto.eventHandlersSet||(r.removeAttr("onclick"),r.click(function(t){return i.PaginationGoto.clickDotDotDot(o,n),t.stopImmediatePropagation(),!1}),i.PaginationGoto.eventHandlersSet[o]=!0,r.click()),!1}}})(jQuery,window),window.DWait&&DWait.run("jms/lib/da.misc.widgets.pager.js")});if(window.DWait){DWait.count()}