// photoslideshow.js

window.categories = new Array();
window.photos = new Array();

function category(categoryId, name) {
	// category construction
	this.id = "a" + categoryId;
	this.name = name;
	this.photoIds = new Array();
	this.photos = new Array();
	this.images = new Array();
	this.pics_loaded = 0;
}

function photo(photoId, source, linktext, caption, categoryId) {
	// photo constructor
	this.id = "a" + photoId;
	this.source = source;
	this.linktext = linktext;
	this.caption = caption;
	this.categoryId = categoryId;
	
	// put it in the All category
	var allCategory = window.categories[0];
	allCategory.photoIds[allCategory.photoIds.length] = photoId;
	allCategory.photos[allCategory.photos.length] = this; //"a" + photoId
	
	// and put it in its own category
	var thisCategory = window.categories[categoryId];
	thisCategory.photoIds[thisCategory.photoIds.length] = photoId;
	thisCategory.photos[thisCategory.photos.length] = this; //"a" + photoId
}

var allCategoryId         = "0"; window.categories[window.categories.length] = new category(allCategoryId,"All");
var doorCategoryId        = "1"; window.categories[window.categories.length] = new category(doorCategoryId,"Doors")
var panelCategoryId       = "2"; window.categories[window.categories.length] = new category(panelCategoryId,"Panels")
var cabinetDoorCategoryId = "3"; window.categories[window.categories.length] = new category(cabinetDoorCategoryId,"Cabinet Doors")
var lampCategoryId        = "4"; window.categories[window.categories.length] = new category(lampCategoryId,"Lamps & Lanterns")
var mosaicCategoryId      = "5"; window.categories[window.categories.length] = new category(mosaicCategoryId,"Mosaics")
var otherCategoryId       = "6"; window.categories[window.categories.length] = new category(otherCategoryId,"Other")
var nevinsCategoryId      = "7"; window.categories[window.categories.length] = new category(nevinsCategoryId,"Nevins Memorial Library")
var billericaCategoryId   = "8"; window.categories[window.categories.length] = new category(nevinsCategoryId,"Billerica Public Library")
var commercialCategoryId  = "9"; window.categories[window.categories.length] = new category(commercialCategoryId,"Commercial Installations")

// alert("categories defined");

// door photos
window.photos[window.photos.length] = new photo(window.photos.length,"images/EntryAbstractInPage.jpg", "Abstract Entry Door", "", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/DoorFLWReproductionInPage.jpg", "Frank Lloyd Wright style Door", 
 "This Frank Lloyd Wright panel insert for the front entry of this glorious private residence in Newport, RI was built at Trinity to exactly duplicate " +
 "an original antique panel already owned by this client.", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/HutchDoorInPage.jpg", "Hutch Door", "", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsTopiaryInstalledInPage.jpg", "Topiary Hutch Doors", 
 "This topiary design was requested by the client to compliment the old world decor of this beautiful home.", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/TopiaryDoorsDetail.jpg", "Topiary Hutch Doors - Detail view", "", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/RoomDividerScreen.jpg", "Room Divider Screen", "", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/FloralSidelightEntry.jpg", "Floral Sidelight Entry Door", 
 "Amy designed this sidelight to closely match the design and color scheme of a light fixture that the customers already owned.  The trellis, " +
 "which is not present in the light shade design, was added for interest and color.", doorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/LeadedSidelightsYellowGreenInPage.jpg", "Leaded Sidelights", "A pair of leaded sidelights in the Victorian style", doorCategoryId);

// panel photos
window.photos[window.photos.length] = new photo(window.photos.length,"images/Lighthouses-full-panel-cropped.jpg", "Lighthouses Panel", "", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Lighthouses-Bug-cropped.jpg", "Lighthouses Panel, Bug Light", "", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Lighthouses-Gurnet-cropped.jpg", "Lighthouses Panel, The Gurnet", "", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Lighthouses-Minots-cropped.jpg", "Lighthouses Panel, Minot's Ledge Light", "", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Lighthouses-Graves-cropped.jpg", "Lighthouses Panel, Graves Light", "", panelCategoryId);

var morsefamilypanelslinkelement = "<a target='_blank' href='images/MorsePanels.html' style='color: cc9900; font-weight: normal; text-decoration: underline;'>Read More...</a>"
window.photos[window.photos.length] = new photo(window.photos.length,"images/SunandMoonPanelTrio.jpg", "Sun and Moon Panel",
"The Sun and Moon window is one of two windows commissioned by the Morse family of Warwick, RI, for their children's bedrooms. " + morsefamilypanelslinkelement + "<br><br>" +
"The Sun and Moon window, commissioned first, was built for the girls who both had a lot of input into the design and color choices.", panelCategoryId);

window.photos[window.photos.length] = new photo(window.photos.length,"images/RISailBoatPanelTrio.jpg", "Hope Panel",
"The Hope window is the second of two windows commissioned by the Morse family. " + morsefamilypanelslinkelement + "<br><br>" +
"The Hope window was built for the boys and has a nautical/Rhode Island theme.", panelCategoryId);

window.photos[window.photos.length] = new photo(window.photos.length,"images/BoxerPanelTrio.jpg", "Biff Panel",
"Biff, a Champion Boxer, owned by Dr. & Mrs. William Truesdale, is memorialized in this custom panel.  Using a photograph of the dog, Biff's " +
"likeness was created implementing both the copper foil and lead came methods, and includes painted and sandblasted details.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/KitchenValanceCabinetWorks.jpg", "Kitchen Valance and Mirrored Window Sash", 
"A custom valance on display in the showroom at Cabinet Works, Inc. in Warwick, RI.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/FLWBathWhiteInPage.jpg", "FLW style Bath Panel", 
 "This large leadlight was commissioned for use in a private residence.  The clients requested something in the style of Frank Lloyd Wright, and Amy " + 
 "adapted this design from multiple photographs in books on Wright.  The customers were pleased, and subsequently ordered a pair of sidelights for " + 
 "their front entry in another adaptation of a Wright design.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/HorseandSunInPage.jpg", "Horse Panel", "A custom window installed as an interior transom in the home of a horse lover", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/KitchenValanceInPage.jpg", "Kitchen Valance", "", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/SwansBathroomPanel.jpg", "Swans Bathroom Panel", 
 "The owner of this stunning bathroom commissioned Amy to build a pair of large windows to compliment her elegant decor, and her swan theme, and to " +
 "allow for privacy above her jacuzzi tub.  The panels were installed into existing crank-out windows.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/MagnoliaCornerPanel.jpg", "Magnolia Corner Panel", 
 "One of a pair of Magnolia window brackets which can easily be installed in most types of windows", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/RoundFloralPanels.jpg", "Round Floral Panels", 
 "These two small lead lights, constructed in the Tiffany copper foil method, were installed on the inside of fixed lights on either side of the " +
 "customer's front door.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/DogMemorialPanel.jpg", "Best Friend Panel", 
 "This custom panel was commissioned by the customer as a memorial to his beloved best friend.", panelCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/FLWBathWindow.jpg", "FLW style Bath Window", "", panelCategoryId);

// cabinet door photos
window.photos[window.photos.length] = new photo(window.photos.length,"images/BevelClusterKitchenCabinetDoorcropped.jpg", "Bevel cluster Kitchen Cabinet Door", "This Cabinet Door uses clear textures to enhance the bevels", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsSouthwesternInPage.jpg", "Southwestern Cabinet Doors", "A Southwestern mural of four panels for cabinet inserts", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsDiamondBevelsSidebar.jpg", "Diamond Bevels Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsIvyTrellisSidebar.jpg", "Ivy Trellis Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/GreenLeavesCabinetDoor.jpg", "Green Leaves Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsNarrowBevelsInPage.jpg", "Beveled Cabinet Doors", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CabinetDoorsRectangularBevelsInPage.jpg", "Rectangular Beveled Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/ShellBevelPanelDoors.jpg", "Shell Bevel Cabinet Doors", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/GeometricCabinetDoors.jpg", "Kitchen Cabinet Doors", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/TulipCabinetDoor.jpg", "Tulip Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/TwoCallaLilyCabinetDoors.jpg", "Calla Lillies Cabinet Doors", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/MissionRoseCabinetDoor.jpg", "Mission Rose Cabinet Door", "", cabinetDoorCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/DiamondCabinetDoors.jpg", "Diamond Cabinet Doors", 
 "A set of leaded cabinet doors installed in a newly re-modeled kitchen in a fully restored turn-of-the-century private residence.  These are four of " + 
 "six matching doors commissioned by the client, and the glass is clear, hand-drawn, German 'Antique' glass.", cabinetDoorCategoryId);

// lamps
var waterlilylinkelement = "<a target='_blank' href='images/Water Lily Cone Desc.html' style='color: cc9900; font-weight: normal; text-decoration: underline;'>Read More...</a>"
window.photos[window.photos.length] = new photo(window.photos.length,"images/Water Lily Cone Lamp cropped.gif", "Water Lily Cone Lamp", 
                 "This 420 piece lampshade was built using the Odyssey system, and was the 'teacher example' for our annual Tiffany Lamp Construction Workshop at " +
                 "Trinity. " + waterlilylinkelement + "<br><br>This lamp is on display, and for sale at Newport Fine Arts, 135 Spring Street, Newport, Rhode Island.", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/WaterLilyConeLampCloseup.gif", "Water Lily Cone Lamp", "A Closeup View<br>" + waterlilylinkelement + "", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/WaterLilyConeLampDetailTop.gif", "Water Lily Cone Lamp", "The View from the top<br>" + waterlilylinkelement + "", lampCategoryId);

window.photos[window.photos.length] = new photo(window.photos.length,"images/LambertsLamp.jpg", "Arts &amp; Crafts Style Lamp", 
                 "This Arts & Crafts style lamp shade is in a patinated metal frame, and was made using Lamberts mouth blown glass.", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/FilligreeLamp.jpg", "Filigree Lamp", 
									"Tiffany-style filigree overlay shade with ball chain trim, and green patina.", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/ChestnutLamp.jpg", "Chestnut Lamp", "Tiffany style Chestnut lamp, with hammered solder seams", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/StonesLamp.jpg", "Panel Lamp", 
 "The design for this 17-inch diameter, 4-panel shade was taken from the wonderful book, 'Elegant Lamps Four', " + 
 "and fabricated by Amy, using Youghiogheny Stipple glass.  Both the book and the glass are, of course, available at Trinity.", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/ArtsCraftsLamp.jpg", "Arts &amp; Crafts Rose Lamp", 
"Small Arts & Crafts style table lamp, adapted from the Mackintosh Rose design", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/RedLanternLamp.jpg", "Red Lantern", "Arts & Crafts style lantern, designed and fabricated by Amy Custis", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/GrapesLanternLamp.jpg", "Solder Carved Lantern", "", lampCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/CopperTreeSculptureLantern.jpg", "Copper Tree Lantern", 
 "Sculpted copper tree applied to Uroboros ripple glass makes this lantern one-of-a-kind", lampCategoryId);

// mosaics
window.photos[window.photos.length] = new photo(window.photos.length,"images/MosaicTabletopMagnolias.jpg", "Magnolia Mosaic Table top", "Magnolia Glass mosaic table top designed by Joyce Vass at Trinity", mosaicCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/SunflowerTableMosaic.jpg", "Sunflower Mosaic Table top", "Sunflower Glass mosaic table top designed and fabricated at Trinity", mosaicCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/GrapesTableMosaic.jpg", "Grapes Mosaic Table top", "Grapes Glass mosaic table top designed and fabricated at Trinity", mosaicCategoryId);

// other photos
window.photos[window.photos.length] = new photo(window.photos.length,"images/WallMirror.jpg", "Wall Mirror", "", otherCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/ClassesLeadPanelsInPage.jpg", "Lead Panels Class Projects", 
 "These two panels are examples of the pattern choices that a student has when taking Trinity's 'Intro to the Lead Came Method' workshop.", otherCategoryId);

// Nevins photos
var journeylinkelement = "<a target='_blank' href='publications/The Four Seasons Windows.pdf' style='color: cc9900; font-weight: bold; text-decoration: underline;'>The Nevins Journey</a><br><br>"
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsLibraryLampsinRoom.jpg", "Nevins Memorial Library - Lamps", 
 journeylinkelement + "Amy was commissioned to design and build the two matching lamps which stand on posts and reflect the colors of the overhead window.", nevinsCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsLibraryLampsAmy.jpg", "Nevins Memorial Library - Lamps", 
 journeylinkelement + "Amy stands alongside the Lamps", nevinsCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsLibraryLampCloseup.jpg", "Nevins Memorial Library - Lamps", journeylinkelement + "One of the Lamps in detail", nevinsCategoryId);

window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsMcGrainSpringsm.jpg", "Nevins Memorial Library - Four Seasons Windows", journeylinkelement + "Spring, in collaboration with Peter McGrain", nevinsCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsMcGrainSummersm.jpg", "Nevins Memorial Library - Four Seasons Windows", journeylinkelement + "Summer, in collaboration with Peter McGrain", nevinsCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsMcGrainFallsm.jpg"  , "Nevins Memorial Library - Four Seasons Windows", journeylinkelement + "Fall, in collaboration with Peter McGrain"  , nevinsCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/NevinsMcGrainWintersm.jpg", "Nevins Memorial Library - Four Seasons Windows", journeylinkelement + "Winter, in collaboration with Peter McGrain", nevinsCategoryId);

// Billerica photos

var billericalinkelement = "<a target='_blank' href='publications/The Billerica Story.pdf' style='color: cc9900; font-weight: bold; text-decoration: underline;'>The Billerica Story</a><br><br>";

window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/01-BillericaMusicalDragonfly.jpg"                 , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/02-BillericaWhaleDragonfly.jpg"                   , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/03-BillericaOrangeButterfly.jpg"                  , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/04-BillericaButterflyAndLadyBug.jpg"              , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/05-BillericaThreeWindows.jpg"                     , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/06-BillericaTwoWindows.jpg"                       , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/07-BillericaCaterpillarFarAwayLand.jpg"           , "Billerica Public Library - Windows" , billericalinkelement + "in collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/08-BillericaBlueButterfly.jpg"                    , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/09-BillericaButterflyAndLadybugBird.jpg"          , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/10-BillericaButterflyAndLadybugHands.jpg"         , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/11-BillericaButterflyAndLadybugBoat.jpg"          , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/12-BillericaOrangeBufferflyRabbit.jpg"            , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/13-BillericaOrangeButterflyKey.jpg"               , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/14-BillericaMusicalDragonflyDonkey.jpg"           , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/15-BillericaBlueFlowerClothespin.jpg"             , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/16-BillericaBlueFlowerTrumpet.jpg"                , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/17-BillericaLeafDinosour.jpg"                     , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/18-BillericaLeafComb.jpg"                         , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/19-BillericaLeafSneaker.jpg"                      , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/20-BillericaPinkFlowerMushroom.jpg"               , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/21-BillericaWhaleDragonflyWhales.jpg"             , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/22-BillericaWhaleDragonflyHappilyEverAfter.jpg"   , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/Billerica/23-BillericaWhaleDragonflyCCBloom.jpg"            , "Billerica Public Library - Windows" , billericalinkelement + "In collaboration with Peter McGrain" , billericaCategoryId);

// commercial photos
var tsRestaurantlinkelement = "<a target='_blank' href='images/TsRestaurantDesc.html' style='color: cc9900; font-weight: normal; text-decoration: underline;'>Read More...</a>"
window.photos[window.photos.length] = new photo(window.photos.length,"images/TsRestaurantLogoCropped.gif", "T's Restaurant, Cranston, RI", 
	"Anthony and Tina Tomaselli, owners of the long-popular T's Restaruant, on Park Avenue<br><br>" +
	"T's medallion panel built by Trinity<br><br>" + tsRestaurantlinkelement + "", commercialCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/TsRestaurantRoseCropped.jpg", "T's Restaurant, Cranston, RI",
	"Old lead light in the stylized rose design<br><br>" + tsRestaurantlinkelement + "", commercialCategoryId);
window.photos[window.photos.length] = new photo(window.photos.length,"images/TsRestaurantColorPanelsDistantCropped.jpg", "T's Restaurant, Cranston, RI", 
	"Colorful glass Divider panels<br><br>" + tsRestaurantlinkelement + "", commercialCategoryId);

// alert("photos loaded");

var timer;
var current_location = 0; //1;
var next_location = 0; // 1;
//var pics_loaded = 0;
var onoff = 0;
var direction = 1;
var timeout_value;
//var images = new Array;
var photo_urls = new Array;
var photo_captions = new Array;
var transitionNames = new Array;
var transitions = new Array;
var current_transition = 0;
var loop = 1;

transitions[0] = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
var transition_count = 1;

window.current_categoryId = 0; // initialize to All 
function current_category() { /*alert("in current_category and current_categoryId is " + window.current_categoryId); */ return window.categories[window.current_categoryId]; }
function photo_count() { /*alert("in photo_count"); */ return current_category().photos.length; } // var photo_count = window.photos.length; 

// Browser capabilities detection ---
// - assume only IE4+ and NAV6+ can do image resizing, others redirect to low
if (is_ie4up || is_opera5up || is_nav6up) {
    //-- it's all good ---
} else {
    //-- any other browser, no go ---
    alert("You need a newer browser version to see the slide show.\n\nPlease visit the other areas of our website for samples of our work.");
}

// - IE5.5 and up can do the blending transition.
var browserCanBlend = (is_ie5_5up);

function stopOrStart() {
    if (onoff) stop(); else play();
}

function toggleLoop() {
    if (loop) loop = 0; else loop = 1;
}

function changeElementText(id, newText) {
    element = document.getElementById(id);
    element.innerHTML = newText;
}

function stop() {
    changeElementText("stopOrStartText", "Click here to Resume");
    onoff = 0;
    clearTimeout(timer);

}

function play() {
    changeElementText("stopOrStartText", "Click here to Pause");

    onoff = 1;
    go_to_next_photo();
}

function changeDirection() {
    if (direction == 1) {
			direction = -1;
			changeElementText("changeDirText", "forward");
    } else {
			direction = 1;
			changeElementText("changeDirText", "reverse");
    }
    preload_next_photo();

}

function change_transition() {
    current_transition = document.TopForm.transitionType.selectedIndex;
}

function preload_complete() {
}

function reset_timer() {
    clearTimeout(timer);
    if (onoff) {
	timeout_value = 5000; //1000;
	timer = setTimeout('go_to_next_photo()', timeout_value);
    }
}

function wait_for_current_photo() {

    /* Show the current photo */
    if (!show_current_photo()) {

			/*
			 * The current photo isn't loaded yet.  Set a short timer just to wait
			 * until the current photo is loaded.
			 */
			clearTimeout(timer);
			timer = setTimeout('wait_for_current_photo()', 500);
			return 0;
    } else {
			preload_next_photo();
			reset_timer();
    }
}

function go_to_next_photo() {
    /* Go to the next location */
    current_location = next_location;

    /* Show the current photo */
    if (!show_current_photo()) {
			wait_for_current_photo();
			return 0;
    }

    preload_next_photo();
    reset_timer();
}

function preload_next_photo() {

    /* Calculate the new next location */
    next_location = (parseInt(current_location) + parseInt(direction));
    if (next_location == photo_count()) { // was >
			next_location = 0; // was 1;
			if (!loop) stop();
    }
		
    if (next_location == -1) { // was 0
        next_location = photo_count();
				if (!loop) stop();
    }

    /* Preload the next photo */
    preload_photo(next_location);
}

function show_current_photo() {

    /*
     * If the current photo is not completely loaded don't display it.
     */
    if (!current_category().images[current_location] || !current_category().images[current_location].complete) {
			preload_photo(current_location);
			return 0;
    }

    /* transition effects */
    if (browserCanBlend){
			var do_transition;
			if (current_transition == (transition_count)) {
	    	do_transition = Math.floor(Math.random() * transition_count);
			} else {
	    	do_transition = current_transition;
			}
			document.images.slide.style.filter=transitions[do_transition];
			document.images.slide.filters[0].Apply();
    }
		
    document.slide.src = current_category().images[current_location].src;
		setTitle(current_category().photos[current_location].linktext); //setTitle(window.photos[current_location].linktext);
    setCaption(current_category().photos[current_location].caption); //setCaption(window.photos[current_location].caption);

    if (browserCanBlend) {
			document.images.slide.filters[0].Play();
    }

    return 1;
}

function preload_photo(index) {

    /* Load the next picture */
    if (current_category().pics_loaded < photo_count()) {

			/* not all the pics are loaded.  Is the next one loaded? */
			if (!current_category().images[index]) {
			    current_category().images[index] = new Image;
			    current_category().images[index].onLoad = preload_complete();
			    current_category().images[index].src = current_category().photos[index].source; //window.photos[index].source;
			    current_category().pics_loaded++;
			}
		}
}

function setTitle(text) {
    changeElementText("title", text);
}

function setCaption(text) {
    changeElementText("caption", text);
}

function categoryClick(selectedCategoryId) {
	var lastCategoryId = window.current_categoryId;
	var lastCategoryLink =  document.getElementById("categorylinks_" + lastCategoryId); //eval("window.categorylinks_" + lastCategoryId);
	lastCategoryLink.style.color = "cc9900";
	var newCategoryLink = document.getElementById("categorylinks_" + selectedCategoryId); //eval("window.categorylinks_" + selectedCategoryId);
	newCategoryLink.style.color = "ffffff"; // white for the selected category
	
	stop();
	//alert("currentcategory is " + window.current_categoryId + " new category is " + selectedCategoryId );
	window.current_categoryId = selectedCategoryId;
	window.current_location = 0;
	window.next_location = 0;
	play();
}