 
 function Down(evt)
 {
     this.inUse=1;
     this.move(evt);
     //for (i=0;i<20;i++) document.writeln(evt[i]+" : "+evt[evt[i]]);
 };
 function Move(evt)
 {
    if (evt==null) evt=event;
    if (wpro=="expl" && evt.button!=1) this.inUse=0;
    src = (evt.srcElement==null?evt.target:evt.srcElement);
    //for (i=0;i<20;i++) document.writeln(src.style[i]+" : "+src.style[src.style[i]]);
    //window.status = evt.type+" "+src.id+" "+evt.button+" "+evt.which+" "+(evt.clientY-this.pomTop)+" "+(evt.screenY-this.pomTop)+" "+this.scrmover.offsetTop+" "+this.inUse;
    //window.status = " "+src.clientTop+" "+src.style[0]+" "+src.style.pixelTop+" "+src.offsetTop+" "+src.style.top+" ";
    //if (src!=this.hlp) return;  
    if (this.inUse)
    {
        ppx = evt.clientY-this.pomTop-this.scrmover.offsetHeight/2;
        //if (src==this.scrmover) ppx+=this.scrmover.style.pixelTop;
        ppx = Math.max(this.top,Math.min(ppx,this.top+this.height));
        this.scrmover.style.top = ppx;
        this.textobj.style.top=(this.top-ppx)*this.koef;
        //window.status = "moved. "+ppx;
    }
 }
 
 function ScrollBy(kolik)
 {
        var pomx = -this.textobj.offsetTop;  //style.pixelTop;
        if (this.inn.scrollTop!=0) 
        {  
           this.textobj.style.top=this.inn.scrollTop;
           this.scrmover.style.top = this.textobj.offsetTop/this.koef+this.top;
           pomx= - this.textobj.style.top;
           this.inn.scrollTop=0;

        };
 
 	if (kolik>0)
 	{
 		if (pomx+kolik<this.scrHeight-this.height*0.9) pomx += kolik
 		else pomx = this.scrHeight-this.height*0.9;
 	} else {
 		if (pomx+kolik>0) pomx += kolik
 		else pomx = 0; 
	};
 	
 	this.textobj.style.top=-pomx;
 	this.scrmover.style.top = pomx/this.koef+this.top;
 }
 
 function makeScroll(sbname)
 {
	if (this.scrmover.style.visibility=="hidden") {this.scrby=0; return; };
	if (this.scrby>0) this.scrby += 5; 
	if (this.scrby<0) this.scrby -= 5; 
	this.scrollBy(this.scrby); 
	if (this.scrby!=0) window.setTimeout(sbname+".makeScroll('"+sbname+"')",((this.scrby<10 && this.scrby>-10)?100:50));
 }
 
 
 function ScrollArea(kontejner,inn, text, scrbar, mover,pom)
 {
    this.mainobj = kontejner;
    this.textobj = text;
    this.inn = inn;
    this.scrbar = scrbar;
    this.scrmover = mover;
    this.inUse = 0;
    this.height = scrbar.offsetHeight-16;  //scrbar.style.pixelHeight-16;
    this.scrHeight = text.offsetHeight;
    if (this.scrHeight<=inn.offsetHeight)
    {
      this.koef = 1;
      this.scrmover.style.visibility="hidden";
    } else {
      this.koef = this.scrHeight/this.height-0.9;
      this.scrmover.style.visibility="visible";
    };
    this.move = Move;
    this.down = Down;
    this.scrollBy = ScrollBy;
    this.scrby = 0;
    this.top = 0;
    this.hlp = pom;
    this.makeScroll = makeScroll;
    this.scrmover.style.top = this.textobj.offsetTop/this.koef+this.top;
    ph=0;
    //pq = "";
    pp=pom;
    while (pp!=null && pp.offsetTop!=null) {
       ph+=pp.offsetTop;
       //pq += pp.id+" ";
       if (pp.parentElement!=null) pp = pp.parentElement;
       else pp=pp.__parent__;
    };
    this.pomTop = ph;
    //window.status = pq+" :"+ph;
// 	this.scrbar.onmousemove=this.Move;
//    this.scrmover.onmousedown="src.Down();";
//    alert(this.textobj);
 };
 
 function PrepareScroll(sbname,thewind,thein,thetext,cudlik,btdn,btup,scrbar)
 {

	//scrbar.onmousemove = function anonymous() {scrb.move();};
/*	cudlik.onmouseover = new Function("this.style.filter='Alpha(Opacity=100)'");
	cudlik.onmouseout = new Function("this.style.filter='Alpha(Opacity=50)'");
	btdn.onmouseover = new Function("this.style.filter='Alpha(Opacity=100)'");
	btdn.onmouseout = new Function("this.style.filter='Alpha(Opacity=50)'");
	btup.onmouseover = new Function("this.style.filter='Alpha(Opacity=100)'");
	btup.onmouseout = new Function("this.style.filter='Alpha(Opacity=50)'");
*/
    //scrbar.onmousemove = new Function(sbname+".move()");
    pom = document.getElementById(sbname+"_hlp");
    pom.onmouseup = new Function(sbname+".inUse = 0;window.status='hlp'"); //+sbname+".scrmover.style.filter='Alpha(Opacity=50)'");
    cudlik.onmouseup = new Function(sbname+".inUse = 0; window.status='cudlik'"); //+sbname+".scrmover.style.filter='Alpha(Opacity=50)'");
    scrbar.onmouseup = new Function(sbname+".inUse = 0;window.status='bar'"); //+sbname+".scrmover.style.filter='Alpha(Opacity=50)'");

    thein.style.height = Math.max(thewind.offsetHeight-thein.offsetTop,100);
    thein.style.width = thewind.offsetWidth;
    btdn.style.top = thewind.offsetHeight - btdn.offsetHeight;
    scrbar.style.height = thewind.offsetHeight - btdn.offsetHeight - btup.offsetHeight;
    scrbar.style.left = thewind.offsetWidth - scrbar.offsetWidth;
    pom.style.height=scrbar.style.height;
    pom.style.width =scrbar.offsetWidth;
    pom.style.zIndex=100;
    cudlik.style.zIndex=90;
    btup.style.left = btdn.style.left = scrbar.style.left;

    scrbpom = new ScrollArea(thewind,thein,thetext,scrbar,cudlik,pom);

    pom.onmousemove =new Function("ee",sbname+".move(ee)");
    pom.onmousedown = new Function("ee",sbname+".down(ee)");
    cudlik.onmousedown = new Function("ee",sbname+".down(ee)");
    cudlik.onmousemove =new Function("ee",sbname+".move(ee)");  
    return  scrbpom;
 };
 
 function wheel(sb)
 {
   if (sb.scrmover.style.visibility=="hidden") return; 
   // pp.innerText+=" "+event.wheelDelta;
	sb.scrollBy(-event.wheelDelta/2);
 };
 
 function clicked()
 {
	window.event.returnValue = confirm('Pokračovat ?');
 };
 