function collapseToggle(displayId, hiddenId, style) {
    if (style==null) style='block';
    d=$(displayId).style.display;
    h=$(hiddenId).style.display;
                
    if (d==h) {
        d=style;
        h='none';
    } else if(d=='none') {
        d=style;
        h='none';
    } else {
        d='none';
        h=style;
    }
    $(displayId).style.display=d;
    $(hiddenId).style.display=h;
}

function toggleOther(src_id, dst_id, specialValue) {
    if (specialValue == null) specialValue = 'Other';
    if ($(src_id).options[$(src_id).selectedIndex].text == specialValue) {
        Element.show($(dst_id));
    }
    else {
        Element.hide($(dst_id));
    }
}


function displayId(id, a) {
    if (a == null) a='block';
    var d = $(id).style.display;

    if (d=='none') d=a;
    else if (d==a || d=='') d='none';
    else d=a;
    $(id).style.display=d;
    return true;
}

function checkboxDisplay(checkboxId, targetId, onState) {
    if (onState == undefined) onState = 'block';
    if (onState == 'block') offState = 'none';
    else offState = 'block';
    
    if (document.getElementById(checkboxId).checked) {
        document.getElementById(targetId).style.display = onState;
    } else {
        document.getElementById(targetId).style.display = offState;
    }
}
// Add Actions to row entries on indexes //
function addActions(table_id, ignoreClass) {
    var e;
    var a;
    e=$(table_id).getElementsByTagName('tr');
    for(i=0;i<e.length;i++) {
        a = e[i].getElementsByTagName('a');
        e[i].anchor = a[0];
        e[i].onmouseover=function onmouseover() {
            this.curColor=this.style.background;
            setColor(this,'#EDEFF1');
            this.style.cursor='pointer';
            this.style.cursor='hand';
            window.status=this.anchor;
        };
        e[i].onmouseout=function onmouseout() {
            setColor(this,this.curColor);
            window.status='';
        };
    }
    e=$(table_id).getElementsByTagName('td');
    for (i=0;i<e.length;i++){
        if (e[i].className!=ignoreClass) {
            e[i].onclick=function onclick() {
                document.location = this.parentNode.anchor;
            };
        }
    }
}
function setColor(element, color) {
    element.style.backgroundColor=color;
}

function toggleCategory(element){
    Element.toggle(element+'_add');
    Element.toggle(element+'_minus');
    Effect.toggle(element, 'blind');
}

/*
 Functions for moving options from one select box to another
*/
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}


function selectAllOptions(selStr){
  if ($(selStr) == undefined) return;
  var selObj = $(selStr);
  for (var i=0; i<selObj.options.length; i++) {
    selObj.options[i].selected = true;
  }
}
/*
 End of moving select options functions //
*/
