
// See http://www.htmldog.com/articles/suckerfish/dropdowns/
// Internet Explorer doesn't support the :hover pseudo class, so
// explicitly label 'li' tags.
tempoOver = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function() {
            this.className += " over";
        }
        sfEls[i].onmouseout = function() {
            this.className = this.className.replace(new RegExp(" over\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", tempoOver);


//
// Build a navigation list for the TEMPO pages at a node with id = "nav".
// Note: Because the Safari browser has a problem with padding and margins,
//       add a leading space to sublists for better esthetics.
//
function buildMenuList() {
    var text = "<ul>";
    text += "    <li><a href='#'>Home</a>";
    text += "        <ul>";
    text += "            <li><a href='/index.html'>&nbsp;TEMPO Home</a></li>";
    text += "            <li><a href='http://blanco.biomol.uci.edu/index.shtml'>&nbsp;White Lab Home</a></li>";
    text += "        </ul>";
    text += "    </li>";
    text += "    <li><a href='/index.html#news'>News</a></li>";
    text += "    <li><a href='#'>Research</a>";
    text += "        <ul>";
    text += "            <li><a href='/research/FernandezVidalAlphaHelixAmphilicity/AlphaHelixAmphilicity.html'>";
    text += "                &nbsp;Alpha-Helix&nbsp;Amphilicity</a>";
    text += "            </li>";
    text += "            <li><a href='/research/Jaudc2Domain/c2Domain.html'>";
    text += "                 &nbsp;c2&nbsp;domain&nbsp;of&nbsp;cPLA2</a>";
    text += "            </li>";
    text += "            <li><a href='/research/SasakiLPSPhysChar/LPSCharacterization.html'>";
    text += "                 &nbsp;LPS&nbsp;Characterization</a>";
    text += "            </li>";
    text += "            <li><a href='/research/FernandezVidalMembraneInsertionS4KChannel/MembraneInsertion.html'>";
    text += "                &nbsp;Membrane&nbsp;Insertion</a>";
    text += "            </li>";
    text += "        </ul>";
    text += "    </li>";
    text += "    <li><a href='#'>Publications</a></li>";
                     // to be found in /bibliography/...
    text += "    <li><a href='#'>Tools</a>";
    text += "        <ul>";
    text += "            <li><a href='/tools/RyansScripts/index.html'>&nbsp;Ryan's Scripts</a></li>";
    text += "            <li><a href='/tools/sfgrapher/sfgrapher.html'>&nbsp;sfgrapher</a></li>";
    text += "        </ul>";
    text += "    </li>";
    text += "    <li><a href='#'>People</a>";
    text += "        <ul>";
    text += "            <li><a href='/people/StephenW.html'>&nbsp;Stephen&nbsp;White</a></li>";
    text += "            <li><a href='/people/MagnusA.html'>&nbsp;Magnus&nbsp;Andersson</a></li>";
    text += "            <li><a href='/people/NicoletaB.html'>&nbsp;Nicoleta&nbsp;Bondar</a></li>";
    text += "            <li><a href='/people/AlfredoF.html'>&nbsp;Alfredo&nbsp;Freites</a></li>";
    text += "            <li><a href='/people/EricL.html'>&nbsp;Eric&nbsp;Lindner</a></li>";
    text += "            <li><a href='/people/EllaM.html'>&nbsp;Ella&nbsp;Mihailescu</a></li>";
    text += "            <li><a href='/people/EricS.html'>&nbsp;Eric&nbsp;Schow</a></li>";
    text += "            <li><a href='/people/CraigS.html'>&nbsp;Craig&nbsp;Snider</a></li>";
    text += "            <li><a href='/people/contacts.html'>&nbsp;Lab&nbsp;Contact&nbsp;Points</a></li>";
    text += "            <li><a href='/people/TEMPOGallery.html'>&nbsp;Photo&nbsp;Gallery</a></li>";
    text += "            <li><a href='#'>&nbsp;Alumni ...</a>";
    text += "                <ul>";
    text += "                    <li><a href='/people/RyanB.html'>&nbsp;Ryan&nbsp;Benz</a></li>";
    text += "                    <li><a href='/people/alumni/FranciscoC.html'>&nbsp;Francisco&nbsp;Castro-Rom&aacute;n</a></li>";
    text += "                    <li><a href='/people/alumni/MonicaF.html'>&nbsp;M&oacute;nica&nbsp;Fern&aacute;ndez-Vidal</a></li>";
    text += "                    <li><a href='/people/AzucenaG.html'>&nbsp;Azucena&nbsp;Gonzalez</a></li>";
    text += "                    <li><a href='/people/alumni/SimonJ.html'>&nbsp;Simon&nbsp;Jaud</a></li>";
    text += "                    <li><a href='/people/EwaK.html'>&nbsp;Ewa&nbsp;Krupinska</a></li>";
    text += "                    <li><a href='/people/MikeM.html'>&nbsp;Mike&nbsp;Myers</a></li>";
    text += "                    <li><a href='/people/BenR.html'>&nbsp;Ben Robinson</a></li>";
    text += "                    <li><a href='/people/HirotakaS.html'>&nbsp;Hirotaka&nbsp;Sasaki</a></li>";
    text += "                    <li><a href='/people/JessicaS.html'>&nbsp;Jessica&nbsp;Schulz</a></li>";
    text += "                    <li><a href='/people/NeelaS.html'>&nbsp;Neelanjana&nbsp;Sengupta</a></li>";
    text += "                </ul>";
    text += "            </li>";
    text += "        </ul>";
    text += "    </li>";
    text += "</ul>";

    var navNode = document.getElementById("nav");
    navNode.innerHTML += text;
}


//
// Add what ever special message at a node with id = "specialHeaderMessage".
//
function addSpecialMessage() {
    // Temporarily, add 'under construction' icon.
	// addUnderConstructionIcon();
}

function addUnderConstructionIcon() {
	//var text = "<p><img class='imgDivider' src='/images/uc_bar59.jpg' alt='' width='300' height='22' /></p>";
    //var specialMessageNode = document.getElementById("specialHeaderMessage");
    //specialMessageNode.innerHTML += text;
}


// Downloading a large applet can take some time, and also requires the Java
// virtual machine to be loaded.  MPEx is a signed applet, which will require
// user authorization.  The idea here is to not impose all this on a visitor
// when the page is visited, but to wait until the applet is explicitly sought.
//
// The parameters should be pretty self-explanatory. oldNodeId should represent a
// string which will identify and html element with document.getElementById().

var replacedTheAppletAlready = false;

function replaceWithApplet(oldNodeId, appletClass, appletCodebase, appletArchive, appletHeight, appletWidth, appletTextElem) {
    if (replacedTheAppletAlready) return;
    document.onclick = null;

    // Structure of replacement code based on what HtmlConverter does
    // to applet tags (see below):
    var text = "<applet code='" + appletClass + "' \n";
    text += "           codebase='" + appletCodebase + "' \n";
    text += "           archive='" + appletArchive + "' \n";
    text += "           width='" + appletWidth + "' \n";
    text += "           height='" + appletHeight + "'>\n";
    text += "           <h2>\n";
    text += "               <em>'Start MPEx' button<br />(Java not enabled)</em>.\n";
    text += "           </h2>\n";
    text += "</applet>";

    var newChild = document.createElement("div");
    newChild.innerHTML += text;
    newChild.style.border = "0";

    // Can't just replace the old child, because that's where the call to this function
    // originated, so just hide it after adding the new one.
    //var oldChild = document.getElementById("htmlButton");
    var oldChild = document.getElementById(oldNodeId);
    oldChild.parentNode.insertBefore(newChild, oldChild);
    oldChild.style.display = "none";  // Make the original image disappear.

    replacedTheAppletAlready = true;
}
