function goBack() {
    window.history.back()
}


function getMultiSelected(element){   
    var ids = new Array();
    for(var i=0;i<element.options.length;i++){
        if(element.options[i].selected){
            ids.push(element.options[i].value);
        }
    }
    return ids;
}


function formatFacultiesParam(aryList){
    if(aryList.length >0){
        for(var i=0;i<aryList.length;i++){
            aryList[i] = "faculty[id][]="+aryList[i];
        }
    }
    return aryList.join('&');
}

function formatHostUnitsParam(aryList){
    if(aryList.length >0){
        for(var i=0;i<aryList.length;i++){
            aryList[i] = "host_unit[id][]="+aryList[i];
        }
    }
    return aryList.join('&');
}

//used to showHide the advanced search div.
function showHideDiv(element, type){
    var advLink = document.getElementById("showHidAdvancedLink");
   
    if(!type){type = 'block';}

    if(element.style.display == 'none' || !element.style.display){
        element.style.display = type;
        advLink.innerHTML = 'simple search';
    }else{        
        advLink.innerHTML = 'advanced search';
        clearAdvancedSearchForm();
        element.style.display = 'none';
    }
}

function clearAdvancedSearchForm(){
    document.getElementById('faculty_ids').selectedIndex = -1;
    var selHostUnits = document.getElementById('host_unit_ids');
    selHostUnits.selectedIndex = -1;
    document.getElementById('degree_masters').checked = false;
    document.getElementById('degree_phd').checked = false;

    //Remove the options from units list. 
    for(i=(selHostUnits.options.length-1);i != 0; i--){        
        if(selHostUnits.options[i].value != 'All' && selHostUnits.options[i].value != ''){          
            selHostUnits.remove(i);
        }
    }

    return false;
}
