
var homeId = 1;
var intervalId = 0;

homeArray = new Array(11);

function rotator() {

    clearInterval(intervalId);
    if (++homeId > 10) homeId = 1;
    $("div#middle div#index-background").fadeTo(350, 0.05, function () {
        $(this).css("background", "url('resources/home" + homeId + ".jpg') no-repeat scroll left top transparent").fadeTo(350, 1);
    });
    intervalId = window.setInterval("rotator()", 4000);
};

$(document).ready(function () {

    $("div#middle div#index").after("<div id='index-background'>&nbsp;</div>");
    $("div#middle div#index-background").css("background", "url('resources/home" + homeId + ".jpg') no-repeat scroll left top transparent");
    $("div#middle div#index").css("background", "none");

    homeArray[1] = new Image();
    homeArray[1].src = "resources/home1.jpg";
    homeArray[2] = new Image();
    homeArray[2].src = "resources/home2.jpg";
    homeArray[3] = new Image();
    homeArray[3].src = "resources/home3.jpg";
    homeArray[4] = new Image();
    homeArray[4].src = "resources/home4.jpg";
    homeArray[5] = new Image();
    homeArray[5].src = "resources/home5.jpg";
    homeArray[6] = new Image();
    homeArray[6].src = "resources/home6.jpg";
    homeArray[7] = new Image();
    homeArray[7].src = "resources/home7.jpg";
    homeArray[8] = new Image();
    homeArray[8].src = "resources/home8.jpg";
    homeArray[9] = new Image();
    homeArray[9].src = "resources/home9.jpg";
    homeArray[10] = new Image();
    homeArray[10].src = "resources/home10.jpg";

});

$(window).load(function () {
    intervalId = window.setInterval("rotator()", 1800);
});
