
///////////////  BEGIN ORIGIONAL //////////////////////////////////////////////////////

var interval = 5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;

var intervalSmall = 7.5
intervalSmall *= 1000

var image_index = 0;
image_list = new Array();


/*
image_list[image_index++] = new imageItem("images/framedCabinets.jpg");
image_list[image_index++] = new imageItem("images/framedDoors.jpg");
image_list[image_index++] = new imageItem("images/framedFlooring.jpg");
image_list[image_index++] = new imageItem("images/framedLumber.jpg");
image_list[image_index++] = new imageItem("images/framedPlumbing.jpg");
image_list[image_index++] = new imageItem("images/framedWindows.jpg");
*/

/*
image_list[image_index++] = new imageItem("images/framedA.jpg");
image_list[image_index++] = new imageItem("images/framedB.jpg");
image_list[image_index++] = new imageItem("images/framedC.jpg");
image_list[image_index++] = new imageItem("images/framedD.jpg");
image_list[image_index++] = new imageItem("images/framedE.jpg");
image_list[image_index++] = new imageItem("images/framedF.jpg");
image_list[image_index++] = new imageItem("images/framedG.jpg");
image_list[image_index++] = new imageItem("images/framedH.jpg");
image_list[image_index++] = new imageItem("images/framedI.jpg");
image_list[image_index++] = new imageItem("images/framedJ.jpg");
*/

image_list[image_index++] = ("images/framedA.jpg");
image_list[image_index++] = ("images/framedB.jpg");
image_list[image_index++] = ("images/framedC.jpg");
image_list[image_index++] = ("images/framedD.jpg");
image_list[image_index++] = ("images/framedE.jpg");
image_list[image_index++] = ("images/framedF.jpg");
image_list[image_index++] = ("images/framedG.jpg");
image_list[image_index++] = ("images/framedH.jpg");
image_list[image_index++] = ("images/framedI.jpg");
image_list[image_index++] = ("images/framedJ.jpg");

var number_of_image = image_list.length;


image_index = 0;
image_listSmall = new Array();

/*
image_listSmall[image_index++] = new imageItem("images/framedCabinetsSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedDoorsSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedFlooringSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedLumberSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedPlumbingSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedWindowsSmall.jpg");
*/
image_listSmall[image_index++] = new imageItem("images/framedCabinetSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedCarpetSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedClosetDoorsSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedDeskSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedLumberStackSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedShowerSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedSinkSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedTileSmall.jpg");

image_listSmall[image_index++] = new imageItem("images/framedClosetDoorsSmall.jpg");
image_listSmall[image_index++] = new imageItem("images/framedDeskSmall.jpg");

var number_of_imageSmall = image_listSmall.length;


function generate(x, y)
{
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function get_ImageItemLocation(imageObj)
{
	return(imageObj.image_item.src)
}

function getNextImage()
{
	if (random_display)
	{
		image_index = generate(0, number_of_image-1);
	}
	else
	{
		image_index = (image_index+1) % number_of_image;
	}

	return(image_index);
}

function imageItem(image_location)
{
	this.image_item = new Image();
	this.image_item.src = image_location;
}


function loadImage()
{

	loadInitFade()
	loadSmallImage()
	//loadLargeImage()

}

function loadLargeImage()
{
	var new_imageIndex = getNextImage();
	var new_image = get_ImageItemLocation(image_list[new_imageIndex]);

	document['imgPictureFrame'].src = new_image;

	var recur_call = "loadLargeImage('imgPictureFrame')";
	setTimeout(recur_call, interval);

}

function loadSmallImage()
{
	var new_imageIndex = getNextImage();
	var new_imageSmall = get_ImageItemLocation(image_listSmall[new_imageIndex]);

	document['imgPictureFrameBottom'].src = new_imageSmall;
    
    var recur_callSmall = "loadSmallImage('imgPictureFrameBottom')";
	setTimeout(recur_callSmall, intervalSmall);

}

///////////////////////////////// END ORIGIONAL //////////////////////////////////////////////////



/////////////////////// NEW STUFF  ////////////////////////////////
// image_list

var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity = new Array();
//var imageArray = new Array("img1.jpg","img2.jpg","img3.jpg","img4.jpg","img5.jpg","img6.jpg","img7.jpg","img8.jpg");
//var imageArray = new Array("http://localhost/CannonRecovery/images/framedA.jpg","http://localhost/CannonRecovery/images/framedB.jpg","http://localhost/CannonRecovery/images/framedC.jpg","http://localhost/CannonRecovery/images/framedD.jpg","http://localhost/CannonRecovery/images/framedE.jpg","http://localhost/CannonRecovery/images/framedF.jpg","http://localhost/CannonRecovery/images/framedG.jpg","http://localhost/CannonRecovery/images/framedH.jpg");

var FADE_STEP = 2;
var FADE_INTERVAL = 10;
var pause = false;

function loadInitFade()
{
//document.getElementById("mContainer").visible = false;
//alert(document.getElementById("mContainer").visible);
//document.getElementById("mContainer").innerHTML = "<div id=\"photo\" name=\"photo\" class=\"mPhoto\"><img src=\"" + image_list[0]  +"\"></div>"

	currentOpacity[0]=100;
	//for(i=1;i<imageArray.length;i++)currentOpacity[i]=0;
	for(i=1;i<image_list.length;i++)currentOpacity[i]=0;
	mHTML="";
	//for(i=0;i<imageArray.length;i++)mHTML+="<div id=\"photo\" name=\"photo\" class=\"mPhoto\"><img src=\"" + imageArray[i]  +"\"></div>";
	for(i=0;i<image_list.length;i++)
	{
		mHTML+="<div id=\"photo\" name=\"photo\" class=\"mPhoto\"><img src=\"" + image_list[i]  +"\"></div>";
	}	
		
		//alert(mHTML);
		
	document.getElementById("mContainer").innerHTML = mHTML;
	
	
//	document.getElementById("mContainer").visible = true;



	if(document.all) {
		//document.getElementsByName("photo")[currentPhoto].style.filter="alpha(opacity=100)";
		document.getElementsByName("photo")[currentPhoto].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photo")[currentPhoto].style.MozOpacity = "100%";
	}

	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}

function crossFade() {
	if(pause)return;

	currentOpacity[currentPhoto]-=FADE_STEP;
	currentOpacity[secondPhoto] += FADE_STEP;

	if(document.all) {
	//filter:progid:DXImageTransform.Microsoft.Checkerboard(squaresX=<SPAN id=oSquaresX>2</SPAN>, squaresY=<SPAN id=oSquaresY>2</SPAN>, direction='<SPAN id=oDirection>right</SPAN>', duration=<SPAN id=oDuration>4</SPAN>)
	
		document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
		
		//<IMG ID=sample SRC=sample.jpg STYLE="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20)">
		
		//Checkerboard(squaresX=2, squaresY=2, direction='right', duration=4)
		
		//document.getElementsByName("photo")[currentPhoto].style.filter = "checkerboard(squaresX=2, squaresY=2, direction='right', duration=4)";
		//document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
		
		//document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		//document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
	} else {
		//document.getElementsByName("photo")[currentPhoto].style.MozOpacity = currentOpacity[currentPhoto]/100;
		//document.getElementsByName("photo")[secondPhoto].style.MozOpacity =currentOpacity[secondPhoto]/100;
		document.getElementsByName("photo")[currentPhoto].style.MozOpacity = currentOpacity[currentPhoto]/101;
		document.getElementsByName("photo")[secondPhoto].style.MozOpacity =currentOpacity[secondPhoto]/101;
	}

	if(currentOpacity[currentPhoto]<=0) {
		currentPhoto = secondPhoto;
		secondPhoto++;
		//if(secondPhoto == imageArray.length)secondPhoto=0;		
		if(secondPhoto == image_list.length)secondPhoto=0;
		pause = true;
		xInterval = setTimeout("pause=false",8000);
	}
}


/*
bTranState = 0;
function fnToggle() {
    oTransContainer.filters[0].Apply();
    if (bTranState=='0') { 
		bTranState = 1;
        oDIV2.style.visibility="visible"; 
		oDIV1.style.visibility="hidden";}
    else {  
		bTranState = 0;
        oDIV2.style.visibility="hidden"; 
		oDIV1.style.visibility="visible";}
    	oTransContainer.filters[0].Play();}
*/


////////////////////// END NEw STUFF /////////////////////////////


