
var houses = [];//create array        var counter = 0; //create index for the array to loop through
var counter = 1;
    
//add array to our array    
houses[1] = [];
houses[2] = [];
houses[3] = [];

// NOTE: the last house in this group of arrays should always be the same as the
// hard coded images in the index.html page. The home page will display the 
// hardcoded images first, and then begin using these arrays to change the 
// images and text. the last house in the array is the dynamic version of the 
// index.html page hard coded images.

houses[1]["pic1"] = "gdresources/images_work/mendez/Mendez_0064_homepage.jpg";
houses[1]["pic2"] = "gdresources/images_work/mendez/Mendez_063_thumb.jpg";
houses[1]["pic3"] = "gdresources/images_work/mendez/Mendez_DSC_0007_thumb.jpg";
houses[1]["href"] = "work_mendez.html";
houses[1]["caption"] = "Mendez Residence.";

houses[2]["pic1"] = "gdresources/images_work/cobre/Cobre_Construction_B45S0530_homepage.jpg";
houses[2]["pic2"] = "gdresources/images_work/cobre/Cobre_Construction_IMG_8828_thumb.jpg";
houses[2]["pic3"] = "gdresources/images_work/cobre/Cobre_Construction_IMG_8857_thumb.jpg";
houses[2]["href"] = "work_cobre.html";
houses[2]["caption"] = "Cobre Construction Building.";

houses[3]["pic1"] = "gdresources/images_work/lanning_hiller/Hiller_Lanning_IMG_3659_homepage.jpg";
houses[3]["pic2"] = "gdresources/images_work/lanning_hiller/Hiller_Lanning_IMG_3649_thumb.jpg";
houses[3]["pic3"] = "gdresources/images_work/lanning_hiller/Hiller_Lanning_B45S7478_thumb.jpg";
houses[3]["href"] = "work_lanning_hiller.html";
houses[3]["caption"] = "Lanning / Hiller Residence.";



function checkCounter()
{
    // set this conditional to the number of houses arrays that exist
    if(counter > 3)
    {
        counter = 1;//set this to beginning counter number
    }
    else
    {
        return counter;
    }
}

function setCounter()
{
    return counter++;
}

function getCounter()
{  
    checkCounter();
    return counter;
}

// fades out the pictures, changes the URLs and text for the images on the page
// that correspond to each houses array
function swapImages()
{
    var i = getCounter();              
    
    $("#homePic1").fadeOut(550, function(){
                $("#homePic1").attr("src", houses[i]["pic1"]);
                $("#picLink1").attr("href", houses[i]["href"]);
                $("#homePic1").fadeIn(1000);
            }
        );
    $("#homePic2").fadeOut(394, function(){
                $("#homePic2").attr("src", houses[i]["pic2"]);
                $("#picLink2").attr("href", houses[i]["href"]);
                $("#homePic2").fadeIn(575);
            }
        );
    $("#homePic3").fadeOut(450, function(){
                $("#homePic3").attr("src", houses[i]["pic3"]);
                $("#picLink3").attr("href", houses[i]["href"]);
                $("#homePic3").fadeIn(695);
            }
        );    
    
    $("#homeCaption h3").text( houses[i]["caption"] );
    $("#picLink4").attr("href", houses[i]["href"]);
    
    setCounter();
    
}

$(document).ready(function(){

    // fix stupid opacity bug in FF 2 on the MAC cause we're using
    // the fadeOut method, which uses opacity and triggers the stupid bug
    $('body').css('opacity', 0.9999); 
        
    // keep looping through and calling our function
    setInterval("swapImages()", 8000);            

});
