$(window).load( function showscroll(){ $$ = function(id){return document.getElementById(id)} function addClass(o,cn){var re = new RegExp("(\\s*|^)"+cn+"\\b","g");o.className +=o.className?(re.test(o.className)?"":" "+ cn):cn} function removeClass(o,cn){var re = new RegExp("(\\s*|^)"+cn+"\\b","g");var sName = o.className;o.className = sName.replace(re,"")} window.onscroll=window.onresize=function(){ var scrTop = document.documentElement.scrollTop+document.body.scrollTop,offTop = $$("automenu").getBoundingClientRect().top+scrTop-document.documentElement.clientTop+30; if($$("floats")) scrTop>offTop?addClass($$("floats"),"addclass"):removeClass($$("floats"),"addclass"); } } )