
// initialize element behaviors
// -----------------------------------------------------
$(document).ready(function(){

	// yellow fade
	Fat.fade_all();

	// suckerfish
	$('#menu li').hover(
		function() { $(this).addClass('sfhover'); }, 
		function() { $(this).removeClass('sfhover'); }
	);

});

// general usage funcs
// -----------------------------------------------------

// generic confirm alert prompt
function verify(msg) { return confirm(msg); }

// clear textfield default text 
function clearText(thefield) {
	if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 

// replace textfield default text
function replaceText(thefield) {
	if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

// toggles display style of object w/ specified id
// -----------------------------------------------------
function toggleDisplay(obj_id,vis)
{
	if (document.getElementById){
		var obj = document.getElementById(obj_id);
		if (vis!=null) {
			var state = (vis ? 'block' : 'none');
		} else {
			if (obj.style.display == '' || obj.style.display == 'none'){
				var state = 'block';
			} else {
				var state = 'none';
			}
		}
		obj.style.display = state;
	}
}

// selects all checkboxes inside object
// -----------------------------------------------------
function selectall(obj_id) {
	var cnt = 0;
	var obj = document.getElementById(obj_id);
	var cbx = obj.getElementsByTagName('input');
	var cnt = cbx.length;
	for (var i=0; i < cnt; i++) 
		if (cbx[i].type == 'checkbox') cbx[i].checked = true;
}

// de-selects all checkboxes inside object
// -----------------------------------------------------
function deselectall(obj_id) {
	var cnt = 0;
	var obj = document.getElementById(obj_id);
	var cbx = obj.getElementsByTagName('input');
	var cnt = cbx.length;
	for (var i=0; i < cnt; i++) 
		if (cbx[i].type == 'checkbox') cbx[i].checked = false;
}

// -----------------------------------------------------
function move(fbox, tbox)
{
  var arrFbox = new Array();
  var arrTbox = new Array();
  var arrLookup = new Array();
  var i;
  for (i = 0; i < tbox.options.length; i++) {
    arrLookup[tbox.options[i].text] = tbox.options[i].value;
    arrTbox[i] = tbox.options[i].text;
  }
  var fLength = 0;
  var tLength = arrTbox.length;
  for(i = 0; i < fbox.options.length; i++) {
    arrLookup[fbox.options[i].text] = fbox.options[i].value;
    if (fbox.options[i].selected && fbox.options[i].value != "") {
      arrTbox[tLength] = fbox.options[i].text;
      tLength++;
    }
    else {
      arrFbox[fLength] = fbox.options[i].text;
      fLength++;
    }
  }
  arrFbox.sort();
  arrTbox.sort();
  fbox.length = 0;
  tbox.length = 0;
  var c;
  for(c = 0; c < arrFbox.length; c++) {
    var no = new Option();
    no.value = arrLookup[arrFbox[c]];
    no.text = arrFbox[c];
    fbox[c] = no;
  }
  for(c = 0; c < arrTbox.length; c++) {
    var no = new Option();
    no.value = arrLookup[arrTbox[c]];
    no.text = arrTbox[c];
    tbox[c] = no;
  }
}
