  var browser;
  
  if (navigator.userAgent.indexOf("Opera") != -1)
  // â Opere navigator.appName == "Microsoft Internet Explorer" è document.all, 
  // è document.getElementById
  {
  	browser = "opera";
  }
  else if ((navigator.appName == "Microsoft Internet Explorer") && document.all)
  {
  	browser = "ie";
  }
  else if (navigator.appName == "Netscape")
  // â NN6 è Mozilla - document.getElementById
  {
  	browser="nn6";
  }

  // ---- Configure Parameters ---
  FlakesPath = "/img/snow_op";
  FlakesType = ".gif";
  MaxFlakePics = 2; 
  MaxFlakes = 8;
  XPos = 0;
  YPos = 0;
  MaxXPos = 600; // Or main layer width
  MaxYPos = 400; // Or main layer width
  TimeInterval = 50;

  YSpeed_Const = 2;
  YSpeed_Max = 4;

  XSpeed_Const = 0;

  Omega_Const = 10;
  Omega_Max = 30;
  OmegaOnSpeed_Const = 4;
  OmegaOnSpeed_Max = 6;
  Omega_Norm = (Omega_Const + Omega_Max)*3.14/180/1;

  Radius_Const = 20;
  Radius_Max = 50;
  RadiusOnSpeed_Const = 4;
  RadiusOnSpeed_Max = 10;
  Radius_Norm = ((Radius_Max + Radius_Const)/1);

  YRadius_Max = 1;
  YRadius_Smallest = 4;

  LongPause_Const = 5;
  LongPause_Max = 70;

  ShotPause_Const = 25;
  ShotPauseOnDelta_Const = 400;
  ShotPause_Max = 800;

  //--- Load Flakes Image ----
  var FlakesPics;
  FlakesPics = new Array();
  
  for( i = 0; i < MaxFlakePics; i++)
  {
    FlakesPics[i] = new Image();
    FlakesPics[i].src = (FlakesPath + i + FlakesType);
  }

  function FlakeLayerDOM(num)
  {
    document.write( "<img src='/img/flake.gif' id='fi" + num + "' style='position:absolute; z-index: 2000'>" ); // Path not nessesary
  };

  //--- Create Flakes Laer ---
  for ( i = 0; i < MaxFlakes; i++ ) {
    FlakeLayerDOM(i);
  }

  var Flakes = new Array();

  //---------------------
  //--- Flake Object ----
  //---------------------

  function CreateFlake(Number)
  {
  // Constructor
    this.Number = Number;
  };

  function GetNewOmega( Flake, speed )
  {
  // Craete owega speed
     if ( Flake.limit == 0 )
       t_omega = (Omega_Const + Math.random()*Omega_Max);
     else
       t_omega = (speed*OmegaOnSpeed_Const + Math.random()*speed*OmegaOnSpeed_Max);

     t_omega = t_omega * 3.14 / 180 / 6; // transform in radian
     return t_omega;
  };

  function GetNewRadius( Flake, speed )
  {
     if ( Flake.limit == 1 )
      t_radius = Radius_Const + Math.random(Radius_Max);
     else
      t_radius = speed*RadiusOnSpeed_Const + Math.random()*RadiusOnSpeed_Max;
      if ( t_radius < 4 )
        t_radius = 0;
      return t_radius;
  }

  function GetLongPause( speed )
  {
      return (LongPause_Const + Math.random()*LongPause_Max);
  }


  function GetShotPause(speed, delta)
  {
     return ( ShotPause_Const+ delta*ShotPauseOnDelta_Const + Math.random() *delta*ShotPause_Max);
  }


  function FlakeInit( Flake )
  {
  // Init new Flakes
  
    flakeId = 'fi' + Flake.Number;
    
    document.getElementById(flakeId).src = FlakesPics[Math.floor(Math.random() * MaxFlakePics)].src; //Change image
    
    Flake.y = YPos;
    Flake.x = XPos + Math.random()*MaxXPos;

    Flake.x_speed = XSpeed_Const;
    Flake.y_speed = (YSpeed_Const + Math.random()*YSpeed_Max);

    Flake.limit = Math.floor(Math.random() * 2); // Owega Or Radius Limit

    Flake.omega = GetNewOmega(Flake, Flake.y_speed);
    Flake.omega_v = 0;
    Flake.o_pause = 50;
    Flake.o_count = 0;

    Flake.radius = GetNewRadius(Flake, Flake.y_speed);
    Flake.radius_v = 0;
    Flake.r_pause = 0;
    Flake.r_count = 100;


    Flake.y_rad = Math.random()*YRadius_Max*Flake.radius/YRadius_Smallest;

    Flake.fi = Math.random()*360;
    Flake.fi = Flake.fi * 3.14 / 180;


    Flake.y = Flake.y - Flake.radius;
    
  }
  function Next( Flake )
  {
  //--- Control Traectory ---
    Flake.x += Flake.x_speed;
    Flake.y += Flake.y_speed;

    Flake.fi += Flake.omega;
    Flake.radius += Flake.radius_v;
    Flake.omega += Flake.omega_v;

    Flake.r_count++;
    if ( Flake.r_count > Flake.r_pause )
    {
      Flake.r_count = 0;
      if ( Flake.radius_v != 0 )
      {
         Flake.radius_v = 0;
         Flake.r_pause = GetLongPause( Flake.y_speed );
      }
      else
      {
         a = GetNewRadius(Flake, Flake.y_speed);
         Flake.r_pause = GetShotPause( Flake.y_speed, Math.abs(a - Flake.radius)/Radius_Norm );
         Flake.radius_v = ( a - Flake.radius)/Flake.r_pause;
      };
    };

    Flake.o_count++;
    if ( Flake.o_count > Flake.o_pause )
    {
      Flake.o_count = 0;
      if ( Flake.omega_v != 0 )
      {
         Flake.omega_v = 0;
         Flake.o_pause = GetLongPause( Flake.y_speed );
      }
      else
      {
         a = GetNewOmega(Flake, Flake.y_speed);
         Flake.o_pause = GetShotPause( Flake.y_speed, Math.abs(a - Flake.omega)/Omega_Norm );
         Flake.omega_v = ( a - Flake.omega)/Flake.o_pause;
      };
    };
  }


  function FlakeGetX(Flake)
  {
    a = Flake.x + Flake.radius * Math.cos(Flake.fi);
    return a;
  }

  function FlakeGetY(Flake)
  {
    a = Flake.y  + Flake.y_rad * Math.sin(Flake.fi);
    return a;
  }
  //--- End Flake Object ----

  //-------------------------

  //--- SetPosition ---
  function PositionFlake( Flake )
  {
    flakeId = "fi" + Flake.Number;
    document.getElementById(flakeId).style.top = FlakeGetY( Flake );
    document.getElementById(flakeId).style.left = FlakeGetX( Flake );
  };


  function OnTimer()
  {
    for ( i = 0; i < MaxFlakes; i++ )
    {
      Flake = Flakes[i];
      if ( FlakeGetY( Flake ) > MaxYPos )
        FlakeInit( Flake );
      Next(Flake);
      PositionFlake(Flake);
    }
  };

  //--- Chenge size-position on scroll on resize
  function SetNewVal()
  {
    if (browser == "opera" || browser == "nn6")
    {
      YPos = window.pageYOffset;
      XPos = window.pageXOffset;
      MaxXPos = window.pageXOffset + window.innerWidth- 100;
      MaxYPos = window.pageYOffset + window.innerHeight-50;       
    }
    else if (browser == "ie") 
    {
      YPos = document.body.scrollTop;
      XPos = document.body.scrollLeft;
      MaxXPos = document.body.scrollLeft + document.body.clientWidth- 100;
      MaxYPos = document.body.scrollTop + document.body.clientHeight-50;
    }
  };

  //--- Set position and event ---
  //--- if not needed coment this block ----
  window.onresize = SetNewVal;
  window.onscroll = SetNewVal;
  SetNewVal();
  
  //--- Crate Flake and timer---
  for ( i = 0; i < MaxFlakes; i++ )
  {
    Flakes[i] = new CreateFlake(i);
    
    FlakeInit(Flakes[i]);
    
    Flakes[i].y = Math.random() * MaxYPos;
  }

  snowIntervalId = window.setInterval("OnTimer();", TimeInterval);  

