var $stickyHeight = 70;
var $padding = 0;
var $topOffset = 270;
var $footerHeight = 270;

function scrollSticky(){
	if(jQuery(window).height() >= $stickyHeight) {
		var aOffset = jQuery('#floatwrap').offset();

		if(jQuery(document).height() - $footerHeight - $padding < jQuery(window).scrollTop() + $stickyHeight) {
			var $top = jQuery(document).height() - $stickyHeight - $footerHeight - $padding;
			jQuery('#floatwrap').attr('style', 'position:absolute; top:'+$top+'px;');

		}else if(jQuery(window).scrollTop() + $padding > $topOffset) {
			jQuery('#floatwrap').attr('style', 'position:fixed; top:'+$padding+'px;');

		}else{
			jQuery('#floatwrap').attr('style', 'position:absolute; top:270px; ');
		}
	}
}

jQuery(window).scroll(function(){
	scrollSticky()
});