// Initializer
  var allowStartMap = 0;
  function init() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    iRotate.init();
    iDrawer.init();
    iLightbox.init();
    if (allowStartMap) if (GBrowserIsCompatible()) startMap();
  }
  if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
  }
  if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
          clearInterval(_timer);
          init();
        }
    }, 10);
  }
  /*@cc_on @*/
  /*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      init(); // call the onload handler
    }
  };
  /*@end @*/
  window.onload = init;

// Push Rotation
  var iRotate = function() {
    var pushes = new Array();
    var pushesCreated = 0;
    var currentPush = -1;
    var rotation;
    return {
      init: function() {
        if (pushes.length>0) iRotate.go();
        if (pushes.length>1) rotation = window.setInterval('iRotate.go()', 10000);
      },
      addPush: function(imageURL, altText, backgroundURL) {
        next = pushes.length;
        pushes[next] = { 'image': imageURL, 'text': altText, 'background': backgroundURL };
      },
      go: function() {
        pushElement = document.getElementById("rotation");
        pushCount = pushes.length;
        if (pushesCreated!=1) {
          for (iPush=0; iPush<pushCount; iPush++) {
            var pushDiv = document.createElement("div");
                pushDiv.setAttribute("id", "push-"+iPush);
                pushDiv.style.display = 'none';
                pushDiv.style.opacity = '0';
                pushDiv.style.position = 'absolute';
                pushDiv.style.top = '0';
                pushDiv.style.width = '100%';
                pushDiv.style.height = '346px';
                pushDiv.style.background = 'url('+pushes[iPush]['background']+')';
                pushDiv.style.backgroundRepeat = 'repeat-x';
                pushDiv.style.backgroundPosition = '0 0';
            var pushImg = document.createElement("img");
                pushImg.setAttribute("src", pushes[iPush]['image']);
                pushImg.setAttribute("alt", pushes[iPush]['text']);
                pushImg.style.display = 'block';
                pushImg.style.marginLeft = 'auto';
                pushImg.style.marginRight = 'auto';
                pushImg.style.width = '950px';
                pushImg.style.height = '346px';
                pushDiv.appendChild(pushImg);
                pushElement.appendChild(pushDiv);
          }
          pushesCreated = 1;
        }
        useOld = 0;
        if (pushCount>1 && currentPush!=-1) useOld = 1;
        var nextPush = currentPush+1;
        if (nextPush>pushCount-1) nextPush = 0;
        try {
          document.getElementById("push-"+nextPush).style.zIndex = 2;
        } catch(e) {
          var pushDiv = document.createElement("div");
              pushDiv.setAttribute("id", "push-"+nextPush);
              pushDiv.style.display = 'block';
              pushDiv.style.visibility = 'hidden';
              pushDiv.style.opacity = '0';
              pushDiv.style.position = 'absolute';
              pushDiv.style.top = '0';
              pushDiv.style.width = '100%';
              pushDiv.style.height = '346px';
              pushDiv.style.background = 'url('+pushes[nextPush]['background']+')';
              pushDiv.style.backgroundRepeat = 'repeat-x';
              pushDiv.style.backgroundPosition = '0 0';
          var pushImg = document.createElement("img");
              pushImg.setAttribute("src", pushes[nextPush]['image']);
              pushImg.setAttribute("alt", pushes[nextPush]['text']);
              pushImg.style.display = 'block';
              pushImg.style.marginLeft = 'auto';
              pushImg.style.marginRight = 'auto';
              pushImg.style.width = '950px';
              pushImg.style.height = '346px';
              pushDiv.appendChild(pushImg);
              pushElement.appendChild(pushDiv);
        }
        try {
          deadPush = document.getElementById("push-"+lastPush);
          deadPush.style.display = 'none';
        } catch(e) {}
        if (useOld) {
          oldPush = document.getElementById("push-"+currentPush);
          oldPush.style.zIndex = 1;
        }
        newPush = document.getElementById("push-"+nextPush);
        newPush.style.zIndex = 2;
        setOpacity(newPush, 0);
        newPush.style.display = 'block';
        newPush.style.visibility = 'visible';
        fadeIn("push-"+nextPush, 0, 100, 5);
        lastPush = currentPush;
        currentPush = nextPush;
      }
    }
  }();

// Drawer System
  var iDrawer = function() {
    var dHandles = new Array();
    var drawers = new Array();
    var dNames = new Array();
    var dItems = new Array();
    var dCompartments = new Array();
    var dFullCompartments = new Array();
    var dOverflow = new Array();
    var currentDrawer = -1;
    var lastDrawer = 0;
    var currentSet = -1;
    var lastSet = 0;
    var itemsPerSet = 7;
    var startTimer, prev, next;
    var direction = 'right';
    var inferiorOpacity = '80';
    return {
      init: function() {
        dHandles = document.getElementById("handles").getElementsByTagName("li");
        drawers = document.getElementById("drawer").getElementsByTagName("div");
        var selected;
        for (var i=0; i<dHandles.length; i++) {
          dNames[i] = dHandles[i].id.replace('handles-', '');
          if (!hasClass(document.getElementById("handles"), 'subdivision')) {
            dHandles[i].getElementsByTagName("a")[0].onclick = iDrawer.open;
            if (hasClass(dHandles[i], 'selected')) currentDrawer = i;
          } else {
            currentDrawer = i;
          }
          drawerContents = drawers[i].getElementsByTagName("a");
          dItems[i] = drawerContents.length;
          for (var iContent=0; iContent<dItems[i]; iContent++) {
            if (currentDrawer==i && i==0 && iContent==0) selected = hasClass(drawerContents[iContent], 'selected');
            drawerContents[iContent].id = dNames[i]+'-'+iContent;
            if (currentSet==-1 && hasClass(drawerContents[iContent], 'selected')) currentSet = Math.floor(iContent/itemsPerSet);
            removeClass(drawerContents[iContent], 'selected');
          }
          dCompartments[i] = Math.ceil(dItems[i]/itemsPerSet);
          dFullCompartments[i] = Math.floor(dItems[i]/itemsPerSet);
          dOverflow[i] = dItems[i]%itemsPerSet;
        }
        prev = document.getElementById("previous");
        prev.onclick = iDrawer.revealPrevious;
        if (selected) addClass(prev, 'disabled');
        next = document.getElementById("next");
        next.onclick = iDrawer.revealNext;
        startTimer = window.setTimeout('iDrawer.reveal()', 100);
      },
      open: function() {
        lastDrawer = currentDrawer;
        direction = 'right';
        drawerName = this.parentNode.id.replace('handles-', '');
        var allowReveal = 0;
        for (var i=0; i<drawers.length; i++) {
          if (drawerName==dNames[i]) {
            if (i!=currentDrawer) {
              drawerContents = drawers[i].getElementsByTagName("a");
              for (var iContent=0; iContent<drawerContents.length; iContent++) setOpacity(drawerContents[iContent], 0);
              addClass(dHandles[i], 'selected');
              currentDrawer = i;
              currentSet = 0;
              allowReveal = 1;
            }
          } else {
            removeClass(dHandles[i], 'selected');
            if (lastDrawer!=i) removeClass(drawers[i], 'selected');
          }
          if (allowReveal) iDrawer.hide();
        }
        return false;
      },
      hide: function() {
        drawerContents = drawers[lastDrawer].getElementsByTagName("a");
        itemCount = itemsPerSet;
        if (lastSet==dFullCompartments[lastDrawer]) itemCount = dOverflow[lastDrawer];
        if (lastSet>=dCompartments[lastDrawer]) itemCount = 0;
        var startItem = itemsPerSet*lastSet;
        var move = -10;
        if (direction=='right') move = 10;
        for (var i=startItem; i<startItem+itemCount; i++) {
          if (hasClass(drawerContents[i], 'inferior')) fadeOut(drawerContents[i].id, inferiorOpacity, 0, 11);
          else fadeOut(drawerContents[i].id, 100, 0, 11);
          slide(drawerContents[i].id, move);
        }
        window.setTimeout("iDrawer.reveal()", 300);
      },
      reveal: function() {
        if (lastDrawer!=currentDrawer) {
          removeClass(drawers[lastDrawer], 'selected');
          addClass(drawers[currentDrawer], 'selected');
        }
        drawerContents = drawers[currentDrawer].getElementsByTagName("a");
        for (var iContent=0; iContent<drawerContents.length; iContent++) {
          setOpacity(drawerContents[iContent], 0);
          setPosition(drawerContents[iContent], 0);
          removeClass(drawerContents[iContent], 'selected');
        }
        itemCount = itemsPerSet;
        if (currentSet==dFullCompartments[currentDrawer] || (currentSet==dFullCompartments[currentDrawer]-1 && dOverflow[currentDrawer]==0)) {
          if (currentSet!=dFullCompartments[currentDrawer]-1) itemCount = dOverflow[currentDrawer];
          next.removeAttribute("href");
          addClass(next, 'disabled');
        } else {
          next.href = '?drawer='+dNames[currentDrawer]+'&compartment='+(currentSet+1);
          removeClass(next, 'disabled');
        }
        if (currentSet>=dCompartments[currentDrawer]) itemCount = 0;
        if (currentSet==0) {
          prev.removeAttribute("href");
          addClass(prev, 'disabled');
        } else {
          var compartment = '';
          if (currentSet>1) compartment = '&compartment='+(currentSet-1);
          prev.href = '?drawer='+dNames[currentDrawer]+compartment;
          removeClass(prev, 'disabled');
        }
        var startItem = itemsPerSet*currentSet;
        for (var i=startItem; i<startItem+itemCount; i++) {
          var move = 10;
          if (direction=='right') move = -10;
          setPosition(drawerContents[i], move);
          addClass(drawerContents[i], 'selected');
          var contentsItem = dNames[currentDrawer]+'-'+i;
          if (hasClass(drawerContents[i], 'inferior')) fadeIn(contentsItem, 0, inferiorOpacity, 11);
          else fadeIn(contentsItem, 0, 100, 11);
          slide(contentsItem, 0);
        }
      },
      revealPrevious: function() {
        lastDrawer = currentDrawer;
        lastSet = currentSet;
        direction = 'right';
        currentSet--;
        if (currentSet<0) currentSet = 0; 
        else iDrawer.hide();
        return false;
      },
      revealNext: function() {
        lastDrawer = currentDrawer;
        lastSet = currentSet;
        direction = 'left';
        currentSet++;
        if (currentSet>=dCompartments[currentDrawer]) currentSet = dCompartments[currentDrawer]; 
        else iDrawer.hide();
        return false;
      }
    }
  }();

// Details Lightbox
  var iLightbox = function() {
    var dBox;
    var details = new Array();
    var dNames = new Array();
    var currentDetails = -1;
    var currentDetailsWidth = -1;
    var loadingItem, selectedItem, subElement, closeButton, loadingThrobber, stall, tmpImage, imageSrc;
    var imageCreated = new Array();
    return {
      init: function() {
        if (hasClass(document.getElementsByTagName("body")[0], 'page-home')) {
          dBox = document.getElementById("details");
          details = dBox.getElementsByTagName("div");
          for (var i=0; i<details.length; i++) {
            dNames[i] = details[i].id.replace('details-', '');
            if (hasClass(details[i], 'selected')) currentDetails = i;
            var detailsLink = document.getElementById('show-'+dNames[i]).getElementsByTagName("a")[0];
            detailsLink.onclick = iLightbox.openDetails;
            detailsLink.href = './#'+dNames[i];
          }
        } else {
          dBox = document.createElement("div");
          dBox.id = 'details';
          document.getElementsByTagName("body")[0].appendChild(dBox);
        }
        document.getElementsByTagName("body")[0].appendChild(dBox);
        var anchors = document.getElementsByTagName("a");
        var lightboxItems = 0;
        for (var i=0; i<anchors.length; i++) {
          if (anchors[i].rel=='lightbox') {
            anchors[i].onclick = iLightbox.openImage;
            if (!anchors[i].id) anchors[i].id = 'lightbox-'+lightboxItems;
            lightboxItems++;
          }
        }
        dBox.style.zIndex = '1000';
        clickableBackground = document.createElement("a");
        clickableBackground.href = '#';
        clickableBackground.onclick = iLightbox.close;
        clickableBackground.id = 'close-background';
        clickableBackground.title = 'Return to Hawks Ridge';
        clickableBackground.style.display = 'block';
        clickableBackground.style.position = 'absolute';
        clickableBackground.style.top = '0';
        clickableBackground.style.left = '0';
        clickableBackground.style.bottom = '0';
        clickableBackground.style.right = '0';
        clickableBackground.style.width = '100%';
        if (document.all) clickableBackground.style.height = document.getElementsByTagName("html")[0].offsetHeight;
        clickableBackground.style.zIndex = '1001';
        clickableBackground.style.outline = 'none';
        clickableBackground.style.backgroundColor = '#000';
        clickableBackground.style.opacity = '.6';
        clickableBackground.style.mozOpacity = '.6';
        clickableBackground.style.khtmlOpacity = '.6';
        clickableBackground.style.filter = 'alpha(opacity=60)';
        dBox.appendChild(clickableBackground);
        closeButton = document.createElement("a");
        closeButton.href = '#';
        closeButton.onclick = iLightbox.close;
        closeButton.id = 'close-button';
        closeButton.style.display = 'block';
        closeButton.style.position = 'absolute';
        closeButton.style.top = '0';
        closeButton.style.left = '100%';
        closeButton.style.marginLeft = '-20px';
        closeButton.style.width = '20px';
        closeButton.style.height = '20px';
        closeButton.style.backgroundColor = '#fff';
        closeButton.style.backgroundImage = 'url(/_presentation/close.png)';
        closeButton.style.backgroundRepeat = 'no-repeat';
        closeButton.style.backgroundPosition = '0 0';
        closeButton.style.zIndex = '1009';
        dBox.appendChild(closeButton);
        loadingThrobber = document.createElement("div");
        loadingThrobber.id = 'loading-throbber';
        loadingThrobber.style.position = 'absolute';
        loadingThrobber.style.top = '50%';
        loadingThrobber.style.left = '50%';
        loadingThrobber.style.marginTop = '-16px';
        loadingThrobber.style.marginLeft = '-16px';
        loadingThrobber.style.width = '32px';
        loadingThrobber.style.height = '32px';
        loadingThrobber.style.backgroundColor = '#f0f0f0';
        loadingThrobber.style.borderWidth = '10px';
        loadingThrobber.style.borderStyle = 'solid';
        loadingThrobber.style.borderColor = '#fff';
        loadingThrobber.style.zIndex = '1010';
        loadingThrobberImage = document.createElement("img");
        loadingThrobberImage.setAttribute('src', '/_presentation/loading.gif');
        loadingThrobberImage.setAttribute('width', '32px');
        loadingThrobberImage.setAttribute('height', '32px');
        loadingThrobber.appendChild(loadingThrobberImage);
        dBox.appendChild(loadingThrobber);
      },
      openDetails: function() {
        stall = 0;
        tmpImage = '';
        imageSrc = '';
        detailsName = this.parentNode.id.replace('show-', '');
        for (var i=0; i<details.length; i++) {
          if (dNames[i]==detailsName) currentDetails = i;
          else removeClass(details[i], 'selected');
        }
        selectedItem = details[currentDetails];
        addClass(selectedItem, 'selected');  
        iLightbox.reveal();
        return false;
      },
      openImage: function() {
        if (imageCreated[this.id]!=1) {
          stall = 1;
          imageSrc = this.href;
          var lightboxImageDiv = document.createElement("div");
          lightboxImageDiv.id = 'image-'+this.id
          var lightboxImage = document.createElement("img");
          lightboxImage.src = imageSrc;
          lightboxImageDiv.appendChild(lightboxImage);
          dBox.appendChild(lightboxImageDiv);
          loadingItem = document.getElementById("image-"+this.id);
          selectedItem = loadingThrobber;
          imageCreated[this.id] = 1;
          tmpImage = new Image();
          tmpImage.src = imageSrc;
          tmpImage.onload = iLightbox.swapImage;
          window.setTimeout("iLightbox.swapImage()", 4000);
        } else {
          stall = 0;
          imageSrc = '';
          selectedItem = document.getElementById("image-"+this.id);
        }
        addClass(selectedItem, 'selected');
        iLightbox.reveal();
        return false;
      },
      close: function() {
        removeClass(loadingThrobber, 'selected');
        removeClass(selectedItem, 'selected');
        removeClass(dBox, 'selected');
        /*@cc_on
          var objs = document.getElementsByTagName("object");
          if (objs.length!=0) objs[0].style.visibility = 'visible';
          document.getElementById("drawer").style.visibility = 'visible';
        @*/
        return false;
      },
      reveal: function() {
        subElement = selectedItem.getElementsByTagName("*")[0];
        subElement.style.position = 'relative';
        subElement.style.zIndex = '1007';
        /*@cc_on
          if (!window.XMLHttpRequest) selectedItem.style.position = 'absolute';
          var objs = document.getElementsByTagName("object");
          if (objs.length!=0) objs[0].style.visibility = 'hidden';
          document.getElementById("drawer").style.visibility = 'hidden';
        @*/
        selectedItem.appendChild(closeButton);
        closeButton.style.display = 'none';
        setOpacity(selectedItem, 0);
        addClass(dBox, 'selected');
        iWidth = subElement.offsetWidth;
        iHeight = subElement.offsetHeight;
        if (subElement.nodeName!='IMG') {
          iWidth = 550;
          iHeight = selectedItem.offsetHeight;
          if (iHeight<100) iHeight = 100;
        }
        selectedItem.style.position = 'absolute';
        selectedItem.style.left = '50%';
        selectedItem.style.width = iWidth+'px';
        selectedItem.style.height = iHeight+'px';
        selectedItem.style.top = ((document.getElementsByTagName("html")[0].offsetHeight-iHeight)/2)+'px';
        selectedItem.style.marginLeft = '-'+(iWidth/2)+'px';
        selectedItem.style.backgroundColor = '#f0f0f0';
        selectedItem.style.borderWidth = '10px';
        selectedItem.style.borderStyle = 'solid';
        selectedItem.style.borderColor = '#fff';
        selectedItem.style.zIndex = '1006';
        fadeIn(selectedItem.id, 0, 100, 20);
        if (stall==0) window.setTimeout("iLightbox.showCloseButton()", 300);
      },
      swapImage: function() {
        if (stall==1) {
          selectedItem = loadingItem;
          iWidth = tmpImage.width;
          iHeight = tmpImage.height;
          selectedItem.appendChild(closeButton);
          closeButton.style.display = 'none';
          setOpacity(selectedItem, 0);
          addClass(selectedItem, 'selected');
          selectedItem.style.position = 'absolute';
          selectedItem.style.left = '50%';
          selectedItem.style.width = iWidth+'px';
          selectedItem.style.height = iHeight+'px';
          selectedItem.style.top = ((document.getElementsByTagName("html")[0].offsetHeight-iHeight)/2)+'px';
          selectedItem.style.marginLeft = '-'+(iWidth/2)+'px';
          selectedItem.style.backgroundColor = '#f0f0f0';
          selectedItem.style.borderWidth = '10px';
          selectedItem.style.borderStyle = 'solid';
          selectedItem.style.borderColor = '#fff';
          selectedItem.style.zIndex = '1006';
          removeClass(loadingThrobber, 'selected');
          fadeIn(selectedItem.id, 0, 100, 20);
          window.setTimeout("iLightbox.showCloseButton()", 300);
          stall = 0;
        }
      },
      showCloseButton: function() {
        closeButton.style.display = 'block';
        setOpacity(closeButton, 0);
        if (document.all) setOpacity(closeButton, 100);
        else fadeIn(closeButton.id, 0, 100, 20);
      }
    }
  }();

// Object Cache
  var objects = new Array();

// Opacity
  function setOpacity(obj, opacity) {
    obj.style.filter = 'alpha(opacity:'+opacity+')';
    obj.style.KHTMLOpacity = opacity/100;
    obj.style.MozOpacity = opacity/100;
    obj.style.opacity = opacity/100;
  }
  function fadeIn(objId, start, end, speed) {
    if (!objects[objId]) objects[objId] = document.getElementById(objId);
    obj = objects[objId];
    if (start>end) {
      setOpacity(obj, end);
    } else {
      setOpacity(obj, start);
      start+= speed;
      window.setTimeout("fadeIn('"+objId+"', "+start+", "+end+", "+speed+")", 50);
    }
  }
  function fadeOut(objId, start, end, speed) {
    if (!objects[objId]) objects[objId] = document.getElementById(objId);
    obj = objects[objId];
    if (start>end) {
      setOpacity(obj, start);
      start-= speed;
      window.setTimeout("fadeOut('"+objId+"', "+start+", "+end+", "+speed+")", 50);
    } else {
      setOpacity(obj, end);
      removeClass(obj, 'selected');
    }
  }

// Motion
  function setPosition(obj, position) {
    obj.style.position = 'relative';
    obj.style.left = position+'px';
  }
  function setLeftMargin(obj, margin) {
    obj.style.marginLeft = margin+'px';
  }
  function slide(objId, end) {
    if (!objects[objId]) objects[objId] = document.getElementById(objId);
    obj = objects[objId];
    position = parseInt(obj.style.left);
    if (position!=end) {
      if (position>end) position--;
      else position++;
      setPosition(obj, position);
      window.setTimeout("slide('"+objId+"', "+end+")", 50);
    }
  }

// Classes
  function hasClass(obj, className) {
    return obj.className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'));
  }
  function addClass(obj, className) {
    if (!this.hasClass(obj, className)) obj.className += " "+className;
  }
  function removeClass(obj, className) {
    if (hasClass(obj, className)) {
      var reg = new RegExp('(\\s|^)'+className+'(\\s|$)');
      obj.className=obj.className.replace(reg, ' ');
    }
  }