//---------------------------------------------------------------------||
// INTERNAL GLOBAL VARIABLES                                           ||
// PURPOSE:     Internal use only, do not modify.                      ||
//---------------------------------------------------------------------||
var xMediaContent2  = new Array();
var xMediaImage2    = new Image;
var iCurrentImage2  = 0;
var iInternalCount2 = 5000;
var xTimerHandle2   = null;
var bTimerRunning2  = 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 TimeInSecondsBetweenCycles2 = 2.5;
var LoadInNewWindow2 = false;
var WrapAtEnd2       = 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.                                   ||
//---------------------------------------------------------------------||
xMediaContent2[0] = "./images/chilepics/chile001.jpg";
xMediaContent2[1] = "images/chilepics/chile001.jpg";

xMediaContent2[2] = "./images/chilepics/chile002.jpg";
xMediaContent2[3] = "images/chilepics/chile002.jpg";

xMediaContent2[4] = "./images/chilepics/chile003.jpg";
xMediaContent2[5] = "images/chilepics/chile003.jpg";

xMediaContent2[6] = "./images/chilepics/chile004.jpg";
xMediaContent2[7] = "images/chilepics/chile004.jpg";

xMediaContent2[8] = "./images/chilepics/chile005.jpg";
xMediaContent2[9] = "images/chilepics/chile005.jpg";




//---------------------------------------------------------------------||
// FUNCTION:    MediaStop                                              ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaStop2()
{
    if( bTimerRunning2 )
        clearTimeout( xTimerHandle2 );

    bTimerRunning2 = false;
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoBack                                            ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoBack2()
{
    MediaStop2();

    if (WrapAtEnd2)
      (iCurrentImage2 == 0) ? iCurrentImage2 = (xMediaContent2.length - 2) : iCurrentImage2-=2;
    else
      (iCurrentImage2 == 0) ? iCurrentImage2 = 0 : iCurrentImage2-=2;

    document.MEDIAIMAGE2.src = xMediaContent2[iCurrentImage2];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoForward                                         ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoForward2()
{
    MediaStop2();

    if (WrapAtEnd2)
      (iCurrentImage2 == (xMediaContent2.length - 2)) ? iCurrentImage2 = 0 : iCurrentImage2+=2;
    else
      (iCurrentImage2 == (xMediaContent2.length - 2)) ? iCurrentImage2 = iCurrentImage2 : iCurrentImage2+=2;

    document.MEDIAIMAGE2.src = xMediaContent2[iCurrentImage2];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaInternalCycle                                     ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Internal media cycle routine                           ||
//---------------------------------------------------------------------||
function MediaInternalCycle2()
{
    (iCurrentImage2 == (xMediaContent2.length - 2)) ? iCurrentImage2 = 0 : iCurrentImage2+=2;
    if( document.MEDIAIMAGE2 ) document.MEDIAIMAGE2.src = xMediaContent2[iCurrentImage2];

    xTimerHandle2   = setTimeout("MediaInternalCycle2()", iInternalCount2);
    bTimerRunning2  = 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 MediaStart2()
{
    iInternalCount2 = TimeInSecondsBetweenCycles2 * 1000;
    MediaStop2();
    MediaInternalCycle2();
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaClick                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Clicks straight through to your media URL              ||
//---------------------------------------------------------------------||
function MediaClick2()
{
    if( LoadInNewWindow2 ) {
        URL = xMediaContent2[iCurrentImage2+1];
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = xMediaContent2[iCurrentImage2+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 MediaClickWithInfo2( AdditionalInfo2 )
{
    if( LoadInNewWindow2 ) {
        URL = xMediaContent2[iCurrentImage2+1] + AdditionalInfo2;
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = (xMediaContent2[iCurrentImage2+1] + AdditionalInfo2);
}


