﻿/***********************************************
* DHTML RotatorItem script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
****
* Source Code modified for use with Rotator Control by Internet Dental Alliance.
****
***********************************************/

function contractboard(RotatrorID, totalDivs, selectedDiv) {
    var inc = 0
    while (document.getElementById(RotatrorID + "_RotatorItem" + inc)) {
        document.getElementById(RotatrorID + "_RotatorItem" + inc).style.display = "none"
        inc++
    }
}

function expandboard(RotatrorID, totalDivs, selectedDiv, tickspeed, effectduration, hidecontent_from_legacy, effects) {
    selectedDivObj = document.getElementById(RotatrorID + "_RotatorItem" + selectedDiv)
    RotatorItemeffects = effects.split("|");
    contractboard(RotatrorID, totalDivs, selectedDiv)
    if (selectedDivObj.filters) {
        if (RotatorItemeffects.length > 0) {
            filterid = Math.floor(Math.random() * RotatorItemeffects.length)
            selectedDivObj.style.filter = "progid:DXImageTransform.Microsoft." + RotatorItemeffects[filterid]
        }
        selectedDivObj.filters[0].duration = effectduration / 1000
        selectedDivObj.filters[0].Apply()
    }
    selectedDivObj.style.display = "block"
    if (selectedDivObj.filters)
        selectedDivObj.filters[0].Play()
    selectedDiv = (selectedDiv < totalDivs - 1) ? selectedDiv + 1 : 0
    setTimeout("expandboard('" + RotatrorID + "'," + totalDivs + "," + selectedDiv + "," + tickspeed + "," + effectduration + "," + hidecontent_from_legacy + ",\"" + effects + "\")", tickspeed)
}

function startbill(RotatrorID, tickspeed, effectduration, hidecontent_from_legacy, effects) {

    if (document.getElementById(RotatrorID) == null)
        return;

    totalDivs = 0;
    selectedDiv = 0;
    while (document.getElementById(RotatrorID + "_RotatorItem" + totalDivs) != null)
        totalDivs++
    if (document.getElementById(RotatrorID + "_RotatorItem0").filters)
        tickspeed += effectduration
    expandboard(RotatrorID, totalDivs, selectedDiv, tickspeed, effectduration, hidecontent_from_legacy, effects)
}
