var ts_scrollTo={clearAllSelections:function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},getWindowClientVisibleRect:function(){var t=document.documentElement,e=document.body,i=t&&t.clientWidth?t:e,o=window.pageYOffset||t.scrollTop||e.scrollTop,l=window.pageXOffset||t.scrollLeft||e.scrollLeft,n=t.clientTop||e.clientTop||0,c=l-(t.clientLeft||e.clientLeft||0),r=i.clientWidth+c,s=o-n,a=i.clientHeight+s;return{left:c,top:s,right:r,bottom:a}},getScrollableElementVisibleRect:function(t){var e=t.scrollLeft-t.clientLeft,i=t.scrollTop-t.clientTop;return{left:e,top:i,right:t.clientWidth+e,bottom:t.clientHeight+i}},getCoordinates:function(t){var e=0,i=0;if(t.getBoundingClientRect){var o=this.getWindowClientVisibleRect(),l=t.getBoundingClientRect();e=Math.round(l.top+o.top),i=Math.round(l.left+o.left)}else for(;t;)e+=parseInt(t.offsetTop),i+=parseInt(t.offsetLeft),t=t.offsetParent;return{top:e,left:i,right:i+t.offsetHeight,bottom:e+t.offsetHeight}},scrollWindowVerticallyToElement:function(t){var e=this.getCoordinates(t),i=this.getWindowClientVisibleRect();e.top<i.top?window.scrollTo(i.left,e.top):e.bottom>i.bottom&&window.scrollBy(0,e.bottom-i.bottom)},scrollVerticallyToElement:function(t,e){var i;t&&t.parent&&(i=e?function(t,e){t.animate({scrollTop:e},"fast")}:function(t,e){t.scrollTop(e)},t.parents().each(function(){var e=jQuery(this),o=Math.round(t.position().top),l=o+t.innerHeight(),n=Math.round(e.position().top),c=n+e.innerHeight();o<n&&e.scrollTop()>0?i(e,e.scrollTop()-n+o):l>c&&i(e,e.scrollTop()-c+l)}),this.scrollWindowVerticallyToElement(t.get(0)))}},autopick_series={};autopick_series.can_run=function(){return"object"==typeof ts_series_info&&null!==ts_series_info},autopick_series.pick_category=function(){if(this.can_run()&&ts_series_info.category){var t=ts_series_info.category.term_id,e=jQuery("#in-category-"+t);if(e.length<1)return this.pick_category_67();ts_scrollTo.scrollVerticallyToElement(jQuery("li#category-"+t),!0),e.is(":checked")||e.trigger("click")}},autopick_series.pick_category_67=function(){if(this.can_run()&&ts_series_info.category){var t=ts_series_info.category.term_id,e=jQuery("#in-category-"+t+"-2");if(e.length<1)return alert("Cannot auto select post category");ts_scrollTo.scrollVerticallyToElement(jQuery("li#in-category-"+t+"-1"),!0),e.is(":checked")||e.trigger("click")}},autopick_series.pick_manga=function(){if(this.can_run()){var t=jQuery("select#ero_series");if(t.length<1)return alert("Cannot auto select Series");t.val(ts_series_info.ID)}},autopick_series.fill_title=function(){if(this.can_run()&&jQuery("input#title").length){var t=jQuery("label#title-prompt-text").html();jQuery("label#title-prompt-text").html(ts_series_info.post_title+""),jQuery("input#title").one("keypress",function(){this.value||(jQuery("input#title").val(ts_series_info.post_title+" "),jQuery("label#title-prompt-text").addClass("screen-reader-text").html(t))})}},autopick_series.run=function(){this.pick_category(),this.fill_title()},autopick_series.pick_manga(),jQuery(document).ready(function(){autopick_series.run()});