//<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
// 1999 (C)opyright by Andrew Golovin
// All rights reserved


  flakesNumber = 15;  // Количество снежинок.
  maxVSpeed = 6;     // Максимальная скорость падения.
  maxWindStep = 4;    // Максимальный шаг затихания ветра.
  maxWind = 4;       // Максимальная сила ветра.
  wind = maxWind-(2*maxWind)*Math.random();      // Начальная сила ветра.
  windStep = (maxWindStep-1)*Math.random() + 1;  // Начальный шаг затихания ветра.
  flakeWidth = 10;    // Ширина изображения снежинки.
  flakeHeight = 10;   // Высота изображения снежинки.
  flakeImage = "images/flake1.gif";   // Путь к изображению снежинки.
  
  snowFall = new Array(flakesNumber);


  function startSnowing() {
    //  Размещаем снежинки вверху экрана.
    for (l=1; l<=flakesNumber; l++) {
      snowFall[l].x = Math.round((client.width-flakeWidth)*Math.random());
      snowFall[l].y = 0
      moveTo(snowFall[l].id,snowFall[l].x,0);
    }
  }
  
  function snezhinka(id) {
     // Создаем новую снежинку.
     this.id = "sn" + id;
     this.y = 0;
     this.x = 0;
     this.vSpeed = (maxVSpeed-1)*Math.random() + 1;
     this.mass = Math.random();
     if (document.all) {
        document.write('<DIV ID="' + this.id + '" NAME="' + this.id + '" STYLE="position: absolute; top: ' + this.y + '; left: ' + this.x + '; width: "' + flakeWidth + '"; height: "' + flakeHeight + '"; padding: 0px; clip: rect(0,10,10,0)"><IMG SRC="' + flakeImage + '" WIDTH="' + flakeWidth + '" HEIGHT="' + flakeHeight + '" BORDER=0 ALT="*"></DIV>');
     } else {
        document.write('<LAYER ID="' + this.id + '" NAME="' + this.id + '" STYLE="position: absolute; top: ' + this.y + '; left: ' + this.x + '; width: "' + flakeWidth + '"; height: "' + flakeHeight + '"; padding: 0px; clip: rect(0,10,10,0)"><IMG SRC="' + flakeImage + '" WIDTH="' + flakeWidth + '" HEIGHT="' + flakeHeight + '" BORDER=0 ALT="*"></LAYER>');
     }
  }

  function moveIt() {
    // Процедура, реализующая один шаг симуляции снегопада.
    for (k=1; k<=flakesNumber; k++) {
      with (snowFall[k]) {
        y = getY(id) + vSpeed;
        x = getX(id) + wind * mass;
//        if (((x+flakeWidth) > client.width) || (x <= 0) || ((y + flakeHeight) > client.height))  {
		if (((x+flakeWidth) > client.width) || (x <= 0) || ((y + flakeHeight) > 100))  {
           // Если снежинка на следующем шаге выйдет за пределы экрана,
           // то задаем ей новые параметры.
           x = (client.width - flakeWidth)*Math.random();
//		   x = (250 - flakeWidth)*Math.random();
           y = 0;
           vSpeed = (maxVSpeed-1)*Math.random() + 1;
           mass = Math.random();
        }
        // Перемещаем снежинку в новые координаты.
        moveTo(id, x, y);
      }
    }
    
    if (wind<0) { 
       if ((wind + windStep) >= 0 ) {
          wind = maxWind-(2*maxWind)*Math.random();
          windStep = (maxWindStep-1)*Math.random() + 1;
       } else {
          wind += windStep;
       }
    } else {
       if ((wind - windStep) <= 0 ) {
          wind = maxWind-(2*maxWind)*Math.random();
          windStep = (maxWindStep-1)*Math.random() + 1;
       } else {
          wind -= windStep;
       }
    }
    
    mTimer = setTimeout("moveIt()",1);
    // Устанавливаем запуск следующего шага через минимально возможный
    // промежуток времени.
 }
   
  function init() {
//    bbdoanim();
    // Инициализируем библиотеку detect.js
    initDetect();
    startSnowing();
    moveIt();
    window.onresize = startSnowing;
  }
  
function detectAgent() {
  with (navigator) {
       var tempAgent = userAgent;
	   var tempName = appName;
	   this.plainAgentStr = userAgent;
	   this.plainNameStr = appName;
	   this.plainVersionStr = appVersion;
	   if (tempAgent.indexOf('Opera')>=0) {
	      this.name = "Opera";
		  this.shortName = "OPR";
		  var tempVer = tempAgent.substring(tempAgent.indexOf("Opera") + 6, tempAgent.length);
		  this.version = tempVer.substring(0, tempVer.indexOf(" "));
          this.minorVer = this.version.substring(tempVer.indexOf(".") + 1, tempVer.length);
          this.language = tempAgent.substring(tempAgent.indexOf("[") + 1, tempAgent.indexOf("]"));
		  
	   }
       else {
	      if (tempAgent.indexOf('MSIE')>=0) {
		     this.name = "Internet Explorer";
			 this.shortName = "EXP";
             var tempVer = tempAgent.substring(tempAgent.indexOf("MSIE") + 5, tempAgent.length);
             this.version = tempVer.substring(0, tempVer.indexOf(";"));
             this.minorVer = this.version.substring(tempVer.indexOf(".") + 1, tempVer.length);
             this.language = browserLanguage;
		  }
		  else {
		    if (tempName.indexOf('Netscape')>=0) {
			   this.name = "Netscape Navigator";
			   this.shortName = "NAV"
			   this.minorVer = appVersion.substring(appVersion.indexOf(".") + 1, appVersion.indexOf(" "));
               this.language = tempAgent.substring(tempAgent.indexOf("[") +1, tempAgent.indexOf("]"));
               this.version = appVersion.substring(0, appVersion.indexOf(" "));			   
			}
			else {
			   this.name = "Unknown";
			   this.shortName = "UNK"
			}
		  }
	   }
  }
}

// Element position and size methods
// 
//

function getWidth(el) {
  if (NN) {
     return(document.layers[el].clip.width);
  }
  else {
     return(document.all[el].style.pixelWidth);
  }
}

function getHeight(el) {
  if (NN) {
     return(document.layers[el].clip.height);
  }
  else {
     return(document.all[el].style.pixelHeight);
  }
}

function setX(el, x) {
   if (NN) {
      document.layers[el].left = x;
   }
   else {
      document.all[el].style.pixelLeft = x;   
   }
}

function setY(el, y) {
   if (NN) {
      document.layers[el].top = y;
   }
   else {
      document.all[el].style.pixelTop = y;
   }
}

function getX(el) {
  if (NN) {
     return(document.layers[el].left);
  }
  else {
     return(document.all[el].style.pixelLeft);
  }
}
  
function getY(el) {
  if (NN) {
     return(document.layers[el].top);
  }
  else {
     return(document.all[el].style.pixelTop);
  }
}
  
function moveTo(el, toX, toY) {
  setX(el,toX);
  setY(el,toY);
}

function moveBy(el, dX, dY) {
  setX(el, getX(el) + dX );
  setY(el, getY(el) + dY );
}

function show(el) {
  if (NN) {
     document.layers[el].visibility = "show";
  }
  else {
     document.all[el].style.visibility = "visible";
  }
}

function hide(el) {
  if (NN) {
     document.layers[el].visibility = "hide";
  }
  else {
     document.all[el].style.visibility = "hidden";
  }
}

// Implementtion of "clientParams" object
// 
//

function getParams() {
	if (NN) {
	   this.width = window.innerWidth;
	   this.height = window.innerHeight;
	}
	else {
	   this.width = document.body.clientWidth;
	   this.height = document.body.clientHeight;
	}
}

function YOffset() {
    return( NN? window.pageYOffset: document.body.scrollTop );
}

function XOffset() {
    return( NN? window.pageXOffset: document.body.scrollLeft );
}

function updateParams() {
   getParams();
}

function clientParams() {
  this.getParams = getParams;
  this.YOffset = YOffset;
  this.XOffset = XOffset;  
  this.updateParams = updateParams;
}

function updateClient() {
  client.getParams();
}

var br = new detectAgent();
var NN = (br.shortName == "NAV");
var IE = (br.shortName == "EXP");
var OP = (br.shortName == "OPR");

function initDetect() {
  client = new clientParams();
  client.getParams();
  window.onresize = updateClient;
}

var bbx=777;var bbdelay=60;var bbjump=4;

function bbdoanim(){
document.all.text.style.left=bbx;bbx-=bbjump;
if(bbx<-777) bbx=777;setTimeout("bbdoanim()", bbdelay);}


