

slideShowDivIdx = 0;

allSlideShowDivs = ['leftPics', 'middlePics', 'rightPics'];
slideShowDivs = ['leftPics', 'middlePics', 'rightPics'];

function slideShow()
{
    if (slideShowDivs.length)
    {
        slideShowDivIdx++;
        if (slideShowDivIdx >= slideShowDivs.length)
            slideShowDivIdx = 0;
        advancePic(slideShowDivs[slideShowDivIdx]);
        poller();
    }
}

function advancePic(whichDiv)
{
	var pics = $('#slideShows .' + whichDiv + ' img');
    var currentPic = 0;
    for (var i=0; i<pics.length; i++)
    {
        if ($(pics[i]).is(":visible"))
            currentPic = i;
    }
    currentPic++;
    if (currentPic >= pics.length)
        currentPic = 0;

    for (var i=0; i<pics.length; i++)
    {
        if (i == currentPic)
		{
			$(pics[i]).show();
		}
        else
		{
			$(pics[i]).hide();
		}
    }
}

function removeSinglePicsFromSlideShows()
{
    // This is so that we don't waste time on divs with only one pic
    for (var i=0; i< allSlideShowDivs.length; i++)
    {
        var whichDiv = allSlideShowDivs[i];
        if ($('#slideShows .' + whichDiv + ' img').length < 2)
        {
            //console.log($('#slideShows .' + whichDiv + ' img'));
            var pos = $.inArray(whichDiv, slideShowDivs);
            slideShowDivs.splice(pos, 1);
            //console.log('deleting position ' + pos );
        }
    }

}


