function hl(element) {
    element.style.backgroundColor = "#ffa";
}

function uhl(element) {
    element.style.backgroundColor = "";
}

function changeLocation(menuObj) {
    var i = menuObj.selectedIndex;
    if (i > 0) {
        window.location = menuObj.options[i].value;
    }
}

function addOpenSearch(base_url,name) {
    if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
        if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
            alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
        } else {
            window.external.AddSearchProvider(base_url + '/' + name + '.xml');
        }
    } else {
        alert("You will need a browser which supports OpenSearch to install this plugin.");
    }
}

function openLink(selectDest, strBaseURL, f) { 
    var index = f[ selectDest ].selectedIndex;
    if (f[ selectDest ].options[index].value != "0") {
        location = strBaseURL+ f[ selectDest ].options[index].value;
    }
}

function getElementsByClassNameTwo(oElm, strTagName, strClassName){
    if (!oElm) return;
    var arrElements = oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function toggleDisplay(oElm, strTagName, strClassName, strDisplayAppearStyle, strText) {
    if (!oElm) return;
    var oSpan = document.getElementById(oElm.getAttribute("id") + '_toggle');
 
    // Get a handle on all of the tags with this class in our
    // container.
    var arrElements = getElementsByClassNameTwo(oElm, strTagName, strClassName);
    var strClassStatus;

    // Run thru toggling the appearance of each element.
    for (var intCount = 0; intCount < arrElements.length; intCount++) {
        arrElements[intCount].style.display = 
               (arrElements[intCount].style.display == "none") ? strDisplayAppearStyle : "none";

        strClassStatus = arrElements[intCount].style.display;
    }

     // We have changed the class's display style, now change what our link shows.    
     // class not displayed we want the option to show.  class displayed option to hide.
     if (strClassStatus == "none") {
          oSpan.innerHTML = "Show " + strText;
          oSpan.style.backgroundColor = '#ff9';
     }
     else {
          oSpan.innerHTML = "Hide " + strText;
          oSpan.style.backgroundColor = '';
     }  
}

function showText(oElm, strText) {
    if (!oElm) return;
    var oSpan = document.getElementById(oElm.getAttribute("id") + '_toggle'); 
    oSpan.innerHTML = "Show " + strText;
    oSpan.style.backgroundColor = '#ff9';
}

function updateRowCount(oElm) {
    if (!oElm) return;
    var numRows = 1;
    var displayNum = 0;
    var table = document.getElementById(oElm);
    for (var numRows = 1; numRows < table.rows.length; numRows++) {
        if (table.rows[numRows].style.display != 'none') {
            displayNum++;
        }
    }
    var oSpan = document.getElementById(oElm + '_count');
    oSpan.innerHTML = displayNum;
}

