//---------------------------------------------------------------------||
// INTERNAL GLOBAL VARIABLES                                           ||
// PURPOSE:     Internal use only, do not modify.                      ||
//---------------------------------------------------------------------||
var xMediaContentJP  = new Array();
var xMediaImageJP    = new Image;
var iCurrentImageJP  = 0;
var iInternalCountJP = 5000;
var xTimerHandleJP   = null;
var bTimerRunningJP  = false;


//---------------------------------------------------------------------||
// USER DEFINED VARIABLES                                              ||
// PURPOSE:     Set these variables to customize your script           ||
//              TimeInSecondsBetweenCycles - Seconds to wait before    ||
//                                           cycling to the next image ||
//              LoadInNewWindow            - When true, the link will  ||
//                                           be opened in a new window ||
//                                           otherwise, it will load in||
//                                           the current window.       ||
//              WrapAtEnd                  - Wraps to start at end.    ||
//                                                                     ||
//              MEDIAIMAGE                - Needs defined in your HTML ||
//                                           page as an image name.    ||
//---------------------------------------------------------------------||
var TimeInSecondsBetweenCyclesJP = 2.5;
var LoadInNewWindowJP = false;
var WrapAtEndJP       = true;


//---------------------------------------------------------------------||
// MEDIA FILES TO LOAD                                                 ||
// PURPOSE:     This is the image that you wish displayed, followed by ||
//              the URL to link to.  All images should be on even      ||
//              numbered lines, URLS on odd.  Pay careful attention to ||
//              increment the counter inside of the [] symbols when you||
//              add more images.  There is no maximum to the amount of ||
//              images you can load.                                   ||
//---------------------------------------------------------------------||
xMediaContentJP[0] = "./images/JayPeakPics/JP01.jpg";
xMediaContentJP[1] = "images/JayPeakPics/JP_Group.jpg";

xMediaContentJP[2] = "./images/JayPeakPics/JP02.jpg";
xMediaContentJP[3] = "images/JayPeakPics/JP02.jpg";

xMediaContentJP[4] = "./images/JayPeakPics/JP03.jpg";
xMediaContentJP[5] = "images/JayPeakPics/JP03.jpg";

xMediaContentJP[6] = "./images/JayPeakPics/JP04.jpg";
xMediaContentJP[7] = "images/JayPeakPics/JP04.jpg";

xMediaContentJP[8] = "./images/JayPeakPics/JP05.jpg";
xMediaContentJP[9] = "images/JayPeakPics/JP05.jpg";

xMediaContentJP[10] = "./images/JayPeakPics/JP06.jpg";
xMediaContentJP[11] = "images/JayPeakPics/JP06.jpg";

xMediaContentJP[12] = "./images/JayPeakPics/JP07.jpg";
xMediaContentJP[13] = "images/JayPeakPics/JP07.jpg";

xMediaContentJP[14] = "./images/JayPeakPics/JP08.jpg";
xMediaContentJP[15] = "images/JayPeakPics/JP08.jpg";

xMediaContentJP[16] = "./images/JayPeakPics/JP10.jpg";
xMediaContentJP[17] = "images/JayPeakPics/JP10.jpg";



//---------------------------------------------------------------------||
// FUNCTION:    MediaStop                                              ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaStopJP()
{
    if( bTimerRunningJP )
        clearTimeout( xTimerHandleJP );

    bTimerRunningJP = false;
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoBack                                            ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoBackJP()
{
    MediaStopJP();

    if (WrapAtEndJP)
      (iCurrentImageJP == 0) ? iCurrentImageJP = (xMediaContentJP.length - 2) : iCurrentImageJP-=2;
    else
      (iCurrentImageJP == 0) ? iCurrentImageJP = 0 : iCurrentImageJP-=2;

    document.MEDIAIMAGEJP.src = xMediaContentJP[iCurrentImageJP];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoForward                                         ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoForwardJP()
{
    MediaStopJP();

    if (WrapAtEndJP)
      (iCurrentImageJP == (xMediaContentJP.length - 2)) ? iCurrentImageJP = 0 : iCurrentImageJP+=2;
    else
      (iCurrentImageJP == (xMediaContentJP.length - 2)) ? iCurrentImageJP = iCurrentImageJP : iCurrentImageJP+=2;

    document.MEDIAIMAGEJP.src = xMediaContentJP[iCurrentImageJP];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaInternalCycle                                     ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Internal media cycle routine                           ||
//---------------------------------------------------------------------||
function MediaInternalCycleJP()
{
    (iCurrentImageJP == (xMediaContentJP.length - 2)) ? iCurrentImageJP = 0 : iCurrentImageJP+=2;
    if( document.MEDIAIMAGEJP ) document.MEDIAIMAGEJP.src = xMediaContentJP[iCurrentImageJP];

    xTimerHandleJP   = setTimeout("MediaInternalCycleJP()", iInternalCountJP);
    bTimerRunningJP  = true;
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaStart                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Starts the media cycling. Call with 'OnLoad' from body ||
//              tag to have an image start cycling on page load.       ||
//---------------------------------------------------------------------||
function MediaStartJP()
{
    iInternalCountJP = TimeInSecondsBetweenCyclesJP * 1000;
    MediaStopJP();
    MediaInternalCycleJP();
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaClick                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Clicks straight through to your media URL              ||
//---------------------------------------------------------------------||
function MediaClickJP()
{
    if( LoadInNewWindowJP ) {
        URL = xMediaContentJP[iCurrentImageJP+1];
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = xMediaContentJP[iCurrentImageJP+1];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaClickWithInfo                                     ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Clicks to the URL you have listing in your media, plus ||
//              the value passed in as 'ADDITIONAL INFO'.  This is     ||
//              useful if you have defined your media URL's as         ||
//              directories, and have multiple files in those directori||
//---------------------------------------------------------------------||
function MediaClickWithInfoJP( AdditionalInfoJP )
{
    if( LoadInNewWindowJP ) {
        URL = xMediaContentJP[iCurrentImageJP+1] + AdditionalInfoJP;
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = (xMediaContentJP[iCurrentImageJP+1] + AdditionalInfoJP);
}


