$(window).ready(function(){ if (navigator.userAgent=="debug") { $('#nav li:first-child, #nav li:first-child a').css('width','150px'); } });//window.ready $(window).load(function(){ if (document.location.pathname=="/Team:Harvard/results") { var sidebar = document.getElementById("sidebar"); var sidebarOP = sidebar.offsetParent; var totalOffset = function(ele) { var x=0, y=0; while(ele){ x+=ele.offsetLeft; y+=ele.offsetTop; ele=ele.offsetParent; } return [x,y]; } tot = totalOffset; var offsSidebarParent = totalOffset(sidebarOP); var offsSidebar = [sidebar.offsetLeft+1, sidebar.offsetTop]; //sidebar.style.position='relative'; sidebar.isFree=0; var updateScroll = function(){ var os = window.scrollY-offsSidebarParent[1]-offsSidebar[1]; if (os>0 && !sidebar.isFree) { sidebar.style.position="fixed"; sidebar.style.top="0px"; sidebar.style.left=''+(offsSidebarParent[0]+offsSidebar[0])+'px'; sidebar.isFree=1; } else if (os<=0) { sidebar.style.position='static'; sidebar.isFree=0; } //Works on WebKit :P //Of course, gecko sucks too much to handle this one line of awesome. //sidebar.style.top=''+(os>0?os:0)+'px'; } $(window).scroll(updateScroll); $(window).resize(function(){ offsSidebarParent = totalOffset(sidebarOP); sidebar.isFree=0; updateScroll(); }); } //document.location.pathname=="/Team:Harvard/results" }) //window.load