<!-- Hide from older browsers

/////////////////////////////////////////////////////////
// declare variables

//how many total pictures are allowed
var totalPics = 10;

//array to hold pictures
var pics = new Array(); //array of images

//track the current picture number
var picNumber = 1;

//store the height of the first pic; this will be used to compare the remaining pics sizes before loading;
//if the script attempts to load a pic that is more than 10% shorter in height, do not load;
//this was implemented due to IE's display of the placehoder box when no image is present; the script thinks that it is an actual image
var picHeight = 0;

//current opacity direction; false=fade out, true=fade in
var dirOpacity = true;

//current opacity value
var currentOpacity;

//minimum amount of opacity for complete fadeout
var minOpacity;

//fade in/fade out rates
var fadeInRate = .01;
var fadeOutRate = .05;

//number of seconds to keep image at 100% opacity
var maxImageWaitTime = 3;

//number of seconds image has been at 100% opacity
var currentImageWaitTime = 0;

/////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////
//set opacities based on browser
if (navigator.appName != "Microsoft Internet Explorer")
{
  minOpacity = .08;
  currentOpacity = .99;
}
else
{
  minOpacity = 8;
  currentOpacity = 99;
}
/////////////////////////////////////////////////////////

//load the picture sources into the array
LoadPics();

//set the rotate function to fire every x milliseconds
setInterval('RotatePics()', 50);

//load the picture sources into the array
function LoadPics() {
	//picture array has extra "dummy" picture at end
	for (i=1; i<totalPics + 2; i++) {
		pic = new Image();
		pic.src = "images/rotator" + i + ".jpg";
		pics[i] = pic;
	}
}

//vary the opacity on a timed call and switch pictures on full fade-out
function RotatePics() {
	//get the image element on the page
    var fImage = document.getElementById('ctl00_ContentPlaceHolder1_rotator');

	if (picHeight == 0) {
		picHeight = pics[1].height;
	}
	
	//set the picture's current opacity
    if (navigator.appName != "Microsoft Internet Explorer") {
      fImage.style.opacity = currentOpacity;
    }
    else {
      fImage.style.filter="alpha(opacity=" + currentOpacity + ")";
    }

	//if currently fading in
    if (dirOpacity == true) {
        if (navigator.appName != "Microsoft Internet Explorer") {
		  //increase the opacity
          currentOpacity += .01;

		  //if max opacity reached
          if (currentOpacity > .99) {
			//increase the current wait time for full opacity; if max not met, exit function
			if (currentImageWaitTime < maxImageWaitTime) {
				currentImageWaitTime += .05;
				return;
			}

			//max wait time has been met, so reset current wait time, opacity back to max, and switch to fade out
			currentImageWaitTime = 0;
			currentOpacity = .99;
            dirOpacity = false;
          }
        }
        else {
          currentOpacity += fadeInRate * 100;

          if (currentOpacity > 99) {
			if (currentImageWaitTime < maxImageWaitTime) {
				currentImageWaitTime += .05;
				return;
			}

			currentImageWaitTime = 0;
			currentOpacity = 99;
            dirOpacity = false;
          }
        }
    }
	//currently fading out
    else {
		//decrease the opacity
        if (navigator.appName != "Microsoft Internet Explorer") {
			currentOpacity -= fadeOutRate;
        }
        else {
			currentOpacity -= fadeOutRate * 100;
        }
		
		//if current opacity is less than declared minimum
        if (currentOpacity < minOpacity) {
			//switch to next picture
			picNumber++;
			
			//if the picture does not exist, calculated by its height compared to the first pic
			if (pics[picNumber].height < picHeight - picHeight * .1) {
				//reset the picture to the first one
				picNumber = 1;
				fImage.src = "images/rotator1.jpg";
			}
			//new picture exists
			else {
				fImage.src = pics[picNumber].src;
			}
			
			//switch opacity direction to fade-in
	        dirOpacity = true;
        }
	}
}

//Hide from older browsers -->
