﻿var _Padding=175,_scrollMax=new Array(),_bnr=new Array(),_bnrTop=new Array(),_prevPos=new Array();
//_bnr[0]=document.getElementById('QuoteBox');

function Scrollinit() {
        //_bnr = document.getElementById('QuoteBox');
        _bnr[0]=document.getElementById('CallBackDiv');

        for(var i=0;i<1;i++) {
            if (screen.width > 600){
                _bnrTop[i] = _bnr[i].offsetTop;
                _scrollMax[i] = document.getElementById('MainContainer').offsetHeight+_bnrTop[i]-_bnr[i].offsetHeight-_Padding;
                _prevPos[i]=0;
            }
        }
        scrollBnr();
}

function scrollBnr() {
    if (screen.width > 600 ){
        for(var i=0;i<1;i++) {
                if (_scrollMax[i] > _bnrTop[i] && _prevPos[i] != pos()) {
                    _prevPos[i] = pos();
                    if (pos() < _scrollMax[i] && pos() > _bnrTop[i]) {
                            _bnr[i].style.top = pos() + 'px';
                    }
                    else if (pos() < _scrollMax[i]) {
                        _bnr[i].style.top = _bnrTop[i] + 'px';
                    }
                    else {
                        _bnr[i].style.top = _scrollMax[i] + 'px';
                    }
                }
                _scrollMax[i] = document.getElementById('MainContainer').offsetHeight+_bnrTop[i]-_bnr[i].offsetHeight-_Padding;
        }
        setTimeout('scrollBnr();',100);
    }

}

function pos() {
         if (window.innerHeight){
          return window.pageYOffset;
         }
         else if (document.documentElement && document.documentElement.scrollTop){
          return document.documentElement.scrollTop;
         }
         else if (document.body) {
          return document.body.scrollTop;
         }
}
window.onload = Scrollinit;
