var current = 1;
var slides = 11;
function slideNext() {
  hideAll();
  current++;
  if (current>11) {
    current = 1;
  }
  slideCurrent();
  return false;
}
function slidePrev() {
  hideAll();
  current--;
  if (current<1) {
    current = 11;
  }
  slideCurrent();
  return false;
}
function slideCurrent() {
  var show = document.getElementById('slide_'+current);
  show.style.display = 'block';
}
function hideAll() {
  for (i=1; i<=slides; i++) {
    var slide = document.getElementById('slide_'+i);
    slide.style.display = 'none';
  }
}
function projectShow(p,max) {
  for (i=1; i<=max; i++) {
    var photo = document.getElementById('project-photo-'+i);
    if (i==p) {
      photo.style.display = 'block';
    } else {
      photo.style.display = 'none';
    }
  }
}
function hideBlock(id) {
  var block = document.getElementById(id);
  block.style.display = 'none';
}
function showBlock(id) {
  var block = document.getElementById(id);
  block.style.display = 'block';
}
function loadExpanded() {
  var path= new String(document.location);
  var parts = path.split("#"); 
  if (parts.length==2) {
    var anchor = parts[1];
    if (isNaN(anchor)) {
      // #view is used in projects page, to default expand renovations
      if (parts[1]=="view") {
        hideBlock("click_0");
        showBlock("content_0");
      }
    } else if (anchor) {
      // use numbers to expand greenpractices
      section = anchor-1;
      hideBlock("click_"+section);
      showBlock("content_"+section);
    }
  }
}
function gpExpand(index) {
  hideBlock('gp'+index+'-short');
  showBlock('gp'+index+'-long');
}
function expandBlock(index, max) {
  hideBlock('click_'+index);
  showBlock('content_'+index);
}
function expandBlockOld(index, max) {
  for (i=0; i<= max; i++) {
    if (i == index) {
      hideBlock('click_'+i);
      showBlock('content_'+i);
    } else {
      hideBlock('content_'+i);
      showBlock('click_'+i);
    }
  }
}
function projectsPrev(current) {
  var prev = current-1;
  if (prev<1) {
    prev=11;
  }
  var url = prev+'.html';
  document.location = url;
}
function projectsNext(current) {
  var next = current+1;
  if (next>11) {
    next=1;
  }
  var url = next+'.html';
  document.location = url;
}
