var theTop = 0;
var old = theTop;

window.onload = function () {
    movemenu();
}

function changeBG(color,num) {
    myEl = 'quickSearchBox' + num;
    document.getElementById(myEl).style.backgroundColor=color;
}

function changeType(type,num) {
    myEl = 'quickSearchType' + num;
    document.getElementById(myEl).action = '/demo/search-' + type;
}

function movemenu() {
    //My position is relative, so some of this code will not work as expected...
    if (window.innerHeight) {
        pos = window.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
        pos = document.documentElement.scrollTop;
    }
    else if (document.body) {
        pos = document.body.scrollTop;
    }

    if (pos <= theTop) {
        pos = theTop;
    }
    else {
        pos = pos - 145;
    }
    if (pos < theTop) { 
        pos = theTop;
    }

    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight;
    if (test1 > test2) {
        //all but Explorer Mac
        bot = test1;
    }
    else {
        // Explorer Mac; would also work in Explorer 6 Strict, Mozilla and Safari
        bot = test2;
    }

    trueBot = bot - 250;
    if (document.getElementById('my_summary').offsetHeight) {
        divBot = document.getElementById('my_summary').offsetHeight; 
    }
    
    trueDivBot = divBot + pos;
    if (pos == old) {
        if ((trueDivBot > 0) && (trueBot > 0)) {
            if (trueDivBot > trueBot) {
                pos = trueBot - divBot;
            }
        }
        document.getElementById('my_summary').style.top = pos; 
    }
    old = pos;

    //And update every .25 seconds
    temp = setTimeout('movemenu()',250);
}

//window.onscroll = movemenu;
