//  CCChome.js includes CCChome (rotating banners) and CCCGlobal

//  CCCGlobal.js  -  scripts for all pages

//  function makeNewWindow()
var newWindow = null;                           // initialize newWindow variable
function makeNewWindow(loc,name,size) {
//      Since we have varying sizes and shapes of windows, we need to
//      close it first, if it exists, so newWindow will open correctly.
  if (newWindow && !newWindow.closed)           // check for an open window
     { newWindow.close(); }                     // and close it if it exists
  newWindow = window.open(loc,name,size);       // then create the newWindow
    return false;                               // override the href #, and
    newWindow.focus();                          // be certain it is on top
}

//  function goBack()
function goBack() { window.history.back(); }

//  function twoClicks() - opens explanatory window for goBack()
var tcWindow = null;
function twoClicks() {
  if (tcWindow && !tcWindow.closed)
     { tcWindow.close(); }
  tcWindow = window.open('/TwoClicks.php','tcWindow','width=535,height=176'); 
    tcWindow.focus();
}

//  CCChome.js  -  rotating banners for the 5 original pages and cc-page2

//  Load page banners, captions, and img alt
var Pix = new Array();
  Pix[0] = new Image(930,165) ;
  Pix[0].src = "images/StG-WB.jpg" ;
  Pix[1] = new Image(760,135) ;
  Pix[1].src = "images/ShakespeareArchB.jpg" ;
  Pix[2] = new Image(930,165) ;
  Pix[2].src = "images/MVatSunsetB.jpg" ;
  Pix[3] = new Image(930,165) ;
  Pix[3].src = "images/LookoutStudioB.jpg" ;
  Pix[4] = new Image(760,135) ;
  Pix[4].src = "images/GooseNecksB.jpg" ;
  Pix[5] = new Image(930,165) ;
  Pix[5].src = "images/VermillionB.jpg" ;
  Pix[6] = new Image(930,165) ;
  Pix[6].src = "images/LakeB.jpg" ;
  Pix[7] = new Image(930,165);
  Pix[7].src = "images/StG-EB.jpg" ;
  Pix[8] = new Image(930,165) ;
  Pix[8].src = "images/DHP-ak1B.jpg" ;
  Pix[9] = new Image(930,165) ;
  Pix[9].src = "images/DHP-ak3B.jpg" ;
  Pix[10] = new Image(930,165);
  Pix[10].src = "images/MonumentValleyB.jpg" ;
  Pix[11] = new Image(930,165) ;
  Pix[11].src = "images/GCDamB.jpg" ;
  Pix[12] = new Image(930,165) ;
  Pix[12].src = "images/MexHatB.jpg" ;
  Pix[13] = new Image(930,165) ;
  Pix[13].src = "images/LookoutStudio2B.jpg" ;
  Pix[14] = new Image(930,165) ;
  Pix[14].src = "images/DHP-kB.jpg" ;
  Pix[15] = new Image(930,165) ;
  Pix[15].src = "images/NavajoBridgeB.jpg" ;
  Pix[16] = new Image(930,165) ;
  Pix[16].src = "images/CombRidgeB.jpg" ;
  Pix[17] = new Image(930,165) ;
  Pix[17].src = "images/HogsbackB.jpg" ;
  Pix[18] = new Image(930,165) ;
  Pix[18].src = "images/ShakespeareArch2B.jpg" ;
  Pix[19] = new Image(930,165) ;
  Pix[19].src = "images/WaterpocketFoldB.jpg" ;

var capt = new Array (
  "City center of St George - an oasis in the desert, looking northwest from airport mesa" ,
  "Shakespeare Arch in Kodachrome Basin, ©James Marvin Phelps" ,
  "Monument Valley at Sunset, ©Christian Mehlführer" ,
  "Lookout Studio in Grand Canyon National Park, photo courtesy National Park Service" ,
  "Goosenecks of the San Juan Utah State Park" ,
  "Vermillion Cliffs along US89A, looking down from high on Kiabab Plateau near Jacob Lake" ,
  "Panguitch Lake, elevation 8,400', on Cedar Mountain, ©Ellen McDonough" ,
  "South St. George, looking east from airport mesa, Hurricane Cliffs in the background" ,
  "Dead Horse Point State Park, ©Aneta Kaluzna" ,
  "Colorado River in Dead Horse Point State Park, ©Aneta Kaluzna" ,
  "Mounument Valley - ©Moritz Zimmermann" ,
  "Glen Canyon & Dam {Panorama photo), ©Christian Mehlführer" ,
  "Mexican Hat Rock at Moonrise, ©PD Tillman",
  "Looking over the edge at Lookout Studio on the south rim of Grand Canyon, courtesy NPS",
  "Dead Horse Point State Park, Utah's Grand Canyon, in winter ©Kenneth Hung",
  "Aerial view of Navajo Bridges and Marble Canyon, ©Frank Holbert" ,
  "U-95 cut through Comb Ridge, south and west of Blanding, Utah" ,
  "U-12 over the Hogsback near Boulder, Utah" ,
  "Shakespeare Arch in Kodachrome Basin, ©Axcordian" ,
  "The west edge of Waterpocket Fold, inside Capital Reef National Park, Utah"
);

var imgAlt=[
  "Downtown St George",
  "Shakespeare Arch",
  "Monument Valley at Sunset",
  "Lookout Studio in Grand Canyon",
  "Goosenecks State Park viewpoint",
  "Vermillion Cliffs along US89A",
  "Panguitch Lake on Cedar Mountain, elevation 8400",
  "St George City south",
  "Dead Horse State Park",
  "Colorado River in Dead Horse State Park",
  "Monument Valley Panorama",
  "Glen Canyon Dam",
  "Mexican Hat Rock at Moonrise",
  "Lookout Studio looking over the edge",
  "Dead Horse State Park in winter",
  "Aerial view of Navajo Bridges and Marble Canyon",
  "U-95 cut through Comb Ridge",
  "U-12 over the Hogsback",
  "Shakespeare Arch",
  "Waterpocket Fold west view"
];

//  Rotating page banner script
var timeDelay = 15; 		// cycle time (in seconds)
var howMany = Pix.length;	// count the banners
timeDelay *= 500;
var PicCurrentNum = Math.floor((Math.random() * howMany));
function startPix() { setInterval("slideshow()", timeDelay); }
function slideshow() {
  PicCurrentNum++;
  if (PicCurrentNum == howMany)
    { PicCurrentNum = 0; }
    document.images[0].src = Pix[PicCurrentNum].src;
    document.getElementById("BannerPix").alt = imgAlt[PicCurrentNum];
    document.getElementById("caption").childNodes[0].nodeValue = capt[PicCurrentNum];
}

//  For pages using caption2
function startPix2() { setInterval("slideshow3()", timeDelay); }
function slideshow3() {
  PicCurrentNum++;
  if (PicCurrentNum == howMany)
    { PicCurrentNum = 0; }
    document.images[0].src = Pix[PicCurrentNum].src;
    document.getElementById("caption2").childNodes[0].nodeValue = capt[PicCurrentNum];
}