function Scroller(jq){

    var parent = jq;
    var self = this;

    this.jq = jq;
    this.parent = parent;

    this.draggin = false;


    this.scroll = jq.find('.scroll');
    this.mask = jq.find('.mask');
    this.target = jq.find('.target');
    this.bar = jq.find('.bar');
    this.offY = 0;

    this.onMouseUp = function(){
        $(document).unbind('mouseup',self.onMouseUp);
        self.bar.removeClass('over');
        self.draggin = false;
    }


    this.bar.mousedown(function(e){
        self.draggin = true;
        $(document).bind('mouseup',self.onMouseUp);
        self.bar.addClass('over'); 

        self.offY = self.bar.offset().top - modal.mouseY;
    });

    this.onUpdate = function(){

        var maxHeight = self.scroll.height() - 30;
        
        if(self.draggin){
            
            var dif = self.scroll.offset().top - modal.mouseY;
            var mt = -dif + self.offY;
            if(mt<0) mt=0;
            if((mt) > maxHeight) { mt =maxHeight; };
                                 
            self.bar.css('margin-top',mt);
        }
        
        
        var perc = toInt(self.bar.css('margin-top')) / maxHeight;
        
        var rest = self.target.height() - self.mask.height();
        
        if(rest<=0){
            self.scroll.css('visibility','hidden');
            self.target.css('margin-top',0);
            self.bar.css('margin-top',0);
            return;
        }else{
            self.scroll.css('visibility','visible');            
        }
        
        var tmp = rest*-perc;
        if (isNaN(tmp))
            tmp = 0; 
            
        self.target.css('margin-top',tmp);
        
    }

    this.intervalCode = setInterval(this.onUpdate,35);






}
