var tickspeed=12000 //ticker speed in miliseconds
var displaymode="auto" //displaymode ("auto" or "manual"). No need to modify as form at the bottom will control it, unless you wish to remove form.

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.bannersarea{display:none;}\n')
document.write('</style>\n')
}

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 (i1=0; i1<alltags.length; i1++)
         {
             if (alltags[i1].className==classname)
             partscollect[inc++]=alltags[i1]
         }
}

function contractall()
{
         var inc=0
         while (partscollect[inc])
         {
               partscollect[inc].style.display="none"
               inc++
         }
}

function expandone()
{
         var selectedDivObj=partscollect[selectedDiv]
         contractall()
         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 populatemenu()
{
         temp=document.gallerycontrol.menu
         for (m=temp.options.length-1;m>0;m--)
             temp.options[m]=null
         for (i=0;i<totalDivs;i++)
         {
             var thesubject=partscollect[i].getAttribute("subject")
             thesubject=(thesubject=="" || thesubject==null)? "HTML Content "+(i+1) : thesubject
             temp.options[i]=new Option(thesubject,"")
         }
         temp.options[0].selected=true
}

function manualcontrol(menuobj)
{
         if (displaymode=="manual")
         {
            selectedDiv=menuobj
            expandone()
         }
}

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()
{
         if (document.getElementById("controldiv")) //if it exists
            document.getElementById("controldiv").style.display="block"
         getElementbyClass("bannersarea")
         totalDivs=partscollect.length
         if (document.gallerycontrol)
         {
            populatemenu()
            if (document.gallerycontrol.mode)
            {
               for (i2=0; i2<document.gallerycontrol.mode.length; i2++)
               {
                   if (document.gallerycontrol.mode[i2].checked)
                      displaymode=document.gallerycontrol.mode[i2].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
