// ********************************************************************************************
//* Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)                  *
//* Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code *
//* Last updated Nov 9th, 2005 by DD.  This notice must stay intact for use.                   *
//*  -- many modifications made by Roy J. Karlson (rjk63@charter.net)                          *
// ********************************************************************************************

//++++++++++++++++++++++++++++++++++++++++//
// Build a couple of other date variables //
//++++++++++++++++++++++++++++++++++++++++//

var adate       = new Date();
var dows        = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months      = new Array ('January','February','March','April','May','June','July','August',
                             'September','October','November','December');
var theday      = adate.getDay();
var thedayte    = adate.getDate();
var themonth    = adate.getMonth();
var theyear     = adate.getFullYear();

var sun = 0; var mon = 1; var tue = 2; var wed = 3;  var thu = 4; var fri = 5; var sat = 6;

var jan = 0; var feb = 1; var mar = 2; var apr = 3;  var may = 4; var jun = 5; var jul = 6;
var aug = 7; var sep = 8; var oct = 9; var nov = 10; var dec = 11;

// Set default image before calendar dates are considered.

// var imagesrc = "../MiscImages/RedSox.gif";

var imagesrc = "../MiscImages/SnowFlake.gif";

// Configure below to change URL path to the image

if ((themonth >= sep) && (themonth <= nov)) {		// football season (fall) //
   if ((themonth == oct) && (thedayte >= 24)) {
      imagesrc = "../MiscImages/Pumpkin.gif";		// halloween
     }
   else if ((themonth == nov) && (thedayte >= 23)) {	// thanksgiving
      imagesrc = "../MiscImages/Turkey.gif";
     }
   else if ((theday >= mon) && (theday <= fri)) {	// falling leaves - during the week //
      if ((theday == mon) || (theday == wed) | (theday == fri)) {
         imagesrc = "../MiscImages/Leaf.gif";
//       imagesrc = "../MiscImages/Baseball.png";
        }
      else {
         imagesrc = "../MiscImages/Leaf2.gif";		// mixing the leaves up a little!
        }
     }
   else {						// saturday & sunday -- football!!
      imagesrc = "../MiscImages/Football.gif";
     }
  }
else if (themonth == dec) {				// still football, not fall (winter)
   if ((thedayte >= 20) && (thedayte <= 28) && (thedayte != 25)) {	// christmas is coming
      imagesrc = "../MiscImages/SnowFlake.gif";
     }
   else if (thedayte == 25) {				// christmas day
      imagesrc = "../MiscImages/SnowFlake.gif";
     }
   else if ((theday >= mon) && (theday <= fri)) {	// snow-flakes
      imagesrc = "../MiscImages/SnowFlake.gif";
     }
   else {						// footballs
      imagesrc = "../MiscImages/Football.gif";
     }
  }
else if (themonth == jan) {
   if (thedayte == 1) {
      imagesrc = "../MiscImages/Football.gif";		// college bowl games
     }
   else if ((theday >= mon) && (theday <= fri)) {	// snow-flakes
      imagesrc = "../MiscImages/SnowFlake.gif";
     }
   else {						// footballs
      imagesrc = "../MiscImages/Football.gif";
     }
  }

// figure out the super bowl date for falling footballs

else if (themonth == feb) {
   // snowflakes, heart image for valentines day
  }
else if (themonth == mar) {
   imagesrc = "../MiscImages/SnowFlake.gif";
  }
else if (themonth == apr) {
   if (thedayte == 15) {
      // tax day - dollar signs image??
     }
   else {
      // baseballs (spring training, season opener)
     }
  }
else if ((themonth == may) || (themonth == jun)) {
   // baseballs
  }
else if (themonth == jul) {
   if (thedayte == 4) {
      // fireworks?
     }
   else {
      // baseballs
     }
  }
else if (themonth == aug) {
   // baseballs
  }

// Configure below to change number of images to render

var no = (randnum(2) + 5);		// at least 5, no more than 7

// Configure whether image should disappear after x seconds (0=never)

var hideimagetime = 0;

// Configure how much image should drop down before fading ("windowheight" or "pageheight")

var imagedistance = "pageheight";

// Stop Config

var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

function iecompattest(){
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
  }

var dx, xp, yp;					// coordinate and position variables
var am, stx, sty;				// amplitude and step variables
var i, doc_width = 800, doc_height = 600; 

if (ns6up) {
   doc_width = self.innerWidth;
   doc_height = self.innerHeight;
  }
else if (ie4up) {
   doc_width = iecompattest().clientWidth;
   doc_height = iecompattest().clientHeight;
  }

dx  = new Array();
xp  = new Array();
yp  = new Array();
am  = new Array();
stx = new Array();
sty = new Array();

imagesrc = (imagesrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : imagesrc;

for (i = 0; i < no; ++ i) {  
   dx[i]  = 0;					// set coordinate variables
   xp[i]  = Math.random()*(doc_width-50);	// set position variables
   yp[i]  = Math.random()*doc_height;
   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

   if (ie4up||ns6up) {
      if (i == 0) {
         document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://www.henrysautoparts.com\"><img src='"+imagesrc+"' border=\"0\"><\/a><\/div>");
        }
      else {
         document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+imagesrc+"' border=\"0\"><\/div>");
        }
     }
  }

function snowIE_NS6() {				// IE and NS6 main animation function

   doc_width  = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
   doc_height = (window.innerHeight && imagedistance=="windowheight")? window.innerHeight : (ie4up && imagedistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && imagedistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;

   for (i = 0; i < no; ++ i) {			// iterate for every dot
      yp[i] += sty[i];
      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] = 0.7 + 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";  
     }
   snowtimer=setTimeout("snowIE_NS6()", 10);
  }

function hidesnow(){
   if (window.snowtimer) {
      clearTimeout(snowtimer);
     }
     {
      for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden";
     }
  }

if (ie4up||ns6up){
   snowIE_NS6();
   if (hideimagetime>0) {
      setTimeout("hidesnow()", hideimagetime*1000);
     }
  }