function confirmDel(whatString) {
  if (!whatString) { whatString='entry' }
  return confirm("Are you sure you want to delete this "+whatString+"?  This cannot be undone.") && confirm("Are you absolutely sure?");
}

function setJSProjections(field_id,current_total_prosecutions,current_new_prosecutions) {
  var id1 = field_id + '_cy_tp';
  var id2 = field_id + '_cy_np';
  document.getElementById(id1).value = current_total_prosecutions;
  document.getElementById(id2).value = current_new_prosecutions;
}

function getJSProjections(inElement) {
  rate = inElement.value;
  field_id = inElement.id;
  related_id = inElement.getAttribute('related_id'); 
  var url = '/utils/calculateData.php?rate='+rate+'&field_id='+field_id+'&sessvar='+related_id;
  top.frames[nextFrame()].location.href = url;
  // tell hidden frame to get the url
  // PHP file in hidden frame should run parent.setProjections(field_id,...) from onload event. See above for args.
}

initProjArr = new Array();
function initProjections() {
  for (i=0;i<initProjArr.length;i++) {
    var id = initProjArr[i];
    //	getProjections(id,document.getElementById(id).value);
  }
}
function validatePassw(id1,id2) {
  if (document.getElementById(id1) && document.getElementById(id2)) {
    var pass1 = document.getElementById(id1).value;
    var pass2 = document.getElementById(id2).value;

    if (pass1 != '' && pass2 != '') {
      if (pass1 == pass2) {
	return true;
      }
      else {
	alert('The desired password and confirm password are not the same. Please re-enter the same desired password in both fields.');
	document.getElementById(id1).focus();
	return false;
      }
    }
  }
}

brows = new Brows();
if (brows.nav6up) {
  document.writeln('<link rel="stylesheet" type="text/css" href="/css/mozilla.css">');
}


var processedRadio = '';
function dispYesNo(radio,useprocessed) {
  if ((useprocessed==true && radio.name != processedRadio) || useprocessed==false){
    pass = true;
  }else if (useprocessed==true){
    pass = false;
  }

  if (document.getElementById('children_'+radio.name) && pass==true) {    
    if ((radio.value == 'Increase' || radio.value == 'Decrease') && radio.checked) {
      dsp = 'block';
      processedRadio = radio.name;	 					
      document.getElementById('children_'+radio.name).style.display = dsp;
      
    }       
    else if (radio.value == 'No Change' && radio.checked) {
      dsp = 'none';
      processedRadio = radio.name;
      document.getElementById('children_'+radio.name).style.display = dsp;
    }
    else {
      
    }
  }
}

function initYesNo() {
  var inputs = new Array();
  inputs = document.getElementsByTagName('input');
  
  for (i = 0; i < inputs.length; i++) {
    if (inputs[i].type == 'radio') {
      dispYesNo(inputs[i],true);
    }
  }
  processedRadio = '';
  
}

function toggleDisplay(id,dt) {
  dsp = document.getElementById(id).style.display;
  document.getElementById(id).style.display = (dsp == dt) ? 'none' : dt;
}

function getHistoricalDataHTML() {
  var rep = document.getElementById('_historical_data');
  return rep.innerHTML;
}

function addInputField (form, fieldType, fieldName, fieldValue) {
	var input = document.createElement("INPUT");
	input.setAttribute('type', fieldType);	
	input.setAttribute('name', fieldName);
	input.setAttribute('value', fieldValue);
	form.appendChild(input);
}

function getPicklistGroupSelection(thisElement) {
     var selected = new Array();
     for (var i=0; i<thisElement.options.length; i++) {
          if (thisElement.options[i].selected) selected.push(thisElement[i].value);
     }
     return selected;
} 
