function swichtLayers() {
    objBody = document.getElementsByTagName("body").item(0);
    //nodes = objBody.getElementsByTagName("a");
    parent_nodes = objBody.getElementsByTagName("div");
    for (i=0; i<parent_nodes.length; i++) {
        
        if (parent_nodes[i].className.substring(0, 5) == "layer") {
            var main = parent_nodes[i];
            var nodes = main.getElementsByTagName("a");
            for (e=0; e<nodes.length; e++) {
        
               if (nodes[e].rel.substring(0, 5) == "layer") {
            
                   nodes[e].onclick = function() {
                      main.className = this.rel;
                      return false;
                   }
               }
            }
        }
    }

}

// add main div id here
switchThis = "details";
// then just add rel="layer" + n to each layer switch link

window.onload = function () {
    swichtLayers();
}