  // This JavaScript code can be freely redistributed
  // as long as this copyright notice is keept unchanged.
  // This code is used on AS-IS basis and
  // you use it on your own risk. Author of this code
  // is not responsible for any damage that this
  // code may make.
  //
  // JS Snow v0.2
  // finished on 11-10-1999 23:04 in Zagreb, Croatia.
  // modified on 06-12-2005 11:20 in Zagreb, Croatia.
  //
  // Copyright 1999,2005 Altan d.o.o.
  // http://www.altan.hr/snow/index.html
  // E-mail: snow@altan.hr

// changed by ppershing  
  
  var no = 10; // snow number
  var global_time=0;
  var wind_strength=3;
  var wind_freq=0.00005;

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 800, doc_height = 600;
  var flake_count=2;
  

  flake_url = new Array("http://www.fks.sk/js/snow/snowflake1.gif",
                        "http://www.fks.sk/js/snow/snowflake2.gif");


  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();

  function get_wind_strength(){
   return Math.sin(global_time*wind_freq*2*Math.PI)*wind_strength;
  }
  
  function generate_new_flake_position(i,starting){
   if (starting==1) {
    xp[i] = Math.random()*(doc_width-50);
    yp[i] = Math.random()*(doc_height-50);
   } else {
    if (Math.random()<0.5) {
        xp[i] = Math.random()*(doc_width-50);  
        //yp[i] = Math.random()*40;
        yp[i] = doc_height - Math.random()*40;
    } else {
        if (Math.random()<0.5) xp[i]=10; else xp[i]=doc_width-60;
        yp[i]=Math.random()*(doc_height-50);

    }
    }

    dx[i] = 0;                        // set coordinate variables
    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
    sty[i] =  1.3 - Math.random();     // set step variables
  }
  
  function snow() {
   global_time++;
   
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      var x,y;
      yp[i] += sty[i];
      dx[i] += stx[i];
      xp[i] +=get_wind_strength();
      
      x= xp[i] + am[i]*Math.sin(dx[i]);
      y= yp[i];
      
      if (y > doc_height-50 || x>doc_width-30 || x<-20) {
     // if (y < -20 || x>doc_width-30 || x<-20) {
       generate_new_flake_position(i,0);       
       i--;
      } else { 
      document.getElementById("dot"+i).style.top=y+"px";
      document.getElementById("dot"+i).style.left=x+"px";
      }
    }
    
    setTimeout("snow()", 30);
  }



function create_images(){
  for (i = 0; i < no; ++ i) {  
      document.write(
      "<div id=\"dot"+ i +"\" style=\"position: absolute; z-index: "+ i +
      "; visibility: visible; top: 15px; left: 15px;\"> <img src=\""+
      flake_url[Math.floor(Math.random()*(flake_count-0.01))]+
      "\" border=\"0\" title=\"*\" alt=\"*\"></div>");

  }

}

function init(){
  doc_width = document.body.clientWidth;
  doc_height = document.body.clientHeight;
  for (i = 0; i < no; ++ i) {  
  generate_new_flake_position(i,1);
  }
snow();
}

//if (navigator.userAgent=="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9") {

create_images();


//init();
//snow();
window.onload=init;
//}
