var roll_Class=function(){
     this.initialize.apply(this,arguments);
}

roll_Class.prototype={

    initialize:function(){

        this.className=arguments[0]?arguments[0]:null;
        this.foundit(arguments[1],'',false);
        this.contents=new Array('0');
        this.contents_delay=null;
        this.nowdelay=null;
        this.foundit(
            this.roll.childNodes,
            this.foundvalue,

            function(rt,that){
                case_size = that.case_size;
                if(that.constrain_size !== null) that.foundit(rt.childNodes,'IMG',function(rt,that){rt.style[(this.moving != 'left' ? 'width' : 'height')] = that.constrain_size;});
                that.contents_delay=that.contents[that.contents.length]=that.contents_delay+-rt[(that.moving=='left'?'offsetWidth':'offsetHeight')];
            }
        );

        {
            this.rollHeight=this.proll.style[(this.moving=='left'?'width':'height')]=case_size;
            this.roll.appendChild(this.roll.cloneNode(true));
        };

    },

    foundit:function(tg,n){

        var temp=new Array();

        for(var v in tg)
            switch(typeof arguments[2]){
                case 'object':if(arguments[2].initialize(tg[v],n,this)==true) return; else break;
                case 'function':if(tg[v].nodeName==n) arguments[2](tg[v],this); break;
                case 'boolean':this[v]=tg[v]; break;
                default:if(tg[v].nodeName==n) return tg[v];
            }

        return temp;

    },

    inaction:function(time){
        this.roll.style[this.moving]=time=time < 0 ?(this.fall==false && time < -Math.abs(this.contents[this.contents.length-1])?0:time):-Math.abs(this.contents[this.contents.length-1]),null;
        this.foundit(this.contents,time,{initialize:function(rt,vrt,that){if(Math.abs(rt - vrt) <(that.fast==false?that.tick:that.ftick)){that.roll.style[that.moving]=rt; that.nowdelay=that.fast==true?that.lengthen:that.delay; that.fast=false; return true;} else that.nowdelay=that.lengthen;}});
        {var ticks=this.fast==true?this.ftick:this.tick;}
        this.control=setTimeout(this.className+".inaction("+(parseInt(this.roll.style[this.moving])+(this.fall==true?ticks:-ticks))+");",this.nowdelay);

    },

    stop:function(){

        this.temp=parseInt(this.roll.style[this.moving]);
        clearTimeout(this.control);

    },

    prec:function(time) {
        con_size = this.contents[this.contents.length-1]/(this.contents.length-1);
        con_msize = parseInt(this.roll.style[this.moving]);
        con_m = con_msize % con_size;
        if (con_msize != this.contents[this.contents.length-1]) {
            if (con_m == 0) {
                con_size1 = con_msize + con_size;
            } else {
                con_size1 = con_msize + (con_size - con_m);
            }
            this.temp=this.roll.style[this.moving]=con_size1;
        } else {
            this.temp=this.roll.style[this.moving]=con_size;
        }
    },

    next:function(time) {
        con_size = this.contents[this.contents.length-1]/(this.contents.length-1);
        con_msize = parseInt(this.roll.style[this.moving]);
        con_m = con_msize % con_size;
        if (con_msize != 0) {
            if (con_m == 0) {
                con_size1 = con_msize - con_size;
            } else {
                con_size1 = con_msize - con_m;
            }
            this.temp=this.roll.style[this.moving]=con_size1;
        } else {
            this.temp=this.roll.style[this.moving]=this.contents[this.contents.length-1]-con_size;
        }
    }
};


//스크롤따라다니는 배너 시작

function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
    this.FloatingObj = FloatingObj;
    this.MarginX = (MarginX) ? MarginX : 0;
    this.MarginY = (MarginY) ? MarginY : 0;
    this.Percentage = (Percentage) ? Percentage : 20;
    this.setTime = (setTime) ? setTime : 10;
    this.FloatingObj.style.position = "absolute";
    this.Body = null;
    this.setTimeOut = null;
    this.Run();
}

Floating.prototype.Run = function () {
    if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
        this.Body = document.documentElement;
    } else {
        this.Body = document.body;
    }

    var This = this;
    var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
    var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
    var DocLeft = this.Body.scrollLeft + this.MarginX;
    var DocTop = this.Body.scrollTop + this.MarginY;

    //var MoveX = Math.abs(FloatingObjLeft - DocLeft);
    //MoveX = Math.ceil(MoveX / this.Percentage);
    var MoveY = Math.abs(FloatingObjTop - DocTop);
    MoveY = Math.ceil(MoveY / this.Percentage);

    //if (FloatingObjLeft < DocLeft) {
    //    this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
    //} else {
    //    this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
    //}

    if (FloatingObjTop < DocTop) {
        this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
    } else {
        this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
    }

    window.clearTimeout(this.setTimeOut);
    this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}

//스크롤따라다니는 배너 끝