// =======================================
// set the slideshow variables
// =======================================
var slideShowSpeed = 20000; // Set slideShow Speed in milliseconds

// Specify the images (alt text and caption)
var preLoad = new Array()

preLoad[0] = new Array();
preLoad[0][0] = new Image();
preLoad[0][0].src = 'images/tub-support.jpg';
preLoad[0][1] = ""; // alt text
preLoad[0][2] = "<strong>Inadequate Support:</strong> Sealing foam is not an appropriate material for supporting heavy loads such as a master tub."; // caption

preLoad[1] = new Array();
preLoad[1][0] = new Image();
preLoad[1][0].src = 'images/weep-holes.jpg';
preLoad[1][1] = ""; // alt text
preLoad[1][2] = "<strong>No Weep Holes:</strong> Brick veneer should have weep holes, which help prevent moisture buildup in exterior walls and resultant wood rot."; // caption

preLoad[2] = new Array();
preLoad[2][0] = new Image();
preLoad[2][0].src = 'images/drainage-corrosion.jpg';
preLoad[2][1] = ""; // alt text
preLoad[2][2] = "<strong>Drainage:</strong> Corrosion."; // caption

preLoad[3] = new Array();
preLoad[3][0] = new Image();
preLoad[3][0].src = 'images/dangerous-switch.jpg';
preLoad[3][1] = ""; // alt text
preLoad[3][2] = "<strong>Dangerous Switch:</strong> Switch can be operated while standing in the shower, creating a shock hazard. Switch should be moved out of reach."; // caption

preLoad[4] = new Array();
preLoad[4][0] = new Image();
preLoad[4][0].src = 'images/ducts-vents.jpg';
preLoad[4][1] = ""; // alt text
preLoad[4][2] = "<strong>Ducts and Vents:</strong> Excessive air loss at taped joints."; // caption

preLoad[5] = new Array();
preLoad[5][0] = new Image();
preLoad[5][0].src = 'images/attic-hatch.jpg';
preLoad[5][1] = ""; // alt text
preLoad[5][2] = "<strong>Attic Access:</strong> Attic stairs should be fastened to the ceiling framing with approved fasteners at prepunched side pivot plates and rear spring mount holes to prevent accidents. Follow manufacturer's guidelines."; // caption

preLoad[6] = new Array();
preLoad[6][0] = new Image();
preLoad[6][0].src = 'images/service-panels.jpg';
preLoad[6][1] = ""; // alt text
preLoad[6][2] = "<strong>Service Panels:</strong> Front panel is not secured with proper blunt-end screws. Sharp ends can pierce electrical wire insulation causing an electrocution hazard."; // caption

preLoad[7] = new Array();
preLoad[7][0] = new Image();
preLoad[7][0].src = 'images/vacuum-systems.jpg';
preLoad[7][1] = ""; // alt text
preLoad[7][2] = "<strong>Central Vacuum Systems:</strong> Maintenance needed."; // caption


// Declare looping var
var t;
var previousPic;

function runSlideShow(){
	// declare variables
	var PicToShow = -1
	var SlideShowDiv = returnObjById("slideShowDiv");
	
	// Check for slide show div.
	if (SlideShowDiv) {
		// grab the img tag and caption para
		var SlideShowImg = returnObjById("slideShowImage");
		var SlideShowCap = returnObjById("slideShowCaption");
		
		// Randomly pick item to show (and make sure it's different from the previous one)
		do
		{
			PicToShow = Math.floor(Math.random()*preLoad.length);
		}
		while (PicToShow == previousPic);
		
		// set value for next time
		previousPic = PicToShow;

		// set a blending transition (for IE)
		if (document.all){
			SlideShowImg.style.filter="blendTrans(duration=2)"
			SlideShowImg.filters.blendTrans.Apply()      
		}
		
		// show picture and set alt and caption text
		SlideShowImg.src = preLoad[PicToShow][0].src;
		if (document.all) SlideShowImg.filters.blendTrans.Play();
		SlideShowImg.alt = preLoad[PicToShow][1];
		SlideShowCap.innerHTML = preLoad[PicToShow][2];

		// set this function to execute again in defined # of milliseconds
		t = setTimeout('runSlideShow()', slideShowSpeed);
	}
}

function returnObjById( id ) {
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}