function swichtLayers(id) {
    if (document.getElementById(id)) {
        main  = document.getElementById(id);
    }
    
    nodes = main.getElementsByTagName("a");
    
    for (i=0; i<nodes.length; i++) {
        
        if (nodes[i].rel.substring(0, 5) == "layer") {
            
            nodes[i].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("images");
}
