$(document).ready(function(){setupScroll();});function setupScroll(){var loadDone=false;var theMax=0;var maxSet=false;var waitUp=false;var index=0;var bottomSpace=parseInt($("#stuff").css("marginBottom"));var theWrap="<div class='set'><\/div>";window.scrollTo(0,0);setTimeout(function(){window.scrollTo(0,0);},100);$("#loader img").animate({opacity:"1"},1000);setTimeout(startScrolly,700);function startScrolly(){if($("#stuff").height()<=(parseInt($(window).height())+bottomSpace)){loadItUp();}else{loadDone=true;}
$(window).scroll(function(event){if(($(document).height()-$(window).height())-$(window).scrollTop()<bottomSpace/1.5&&waitUp==false&&(maxSet==false||index<=theMax)&&loadDone==true){waitUp=true;setTimeout(loadItUp,100);}});}
function loadItUp(){$("#stuff").append(theWrap);$("#stuff .set:last").hide().load("set"+index+".html",function(response,status){if(status=="error"&&(maxSet==false||index<=theMax)){theMax=index-1;maxSet=true;index=0;loadItUp();}else{$("#stuff .set:last").fadeIn(800);index=(maxSet==true&&index==theMax)?0:index+1;if($("#stuff").height()<=(parseInt($(window).height())+bottomSpace)){loadItUp();}else{loadDone=true;}}
waitUp=false;});}}
