
var randomquoteid = 0;
function RandomQuotes(quotes, delay)
{
    randomquoteid++ ;
    this.quotes = "quote"+(randomquoteid);
    this.randomQuotes = quotes ;
    this.currentQuote = 0 ;
    this.delay = delay || 10000; // default speed of rotation
    var index = RandomQuotes.col.length; RandomQuotes.col[index] = this;
    this.instance = "RandomQuotes.col[" + index + "]";
    this.startQuote = function()
    {
        startQuote = Math.round(Math.random()*this.randomQuotes.length) -1;
        this.currentQuote = startQuote ;
        return startQuote;
    }
    this.startRotation = function()
    {
        for(index=0; index < this.randomQuotes.length ; index++)
        {
            document.getElementById(this.quotes+index).style.display = 'none';
        }
        this.currentQuote = this.currentQuote + 1;
        if( this.currentQuote == this.randomQuotes.length )
        {
            this.currentQuote = 0;
        }
        document.getElementById(this.quotes+this.currentQuote).style.display = 'inline';
        setTimeout( this.instance+".startRotation()", this.delay);
    }
    this.getQuotes = function()
    {
        for(index=0; index < this.randomQuotes.length; index++)
        {
            whoString = "" ;
            if( this.randomQuotes[index][1] != "" )
            {
                whoString = "<div><strong>- "+this.randomQuotes[index][1]+"</strong></div>";
            }
            theQuote = "<div><i>&ldquo;"+this.randomQuotes[index][0]+"&ldquo;</i></div>"+whoString ;
            document.write('<div style="" id="'+this.quotes+index + '">' + theQuote + '</div>');
        }
        this.startRotation(this.startQuote());
    }
}
RandomQuotes.col = []; // hold instances

//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------

var randomstatementid = 0;
function RandomStatements(statements, delay)
{
    randomstatementid++ ;
    this.statements = "statement"+(randomstatementid);
    this.randomStatements = statements ;
    this.currentStatement = 0 ;
    this.delay = delay || 10000; // default speed of rotation
    var index = RandomStatements.col.length; RandomStatements.col[index] = this;
    this.instance = "RandomStatements.col[" + index + "]";
    this.startStatement = function()
    {
        startStatement = Math.round(Math.random()*this.randomStatements.length) -1;
        this.currentStatement = startStatement ;
        return startStatement;
    }
    this.startRotation = function()
    {
        for(index=0; index < this.randomStatements.length ; index++)
        {
            document.getElementById(this.statements+index).style.display = 'none';
        }
        this.currentStatement = this.currentStatement + 1;
        if( this.currentStatement == this.randomStatements.length )
        {
            this.currentStatement = 0;
        }
        document.getElementById(this.statements+this.currentStatement).style.display = 'inline';
        setTimeout( this.instance+".startRotation()", this.delay);
    }
    this.getStatements = function()
    {
        for(index=0; index < this.randomStatements.length; index++)
        {
            theStatement = "<div>"+this.randomStatements[index][0]+"</div>" ;
            document.write('<div style="" id="'+this.statements+index + '">' + theStatement + '</div>');
        }
        this.startRotation(this.startStatement());
    }
}
RandomStatements.col = []; // hold instances

//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------

function RandomMarquee(images,count,height,delay)
{
    this.randomimages = images ;
    this.count = count || 10; // number of images used in marquee
    this.height = height || 100;
    this.delay = delay || 1;
    this.nextindex = Math.floor(Math.random()*(this.randomimages.length)) ;
    var preload = new Array() ;
    for( n=0; n<this.randomimages.length; n++ )
    {
        preload[n]=new Image()
        preload[n].src=this.randomimages[n]
    }
    var index = RandomMarquee.col.length; RandomMarquee.col[index] = this;
    this.next=function()
    {
        this.nextindex++ ;
        if( this.nextindex >= this.randomimages.length )
            this.nextindex = 0 ;
        //nextindex = Math.floor(Math.random()*(this.randomimages.length)) ;
        return this.randomimages[this.nextindex] ;
    }
    this.display=function()
    {
        document.write( "\n<marquee scrolldelay=\""+this.delay+"\" scrollamount=\"2\">\n");
        for (var i = 1; i <= this.count; i++)
        {
            document.write( "<img style=\"height: "+this.height+"px;\" class=marquee src=\""+this.next()+"\" >\n" );
        }
        document.write("</marquee>" ) ;
    }
}
RandomMarquee.col = []; // hold instances

//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------

function RandomSlideShow(images,height,delay)
{
    this.randomimages = images ;
    this.delay = delay || 3000; // default speed of rotation
    this.height = height || 100;
    this.timer=0;
    this.curindex=0 ;
    var preload = new Array() ;
    for( n=0; n<this.randomimages.length; n++ )
    {
        preload[n]=new Image()
        preload[n].src=this.randomimages[n]
    }
    RandomSlideShow.imagenameid++ ;
    this.imagename = "randomimage"+RandomSlideShow.imagenameid ;
    //alert( this.imagename ) ;
    var index = RandomSlideShow.col.length; RandomSlideShow.col[index] = this;
    this.show = "RandomSlideShow.col[" + index + "]";
    this.display=function()
    {
        document.write("<img name=\""+this.imagename+"\" style=\"height: "+this.height+"px;\" src=\""+this.randomimages[Math.floor(Math.random()*(this.randomimages.length))]+"\">") ;
        this.rotate() ;
    }
}
RandomSlideShow.col = []; // hold instances
RandomSlideShow.imagenameid = 0   // image name id 
RandomSlideShow.prototype.rotate = function() 
{
    clearTimeout(this.timer); this.timer = null;
    if( this.curindex==(tempindex=Math.floor(Math.random()*(this.randomimages.length))))
    {
        this.curindex = this.curindex==0? 1 : this.curindex-1 ;
    }
    else
    {
        this.curindex = tempindex ;
    }
    eval("document.images."+this.imagename).src=this.randomimages[this.curindex]
    this.timer = setTimeout( this.show + ".rotate()", this.delay);
}


