// JavaScript Document

function unhide() {
  // Get parent
  var node = document.getElementById("submenus");
  node.className = "show";
}

function fromHTML(html) {
	var root = document.createElement('div');
	root.innerHTML = html;
	return root.firstChild;
}

function closePopup() { 
	divThing = document.getElementById('picviewer');
	divThing.parentNode.removeChild(divThing); 
}

function showpic(a) { 
	var newImg = new Image();
	newImg.src = '/assets/images/gallery/' + a;
	var w = newImg.width;
	var imgpopup = fromHTML('<div id="picviewer">' +
							   '<div id="imgblock" style="width: '+w+'px; margin-left: -'+w/2+'px">' +
								   '<a href="#" onclick="closePopup(); return false;">Close Picture Viewer</a>' +
								   '<img src="/assets/images/gallery/' + a + '" />' +
							   '</div>' +
						    '</div>');
	document.getElementById('gallery').parentNode.appendChild(imgpopup);
}

function toggle_ul(a) {
  // Get parent
  var parent = a.parentNode;
  var children = parent.childNodes;
  for (i=0; i<children.length; i++) {
    if (children[i].nodeName == "UL") { 
      var ul = children[i];
      if (ul.style.display == "none") {
        ul.style.display = "";
      } else {
        ul.style.display = "none";
      }
    }
  }
}
