$(window).scroll(function(){varsc=$(window).scrollTop();varrwidth=$(window).width()+$(document).scrollLeft();varrheight=$(window).height()+$(document).scrollTop();if(sc>800){$("#goTop").css("display","block");var_width=$(".progress").width()+$(".progress").offset().left+110;$("#goTop").css("right",(rwidth-_width)+"px");}else{$("#goTop").css("display","none");}});$("#goTop").click(function(){$('body,html').animate({scrollTop:0},300);});

<divid="goTop"class="goTop"></div>

.goTop{background:url(p_w_picpaths/return-top.png)no-repeat;height:32px;width:32px;position:fixed;bottom:20px;right:0;display:none;cursor:pointer;}