document.wm = new Object();
document.wm.menu = new Object();
document.wm.menu.dropdown = new Array();

function initialiseMenu() {
    var i;
    if (document.all) {
	for(i = 0; i < document.all("menu").all.length; i++) {
	    if ((document.all("menu").all[i].className == "primary") ||
		(document.all("menu").all[i].className == "secondary")) {
		    document.wm.menu.dropdown[document.wm.menu.dropdown.length] = document.all("menu").all[i];
	    }
	}
    } else if (document.getElementsByTagName && document.getElementById) {
	var contained = document.getElementById("menu").getElementsByTagName("div");
	for(i = 0; i < contained.length; i++){
	    if ((contained[i].getAttribute("class") == "primary") ||
		(contained[i].getAttribute("class") == "secondary")) {
		  document.wm.menu.dropdown[document.wm.menu.dropdown.length] = contained[i];
	    }
	}
    }
    return true;
}

function collapse(item) {
    var imgname,imgfilename;
    if (document.wm.menu.dropdown.length) {
	imgfilename = document.wm.menu.dropdown[item].id;
	imgname = imgfilename + "img";
	if (document.wm.menu.dropdown[item + 1].style.display == "none") {
	    document.wm.menu.dropdown[item + 1].style.display = "";
	    
	} else {
	    document.wm.menu.dropdown[item + 1].style.display = "none";
	    
	}
    }
}

function imageSwap(img,src){
  if (document.images) {
    document.images[img].src = src;
  }
}