﻿var tickspeed=4500
var displaymode="auto"

var selectedDiv=0
var totalDivs=0

function getElementbyClass(classname){
    partscollect=new Array()
    var inc=0
    var alltags=document.all? document.all.tags("DIV") : document.getElementsByTagName("*")
    for (i=0; i<alltags.length; i++){
        if (alltags[i].className==classname)
            partscollect[inc++]=alltags[i]
    }
}

function contractall(){
    var inc=0
    while (partscollect[inc]){
        partscollect[inc].style.display="none"
        inc++
    }
}

function expandone(){
    var selectedDivObj=partscollect[selectedDiv]
    contractall()
    
    if (selectedDivObj)
        selectedDivObj.style.display="block"
    if (document.gallerycontrol)
        temp.options[selectedDiv].selected=true
    selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
    if (displaymode=="auto")
        autocontrolvar=setTimeout("expandone()",tickspeed)
}

function preparemode(themode){
    displaymode=themode
    if (typeof autocontrolvar!="undefined")
        clearTimeout(autocontrolvar)
    if (themode=="auto"){
        document.gallerycontrol.menu.disabled=true
        autocontrolvar=setTimeout("expandone()",tickspeed)
    }
    else
        document.gallerycontrol.menu.disabled=false
}

function startgallery(){
    getElementbyClass("gallerycontent")
    totalDivs=partscollect.length
    if (document.gallerycontrol){
        populatemenu()
        if (document.gallerycontrol.mode){
            for (i=0; i<document.gallerycontrol.mode.length; i++){
                if (document.gallerycontrol.mode[i].checked)
                    displaymode=document.gallerycontrol.mode[i].value
            }
        }
    }
    if (displaymode=="auto" && document.gallerycontrol)
        document.gallerycontrol.menu.disabled=true
    expandone()
}

if (window.addEventListener)
    window.addEventListener("load", startgallery, false)
else if (window.attachEvent)
    window.attachEvent("onload", startgallery)
else if (document.getElementById)
    window.onload=startgallery
