// JavaScript Document

//===============================================================================
// DHTML functions, to create a common DHTML between browsers
//===============================================================================

//---------------------------------------------------------------------------------
// getBrowser - returns the browser type and version
// getObject  - gets an object id, returns a reference to the DHTML object
// getStyle   - gets an object id, returns a reference to the DHTML object's style
//---------------------------------------------------------------------------------

function getBrowser() {
    if (document.getElementById) return ( "W3C" );	//all new browsers       
    else if (document.all)       return ( "IE" );    	//IE4 +
    else if (document.layers)    return ( "N4" );	//N4  only
    else                         return ( "other" );
}

//---------------------------------------------------------------------------------
function getObj(objID) {
    var browser = getBrowser();
    if (browser == "W3C")        return( document.getElementById(objID) ); 
    if (browser == "IE")         return( document.all[objID]            ); 
    if (browser == "N4")         return( document.layers[objID]         ); 
}

//---------------------------------------------------------------------------------
function getStyle(objID) {
    var browser = getBrowser();
    if (browser == "W3C")        return( document.getElementById(objID).style ); 
    if (browser == "IE")         return( document.all[objID].style            ); 
    if (browser == "N4")         return( document.layers[objID]               ); 
}


//===============================================================================
// Slideshow 
//===============================================================================

//-------------- Change the following to customize your slide show ------------------

var imgName  = "images/qb3mal_b";                      //URL of the images
var imgType  = ".jpg";                             //type of image .gif, .jpg or .png
var total    =  3;                                //total number of images
var next     =  2;                                 //start image number
var repeat   =  true;                              //continue loop? true or false
var interval =  10000;                              //interval 2 second

//-------------- Do not alter the code below ----------------------------------------

var picArray = new Array();                        //Create Array to store images

for (var i = 1; i <= total; i++) {
    picArray[i]     =  new Image();                //Create an Image object 
    picArray[i].src = imgName + i + imgType;       //Load object with the .jpg file
}

function run() {
    document.slideShow.src = picArray[next].src;   //Move next image into slideShow
    next = next+1;
    if (repeat && next > total)                    //if repeat is requested
        next = 1;                                  //reset number to 1
    if (next > total)                    
        clearInterval(timer);                      //stop the show
}

function move(direction) {
    next += direction;
    if (next > total)
        next = 1;
    if (next < 1)
        next = total;
    document.slideShow.src = picArray[next].src;   //Move next image into slideShow
}