
var probiha = new Array();
var akce = 0;
var cislox = 0;
var startt = 0;
for (i=0;i<11;i++){
    probiha[i]=false;
}

function rgbToHex(R, G, B) {
    return (
        Math.round(256 + R).toString(16).substr(1) +
        Math.round(256 + G).toString(16).substr(1) +
        Math.round(256 + B).toString(16).substr(1)
    )
}
function stoproll(){
    for (i=1;i<11;i++){
      clearInterval(akce);
      probiha[i]=false; 
      if (document.getElementById("row" + i + "")==null) break;
      document.getElementById("row" + i + "").style.backgroundColor= "#ffffff";
    }
}


function startroll(id,cislo){
  if(!probiha[cislo]){
    for (i=1;i<11;i++){
      probiha[i]=false;
      if (document.getElementById("row" + i + "")==null) break;
      document.getElementById("row" + i + "").style.backgroundColor= "#ffffff";
    }
  probiha[cislo]=true;
   document.getElementById(id).style.backgroundColor= "#ffffff";
  clearInterval(akce); 
  startt= (new Date()).getTime();
  cislox = cislo;
  idx = id;
  akce=window.setInterval("krok2(startt,cislox,idx)", 10) ;
    }  
  }



function krok2(time,cislo,id){
		var elapsed	= (new Date()).getTime() - time;
	  if (elapsed < 1200) {
		  color2 = 255- ((1000000 - (Math.round(Math.pow(1000 - (elapsed/1200)*1000, 2)))) * 0.000075);
		  color3 = 255- ((1000000 - (Math.round(Math.pow(1000 - (elapsed/1200)*1000, 2)))) * 0.000050);
		  color4 = 255- ((1000000 - (Math.round(Math.pow(1000 - (elapsed/1200)*1000, 2)))) * 0.000030);
		}else{
     clearInterval(akce); 
     
    }
   document.getElementById(id).style.backgroundColor= "#" + rgbToHex(color2, color3, color4);
}
// texttttttttttttttttttttt--------------------------------------------------------------------------------------//
var akcetext = 0;
var probihatext = new Array();
for (j=1;j<20;j++){probihatext[j]==false;}

function startrollText(id,cislo){
element=document.getElementById(id);
if(!probihatext[cislo]){
    for (i=1;i<11;i++){
      probihatext[i]=false;
      if (document.getElementById("odr" + i + "")==null) break;
      document.getElementById("odr" + i + "").style.marginLeft ="0px";
     
    }
  probihatext[cislo]=true;
  clearInterval(akcetext); 
  element.style.marginRight = 5 + "px";
  starting= (new Date()).getTime();
  akcetext=window.setInterval("krokText(starting,element)", 50) ;    
  }
}  
  
function krokText(time,element){
		var elapsed	= (new Date()).getTime() - time;
	  if (elapsed < 700) {
		  right = ((1000000 - (Math.round(Math.pow(1000 - (elapsed/700)*1000, 2)))) * 0.000010);
		  
		}else{
     clearInterval(akcetext);  
    }
  
   element.style.marginLeft = right + "px";
}

function stoprolltext(){
    for (i=1;i<12;i++){
      clearInterval(akcetext);
      probihatext[i]=false; 
      if (document.getElementById("odr" + i + "")==null) break;
      document.getElementById("odr" + i + "").style.marginLeft ="0px";
      
    }
}
