var menus = new Array();
menus[menus.length] = new menu( "home", "Home", "home.htm" );
menus[menus.length] = new menu( "rooms", "Rooms & Rates", "rooms.htm" );
menus[menus.length] = new menu( "amenities", "Amenities", "amenities.htm" );
menus[menus.length] = new menu( "letters", "Rave Reviews", "letters.htm" );
menus[menus.length] = new menu( "contact", "Reservations", "contact.htm" );
menus[menus.length] = new menu( "gps", "Maps and GPS", "gps.htm" );
menus[menus.length] = new menu( "attractions", "Area Guide", "attractions.htm" );
menus[menus.length] = new menu( "history", "History", "history.htm" );
menus[menus.length] = new menu( "gallery", "Gallery", "gallery.htm" );

var submenus = new Array();
submenus[submenus.length] = new submenu( "home", "rooms", "Rooms & Rates", "rooms.htm" );
submenus[submenus.length] = new submenu( "home", "amenities", "Amenities", "amenities.htm" );
submenus[submenus.length] = new submenu( "home", "letters", "Rave Reviews", "letters.htm" );
submenus[submenus.length] = new submenu( "home", "contact", "Reservations", "contact.htm" );
submenus[submenus.length] = new submenu( "home", "maps", "Maps and GPS", "gps.htm" );
submenus[submenus.length] = new submenu( "home", "attractions", "Area Guide", "attractions.htm" );
submenus[submenus.length] = new submenu( "home", "gallery", "Gallery", "gallery.htm" );

submenus[submenus.length] = new submenu( "rooms", "venetian", "Venetian", "venetian.htm" );
submenus[submenus.length] = new submenu( "rooms", "skyline", "Skyline", "skyline.htm" );
submenus[submenus.length] = new submenu( "rooms", "tigereye", "Tiger Eye", "tigereye.htm" );
submenus[submenus.length] = new submenu( "rooms", "policies", "Policies", "policies.htm" );

submenus[submenus.length] = new submenu( "gps", "gps", "GPS Coordinates", "gps.htm" );
submenus[submenus.length] = new submenu( "gps", "from81", "From Interstate 81", "from81.htm" );
submenus[submenus.length] = new submenu( "gps", "fromPkwy", "From the Parkway", "fromPkwy.htm" );
submenus[submenus.length] = new submenu( "gps", "from220", "North on 220", "from220.htm" );
submenus[submenus.length] = new submenu( "gps", "maps", "Maps", "maps.htm" );

submenus[submenus.length] = new submenu( "gallery", "ourinn", "Our Inn", "ourinn.htm" );
submenus[submenus.length] = new submenu( "gallery", "history", "History", "historygallery.htm" );
submenus[submenus.length] = new submenu( "gallery", "xmas", "Christmas", "xmas.htm" );
submenus[submenus.length] = new submenu( "gallery", "roanoke", "Roanoke", "roanoke.htm" );
submenus[submenus.length] = new submenu( "gallery", "scenic", "Scenic", "scenic.htm" );

submenus[submenus.length] = new submenu( "attractions", "art", "Art & Entertainment", "art.htm" );
submenus[submenus.length] = new submenu( "attractions", "shopping", "Shopping", "shopping.htm" );
submenus[submenus.length] = new submenu( "attractions", "food", "Food and Wine", "food.htm" );
submenus[submenus.length] = new submenu( "attractions", "outdoor", "Outdoor", "outdoor.htm" );
submenus[submenus.length] = new submenu( "attractions", "landmarks", "Landmarks", "landmarks.htm" );


function menu( mid, txt, url ) {
    this.mid = mid;
    this.txt = txt;
    this.url = url;
}
function submenu( parentid, mid, txt, url ) {
    this.mid = mid;
    this.txt = txt;
    this.url = url;
    this.parentid = parentid;
}

function showMenus() {
    var activeId = "";
    var mainDiv = document.getElementById("menudiv");
    var currentPageDiv = document.getElementById("currentPage");
    for ( var i = 0 ; i < menus.length ; i++ ) {
        var span = document.createElement("span");
        span.id = menus[i].mid;
        span.className = "menu1";
        var ref = document.createElement("a");
        ref.href = menus[i].url;
        if ( pageId == menus[i].mid || parentId == menus[i].mid ) {
            ref.appendChild( document.createTextNode( menus[i].txt ) );
            activeId = menus[i].mid;
            ref.className = activeId;
            currentPageDiv.appendChild( document.createTextNode( menus[i].txt ) );
        } else {
            ref.appendChild( document.createTextNode( menus[i].txt ) );
        }
        span.appendChild( ref );
        mainDiv.appendChild( span );
    }
    var subdiv = document.createElement("div")
    mainDiv.appendChild( subdiv );

    var subdiv2 = document.createElement("div")
    var sashDiv = document.getElementById("sash");
    sashDiv.appendChild( subdiv2 );

    for ( var i = 0 ; i < submenus.length ; i++ ) {
        if ( submenus[i].parentid == activeId ) {
            var subspan = document.createElement("span");
            subspan.id = submenus[i].mid;
            subspan.className = "menu2";
            var subref = document.createElement("a");
            subref.href = submenus[i].url;
            if ( pageId == submenus[i].mid ) {
                subref.appendChild( document.createTextNode( submenus[i].txt ) );
                subref.className = "active " + activeId;
            } else {
                subref.appendChild( document.createTextNode( submenus[i].txt ) );
                subref.className = activeId;
            }
            subspan.appendChild( subref );
            if ( pageId != "home" && pageId != "contact" && pageId != "dining" && pageId != "business travelers" ) {
                subdiv.appendChild( subspan );
            }

            var subspan2 = document.createElement("div");
            var subref2 = subref.cloneNode( true );
            if ( pageId == submenus[i].mid ) {
                subref2.className = "active";
            } else {
                subref2.className = "";
            }
            subspan2.className = "menu2b";
            subspan2.appendChild( subref2 );
            subdiv2.appendChild( subspan2 );
        }
    }
//    valovers = document.createElement("img");
//    valovers.src = "images/Arial180Arial180va4love.jpg";
//    valovers.id = "Arial180va4lovers";
//    subdiv2.appendChild( valovers );
    clr = document.createElement("img");
    clr.src = "images/clear.gif";
    clr.id = "sashspacer";
    subdiv2.appendChild( clr );
}

function showRoomImage( src ) {
    var mainimg = document.getElementById("roomImage");
    if ( mainimg ) mainimg.src = src;
}

//
// CSS Photo Shuffler v1.0 by
//   Carl Camera
//   http://iamacamera.org
//
// SetOpacity Function and inpiration from Photo Fade by
//   Richard Rutter
//   http://clagnut.com
//
// License: Creative Commons Attribution 2.5  License
//   http://creativecommons.org/licenses/by/2.5/
//

// Customize your photo shuffle settings
//
// * Surround the target < img /> with a < div >. specify id= in both
// * The first and final photo displayed is in the html <img> tag
// * The array contains paths to photos you want in the rotation.
//   If you want the first photo in the rotation, then it's best to
//   put it as the final array image.  All photos must be same dimension
// * The rotations variable specifies how many times to repeat array.
//   images. zero is a valid rotation value.

var gblPhotoShufflerDivId = "homeimagediv";
var gblPhotoShufflerImgId = "homeimage";
var gblImg = new Array(
  "images/dormer960.jpg"
  , "images/snow960.jpg"
  , "images/balcony960.jpg"
  );
var gblPauseSeconds = 2.25;
var gblFadeSeconds = .85;
var gblRotations = 20;

var gblDeckSize = gblImg.length;
var gblOpacity = 100;
var gblOnDeck = 0;
var gblStartImg;
var gblImageRotations = gblDeckSize * (gblRotations+1);

//window.onload = photoShufflerLaunch;

function photoShufflerLaunch() {
    var theimg = document.getElementById(gblPhotoShufflerImgId);
    gblStartImg = theimg.src; // save away to show as final image

    document.getElementById(gblPhotoShufflerDivId).style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
    setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
}

function photoShufflerFade() {
    var theimg = document.getElementById(gblPhotoShufflerImgId);

    // determine delta based on number of fade seconds
    // the slower the fade the more increments needed
    var fadeDelta = 100 / (30 * gblFadeSeconds);

    // fade top out to reveal bottom image
    if (gblOpacity < 2*fadeDelta )
    {
      gblOpacity = 100;
      // stop the rotation if we're done
      if (gblImageRotations < 1) return;
      photoShufflerShuffle();
      // pause before next fade
      setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
    } else {
      gblOpacity -= fadeDelta;
      setOpacity(theimg,gblOpacity);
      setTimeout("photoShufflerFade()",30);  // 1/30th of a second
    }
}

function photoShufflerShuffle() {
    var thediv = document.getElementById(gblPhotoShufflerDivId);
    var theimg = document.getElementById(gblPhotoShufflerImgId);

    // copy div background-image to img.src
    theimg.src = gblImg[gblOnDeck];
    // set img opacity to 100
    setOpacity(theimg,100);

    // shuffle the deck
    gblOnDeck = ++gblOnDeck % gblDeckSize;
    // decrement rotation counter
    if (--gblImageRotations < 1)
    {
      // insert start/final image if we're done
      gblImg[gblOnDeck] = gblStartImg;
    }

    // slide next image underneath
    thediv.style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

// END

// Show / Hide Map images
function showNone() {
    showImages(0);
}
function showImages( size ) {
    if (document.getElementById( "img1" )) document.getElementById( "img1" ).style.width = size;
    if (document.getElementById( "img2" )) document.getElementById( "img2" ).style.width = size;
    if (document.getElementById( "img3" )) document.getElementById( "img3" ).style.width = size;
    if (document.getElementById( "img4" )) document.getElementById( "img4" ).style.width = size;
    if (document.getElementById( "img5" )) document.getElementById( "img5" ).style.width = size;
    if (document.getElementById( "img6" )) document.getElementById( "img6" ).style.width = size;
    if (document.getElementById( "img7" )) document.getElementById( "img7" ).style.width = size;
    if ( size == 0 ) {
        if (document.getElementById( "col1" )) document.getElementById( "col1" ).style.width=720;
        if (document.getElementById( "col2" )) document.getElementById( "col2" ).style.width=0;
    } else {
        if (document.getElementById( "col1" )) document.getElementById( "col1" ).style.width=420;
        if (document.getElementById( "col2" )) document.getElementById( "col2" ).style.width=300;
    }
}

//* Gallery Functions *//

function mouseOVER( obj ) {
    showChanges( obj );
    checkViewerLocation();
}
function checkViewerLocation() {
    var viewer = document.getElementById("viewer");
    if ( document.body.scrollTop < 50 ) {
        viewer.style.top = 0;
    } else {
        viewer.style.top = document.body.scrollTop - 50;
    }
}
function showChanges( o ) {
    var isrc = o.src;
    var viewer = document.getElementById("viewer");
    viewer.src = isrc;
}



