// JavaScript Document
var no = 35; // количество рисунков
var speed = 50; // скорость движения
var snowflake = "/js/snow/sneg.gif"; //адрес рисунка


var dx, xp, yp;
var am, stx, sty;
var i;

var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);

function getDocumentHeight() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
}
 
function getViewportHeight() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}

var doc_width  = document.body.offsetWidth;
var doc_height = getDocumentHeight();

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i) {
dx[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();


document.write("<div id=\"dot"+ i +"\" style='position:absolute;left:15px;top:15px;z-index:100' ");
document.write("><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");

}

function snow() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i]*3;
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width - am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 1 + 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("snow()", speed);
}




