It looks like you're not actually returning calculated values in 3 of your functions. Try this:
//get the scrollPos
var scrollPos = function(){
return $(window).scrollTop();
};
//find the position of the top of element
var topPos = function(a){
return $(a).offset().top;
};
//find the position of the bottom of element
var bottomPos = function(a){
return $(a).offset().top + $(a).height();
};
Side Note: You may want to get ride of the return
in the window
- scroll
- else
statement?