// JavaScript Document
function openGroup(group) {
    var grouplinks = document.getElementById('cnx_find_browse_pane1').getElementsByTagName('li');
    var groups = document.getElementById('cnx_find_browse_pane2').getElementsByTagName('div');
    var i;
    for (i=0; i<grouplinks.length; i++) {
	if (grouplinks[i].className == 'selected') grouplinks[i].className = '';
	if (groups[i].style.visbility = 'visible') groups[i].style.visibility = 'hidden';
    }
    document.getElementById('cnx_find_browse_' + group + 'link').className = 'selected';
    document.getElementById('cnx_find_browse_' + group).style.visibility = 'visible';
}

window.onload = function(e) {
    openGroup('subject');
    initOverLabels();
}

// adapted from: http://alistapart.com/articles/makingcompactformsmoreaccessible

function initOverLabels () {
  if (!document.getElementById) return;  	

  var label, field;

  // Set focus and blur handlers to hide and show 
  // LABEL with 'overlabel' class names.

  label = document.getElementById('cnx_find_search').getElementsByTagName('label')[0];
  field = document.getElementById('cnx_find_search_words');

  // Change the applied class to hover the label over the form field.
  label.className = 'overlabel-apply';

  // Hide any fields having an initial value.
  if (field.value !== '') {
    label.style.textIndent = '-1000px';
  }

  // Set handlers to show and hide labels.
  field.onfocus = function () {
    label.style.textIndent = '-1000px';
  };
  field.onblur = function () {
    if (this.value === '') {
      label.style.textIndent = '0px';
    }
  };

  // Handle clicks to LABEL elements (for Safari).
  label.onclick = function () {
    field.focus();
  }

};
