<!--
/* FUNZIONI DI USO COMUNE */

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. If something
   // besides a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }

   return retValue; // Return the trimmed string back to the user
}




// mostra un pop-up
function showPopup(url, target, width, height, top, left) {
  return window.open(url, target, "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
}


// seleziona (STATUS=true) o deseleziona (STATUS=false) tutte le caselle checkbox con nome OBJ
function checkAll(obj,status) {
  var checks = document.getElementsByName(obj);
  for ( i=0; i < checks.length; i++ ) {
    checks[i].checked = status;
  }
}


// annulla l'uso del tasto ENTER
function disableEnterKey() { 
  if (window.event.keyCode == 13) window.event.keyCode = 0; 
}


// accetta l'inserimento di sole lettere
function solo_lettere(codice) {
  // proibisco l'inserimento di qualsiasi carattere che non sia una lettera
  if ((codice < 65 || codice > 122) || (codice > 90 && codice < 97))
    return false;
}

function getElement(nome){
  if (document.all) {
     return document.all[nome]; /* con IE*/     
  } else if (document.layers){ //NN4
     return document.layers[nome];
  } else if (document.getElementById) { //NN6 ed Opera
     return document.getElementById(nome);
  } 
}
//-->
