/* jQuery Plugin Endless.js v2.1.0 | (c) 2014 totodunet, (http://totodu.net/) | Licensed under the MIT License (http://opensource.org/licenses/MIT) | Requires: jQuery 1.6.0+ */
!function(s){s.fn.scrollBottom=function(){return s(this).is(document)?s(this).height()-s(this).scrollTop()-s(window).height():s(this).prop("scrollHeight")-s(this).prop("offsetHeight")-s(this).scrollTop()},s.fn.scrollRight=function(){return s(this).is(document)?s(this).width()-s(this).scrollLeft()-s(window).width():s(this).prop("scrollWidth")-s(this).prop("offsetWidth")-s(this).scrollLeft()},s.fn.endless=function(t){var l,i,h=function(){},e={direction:"down",append:h,prepend:h,n_append:h,n_prepend:h},o=s.extend(e,t),d=s(this).height(),c=s(this).width(),r=s(this).scrollTop();s(this).is(document)?(i=s(this).scrollLeft(),"down"==o.direction||"up"==o.direction||"vertical"==o.direction?s("body").height()<=s(window).height()?(l='
'+s("body").html()+"
",s("body").css("height",s(window).height()+2)):l=''+s("body").html()+"
":s("body").width()<=s(window).width()?(l=''+s("body").html()+"
",s("body").css("width",s(window).width()+2)):l=''+s("body").html()+"
",s("body").html(l)):(i=s(this).parent().scrollLeft(),l="down"==o.direction||"up"==o.direction||"vertical"==o.direction?s(this).offset().top+s(this).height()<=s(this).parent().height()?''+s(this).html()+"
":''+s(this).html()+"
":s(this).offset().left+s(this).width()<=s(this).parent().width()?''+s(this).html()+"
":''+s(this).html()+"
",s(this).html(l)),!o.scrollbar||"enable"!=o.scrollbar&&"disable"!=o.scrollbar||("disable"==o.scrollbar?"down"==o.direction||"up"==o.direction||"vertical"==o.direction?s(this).is(document)?s("body").css("overflow-y","hidden"):s(this).css("overflow-y","hidden"):s(this).is(document)?s("body").css("overflow-x","hidden"):s(this).parent().css("overflow-x","hidden"):"right"==o.direction||"left"==o.direction||"horizontal"==o.direction?s(this).is(document)?s("body").css("overflow-y","scroll"):s(this).css("overflow-y","scroll"):s(this).is(document)?s("body").css("overflow-x","scroll"):s(this).parent().css("overflow-x","scroll"));var n=!1,p=!1;return"down"==o.direction?s(this).scroll(function(){r=d&&(s(this).is(document)?s("body").html(l):s(this).html(l),s(this).scrollTop(1),r=1,n=!1,o.n_prepend.call())):n&&s(this).scrollBottom()>=d&&(s(this).is(document)?(s("body").html(l),s(this).scrollTop(d-s(window).height()-1),r=s(this).scrollTop()):(s(this).html(l),s(this).scrollTop(d-1),r=d-1),n=!1,o.n_prepend.call())}):"up"==o.direction?s(this).scroll(function(){r>=s(this).scrollTop()?(r=s(this).scrollTop(),0==s(this).scrollTop()?(s(this).is(document)?s("body").prepend(l):s(this).prepend(l),s(this).scrollTop(d),r=s(this).scrollTop(),p=!0,o.prepend.call()):s(this).scrollBottom()>=d&&(s(this).is(document)?(s("body").html(l),s(this).scrollTop(d-s(window).height()-1),r=s(this).scrollTop()):(s(this).html(l),s(this).scrollTop(d-1),r=d-1),p=!1,o.n_append.call())):p&&s(this).scrollTop()>=d&&(s(this).is(document)?s("body").html(l):s(this).html(l),s(this).scrollTop(1),r=1,p=!1,o.n_append.call())}):"vertical"==o.direction&&s(this).scroll(function(){r=d&&(s(this).is(document)?s("body").html(l):s(this).html(l),s(this).scrollTop(1),r=1,p=!1,o.n_prepend.call())):r>=s(this).scrollTop()&&(r=s(this).scrollTop(),0==s(this).scrollTop()?(s(this).is(document)?s("body").prepend(l):s(this).prepend(l),s(this).scrollTop(d),r=s(this).scrollTop(),p=!0,o.prepend.call()):s(this).scrollBottom()>=d&&(s(this).is(document)?(s("body").html(l),s(this).scrollTop(d-s(window).height()-1),r=s(this).scrollTop()):(s(this).html(l),s(this).scrollTop(d-1),r=d-1),n=!1,o.n_append.call()))}),"right"==o.direction?s(this).is(document)?s(this).scroll(function(){i=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(1),i=1,n=!1,o.n_prepend.call())):n&&s(this).scrollRight()>=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(c-s(window).width()-1),i=s(this).scrollLeft(),n=!1,o.n_prepend.call())}):s(this).parent().scroll(function(){i=c&&(s(this).children().html(l),s(this).children().css("width",s(this).children().width()/2),s(this).scrollLeft(1),i=1,n=!1,o.n_prepend.call())):n&&s(this).scrollRight()>=0&&(s(this).children().html(l),s(this).children().css("width",s(this).children().children(".endless").width()),s(this).scrollLeft(c-1),i=c-1,n=!1,o.n_prepend.call())}):"left"==o.direction?s(this).is(document)?s(this).scroll(function(){i>=s(this).scrollLeft()?(i=s(this).scrollLeft(),0==s(this).scrollLeft()?(s("body").css("width",2*s("body").width()),s("body").children(".endless").css("float","right"),s("body").prepend(l),s("body").children(".endless:first-child").css("float","left"),s(this).scrollLeft(c),i=s(this).scrollLeft(),p=!0,o.prepend.call()):s(this).scrollRight()>=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(c-s(window).width()-1),i=s(this).scrollLeft(),p=!1,o.n_append.call())):p&&s(this).scrollLeft()>=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(1),i=1,p=!1,o.n_append.call())}):s(this).parent().scroll(function(){i>=s(this).scrollLeft()?(i=s(this).scrollLeft(),0==s(this).scrollLeft()?(s(this).children().css("width",2*s(this).children().width()),s(this).children().children(".endless").css("float","right"),s(this).children().prepend(l),s(this).children().children(".endless:first-child").css("float","left"),s(this).scrollLeft(c),i=s(this).scrollLeft(),p=!0,o.prepend.call()):s(this).scrollRight()>=c&&(s(this).children().html(l),s(this).children().css("width",s(this).children().width()/2),s(this).scrollLeft(c-1),i=c-1,p=!1,o.n_append.call())):p&&s(this).scrollLeft()>=c&&(s(this).children().html(l),s(this).children().css("width",s(this).children().width()/2),s(this).scrollLeft(1),i=1,p=!1,o.n_append.call())}):"horizontal"==o.direction&&(s(this).is(document)?s(this).scroll(function(){i=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(1),i=1,p=!1,o.n_prepend.call())):i>=s(this).scrollLeft()&&(i=s(this).scrollLeft(),0==s(this).scrollLeft()?(s("body").css("width",2*s("body").width()),s("body").children(".endless").css("float","right"),s("body").prepend(l),s("body").children(".endless:first-child").css("float","left"),s(this).scrollLeft(c),i=s(this).scrollLeft(),p=!0,o.prepend.call()):s(this).scrollRight()>=c&&(s("body").html(l),s("body").css("width",s("body").width()/2),s(this).scrollLeft(c-s(window).width()-1),i=s(this).scrollLeft(),n=!1,o.n_append.call()))}):s(this).parent().scroll(function(){i=c&&(s(this).children().html(l),s(this).children().css("width",s(this).children().width()/2),s(this).scrollLeft(1),i=1,p=!1,o.n_prepend.call())):i>=s(this).scrollLeft()&&(i=s(this).scrollLeft(),0==s(this).scrollLeft()?(s(this).children().css("width",2*s(this).children().width()),s(this).children().children(".endless").css("float","right"),s(this).children().prepend(l),s(this).children().children(".endless:first-child").css("float","left"),s(this).scrollLeft(c),i=s(this).scrollLeft(),p=!0,o.prepend.call()):s(this).scrollRight()>=c&&(s(this).children().html(l),s(this).children().css("width",s(this).children().width()/2),s(this).scrollLeft(c-1),i=c-1,n=!1,o.n_append.call()))})),this}}(jQuery);