var docHeight;
var yOffSet=0;
var yOffSetTarget=0;
var prevYOffSetTarget=0;
var shift;
var counter=0;
var seno;


//Slider for the left (menu) and right (ads) panel
function startScrollTop(){
    //vertical length of the page
    docHeight = YAHOO.util.Dom.getDocumentHeight();

    //Set the "divs" vertical position in a way that can be handled by the remaining javascript code
    document.getElementById('divAds').style.top = 90 + "px";
    document.getElementById('divLeftColumn').style.top = 150 + "px";
    //document.getElementById('divHomeBanner').style.top = 0 + "px";

    //Schedule the update of the "divs" vertical position every time interval
    setInterval("scrollTop()",40);
}

//Update the vertical position of the panel divArea
//function scrollTop(minYOffSet, shiftDocHeight){
function scrollTop(){
    //initial vertical length of the page
    docHeight = YAHOO.util.Dom.getDocumentHeight();

    //Get the current vertical position and account for browser specifities
    if (navigator.appName == "Microsoft Internet Explorer") {
        yOffSetTarget = document.body.scrollTop;
    }
    else {
        yOffSetTarget = window.pageYOffset;
    }

    if(Math.abs(yOffSetTarget-prevYOffSetTarget)<5 && counter<20){
        counter+=1.0;
        counter=Math.min(counter,20.0);
        //Shift to be applied at each update
        seno = Math.sin(  counter/20.0 * Math.PI/2.0 );
        shift=(yOffSetTarget-yOffSet)*seno*seno;
        //shift=(yOffSetTarget-prevYOffSet)*Math.sqrt(counter)/5;
        //shift=(yOffSetTarget-prevYOffSet)*counter/25;
        //Apply the shift to the "div" element
        yOffSet=yOffSet+shift;

        yOffSetLeft=Math.min(Math.max(150,yOffSet),docHeight-700)+ "px";
        yOffSetAds=Math.min(Math.max(90,yOffSet),docHeight-700)+ "px";
        document.getElementById('divLeftColumn').style.top = yOffSetLeft;
        document.getElementById('divAds').style.top = yOffSetAds;

        return;
    }
    else{
        counter=0.0;
        prevYOffSetTarget=yOffSetTarget;
        return;
    }
}
