function scrol_panels(id)
{
    this.id=id;
    this.is_scrol = 0;
    
    this.init = function()
    {
        if(!document.getElementById(this.id+"_text"))
            return;
        h2 = xHeight(this.id+"_text"); //h
        h1 = xHeight(this.id+"_text_font"); //H
        h3 = xHeight(this.id+"_panel_font"); //H_b
        
        if(h2<=h1)
        {
             document.getElementById("scrol_panel").style.display = "none";
             document.getElementById("scrol_panel").style.visibility = "hidden";
             this.is_scrol = 0;
             return;
        }
        else
        {
            document.getElementById("scrol_panel").style.display = "block";
            document.getElementById("scrol_panel").style.visibility = "visible";
            this.is_scrol = 1;
        }
        
        p_h1 = Math.ceil(h1*100/h2);
        
        h4 = Math.ceil(h3*p_h1/100);
        document.getElementById(this.id+"_panel").style.height = h4+"px";
       
        document.getElementById(this.id+"_panel").style.marginTop = "0px";
        
        xEnableDrag(this.id+"_panel", this.drag_start, this.on_drag, null);
    }
    
    this.drag_start = function(ele, mx, my)
    {
        
    }
    
    this.mousewheel = function()
    {
        if (window.event.wheelDelta >= 120)
            count=-10;
        else if (window.event.wheelDelta <= -120)
            count=10;   
        
        this.on_drag(window.event, 0, count);
    }
    
    this.down = function()
    {
        count=10;
        this.on_drag(window.event, 0, count);
        this.timer_scrol = setTimeout("scrol_on_on("+count+")", 50);
    }
    
    this.up = function()
    {
        count=-10;
        this.on_drag(window.event, 0, count);
        this.timer_scrol = setTimeout("scrol_on_on("+count+")", 50);
    }
    
    this.delete_timer_scrol = function()
    {
        clearTimeout(this.timer_scrol);
    }
    
    this.on_drag = function(ele, mdx, mdy)
    {
        if(this.is_scrol==0)
            return;
        t = parseInt(document.getElementById(scrol_obj.id+"_panel").style.marginTop);
        h = parseInt(document.getElementById(scrol_obj.id+"_panel_font").offsetHeight) - parseInt(document.getElementById(scrol_obj.id+"_panel").offsetHeight);
        //document.title=h;
        if(t>=0 & t<=h)
        {
            tt = t + mdy;
            if(mdy>0)
            {
                if(tt<=h)
                    document.getElementById(scrol_obj.id+"_panel").style.marginTop = (t + mdy) + "px";
            }
            else
            {
                if(tt>=0)
                    document.getElementById(scrol_obj.id+"_panel").style.marginTop = (t + mdy) + "px";
            }
        }
        else
        {
            if(t>h)
            {
                document.getElementById(scrol_obj.id+"_panel").style.marginTop = h+"px";
            }
            else if(t<=0)
                document.getElementById(scrol_obj.id+"_panel").style.marginTop = "0px";
        }
        
        
        t1 = parseInt(document.getElementById(scrol_obj.id+"_panel_font").offsetHeight)-parseInt(document.getElementById(scrol_obj.id+"_panel").offsetHeight);
        mtop = parseInt(document.getElementById(scrol_obj.id+"_panel").style.marginTop);
        if(mtop<0)
            mtop=0;
        x = Math.ceil(mtop*100/t1);
        if(x>100)
            x=100;
        
        t2 = parseInt(document.getElementById(scrol_obj.id+"_text_font").offsetHeight)-parseInt(document.getElementById(scrol_obj.id+"_text").offsetHeight);
        
        x2 = Math.ceil(t2*x/100);
        
        if(x2>0)
            x2 = x2*(-1);
            
        document.getElementById(scrol_obj.id+"_text").style.marginTop = x2+"px";
    }
}

function scrol_on_on(count)
{
    scrol_obj.on_drag(window.event, 0, count);
    scrol_obj.timer_scrol = setTimeout("scrol_on_on("+count+")", 50);
}
