
/***********************************************
* MultiFrame Image Slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/


// items:
// var seqslides=new Array();
// seqslides[0]=["image0.jpg", "http://www.website.com"];
// seqslides[1]=["image1.jpg", "http://www.website.com"];


// sort randomly the array
seqslides.sort(function() {return 0.5 - Math.random();})


//Set pause between each image display (2000=2 second):
var slidedelay=5000

//Set how many images to show at once (must be less than total # of images above):
var slidestoreveal=1

//Specify code to insert between each slide (ie: "<br>" to insert a line break and create a vertical layout)
//"" for none (or horizontal):
var slideseparater="<br /><br />"

//Set optional link target to be added to all images with a link:
var optlinktarget="_blank"

//Set image border width:
var imgborderwidth=0

//Set opacity value of each image when it's "dimmed", and when it's not, respectively (1=100% opaque/normal).
//Change 0.2 to 0 to completely hide image when it's dimmed:
var opacityvalues=[1,1] //var opacityvalues=[0.2,1]

///No need to edit beyond here///////////

function processimgcode(i,theimg)
{
    if (typeof theimg == "undefined")
    {
        return "";
    }

    var imghtml=""
    if (theimg[1]!="")
        imghtml='<a href="'+theimg[1]+'" target="'+optlinktarget+'" rel="external" onclick="pageTracker._trackPageview(\''+theimg[1]+'\')">'

    imghtml+='<img id="seqslideImg'+i+'" src="'+theimg[0]+'" class="LogoImage" border="'+imgborderwidth+'" style="border: 0 none; filter: alpha(opacity=100); -moz-opacity: 100; opacity: 100;" />'

    if (theimg[1]!="")
        imghtml+='</a>'
    return imghtml
}

var curslide=1 //var to track current slide (total: slidestoreveal)
var curimgindex=0 //var to track current image (total: seqslides.length)
var isfirstcycle=1 //boolean to indicate whether this is the first cycle

if (document.getElementById)
{
    for (i=0;i<slidestoreveal;i++)
        document.write('<span id="seqslide'+i+'" class="seqslidestyle">'+processimgcode(i,seqslides[i])+'</span>'+slideseparater)
    curimgindex=slidestoreveal
}

function displayit()
{
    if (seqslides.length <= slidestoreveal)
    {
        // fix how many images to show value if the array length is less that this
        return;
    }

    if (curslide<slidestoreveal)
    {
        if (!isfirstcycle)
            changeimage(curslide)
        curslide++
    }
    else
    {
        isfirstcycle=0
        changeimage(0)
        curslide=1
    }
}

function changeimage(slideindex)
{
    //Hide("seqslideImg"+slideindex)
    document.getElementById("seqslide"+slideindex).innerHTML=processimgcode(slideindex, seqslides[curimgindex])
    //Show("seqslideImg"+slideindex)
    curimgindex++
    
    if (curimgindex>=seqslides.length)
        curimgindex=0
}

/*****/
// Fade's functions
function Show(id)
{
    opacity(id, 0, 100, 2000); 
}

function Hide(id)
{
    changeOpac(0, id);
}

function shiftOpacity(id, millisec)
{ 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
} 

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id)
{ 
    if (document.getElementById(id) == null)
    {
        return;
    }

    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}
/*****/

if (document.getElementById)
{
    setInterval("displayit()", slidedelay)
}
