function toggleme(section_id) {

  var content = document.getElementById(section_id + "_content");

	if (content.style.display != "none") {
		hideme(section_id);
	} else {
		showme(section_id);
	}
}

function hideme(section_id) {

    var control = document.getElementById(section_id + "_control");
    var content = document.getElementById(section_id + "_content");
	var colour = document.bgColor;

	if(colour == "#ffffff"){
		content.style.display = "block";
		control.style.display = "none";
	}else{
		control.src = "/graphic/icon/show" + control.src.substring(control.src.length - 5, control.src.length - 4) + ".png";
		content.style.display = "none";
		control.alt = "Show";
	}
}

function showme(section_id) {
  var control = document.getElementById(section_id + "_control");
  var content = document.getElementById(section_id + "_content");
	var colour = document.bgColor;
	
	// Assume there is a section with the ID
	if(control){
		if(colour == "#ffffff"){
			content.style.display = "block";
			control.style.display = "none";
		}else{
			control.src = "/graphic/icon/hide" + control.src.substring(control.src.length - 5, control.src.length - 4) + ".png";
			content.style.display = "block";
			control.alt = "Hide";
			var par = content.parentNode;
			if(par.id.length > 8){
				if(par.style.display == "none"){
					var this_id = par.id.substring(0, par.id.length - 8);
					showme(this_id);
				}
			}
		}
	} else {
		// What, no section? Try any element with an ID
		content = document.getElementById(section_id);
		if(content){
			if(colour == "#ffffff"){
				content.style.display = "block";
			}else{
				var par = content.parentNode;
				if(par.id.length > 8){
					if(par.style.display == "none"){
						if(par.id.substring(par.id.length - 8) == "_content"){
							var this_id = par.id.substring(0, par.id.length - 8);
							showme(this_id);
						}
					}
				}
			}
		} else {
			// No element with an ID so try an old style anchor with a name
			anchors = document.getElementsByTagName("a");
			for (var i = 0; i < anchors.length; i++) { 
				if(anchors[i].name == section_id){
					var par = anchors[i].parentNode;
					if(par.id.length > 8){
						if(par.style.display == "none"){
							if(par.id.substring(par.id.length - 8) == "_content"){
								var this_id = par.id.substring(0, par.id.length - 8);
								showme(this_id);
							}
						}
					}
				}
			}
		}
	}
}

function showmehash(){
	if(document.location.hash){
		if(document.location.hash != "#top"){
			showme(unescape(document.location.hash.substring(1)));
		}
	} else {
		if (document.referrer && document.referrer!=""){
			if(document.referrer.indexOf("/search") >= 0){
				toggleall();
			}
		}
	}
}

function toggleall(){
	var allcontrol = document.getElementById("all_control");
	var thistitle = document.getElementById("all_title");
	var allImages = document.getElementsByTagName("img");
	
	if(allcontrol){
		if(allcontrol.alt == "Show all"){
			for(var i in allImages){
				if(allImages[i].id){
					if(allImages[i].id != "all_control" && allImages[i].id.indexOf("_control")){
						var section_id = allImages[i].id.substring(0, allImages[i].id.length - 8);
						showme(section_id);
					}
				}
			}
			allcontrol.src = "/graphic/icon/hide" + allcontrol.src.substring(allcontrol.src.length - 5, allcontrol.src.length - 4) + ".png";
			allcontrol.alt = "Hide all";
			thistitle.innerHTML = "Hide all"; 
		} else {
			for(var i in allImages){
				if(allImages[i].id){
					if(allImages[i].id != "all_control" && allImages[i].id.indexOf("_control")){
						var section_id = allImages[i].id.substring(0, allImages[i].id.length - 8);
						hideme(section_id);
					}
				}
			}
			allcontrol.src = "/graphic/icon/show" + allcontrol.src.substring(allcontrol.src.length - 5, allcontrol.src.length - 4) + ".png";
			allcontrol.alt = "Show all";
			thistitle.innerHTML = "Show all";
		}
	}
} 