var g = new Gallery(); function Gallery() { this.Load = function(id,url) { $('#gallery-'+id).html(''); } this.Move = function(obj,d) { if (d == 0) { h = $(obj).next().children().height(); t = $(obj).next().children().position(); if (0 < t.top*(-1)) { $(obj).next().children().animate({'top':'+=100'}, 200); } } else { h = $(obj).prev().children().height(); t = $(obj).prev().children().position(); if (h-200 > t.top*(-1)) { $(obj).prev().children().animate({'top':'-=100'}, 200); } } } }