// JavaScript Document
var no = 7;   // počet balónků
var speed = 29; // rychlost, menší číslo znamená větší rychlost
//snow = new Array(); // zadefinujte obrázky, můžete mít 1 nebo více obrázků
snow = "../images/balonek.gif"
//snow[1] = "../images/motylek.gif"
//snow[2] = "../images/mracek.gif"

var dx, xp, yp;    // coordinate and position variables
var am, stx, sty;  // amplitude and step variables
var i, doc_width = 800, doc_height = 165;

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
//j = 0;

for (i = 0; i < no; ++ i) {
  dx[i] = 0; // set coordinate variables
  xp[i] = Math.random()*(doc_width-50); // set position variables
  yp[i] = Math.random()*doc_height;
  am[i] = Math.random()*20; // set amplitude variables
  stx[i] = 0.02 + Math.random()/10; // set step variables
  sty[i] = 0.7 + Math.random(); // set step variables
  document.write("<div id=\"dot"+i+"\" style=\"position: absolute; z-index: "+i+"; visibility: visible; top: 15px; left: 15px;\">");
  document.write("<img src=\""+ snow + "\" border=\"0\">");
  document.write("</div>");
  //if (j == (snow.length-1)) { j = 0; } else { j += 1; }
}

function snowA() {
  for (i = 0; i < no; ++ i) { // iterate for every dot
    yp[i] -= sty[i];
    if (yp[i] < -50) {
      xp[i] = Math.random()*(doc_width-am[i]-30);
      yp[i] = doc_height;
      stx[i] = 0.02 + Math.random()/10;
      sty[i] = 0.7 + Math.random();
    }
    dx[i] += stx[i];
	document.getElementById("dot"+i).style.top = yp[i]+"px";
    document.getElementById("dot"+i).style.left = (xp[i] + am[i]*Math.sin(dx[i]))+"px";
  }
  setTimeout("snowA()", speed);
}


snowA();

