var curcontentindex=0;
var messages=new Array();

function getElementByClass(classname){
    var inc=0;
    var alltags=document.all? document.all : document.getElementsByTagName("*");
    for (i=0; i<alltags.length; i++){
        if (alltags[i].className==classname)
            messages[inc++]=alltags[i];
    }
}

function rotatecontent(){
    //get current message index (to show it):
    curcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0;
    //get previous message index (to hide it):
    prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1;
    messages[prevcontentindex].style.display="none"; //hide previous message
    messages[curcontentindex].style.display="block"; //show current message
}

window.onload=function(){
    // Rotate the contributing Institution images 
    if (document.all || document.getElementById){
        getElementByClass("dyncontent");
        setInterval("rotatecontent()", 2000);
    }
    // This will fix the rollover menu in Internet Explorer
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById("nav");
        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
}
function clear_textbox(textbox)
{
    fieldName = document.getElementById(textbox);
    if (fieldName.value == "First Name"){
        fieldName.value = "";
    }
    if (fieldName.value == "Last Name"){
        fieldName.value = "";
    }
}
function checkOtherInstitution(){
    selectName = document.getElementById('institution');
    inputName = document.getElementById('otherInstitutionContainer');
    
    if (selectName.value == "Other"){
        inputName.style.display = 'block';
    }else{
        inputName.style.display = 'none';
    }
}
function triggerSupervisortName(action) {
    selectName = document.getElementById('networkParticipant');
    inputName = document.getElementById('networkParticipantContainer');
    if (action == "show"){
        inputName.style.display = "block";
    }else if(action == "hide"){
        inputName.style.display = "none";
    }
}

//-------------------------------------
// Scripts for zebra tables
// Author: Stephen Poley
// See http://www.xs4all.nl/~sbpoley/webmatters/zebra-tables.html
// ------------------------------------

function paintZebra()
{ if (document.getElementsByTagName) 
  { tables = document.getElementsByTagName("table");
    for(j=0; j<tables.length; j++)
    {
      if (tables[j].className.indexOf('zebra') > -1) // if the classname includes 'zebra'
      { for (k=0; k<tables[j].rows.length; k=k+2)
        {
          tables[j].rows[k].className='even';
        }
      }
    }
  }
}

function viewPresentationDetails(presentation_id){
    var presentationContainer = document.getElementById('presentation_container_'+presentation_id);
    var presentationDetail = document.getElementById('presentation_details_'+presentation_id);
    var presentationOverview = document.getElementById('presentation_overview_'+presentation_id);
    var moreText = document.getElementById('more_link_'+presentation_id);

    if(presentationDetail.style.display == "block") {
        presentationDetail.style.display = "none";
        presentationContainer.style.borderBottom = "none";
        presentationOverview.style.borderBottom = "1px dashed #333";
        moreText.innerHTML = "(more details)";
    }else if(presentationDetail.style.display == "none") {
        presentationDetail.style.display = "block";
        presentationContainer.style.borderBottom = "1px dashed #333";
        presentationOverview.style.borderBottom = "none";
        moreText.innerHTML = "(hide details)";
    }
}
