////////////////////////////////////////////////////////////////////
//  Var / Array initialization
////////////////////////////////////////////////////////////////////
   Ns        = (document.layers)?1:0;
   Ns6       = (document.getElementById&&!document.all)?1:0;
   Count     = 0;
   Amount    = 15;
   WinHeight = window.document.body.clientHeight;
   WinWidth  = window.document.body.clientWidth;

   Ypos   = new Array();
   Xpos   = new Array();
   Speed  = new Array();
   Step   = new Array();
   Cstep  = new Array();
   grphcs = new Array(5)


   if(Main.getMonth() >= 8 && Main.getMonth() <= 10){
      var vec = 220;
      Image0 = new Image();
      Image0.src=grphcs[0] = "images/season/fall/leaf1.gif"

      Image1 = new Image();
      Image1.src=grphcs[1] = "images/season/fall/leaf2.gif"

      Image2 = new Image();
      Image2.src=grphcs[2] = "images/season/fall/leaf3.gif"

      Image3 = new Image();
      Image3.src=grphcs[3] = "images/season/fall/leaf4.gif"

      Image4 = new Image();
      Image4.src=grphcs[4] ="images/season/fall/leaf5.gif"

      Image5 = new Image();
      Image5.src=grphcs[5] = "images/season/fall/leaf6.gif"

      Image6 = new Image();
      Image6.src=grphcs[6] = "images/season/fall/leaf7.gif"
   }
   else{
      var vec = 170;
      Image0 = new Image();
      Image0.src=grphcs[0] = "images/season/winter/snow6.gif"

      Image1 = new Image();
      Image1.src=grphcs[1] = "images/season/winter/snow4.gif"

      Image2 = new Image();
      Image2.src=grphcs[2] = "images/season/winter/snow7.gif"

      Image3 = new Image();
      Image3.src=grphcs[3] = "images/season/winter/snow5.gif"

      Image4 = new Image();
      Image4.src=grphcs[4] ="images/season/winter/snow2.gif"

      Image5 = new Image();
      Image5.src=grphcs[5] = "images/season/winter/snow3.gif"
   }


////////////////////////////////////////////////////////////////////
//  Random positioner of elements and speed
////////////////////////////////////////////////////////////////////
   for(i=0; i < Amount; i++){
      Ypos[i]  = Math.round(Math.random()*WinHeight);
      Xpos[i]  = Math.round(Math.random()*WinWidth);
      Speed[i] = Math.random()*5+3;
      Cstep[i] = 0;
      Step[i]  = Math.random()*0.1+0.05;
   }


////////////////////////////////////////////////////////////////////
//  Draws and redraws falling elements
////////////////////////////////////////////////////////////////////
   function fall(Count){
      var WinHeight = window.document.body.clientHeight;
      var WinWidth  = window.document.body.clientWidth;
      var hscrll    = document.body.scrollTop;
      var wscrll    = document.body.scrollLeft;
      for(i=0; i < Amount; i++){
         sy = Speed[i]*Math.sin(90*Math.PI/vec);
         sx = Speed[i]*Math.cos(Cstep[i]/5);
         Ypos[i] += sy;
         Xpos[i] += sx; 
         if(Ypos[i] > WinHeight && Count < 130){
            Ypos[i]  = -60;
            Xpos[i]  = Math.round(Math.random()*WinWidth);
            Speed[i] = Math.random()*5+3;
         }

         eval("document.all.si"+i).style.left = Xpos[i];
         eval("document.all.si"+i).style.top  = Ypos[i]+hscrll;
         Cstep[i] +=Step[i];
      }
      setTimeout('fall(Count++)',30);
   }



////////////////////////////////////////////////////////////////////
//  Call to start proccess
////////////////////////////////////////////////////////////////////

if((Main.getMonth() >= 8 && Main.getMonth() <= 10) || Main.getMonth() == 11 || Main.getMonth() == 0 || Main.getMonth() == 1){      
      
   ////////////////////////////////////////////////////////////////////
   //  Draws and positions inital elements
   ////////////////////////////////////////////////////////////////////

      document.write('<div style="position:absolute;top:0px;left:0px;"><div style="position:relative">');
      for (i = 0; i < Amount; i++){
         var P=Math.floor(Math.random()*grphcs.length);
         rndPic=grphcs[P];
         document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px;">');
      }
      document.write('</div></div>');

   fall();
}

