﻿
if (window.addEventListener)
    window.addEventListener("load", initPage, false)
else if (window.attachEvent)
    window.attachEvent("onload", initPage);

var menuids = new Array("videopresentations"); //Enter id(s) of UL menus, separated by commas
var submenuoffset = 0;  //Offset of submenus from main menu.



var slideImages = new Array("images/slideshows/slides/BA_Finale_01.jpg", "images/slideshows/slides/BigTree7.jpg", 
"images/slideshows/slides/BlueAngelsShow_31.jpg", "images/slideshows/slides/Dosewallips16.jpg",
"images/slideshows/slides/FleetWeek1.jpg", "images/slideshows/slides/FolkLifeFest08_02.jpg",
"images/slideshows/slides/FremontFair_08.jpg", "images/slideshows/slides/MtRainier1.jpg",
"images/slideshows/slides/NOlympicPen_01.jpg", "images/slideshows/slides/OlympicPen0101.jpg",
"images/slideshows/slides/OtterFalls09.jpg", "images/slideshows/slides/PikeMarket9.jpg", 
"images/slideshows/slides/PioneerSquare1.jpg", "images/slideshows/slides/QuinaultBears_06.jpg",
"images/slideshows/slides/QuinaultValley_05.jpg", "images/slideshows/slides/QuinaultWaterfalls_01.jpg", 
"images/slideshows/slides/SeattleWaterfront1.jpg", "images/slideshows/slides/SP_FG_Bridge.jpg", "images/slideshows/slides/WBCenter5.jpg");
var slideURL = new Array("PhotoPages/SlideShow.aspx?BlueAngelsFinale", "PhotoPages/SlideShow.aspx?BigTrees",
"PhotoPages/SlideShow.aspx?BlueAngelsShow", "PhotoPages/SlideShow.aspx?Dosewallips",
"PhotoPages/SlideShow.aspx?FleetWeek", "PhotoPages/SlideShow.aspx?FolkLifeFest",
"PhotoPages/SlideShow.aspx?FreemontFair", "PhotoPages/SlideShow.aspx?Miscellaneous",
"PhotoPages/SlideShow.aspx?NorthOlympicPen", "PhotoPages/SlideShow.aspx?OlympicPen01",
"PhotoPages/SlideShow.aspx?OtterFalls", "PhotoPages/SlideShow.aspx?PikePlaceMarket",
"PhotoPages/SlideShow.aspx?PioneerSquare", "PhotoPages/SlideShow.aspx?Bears",
"PhotoPages/SlideShow.aspx?QuinaultValley", "PhotoPages/SlideShow.aspx?QuinaultWaterfalls",
"PhotoPages/SlideShow.aspx?Waterfront", "PhotoPages/SlideShow.aspx?FlamingGeyserSP", "PhotoPages/SlideShow.aspx?WBCenter");
var thisSlide = 0;

function initPage() {
    initSlideLink(); 
}





function rotate() {
    thisSlide++;
    if (thisSlide == slideImages.length) {
        thisSlide = 0;
    }
    document.getElementById("slidePic").src = slideImages[thisSlide];
    document.getElementById("slidePic").onclick = newLocation;

    setTimeout("rotate()", 5 * 1000);
}

function newLocation() {
    document.location.href = slideURL[thisSlide];
    return false;
}

function initSlideLink() {
    thisSlide = Math.floor((Math.random() * slideImages.length));
    if (document.getElementById("slidePic").tagName == "A") {
        document.getElementById("slidePic").onclick = newLocation;
    }

    rotate();
}

function showDays() {
    var allTags = document.getElementsByTagName("*");

    for (var i = 0; i < allTags.length; i++) {
        if (allTags[i].className.indexOf("daysTill") > -1) {
            allTags[i].innerHTML = showTheDaysTill(allTags[i].id);
        }
    }

    function showTheDaysTill(thisDate) {
        var theDays;

        switch (thisDate) {
            case "memorialday":
                theDays = daysTill(5, 23);
                break;
            case "july4th":
                theDays = daysTill(7, 4);
                break;
            case "laborday":
                theDays = daysTill(9, 5);
                break;
            case "seafair":
                theDays = daysTill(7, 31);
                break;
            default:
        }
        return theDays + " ";
    }

    function daysTill(mm, dd) {
        var now = new Date();
        var inDate = new Date(now.getFullYear(), mm - 1, dd);

        if (inDate.getTime() < now.getTime()) {
            inDate.setYear(now.getFullYear() + 1);
        }

        return (Math.ceil(dayToDays(inDate) - dayToDays(now)));
    }

    function dayToDays(inTime) {
        return (inTime.getTime() / (1000 * 60 * 60 * 24));
    }
}

function initMap() {
    var mapCanvas = document.getElementById("map_canvas");
    if (mapCanvas){
        if (GBrowserIsCompatible()) {
        
            map = new GMap2(mapCanvas);
            map.setCenter(new GLatLng(47.608888, -122.334534), 12);
            map.setMapType(G_HYBRID_MAP);
            map.enableGoogleBar();
            map.enableScrollWheelZoom();
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
            map.addControl(new GOverviewMapControl());
        }
    }
}



function fireMyPopup() {
    // Determine how much the visitor had scrolled

    var scrolledX, scrolledY;
    if (self.pageYOffset) {
        scrolledX = self.pageXOffset;
        scrolledY = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        scrolledX = document.documentElement.scrollLeft;
        scrolledY = document.documentElement.scrollTop;
    } else if (document.body) {
        scrolledX = document.body.scrollLeft;
        scrolledY = document.body.scrollTop;
    }

    // Determine the coordinates of the center of the page

    var centerX, centerY;
    if (self.innerHeight) {
        centerX = self.innerWidth;
        centerY = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        centerX = document.documentElement.clientWidth;
        centerY = document.documentElement.clientHeight;
    } else if (document.body) {
        centerX = document.body.clientWidth;
        centerY = document.body.clientHeight;
    }
    var leftOffset = scrolledX + (centerX - 250) / 2;
    var topOffset = scrolledY + (centerY - 200) / 2;

    document.getElementById("mypopup").innerHTML = "<object id='popupvideo' width='250' height='560'><param name='movie' value='walkover.swf' /><param  name='wmode' value='transparent'/><embed src='walkover.swf' width='250' height='560' wmode='transparent'></embed></object><br /><input id='closeIntro' type='button' value='Close Intro' style='font-size: x-large; font-weight: bold;' onclick='closeMyPopup();'/>"
    
    document.getElementById("mypopup").style.top = topOffset + "px";
    document.getElementById("mypopup").style.left = leftOffset + "px";
    document.getElementById("mypopup").style.display = "block";
  
}

function closeMyPopup() {
    document.getElementById("mypopup").innerHTML="<object id='popupvideo' width='250' height='560'><param name='movie' value='' /><param  name='wmode' value='transparent'/><embed src='' width='250' height='560' wmode='transparent'></embed></object>';"
    document.getElementById("mypopup").style.display = "none";
}

