var photo1 = new Image();
var photo2 = new Image();
var photo3 = new Image();
var photo4 = new Image();
var photo5 = new Image();
var photo6 = new Image();
var photo7 = new Image();
var photo8 = new Image();
var photo9 = new Image();
var photo10 = new Image();
var photo11 = new Image();
var photo12 = new Image();
var old_rand;
var new_rand;
var new_photo;

function initSlideShow()
{
	var browser = new detectBrowser();
	if(!browser.isIE5up && !browser.isGecko20020823up && !browser.isOpera7up)
	{
		alert("You will not be able to view our photo slide show because the web browser you are using does not support required features of this page.  If you wish to view our slide show we recommend using the latest version of Internet Explorer, Mozilla Firefox, Mozilla, Netscape, or Opera.");
	}
	else
	{
		preloadImages();
		runSlideShow();
	}
}

function detectBrowser() 
{
    var ua = navigator.userAgent.toLowerCase(); 
    this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
    this.isOpera       = (ua.indexOf('opera') != -1); 
    this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
    this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
    this.versionMinor = parseFloat(navigator.appVersion); 
    if (this.isIE && this.versionMinor >= 4) 
    {
       this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
    }
    else if (this.isOpera) 
    {
       this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
    }
    this.versionMajor = parseInt(this.versionMinor); 
    this.isIE5up = (this.isIE && this.versionMajor >= 5);
	this.isIE5x = (this.isIE && this.versionMajor == 5);
    this.isOpera7up = (this.isOpera && this.versionMinor >= 7);
	this.isGecko20020823up = (this.isGecko && this.geckoVersion >= 20020823);
}

function preloadImages()
{
	photo1.src = "images/photo1.JPG";
	photo2.src = "images/photo2.JPG";
	photo3.src = "images/photo3.JPG";
	photo4.src = "images/photo4.JPG";
	photo5.src = "images/photo5.JPG";
	photo6.src = "images/photo6.JPG";
	photo7.src = "images/photo7.JPG";
	photo8.src = "images/photo8.JPG";
	photo9.src = "images/photo9.JPG";
	photo10.src = "images/photo10.JPG";
	photo11.src = "images/photo11.JPG";
	photo12.src = "images/photo12.JPG";
	}

function runSlideShow()
{
	do
	{
		new_rand = Math.round(11*Math.random()+1);
	}
	while(new_rand == old_rand)
	
	switch(new_rand)
	{
		case 1:		new_photo = photo1;		break;
		case 2:		new_photo = photo2;		break;
		case 3:		new_photo = photo3;		break;
		case 4:		new_photo = photo4;		break;
		case 5:		new_photo = photo5;		break;
		case 6:		new_photo = photo6;		break;
		case 7:		new_photo = photo7;		break;
		case 8:		new_photo = photo8;		break;
		case 9:		new_photo = photo9;		break;
		case 10:	new_photo = photo10;	break;
		case 11:	new_photo = photo11;	break;
		case 12:	new_photo = photo12;	break;
		default :	window.status = "ERROR 01";
	}
	document.getElementById("photo_B").src = new_photo.src;
	fadePhoto(100);
	old_rand = new_rand;
	setTimeout("runSlideShow()",6000);
}

function fadePhoto(opacity) 
{
	if(opacity >= 0)
	{
       setOpacity("photo_A",opacity);
       opacity -= 2;
       setTimeout("fadePhoto(" + opacity + ")",50);
	}
	else
	{
		document.getElementById("photo_A").src = new_photo.src;
		setOpacity("photo_A",100);
	}
}

function setOpacity(id,opacity) 
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}