function expandCollapse(baseURL, currPic, totalPic) {
  document.body.style.overflow = (document.body.style.overflow == "hidden") ? "auto" : "hidden";

  var element = document.getElementById("imgboxopen");
  var scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
  var scrollLeft = Math.max(document.body.scrollLeft, document.documentElement.scrollLeft);

  var clientHeight;
  var clientWidth;
  if (document.body.clientHeight == 0)
    clientHeight = document.documentElement.clientHeight;
  else if (document.documentElement.clientHeight == 0)
    clientHeight = document.body.clientHeight;
  else
    clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
  if (document.body.clientWidth == 0)
    clientWidth = document.documentElement.clientWidth;
  else if (document.documentElement.clientWidth == 0)
    clientWidth = document.body.clientWidth;
  else
    clientWidth = Math.min(document.body.clientWidth, document.documentElement.clientWidth);
  var winHeight = (clientHeight - 450) / 2;
  var winWidth = (clientWidth - 550) / 2;

  var position = "";
  if (element.currentStyle)
    position = element.currentStyle["position"];
  else if (window.getComputedStyle)
    position = document.defaultView.getComputedStyle(element, null).getPropertyValue("position");

  if (position == "fixed") {
    /*element.style.top = "100px";*/
    element.style.top = winHeight + "px";
    element.style.left = winWidth + "px";
  }
  else {
    /*element.style.top = (scrollTop + 100) + "px";*/
    element.style.top = (scrollTop + winHeight) + "px";
    element.style.left = (scrollLeft + winWidth) + "px";
  }

  element.style.display = (element.style.display == "none") ? "block" : "none";

  element = document.getElementById("imgboxshade");
  var height = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight );
  var width = Math.max( document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth );
  element.style.height = height + "px";
  element.style.width = width + "px";
  element.style.display = (element.style.display == "none") ? "block" : "none";

  if (baseURL != "")
    changeBigImage(baseURL, currPic, totalPic);
}

function changeBigImage(baseURL, currPic, totalPic) {
  document.getElementById("imgboximage").src = baseURL + currPic + "h.jpg";

  var nav = "";

  if (totalPic > 1) {
    if (currPic > 0)
      nav = "<a href=\"javascript: changeBigImage('" + baseURL + "', " + (currPic - 1) + ", " + totalPic + ");\"><img src='/images/inlinepopup/green_back.png' alt='Previous' /></a> ";
    else
      nav = "<img src='/images/inlinepopup/gray_back.png' /> ";
    nav += "<span>" + (currPic + 1) + " OF " + totalPic + "</span> ";
    if (currPic < (totalPic - 1))
      nav += "<a href=\"javascript: changeBigImage('" + baseURL + "', " + (currPic + 1) + ", " + totalPic + ");\"><img src='/images/inlinepopup/green_forward.png' alt='Next' /></a>";
    else
      nav += "<img src='/images/inlinepopup/gray_forward.png' /> ";
  }
  else if (totalPic != null)
    nav = "<a href='" + document.getElementById("insideTourLink").href + "'><img src='/images/inlinepopup/more_photos.png' alt='Click Here To See More Photos' /></a>";

  document.getElementById("imgboxnav").innerHTML = nav;

  if ((typeof texts[currPic + 1] != "undefined") && (texts[currPic + 1] != "")) {
    var element = document.getElementById("imgboxtext");
    element.innerHTML = texts[currPic + 1];
    element.style.display = "block";
    document.getElementById("imgbox").style.height = "500px";
  }
  else {
    document.getElementById("imgboxtext").style.display = "none";
    document.getElementById("imgbox").style.height = "450px";
  }

  if ((typeof labels[currPic + 1] != "undefined") && (labels[currPic + 1] != ""))
    document.getElementById("imgboxtitle").innerHTML = labels[currPic + 1];
  else
    document.getElementById("imgboxtitle").innerHTML = "";
}

