/**********************************************************
* onload */

function addEvent(elm,listener,fn){
    try{
        elm.addEventListener(listener,fn,false);
    }catch(e){
        elm.attachEvent("on"+listener,fn);
    }
}










/**********************************************************
* scroll box */

var moveBox = function(){this.initialize.apply(this,arguments);}

moveBox.prototype={
    obj:null,idName:null,speed:500,Interval:500,Duration:30,offsetTop:0,marginTop:0,marginBottom:0,timer:0,bkup_position:null,
    initialize:function(){
        this.obj = document.getElementById(arguments[0]);
        this.bkup_position = this.obj.style.position;
        this.obj.style.position= "absolute";
        this.offsetTop = this.obj.offsetTop;
        this.idName= arguments[0];
        if(window.addEventListener){
            window.addEventListener('scroll',this.bind(this.scrollEvent,arguments),false);
        }else if(window.attachEvent){
            window.attachEvent('onscroll',this.bind(this.scrollEvent,arguments),false);
        }
    },
    bind:function(method,arg){
        var _this=this;var _arg=(arg)?arg:[];return function(){
        method.apply(_this,_arg);
        }
    },
    scrollEvent:function(){
        var _this=this;
        var obj = _this.obj;
        var scrollTop  = document.body.scrollTop || document.documentElement.scrollTop;
        var objY;
        var y=obj.offsetTop;
        var round = Math.round;
        var speed= this.speed/1000;
        var duration=this.Duration/100;
        var h;
        //var h = scrollTop + _this.offsetTop;
        if (scrollTop  + this.marginTop>= _this.offsetTop){
        //     h = scrollTop;
             h = scrollTop + this.marginTop;
        }else{
             h = this.offsetTop;
        }
        clearInterval(_this.timer);
        _this.timer= setInterval(function(){
            y += (h - y) * speed * duration;
            if(round(y) != h){
                obj.style.top= y  + "px";
            }else{
                clearInterval(_this.timer);
                //obj.style.position = _this.bkup_position;
            }
        },1);
    }
}

function scrollBox() {
    var box1h = document.getElementById('scrollbox1').offsetHeight;
    var box2h = document.getElementById('scrollbox2').offsetHeight;
    var boxh;
    if (box1h > box2h) {
        boxh = box1h + 30;
    } else {
        boxh = box2h + 30;
    }
    document.getElementById('min5').style.paddingBottom = boxh+'px';
}
addEvent(window,"load",function(){scrollBox()});


