
  function changeimage()
  {
    //=======================================================================================
    //Begin Edit in this section:
    //=======================================================================================
    //Set the range of items to pick from; change this to match the total number of 
    // items in the topbgs array
    var range = 10;
    
    //Set the number of pictures to display; this is how many pictures will be 
    // randomly picked
    var numPicsDisplayed = 3;
    
    //The number of loops for displaying the pics.  This will display the numPicsDisplayed
    // numDisplayLoops times.
    var numDisplayLoops = 3;
    
    //Set the time, in seconds, for each display; this is how long a picture is shown for
    var displayTime = 5;

    //Set up the array of items to pick from.  The number of items in the array
    // should match the number of items in the range
    var topbgs=new Array(range)
     topbgs[0]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top.jpg";
     topbgs[1]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top2.jpg";
     topbgs[2]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top3.jpg";  
     topbgs[3]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top4.jpg";
     topbgs[4]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top5.jpg";
     topbgs[5]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top6.jpg";
     topbgs[6]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top7.jpg";
     topbgs[7]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top8.jpg";
     topbgs[8]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top9.jpg";
     topbgs[9]="http://www.garymcdonaldhomes.com/gmh/images/topbgs/bg_top10.jpg";

    //=======================================================================================
    //End Edit in this section:
    //=======================================================================================
    
    //Create an array to store which pictures were picked
    var PickedPics = new Array(numPicsDisplayed);
    
    //create an image for preloading; size is immaterial
    preloadimage = new Image();
    
    var randnum;

    //Loop through and preload each image and store the items to show
    var NewNumToAdd; //whether a new number was added to the array; used to show 
                         // when we've picked a new number  
    var y;
        
    for (var n = 0; n < numPicsDisplayed; n++)
    {
      //Get a random number and store it
      //We need to pick until we get a number that has not already been picked
      NewNumToAdd = 0;

      while (NewNumToAdd == 0)
      {
        //pick the number
        randnum = get_random(range);

        //Search through the PickedPics and see if it has been selected before.
        for (y = 0; y <= n; y++)
        {
          if (PickedPics[y] == randnum)
          {
            NewNumToAdd = 0;
            break;
          }
          else
          {
            NewNumToAdd = 1;
          }
        } //end for
      } //end while
      //Out of the loop so there is a new number to add; put it in the array
      PickedPics[n] = randnum;

      //Preload the image
      preloadimage.src = topbgs[randnum];
    } //end for
    
    var l; //counters
    var x;     
    var nextTime = 0; //the next time to have a picture change; set to 0 to show the first right away
    
    //Now loop through and display each pic for the specified amount of time; do this for the 
    // specified number of loops
    for (l = 1; l < (numDisplayLoops + 1); l++)
    {
      for (x = 0; x < numPicsDisplayed; x++)
      {
        //Show and pause; each successive change needs to be set later than the last; we
        // are scheduling events
        setTimeout("document.getElementById(\'TopCell\').style.backgroundImage = \"url(\'" + topbgs[PickedPics[x]] + "\')\"",nextTime);
        nextTime = nextTime + (displayTime * 1000);
      } //end for
    } //end for
  } //end function
  
  
  
  //Random number function
  function get_random(range)
  {
    var ranNum= Math.floor(Math.random()*range);
    return ranNum;
  }
  
  

/**************************************************************
* resizeIFrame
* Resizes the specified iFrame to fit the content page within
* This code will only work for pages on the same domain.  
* Cross-domain scripting is disallowed by all modern browsers.
***************************************************************/
function resizeIFrame(iFrameName)
{
  //Resize based on the browser
  var browserName=navigator.appName;
  var frameheight;
  
  switch(browserName)
  {
    case 'Microsoft Internet Explorer':
      //find the height of the internal page
      frameheight = document.getElementById(iFrameName).contentWindow.document.body.scrollHeight;
      
      //change the height of the iframe
      document.getElementById(iFrameName).height= frameheight + 50;
  
      break;
      
    case 'Netscape':
      //find the height of the internal page    
      //document.getElementById(iFrameName).height=768 // required for mozilla/firefox bugs, value can be "", null, or integer
      
      //frameheight = document.getElementById(iFrameName).contentDocument.body.offsetHeight;  //returns 73
      //frameheight = document.getElementById(iFrameName).contentDocument.body.offsetHeight;  //returns 73
	    //frameheight = document.getElementById(iFrameName).contentDocument.documentElement.scrollWidth;  //returns 733 or 750
      //frameheight = window.frames(iFrameName).document.body.scrollHeight;
   
      //alert(frameheight);
      //change the height of the iframe
      //document.getElementById(iFrameName).height= frameheight + 50;
      
      break;
  }  
}


