﻿
var spread = false;
var billboardeffects = ["GradientWipe(GradientSize=1.0 Duration=0.7)", "Inset", "Iris", "Pixelate(MaxSquare=5 enabled=false)", "RadialWipe", "RandomBars", "Slide(slideStyle='push')", "Spiral", "Stretch", "Strips", "Wheel", "ZigZag"];
var tickspeed = 6000;
var effectduration = 800;           //Transitional effect duration in miliseconds
var hidecontent_from_legacy = 1;    //Should content be hidden in legacy browsers- IE4/NS4 (0=no, 1=yes).
var filtersCount = 7;               //Number of filter classes possible (in "<style type="text/css">" section)
var filterid = Math.floor(Math.random()*filtersCount);
var selectedDiv = 0;
var totalDivs = 0;


function SpreadBody(startBill)
{
    if (startBill)
    {
        StartBill();
    }     
}

function StartBill()
{//Initiates bill swap messages
    if (document.getElementById)
    {
        while (document.getElementById("billboard" + totalDivs) != null)
        totalDivs++;
        if (document.getElementById("billboard0").filters)
        {
            tickspeed += effectduration;
        }
        
        ExpandBoard();
        
    }
}

function ExpandBoard()
{//Hides all bills and then displays one, if ie - with filter 
    var selectedDivObj = document.getElementById("billboard" + selectedDiv)
    
    ContractBoard();
    
    if (selectedDivObj.filters) //IE only
    {
        if (filtersCount > 1)
        {            
            //Random filter
            filterid = Math.floor(Math.random()*filtersCount);            
            selectedDivObj.style.filter = "progid:DXImageTransform.Microsoft." + billboardeffects[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()", tickspeed);
}
        
function ContractBoard()
{
    var inc = 0;
    while (document.getElementById("billboard" + inc))
    {
        document.getElementById("billboard"+inc).style.display = "none";
        inc++;
    }    
}     
                                                                                                                                                
           

