
//client side input helper
function makeInt(id) {
  var x = id.value.replace(/'.'/g,'');
  id.value = parseInt(x);
  if (isNaN(id.value)) {
     id.value = '0';
  }
}

function makeFloat(id) {
  var x = id.value.replace(/','/g,'.');
      x.replace(/'.'/,'');
  id.value = parseFloat(x).replace(/'.'/g,',');;
  if (isNaN(id.value)) {
     id.value = '0,00';
  }
}

function clean(id) {
  if ("TTMM"==id.value) { id.value = ''; }
  if ("TT.MM.JJJJ"==id.value) { id.value = ''; }
  if ("MM/JJJJ"==id.value) { id.value = ''; }
  if ("0"==id.value) { id.value = ''; }
  if ("0.00"==id.value) { id.value = ''; }
  if ("0,00"==id.value) { id.value = ''; }
}

// Hide or show a specified target component by toggling its display attribute
// Locates the component with JSF id of targetId which is in the same naming
// container as the calling component. The component's CSS style attribute
// "display" is then toggled between "" and "none", ie visible or hidden.

function toggle(src, targetId) {
  id = src.id;
  lastColon = id.lastIndexOf(':');
  if (lastColon == -1) {
    basePath = "";
  } else {
    basePath = id.substring(0, lastColon + 1);
  }

  fullTargetId = basePath + targetId;
  target = document.getElementById(fullTargetId);

  if (target.style.display == "none") {
    target.style.display = "block";
    src.isTargetHidden = false;
  } else {
    src.isTargetHidden = true;
    target.style.display = "none";
  }

  return false;
}

