// -*- c-mode -*- 

function select_all ( classname, ref ) {
  for ( var i = 0; i < document.getElementsByTagName('input').length; i++ ) {
    if ( document.getElementsByTagName('input')[i].className == classname )
      {
	document.getElementsByTagName('input')[i].checked = ref.checked;
      }
  }
}


function showhidestuff(boxid) {
   box = document.getElementById(boxid);
   switch (box.style.visibility) {
      case '': box.style.visibility='visible'; break
      case 'hidden': box.style.visibility='visible'; break
      case 'visible': box.style.visibility='hidden'; break
   }
   switch (box.style.display) {
      case '': box.style.display='block'; break
      case 'none': box.style.display='block'; break
      case 'block': box.style.display='none'; break
   }
}

function hidestuff ( boxid ) {
  box = document.getElementById ( boxid );
  box.className = 'disabled'; 
  box.disabled = 'disabled'; 
}


function showstuff ( boxid ) {
  box = document.getElementById ( boxid );
  box.className = ''; 
  box.disabled = ''; 
}


function submit_form ()
{
  // Be sure that *all* form elements are not disabled so that they
  // are submited as well.
  for ( var i = 0 ; i < document.search_form.length ; i ++ )
    {
      document.search_form.elements [ i ] . disabled = false;
    }

  // Submit form to be sure all elements are up to date.
  document.search_form.submit();
}



var active;
var last_color;
function change_color ( objectid )
{
    object = document.getElementById ( objectid );
    if ( object )
    {
	if ( active ) 
	{
	    active.style.background = last_color;
	    active.style.border = '0px';
	}
	active = object;
	last_color = object.style.background;
	object.style.background = '#fce94f';
	object.style.border = '1px solid #c4a000;';
  }
}



function insert_at_cursor ( fieldid, value )
{
    field = document.getElementById ( fieldid );

    if ( document.selection ) {
	field.focus();

	sel = document.selection.createRange();
	sel.text = value;
    }

    else if ( field.selectionStart || field.selectionStart == '0' )
    {
	var startPos = field.selectionStart;
	var endPos = field.selectionEnd;
	field.value = field.value.substring ( 0, startPos ) 
	    + '{$' + value + '}' + field.value.substring ( endPos, field.value.length );
    } 
    else
    {
	field.value += value;
    }

    field.focus();
} 


function makepassword(inputid) {
   input = document.getElementById(inputid);
   input.value = SHA1(input.value);
}

/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
