/*
Include this script and to use this, you need to just

1) Generate the Albums.
        1a) Create the Gallery with the createGallery() function.  This returns the id # of the gallery.
        1b) add photos to the gallery, you pass in the gallery id of the gallery you wish to add photos into, the photo url
                (can be relative or absolute), and the caption.  Repeat this step as necessary for each photo in this gallery.
        1c) write the gallery

                Example of Step 1
                      function generateAlbums()
                      {
                              var galleryNumber;
                              galleryNumber = createGallery();
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-3.jpg","Caption is this");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-5.jpg","Changed");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-3.jpg","Alhambra");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-5.jpg","Caption is this");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-3.jpg","Changed");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-5.jpg","Alhambra");
                              writeGallery(galleryNumber, 0);

                              galleryNumber = createGallery();
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-3.jpg","Gallery 2");
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-5.jpg","Gallery 2 picture 2");
                              writeGallery(galleryNumber, 0);

                              galleryNumber = createGallery();
                              addPhotoToGallery(galleryNumber, "http://lasccourtnetdv/internet/VolunteerOpportunities/Data/outReach-3.jpg","Gallery 3");
                              writeGallery(galleryNumber, 0);

                      }

                      and then you need to call generateAlbums. you can do this however you want

        You can repeat 1a-1c as many times as you have different galleries

2)  You must have <div id="gallery(GALLERYNUMBER)"></div> where you want each photo gallery you create to go.

3)  If you want bigger space between the galleries, change the spacerBetweenGalleries variable.

*/

        var photoStreams = new Array();
        var photoStream;
        var galleryHTML = "";

        var nextStream = 0;

        function Photo(photoSrc, caption)
        {
                this.photoSrc = photoSrc;
                this.caption = caption;
        }

        function createGallery()
        {
                photoStream = new Array();
                photoStreams[nextStream] = photoStream;
                nextStream++;
                return (nextStream - 1);
        }

        function addPhotoToGallery(galleryNumber, photoSrc, caption)
        {
                var photoObj = new Photo(photoSrc,caption);
                photoStream = photoStreams[galleryNumber];
                photoStream[photoStream.length] = photoObj;
        }

        function writeGallery(galleryNumber, photoNumber)
        {
                var galleryData = document.getElementById("gallery" + galleryNumber);
                var newGallery = "";
                photoStream = photoStreams[galleryNumber];

                if(photoNumber > photoStream.length - 1)
                {
                        return false;
                }
                else
                {
                        var photoObj = photoStream[photoNumber];
                        newGallery = newGallery + "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
                        newGallery = newGallery + "<tr><td class=\"roundGray_top\"></td></tr>";
                        newGallery = newGallery + "<tr><td><div class=\"roundGray_mid\">";
                        newGallery = newGallery + "<table class=\"tblfont\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
                        newGallery = newGallery + "<tr><td class=\"tblWidth10\"></td><td valign=\"top\" width=\"213\">";
                        newGallery = newGallery + "<span class=\"photoImages\" id=\"galleryPhoto" + galleryNumber + "\"><img class=\"whiteBorder\" src=\"" + photoObj.photoSrc + "\"></span>";
                        newGallery = newGallery + "</td><td class=\"tblWidth10\"></td><td valign=\"top\" class=\"imageCount\">";

                        newGallery = newGallery + "<table class=\"tblfont\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" style=\"margin-bottom: -6px\">";
                        newGallery = newGallery + "<tr><td>";
                        newGallery = newGallery + "<div class=\"galleryNavigation\" id=\"galleryNavigation" + galleryNumber + "\">" + getNavigation(galleryNumber, photoNumber) + "</div>";
                        newGallery = newGallery + "<div class=\"spacer3to1\"></div>";
                        newGallery = newGallery + "<div class=\"spacer1\"></div>";
                        newGallery = newGallery + "<div class=\"galleryCaption\" id=\"galleryCaption" + galleryNumber + "\">" + photoObj.caption + "</div></div>";
                        newGallery = newGallery + "</td></tr></table>";
                        
                        newGallery = newGallery + "</td><td class=\"tblWidth10\"></td></tr></table></div>";
                        newGallery = newGallery + "</td></tr>";
                        newGallery = newGallery + "<tr><td class=\"roundGray_btm\"></td></tr>";
                        newGallery = newGallery + "</table>";
                        galleryData.innerHTML = newGallery;
                }
        }

        function updateGallery(galleryNumber, photoNumber)
        {
                photoStream = photoStreams[galleryNumber];
                photoObj = photoStream[photoNumber];
                photoDiv = document.getElementById("galleryPhoto" + galleryNumber);
                captionDiv = document.getElementById("galleryCaption" + galleryNumber);
                navigationDiv = document.getElementById("galleryNavigation" + galleryNumber);
                photoDiv.innerHTML = "<img class=\"whiteBorder\" border=\"0\" src=\"" + photoObj.photoSrc + "\">";
                captionDiv.innerHTML = photoObj.caption;
                navigationDiv.innerHTML = getNavigation(galleryNumber, parseInt(photoNumber));
                return false;
        }


        function getNavigation(galleryNumber, currentPhoto)
        {
                photoStream = photoStreams[galleryNumber];
                navigation = "Photo Gallery&nbsp;&nbsp;&nbsp;";
                if(currentPhoto > 0)
                {
                        navigation = navigation + "<a href=\"#\" onclick=\"return updateGallery('" + galleryNumber + "', '" + (parseInt(currentPhoto) - 1) + "');\">&lt;</a>&nbsp;"
                }
                else
                {
                        navigation = navigation + "<span style=\"visibility: hidden;\"><a href=\"#\" onclick=\"return updateGallery('" + galleryNumber + "', '" + (parseInt(currentPhoto) - 1) + "');\">&lt;</a>&nbsp;</span>"
                }
                navigation = navigation + (currentPhoto + 1) + " of " + photoStream.length + "&nbsp;";
                if(currentPhoto < photoStream.length - 1)
                {
                        navigation = navigation + "<a href=\"#\" onclick=\"return updateGallery('" + galleryNumber + "', '" + (parseInt(currentPhoto) + 1) + "');\">&gt;</a>&nbsp;"
                }
                return navigation;
        }

