
    var gFolder = "../Images/Photos";
    var gPointer = 0;
    var gActor = "All";
    var gLocation = "All";
    var gPlaying = false;
    var gSlideInterval = 7000;
    var gSlideshow = "";
    var gSong = "";
    var oSong;
    var gBaseVolume = -200;
    var gVolume = gBaseVolume;
    var gLastVolume = gVolume;
    var gMuteVolume = -9999;
    var gMuted = false;
    var gDog = "";
    
    var sDeclaration = "";
    var sSourceAssignment = "";

    var aButtons = new Array();
    
    aButtons[aButtons.length] = "Home";
    aButtons[aButtons.length] = "Back";
    aButtons[aButtons.length] = "Prev";
    aButtons[aButtons.length] = "Next";
    aButtons[aButtons.length] = "Play";
    aButtons[aButtons.length] = "Pause";
    aButtons[aButtons.length] = "Stop";
    aButtons[aButtons.length] = "Mute";
    aButtons[aButtons.length] = "Unmute";
    aButtons[aButtons.length] = "StoryLogo";
    
    for ( i=0; i<aButtons.length; i++ ) {
        sDeclaration = "var o" + aButtons[i] + " = new Image()";
        sSourceAssignment = "o" + aButtons[i] + ".src = '../images/" + aButtons[i] + ".gif' ";
        
        eval( sDeclaration );
        eval( sSourceAssignment );
        
        sDeclaration = "var o" + aButtons[i] + "O = new Image()";
        sSourceAssignment = "o" + aButtons[i] + "O.src = '../images/" + aButtons[i] + "O.gif' ";

        eval( sDeclaration );
        eval( sSourceAssignment );
        
        sDeclaration = "var o" + aButtons[i] + "D = new Image()";
        sSourceAssignment = "o" + aButtons[i] + "D.src = '../images/" + aButtons[i] + "D.gif' ";

        eval( sDeclaration );
        eval( sSourceAssignment );
    }

    var aPhotos = new Array();

    for ( i=0; i<150; i++ ) {
        eval( "var gPhoto" + i + " = new Image(5,5);" );
        eval( "var gPhotoB" + i + " = new Image(5,5);" );
    }


function main() {
//    preloadButtons();
    loadFirst();
    updatePage();
    playSong();
}

function preloadButtons() {
    var oHome = document.getElementById("Home:Button");
    var oBack = document.getElementById("Back:Button");
    var oNext = document.getElementById("Next:Button");
    var oPrev = document.getElementById("Prev:Button");
    var oPlay = document.getElementById("Play:Button");
    var oPause = document.getElementById("Pause:Button");
    var oStop = document.getElementById("Stop:Button");
    var oMute = document.getElementById("Mute:Button");
    var oUnmute = document.getElementById("Unmute:Button");
/*
    if ( oHome ) {
        oHome.className = oHome.baseClass + "Over";
        oHome.className = oHome.baseClass + "Disabled";
        oHome.className = oHome.baseClass;
    }
    if ( oBack ) {
        oBack.className = oBack.baseClass + "Over";
        oBack.className = oBack.baseClass + "Disabled";
        oBack.className = oBack.baseClass;
        if ( history.length == 0 ) {
            oBack.className = oBack.baseClass + "Disabled";
            oBack.title = "- no previous page -";
            oBack.disabled = true;
        }
    }
    if ( oNext ) {
        oNext.className = oNext.baseClass;
        oNext.className = oNext.baseClass + "Over";
        oNext.className = oNext.baseClass + "Disabled";
    }
    if ( oPrev ) {
        oPrev.className = oPrev.baseClass;
        oPrev.className = oPrev.baseClass + "Over";
        oPrev.className = oPrev.baseClass + "Disabled";
    }
    if ( oPlay ) {
        oPlay.className = oPlay.baseClass + "Over";
        oPlay.className = oPlay.baseClass + "Disabled";
        oPlay.className = oPlay.baseClass;
    }
    if ( oPause ) {
        oPause.className = oPause.baseClass;
        oPause.className = oPause.baseClass + "Over";
        oPause.className = oPause.baseClass + "Disabled";
    }
    if ( oStop ) {
        oStop.className = oStop.baseClass;
        oStop.className = oStop.baseClass + "Over";
        oStop.className = oStop.baseClass + "Disabled";
    }
    if ( oMute ) {
        oMute.className = oMute.baseClass + "Over";
        oMute.className = oMute.baseClass + "Disabled";
        oMute.className = oMute.baseClass;
    }
    if ( oUnmute ) {
        oUnmute.className = oUnmute.baseClass + "Over";
        oUnmute.className = oUnmute.baseClass + "Disabled";
        oUnmute.className = oUnmute.baseClass;
    }
    */
}

function loadFirst() {
    var oPhoto = document.getElementById("MainPhoto");
    var oLabel = document.getElementById("PhotoLabel");
    var oText = document.getElementById("PhotoText");
    var oPhoto2 = document.getElementById("Photo2");
    var oLabel2 = document.getElementById("Label2");
    var oNextButton = document.getElementById("Next:Button");
    var oPrevButton = document.getElementById("Prev:Button");

    var sCurrentInfo = aPhotos[0];
    var aInfoParts = sCurrentInfo.split("|");
    var sNumParts = aInfoParts.length;

    if ( oPhoto ) {
        oPhoto.src = gFolder + "/" + aInfoParts[0] + ".jpg";
        gPhoto0.src = oPhoto.src;
    }

    var sLabel = aInfoParts[1];
    if ( oLabel ) {
        oLabel.innerHTML = sLabel;
        oPhoto.alt = sLabel;
    }

    if ( sNumParts > 2 ) {
        var sText = aInfoParts[2];

        if ( oText ) {
            oText.innerHTML = sText;
            oPhoto.alt = sText;
        }
    }
    if ( sNumParts > 3 ) {
        if ( oPhoto2 ) {
            oPhoto2.src = gFolder + "/" + aInfoParts[3] + ".jpg";
            gPhotoB0.src = oPhoto2.src;
        }
    }
    if ( sNumParts > 4 ) {
        var sLabel2 = aInfoParts[4];

        if ( oLabel2 ) {
            oLabel2.innerHTML = sLabel2;
            oPhoto2.alt = sLabel2;
        }
    }
    if ( oNextButton ) {
        oNextButton._disabled = true;
        oNextButton.src = oNextD.src;
        oNextButton.title= "- loading photos -";
    }
    if ( oPrevButton ) {
        oPrevButton._disabled = true;
        oPrevButton.src = oPrevD.src;
        oPrevButton.title= "- no previous photo -";
    }
}

function playSong() {
    var sMuted = "false";
    oSong = document.getElementById("Song");
    if ( parent.getParameter ) {
        sMuted = parent.getParameter( "Muted" );
    }

    if ( oSong ) {
        if ( gSong && false ) {
            oSong.src = gSong;
            oSong.loop = -1;
            oSong.loop = 4;
            if ( sMuted == "true" ) {
                goMute();
            }
            else {
                goUnmute();
            }
        }
        else {
            document.getElementById("Mute:Button").style.display = "none";
        }
    }
}

function goNext() {
    goStop();
    gPointer ++;
    updatePage();
}

function goPrev() {
    goStop();
    gPointer --;
    updatePage();
}

function goPlay() {
    var oPlayButton = document.getElementById("Play:Button");
    if ( gPlaying ) {
        goStop();
    }
    else {
        gPlaying = true;
        incrementSlide();
        gSlideshow = window.setInterval( "incrementSlide()", gSlideInterval );
        if ( oPlayButton ) {
            oPlayButton._disabled = true;
            oPlayButton.src = oPlayD.src;
            oPlayButton.title= "- playing -";
            oPlayButton.style.cursor = "default";
        }
    }
}

function incrementSlide() {
    var sNumPhotos = aPhotos.length;
    if ( gPointer < sNumPhotos - 1 ) {
        gPointer ++;
    }
    else {
        gPointer = 0;
    }
    updatePage();
}

function goStop() {
    var oPlayButton = document.getElementById("Play:Button");
    if ( gPlaying ) {
        gPlaying = false;
        if ( gSlideshow != "" ) {
            window.clearInterval(gSlideshow);
        }
        gSlideshow = "";
        if ( oPlayButton ) {
            oPlayButton._disabled = false;
            oPlayButton.src = oPlay.src;
            oPlayButton.title= "Play Slideshow";
            oPlayButton.style.cursor = "pointer";
        }
    }
}

function goBack() {
    history.back();
}

function goHome() {
    gPointer == 0;
    document.location = "Home.html";
}

function goPage( pPage ) {
    gPointer == 0;
    if ( pPage == "InsideStuff" && checkInsider() ) {
        document.location = "InsideMenu.html";
    }
    else {
        document.location = pPage + ".html";
    }
}

function goMute() {
    if ( oSong ) {
        gLastVolume = oSong.volume;
        oSong.volume = gMuteVolume;
        document.getElementById("Mute:Button").style.display = "none";
        document.getElementById("Unmute:Button").style.display = "";
    }
    gMuted = true;
    if ( parent.setParameter ) {
        parent.setParameter( "Muted", gMuted );
    }
}

function goUnmute() {
    if ( oSong ) {
        oSong.volume = gLastVolume;
        document.getElementById("Mute:Button").style.display = "";
        document.getElementById("Unmute:Button").style.display = "none";
    }
    gMuted = false;
    if ( parent.setParameter ) {
        parent.setParameter( "Muted", gMuted );
    }
}

function updatePage() {
    var oPrevButton = document.getElementById("Prev:Button");
    var oNextButton = document.getElementById("Next:Button");
    var oPhoto = document.getElementById("MainPhoto");
    var oLabel = document.getElementById("PhotoLabel");
    var oText = document.getElementById("PhotoText");
    var oPhoto2 = document.getElementById("Photo2");
    var oLabel2 = document.getElementById("Label2");

    var sNumPhotos = aPhotos.length;
    var sCurrentInfo = aPhotos[gPointer];
    var aInfoParts = sCurrentInfo.split("|");
    var sNumParts = aInfoParts.length;
    var sNextPointer = gPointer + 1;

    var sImageSource = "gPhoto" + gPointer + ".src";

    var sImageBSource = "gPhotoB" + gPointer + ".src";

    if ( oPhoto ) {
        var sImage = aInfoParts[0];
        if ( sImageSource ) {
            oPhoto.src = eval( sImageSource );
        }
        else {
            oPhoto.src = gFolder + "/" + sImage + ".jpg";
        }
    }

    var sLabel = aInfoParts[1];
    if ( oLabel ) {
        oLabel.innerHTML = sLabel;
            oPhoto.alt = sLabel;
    }

    if ( sNumParts > 2 ) {
        var sText = aInfoParts[2];

        if ( oText ) {
            oText.innerHTML = sText;
        }
    }
    if ( sNumParts > 3 ) {
        var sImage2 = aInfoParts[3];

        if ( oPhoto2 ) {
            if ( sImageSource ) {
                oPhoto2.src = eval( sImageBSource );
            }
            else {
                oPhoto2.src = gFolder + "/" + sImage2 + ".jpg";
            }
        }
    }
    if ( sNumParts > 4 ) {
        var sLabel2 = aInfoParts[4];

        if ( oLabel2 ) {
            oLabel2.innerHTML = sLabel2;
            oPhoto2.alt = sLabel2;
        }
    }


    if ( oPrevButton ) {
        if ( gPointer == 0 ) {
            oPrevButton._disabled = true;
            oPrevButton.src = oPrevD.src;
            oPrevButton.title= "- no previous photo -";
            oPrevButton.style.cursor = "default";
        }
        else {
            oPrevButton._disabled = false;
            oPrevButton.src = oPrev.src;
            oPrevButton.title= "Go Back to Previous Photo";
            oPrevButton.style.cursor = "pointer";
        }
    }

    if ( oNextButton ) {
        if ( gPointer < sNumPhotos - 1 ) {
            oNextButton._disabled = false;
            oNextButton.src = oNext.src;
            oNextButton.title= "Go to Next Photo";
            oPrevButton.style.cursor = "pointer";

            // Preload next photo

            sCurrentInfo = aPhotos[ sNextPointer ];
            aInfoParts = sCurrentInfo.split("|");
            sNumParts = aInfoParts.length;

            sImage = aInfoParts[0];
            eval( "gPhoto" + sNextPointer + ".src = '" + gFolder + "/" + sImage + ".jpg'" );
            if ( sNumParts > 3 ) {
                sImage = aInfoParts[3];
                eval( "gPhotoB" + sNextPointer + ".src = '" + gFolder + "/" + sImage + ".jpg'" );
            }
        }
        else {
            oNextButton._disabled = true;
            oNextButton.src = oNextD.src;
            oNextButton.title= "- no more photos -";
            oPrevButton.style.cursor = "default";
        }
    }
}

function checkActor( pSelect ) {
    var sIndex = pSelect.selectedIndex;
    var gActor = pSelect.options(sIndex).text;
}

function checkLocation( pSelect ) {
    var sIndex = pSelect.selectedIndex;
    var gLocation = pSelect.options(sIndex).text;
}

function    checkInsider( pName ) {
    var sName = "";
    if ( pName ) {
        sName = pName;
    }
    if ( parent.getParameter ) {
        sName = parent.getParameter( "Dog" );
    }
    sName = sName.toLowerCase();

    switch (sName) {
        case    "harley":
        case    "harleydog":
        case    "harley dog":
        case    "harley-dog":
        case    "hurley":
            return true;
            break;
        default:
            return false;
    }
}