/** * Usage: new SNExpander(title, holderID, contentElementId); * * {title} What the button's text should say * {holderID} An empty div put where ever you want the button made * {contentElementId} Id of element we want hidden/shown by this expander * * * example: * * [+] Titre --------- click --------> [-] Titre * ____________________ * | | * | | * | contentElementId | * | | * | | * ____________________ * * *holderID is the Div * *that Titre is in * */ function SNExpander(t, hID, cID) { var me = this; var titre = t; var contenu, ancre, imgplus; init(); function init() { if (!document.getElementById(cID)) return; contenu = document.getElementById(cID); if (!document.getElementById(hID)) return; var holder = document.getElementById(hID); ancre = document.createElement("div"); holder.appendChild(ancre); imgplus = new Image(); imgplus.src = "http://media.supernova.com/images/accordion-plussign.gif"; imgplus.className = "sn_ExpandableNodeSign"; ancre.appendChild(imgplus); var txtfld = document.createTextNode(titre); ancre.appendChild(txtfld); ancre.className = "sn_ExpandableNode"; ancre.onclick = function(){me.manageExpansion();} contenu.style.display = "none"; initStretch(); } this.manageExpansion = function() { var b = imgplus.src.match(/plus/ig)!=null; imgplus.src = imgplus.src.replace(b?"plus":"minus",b?"minus":"plus"); contenu.style.display = b ? "block" : "none"; initStretch(); } }