function PreviewDisplay(Caption)
{
    this.Caption = Caption;
}

function PreviewPanel(ImageId, CaptionId, NextButtonId, BackButtonId, ResetButtonId)
{
    this.ImageId = ImageId;
	this.CaptionId = CaptionId;
	this.NextButtonId = NextButtonId;
	this.BackButtonId = BackButtonId;
	this.ResetButtonId = ResetButtonId;
	this.CurrentDisplayIndex = 0;
    this.Displays = new Array();
    this.goNext = goNext;
    this.reset = reset;
}

function goNext(bDirection)
{
    var scrollAmount = 620;
    
    // If bDirection is false, then go back; otherwise, go next.
    if (!bDirection)
    {
        if (this.CurrentDisplayIndex <= 0)
            this.CurrentDisplayIndex = this.Displays.length - 1;
        else
            this.CurrentDisplayIndex--;
    }
    else
    {
        scrollAmount = -620;
        if (this.CurrentDisplayIndex >= (this.Displays.length - 1))
            this.CurrentDisplayIndex = 0;
        else
            this.CurrentDisplayIndex++;
    }

    // Switch out the image and the caption.
    new Effect.MoveBy(this.ImageId, 0, scrollAmount, {duration: 0.2, transition: Effect.Transitions.sinoidal});
    $(this.CaptionId).innerHTML = this.Displays[this.CurrentDisplayIndex].Caption;
    
    // Now decide which buttons should be visible.
    if (this.CurrentDisplayIndex == 0)
    {
        $(this.NextButtonId).style.display = "block";
        $(this.BackButtonId).style.display = "none";
        $(this.ResetButtonId).style.display = "none";
    }
    else if (this.CurrentDisplayIndex == (this.Displays.length - 1))
    {
        $(this.NextButtonId).style.display = "none";
        $(this.BackButtonId).style.display = "block";
        $(this.ResetButtonId).style.display = "block";
    }
    else
    {
        $(this.NextButtonId).style.display = "block";
        $(this.BackButtonId).style.display = "block";
        $(this.ResetButtonId).style.display = "none";
    }
    
}

function reset()
{
    var scrollAmount = (this.Displays.length - 1) * 620;
    
    this.CurrentDisplayIndex = 0;

    // Switch out the image and the caption.
    new Effect.MoveBy(this.ImageId, 0, scrollAmount, {duration: 0.2, transition: Effect.Transitions.sinoidal});
    $(this.CaptionId).innerHTML = this.Displays[this.CurrentDisplayIndex].Caption;
    
    $(this.NextButtonId).style.display = "block";
    $(this.BackButtonId).style.display = "none";
    $(this.ResetButtonId).style.display = "none";
}

var myfamilyPanel = new PreviewPanel("myfamilyImage", "myfamilyCaption", "myfamilyNextButton", "myfamilyBackButton", "myfamilyResetButton");
var classmatesPanel = new PreviewPanel("classmatesImage", "classmatesCaption", "classmatesNextButton", "classmatesBackButton", "classmatesResetButton");
var callisonPanel = new PreviewPanel("callisonImage", "callisonCaption", "callisonNextButton", "callisonBackButton", "callisonResetButton");
var sonoPanel = new PreviewPanel("sonoImage", "sonoCaption", "sonoNextButton", "sonoBackButton", "sonoResetButton");

myfamilyPanel.Displays[0] = new PreviewDisplay("Family dashboard design concept greets members with a summary of most recent activity – the 'family dinner conversation'");
myfamilyPanel.Displays[1] = new PreviewDisplay("Inside page of a private site.  In this concept, chat and calendar features remain visible on every page.");
myfamilyPanel.Displays[2] = new PreviewDisplay("Research and discovery methods included mood boards and visual voice mapping to help define emotional branding");
myfamilyPanel.Displays[3] = new PreviewDisplay("The public site / value proposition");

classmatesPanel.Displays[0] = new PreviewDisplay("I led the redesign of the Reunion section. There were at least a dozen user states to design with multiple points of entry.");
classmatesPanel.Displays[1] = new PreviewDisplay("Sponsors loved this favorites list concept, since targeted advertising on closed networks is such a major challenge");
classmatesPanel.Displays[2] = new PreviewDisplay("These &quot;trading cards&quot; introducing Classmates' personas were distributed throughout the company");

callisonPanel.Displays[0] = new PreviewDisplay("I created Flash-based templates for rapid development of microsites – sometimes launched same-day.");
callisonPanel.Displays[1] = new PreviewDisplay("I created many successful presentations for Callison that were deceptively simple, but highly effective.");
callisonPanel.Displays[2] = new PreviewDisplay("High-definition presentations were expensive and slow to produce before I replaced them using PowerPoint.");

sonoPanel.Displays[0] = new PreviewDisplay("Logo design for SONO contemporary furniture");
sonoPanel.Displays[1] = new PreviewDisplay("Logo design for one of the largest science fiction and fantasy conventions in the U.S.");
sonoPanel.Displays[2] = new PreviewDisplay("Logo design for a Seattle-based environmental nonprofit");
