function enhanceCheckboxes() {

// finds every checkbox on the page
// and converts it to a graphical version

  // find all input controls:
  var els=document.getElementsByTagName("input");

  // for each input element...
  for(var i=0; i < els.length; i++) {

    if (els[i].type=='checkbox') { // its a checkbox

      // hide the original checkbox control:
      els[i].style.display='none';

      // create the graphical alternative:
      var img = document.createElement("img");

      // initial state of graphical checkbox
      // is the same as the original checkbox:

      if (els[i].checked) {
        img.src="./style/maszyna/obrazki/checkbox_checked.gif";
        img.title="Checked";
      }
      else {
        img.src="./style/maszyna/obrazki/checkbox_unchecked.gif";
        img.title="Unchecked";
      }

      // assign our onclick event
      img.onclick= toggleCheckbox;

      // insert the new, clickable image into the DOM
      // infront of the original checkbox:

      els[i].parentNode.insertBefore(img, els[i]);

    }

  }

}

function toggleCheckbox() {

// graphical checkbox onclick event handler

  // toggle the checkbox state:

  if (this.title == "Checked") {

    // toggle the image and title:
    this.src="./style/maszyna/obrazki/checkbox_unchecked.gif";
    this.title="Unchecked";

    // update the hidden real checkbox to match the state of the graphical
    // version:
    this.nextSibling.checked=false;

  }
  else {

    // toggle the image and title:
    this.src="./style/maszyna/obrazki/checkbox_checked.gif";
    this.title="Checked";

    // update the hidden real checkbox to match the state of the graphical
    // version:
    this.nextSibling.checked=true;

  }

}
