
function RandomQuotes(quotes, delay)
{
  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('quote'+index).style.display = 'none';
    }
    this.currentQuote = this.currentQuote + 1;
    if( this.currentQuote == this.randomQuotes.length )
    {
       this.currentQuote = 0;
    }
    document.getElementById('quote'+this.currentQuote).style.display = 'inline';
    setTimeout( this.instance+".startRotation()", this.delay);
  }
  this.getQuotes = function() 
  {
    for(index=0; index < this.randomQuotes.length; index++)
    {
      theQuote = "<p><i>&ldquo;"+this.randomQuotes[index][0]+"&ldquo;</i></p><p><strong>- "+this.randomQuotes[index][1]+"</strong></p>";
      document.write('<div id="quote' + index + '">' + theQuote + '</div>');
    }
    this.startRotation(this.startQuote());
  }
}
RandomQuotes.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);   
}



