// Funkcje do form
if (!Array.prototype.forEach)
{
  Array.prototype.forEach = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        fun.call(thisp, this[i], i, this);
    }
  };
}


function maxLength1(o,v,m){
    document.getElementById(v).innerHTML= 'Do końca ' + (m - ((o.value=o.value.substr(0,m)).length));
    document.getElementById(v).style.color='red';
    document.getElementById(v).style.textDecoration="underline";
}
function maxLength2(e,o,v,m){
  // ponieważ Gecko zdarzenie onkeypress występuje
  // także po naciśnięciu klawiszy nie alfanumerycznych 
  // (event.keyCode!=0), naciśnięcia takiego klawisza 
  // nie jest anulowane
  if(!o.all&&e.keyCode!=0)return!0;
  // anulowanie lub nie w zależności od liczby znaków
  // z jednoczesnym odświerzeniem pola wyświetlającego 
  // liczbę znaków
  return(document.getElementById(v).innerHTML=o.value.length)<m
}
function maxLength3(o,v,m){
  if(o.value.length>m)
    document.getElementById(v).innerHTML=
      ((o.value=o.value.substr(0,m)).length);
}

function FN_SelectEnabled(NameCheckbox,NameSelect){
    // var elements = document.getElementsByTagName('select');
    // Funkcja dedykowana dla asystenta. 
    // W dziale gdzie spać dla nowych Checkbox-ów po zaznaczeniu wyłączam selecta - object_type
    // Spanie w zamkach/pałacach - object_type_id = 294
    el = document.getElementsByName(NameSelect); msg1 = '';
    
    if (el.length == 1){
      e = el.item(0);         
      if (NameCheckbox.checked) {
        e.removeAttribute('enabled');
        e.setAttribute('disabled', 'disabled');
      } else {
          e.removeAttribute('disabled');
          e.setAttribute('enabled', 'enabled');
      }  
    } else if (el.length > 1){
      alert('W dokumencie jest > 1 element o nazwie ' + NameSelect + '\n\nFnkcja: FN_SelectEnabled()');
    } else {
      alert('W dokumencie nie ma elementu o nazwie ' + NameSelect + '\n\nFnkcja: FN_SelectEnabled()');
    }  
		return false;
  }
	
function printElt(element, index, array){
    // Wydrukuje:
    // [0] jest 2
    // [1] jest 5
    // [2] jest 9	
    //alert("[" + index + "] jest " + element);
    return "[" + index + "] jest " + element;
}


