// This function goes through the options for the given
// drop down box and removes them in preparation for
// a new set of values

function emptyList( box ) {
	// Set each option to null thus removing it
	while ( box.options.length ) box.options[0] = null;
}

// This function assigns new drop down options to the given
// drop down box from the list of lists specified

function fillList( box, arr ) {
	// arr[0] holds the display text
	// arr[1] are the values
	for ( i = 0; i < arr[0].length; i++ ) {

		// Create a new drop down option with the
		// display text and value from arr

		option = new Option( arr[0][i], arr[1][i] );

		// Add to the end of the existing options

		box.options[box.length] = option;
	}

	// Preselect option 0

	box.selectedIndex=0;
}

// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set

function changeListSelect( box, target ) {
	// Isolate the appropriate list by using the value
	// of the currently selected option
	list = lists[box.options[box.selectedIndex].value];

	// Next empty the slave list

	emptyList( target );

	// Then assign the new list values

	fillList( target, list );
}
function changeList( box, target ) {
	// Isolate the appropriate list by using the value
	// of the currently selected option
	list = lists[box];
	// Next empty the slave list
	emptyList( target );

	// Then assign the new list values

	fillList( target, list );
}
function hide (target) {
target.style.display = 'none';
}
function show (target) {
target.style.display = 'block';
}
function disable (target) {
target.disabled = true;
}
function enable (target) {
target.disabled = false;
}
function setValue (target, val) {
target.value = val;
}
function getRadioValue (radioButtonOrGroup) {
  var value = null;
  if (radioButtonOrGroup.length) { // group 
    for (var b = 0; b < radioButtonOrGroup.length; b++)
      if (radioButtonOrGroup[b].checked)
        value = radioButtonOrGroup[b].value;
  }
  else if (radioButtonOrGroup.checked)
    value = radioButtonOrGroup.value;
  return value;
}
function selected(target, indexNum) {
target.selectedIndex = indexNum;
}
function check(radioButtonOrGroup, indexNum) {
radioButtonOrGroup[indexNum].checked = true;
}
function uncheck(radioButtonOrGroup, indexNum) {
radioButtonOrGroup[indexNum].checked = false;
}
function checkbox(checkbx, indexNum) {
checkbx.checked = true;
}
function uncheckbox(checkbx, indexNum) {
checkbx.checked = false;
} 
function handleEnter (field, event) {
  var keyCode = event.keyCode ? event.keyCode : 
                event.which ? event.which : event.charCode;
  if (keyCode == 13) {
    var i;
    for (i = 0; i < field.form.elements.length; i++)
      if (field == field.form.elements[i])
        break;
    i = (i + 1) % field.form.elements.length;
    field.form.elements[i].focus();
    return false;
  }
  else
    return true;
}
var popUpWin=0;
function popUpWindow(URL, theWidth, theHeight) {
    if (window.screen) {
        l = window.screen.availWidth * 0.5 - (theWidth * 0.5);
        t = window.screen.availHeight * 0.5 - (theHeight * 0.5);
						}
  if(popUpWin)
  {
	if(!popUpWin.closed) popUpWin.close();
	}
popUpWin = window.open(URL,"popUpWin","width="+theWidth+",height="+theHeight+",left="+l+",top="+t+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width="+theWidth+",height="+theHeight+",left="+l+", top="+t+",screenX="+l+",screenY="+t+"");
}

