(function(c){jQuery.fn.reverse=Array.prototype.reverse;var a={setup:function(i,j,e){i.css("position","relative");a.saveInitialPosition(j);j.each(function(o){var n=c(this);n.css({position:"absolute",left:n.data("left"),top:n.data("top")})});var k=Math.floor(i.width()/j.width()),l=k*e.rows,m=Math.ceil(j.length/k);var f={};f.currentRow=1;f.totalRows=m;f.rowCount=k;f.shownItems=l;f.rowsForPage=e.rows;i.data("config",f);i.children(":gt("+(l-1)+")").hide();j.each(function(o){var n=c(this),p=Math.ceil((o+1)/k);n.addClass("tj_row_"+p)});if($d_nav.length>0){var h=[];for(var g=0;g"))}$d_nav.html(h).find("li:first-child").addClass("active");delete h}d.setup(i,j,e)},saveInitialPosition:function(e){e.each(function(g){var f=c(this);f.data({left:f.position().left+"px",top:f.position().top+"px"})})},get_page:function(f){var e=f.data("config");return Math.ceil(e.currentRow/e.rowsForPage)},get_pages:function(f){var e=f.data("config");return Math.ceil(e.totalRows/e.rowsForPage)},has_next:function(e){return a.get_page(e)1?true:false},activateDot:function(g,f){try{c(f.navL).removeClass("disabled").addClass(a.has_prev(g)?"":"disabled");c(f.navR).removeClass("disabled").addClass(a.has_next(g)?"":"disabled");c(f.navDots).find("li").removeClass("active").end().find("li:nth-child("+a.get_page(g)+")").addClass("active")}catch(h){}}},d={setup:function(f,g,e){d[e.type.mode].setup(f,g,e)},def:{setup:function(g,h,f){var e=g.data("config");h.each(function(l){var j=c(this),n=Math.ceil((l+1)/e.rowCount),k,m=n%f.rows;if(m===1){k="0px"}else{if(m===0){k=(f.rows-1)*h.height()+"px"}else{k=(m-1)*h.height()+"px"}}j.css({top:k})})},pagination:function(l,g,k){var f=l.data("config");if((g===1&&f.currentRow+k.rows>f.totalRows)||(g===-1&&f.currentRow-k.rows<=0)){l.data("anim",false);return false}var j=[],e=[];for(var h=0;hh.totalRows)||(j===-1&&h.currentRow-e.rows<=0)){l.data("anim",false);return false}var n=[],f=[];for(var k=0;kj.totalRows)||(k===-1&&j.currentRow-e.rows<=0)){m.data("anim",false);return false}var p=[],f=[];for(var l=0;lf.rows){k=(f.rows*h.height())}j.css({top:k+"px"})})},pagination:function(k,h,e){var g=k.data("config");if((h===1&&g.currentRow+e.rows>g.totalRows)||(h===-1&&g.currentRow-1<=0)){k.data("anim",false);return false}var n=[];for(var j=0;j<=e.rows;++j){n.push(h===1?".tj_row_"+(g.currentRow+j):".tj_row_"+(g.currentRow+(j-1)))}n=n.join(",");var l;(h===1)?l=k.children(n):l=k.children(n).reverse();var m=l.length,f=0;l.each(function(q){var p=c(this),s=p.attr("class"),r={},o=g.currentRow;if(h===1){if(s==="tj_row_"+(o)){r.opacity=0}else{if(s==="tj_row_"+(o+e.rows)){r.opacity=1}}}else{if(s==="tj_row_"+(o-1)){r.opacity=1}else{if(s==="tj_row_"+(o+e.rows-1)){r.opacity=0}}}p.show();(h===1)?r.top=p.position().top-p.height()+"px":r.top=p.position().top+p.height()+"px";p.stop().animate(r,e.type.speed,e.type.easing,function(){if(parseInt(r.top)<0||parseInt(r.top)>p.height()*(e.rows-1)){p.hide()}++f;if(f===m){k.data("anim",false)}})});(h===1)?g.currentRow+=1:g.currentRow-=1;k.data("config",g);a.activateDot(k,e)}},sequpdown:{setup:function(f,g,e){d.updown.setup(f,g,e)},pagination:function(m,k,e){var j=m.data("config");if((k===1&&j.currentRow+e.rows>j.totalRows)||(k===-1&&j.currentRow-1<=0)){m.data("anim",false);return false}var p=[];for(var l=0;l<=e.rows;++l){p.push(k===1?".tj_row_"+(j.currentRow+l):".tj_row_"+(j.currentRow+(l-1)))}p=p.join(",");var f=e.type.factor,n;var g=1;if(e.type.reverse){g=-1}(k===g)?n=m.children(p):n=m.children(p).reverse();var o=n.length,h=0;n.each(function(s){var r=c(this),u=r.attr("class"),t={},q=j.currentRow;setTimeout(function(){if(k===1){if(u==="tj_row_"+(q)){t.opacity=0}else{if(u==="tj_row_"+(q+e.rows)){t.opacity=1}}}else{if(u==="tj_row_"+(q-1)){t.opacity=1}else{if(u==="tj_row_"+(q+e.rows-1)){t.opacity=0}}}r.show();(k===1)?t.top=r.position().top-r.height()+"px":t.top=r.position().top+r.height()+"px";r.stop().animate(t,e.type.speed,e.type.easing,function(){if(parseInt(t.top)<0||parseInt(t.top)>r.height()*(e.rows-1)){r.hide()}++h;if(h===o){m.data("anim",false)}})},f+s*f)});(k===1)?j.currentRow+=1:j.currentRow-=1;m.data("config",j);a.activateDot(m,e)}},showhide:{setup:function(g,h,f){var e=g.data("config");h.each(function(l){var j=c(this),n=Math.ceil((l+1)/e.rowCount),k,m=n%f.rows;if(m===1){k="0px"}else{if(m===0){k=(f.rows-1)*h.height()+"px"}else{k=(m-1)*h.height()+"px"}}j.css({top:k})})},pagination:function(l,j,e){var h=l.data("config");if((j===1&&h.currentRow+e.rows>h.totalRows)||(j===-1&&h.currentRow-e.rows<=0)){l.data("anim",false);return false}var n=[],f=[];for(var k=0;kg.totalRows)||(h===-1&&g.currentRow-l.rows<=0)){m.data("anim",false);return false}var k=[],e=[];for(var j=0;jg.totalRows)||(h===-1&&g.currentRow-l.rows<=0)){m.data("anim",false);return false}var k=[],e=[];for(var j=0;j").load(function(){++i;if(i===m){a.setup(k,g,f);o.css("visibility","visible");if(j.length){j.bind("click.gridnav",function(r){clearInterval(h);if(k.data("anim")){return false}k.data("anim",true);d[f.type.mode].pagination(k,-1,f);return false})}if(l.length){l.bind("click.gridnav",function(r){clearInterval(h);if(k.data("anim")){return false}k.data("anim",true);d[f.type.mode].pagination(k,1,f);return false})}o.bind("mousewheel.gridnav",function(r,s){if(s>0){if(k.data("anim")){return false}k.data("anim",true);d[f.type.mode].pagination(k,-1,f)}else{if(k.data("anim")){return false}k.data("anim",true);d[f.type.mode].pagination(k,1,f)}return false})}}).attr("src",p.attr("src"))});function n(){if(k.data("anim")){return false}config=k.data("config");if((config.totalRows)===config.currentRow){if($backToTop===false){$backToTop=true}k.data("anim",true);d[f.type.mode].pagination(k,-1,f);return false}else{if($backToTop===true){if(config.currentRow===1){$backToTop=false;k.data("anim",true);d[f.type.mode].pagination(k,1,f)}else{k.data("anim",true);d[f.type.mode].pagination(k,-1,f)}return false}else{if($backToTop===false){k.data("anim",true);d[f.type.mode].pagination(k,1,f);return false}}}}if($timeout>0){var h=setInterval(n,$timeout);k.hover(function(){clearInterval(h)},function(){h=setInterval(n,f.type.timeout)})}})}}};c.fn.gridnav=function(e){if(b[e]){return b[e].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof e==="object"||!e){return b.init.apply(this,arguments)}else{c.error("Method "+e+" does not exist on jQuery.gridnav")}}}})(jQuery);