function $_(id)
{
   return document.getElementById(id);
}
function confirmDelete()
{
   text = "Operacja nieodwracalna!\nCzy na pewno chcesz usunąć ten wpis?";
   return confirm(text);
}
function showHide(titleId, groupId)
{
   dis = $_(groupId).style.display;
   if(dis=='block')
   {
      $_(groupId).style.display = 'none';
      $_(titleId).style.backgroundImage = 'url(grafika/plusik.jpg)';
   }
   else
   {
      $_(groupId).style.display = 'block'; 
      $_(titleId).style.backgroundImage = 'url(grafika/minusik.jpg)';
   }
}
function setAll(findId, findClass, obj)
{
   el = $_(findId).getElementsByTagName('input');
   ch = obj.checked;//sprawdzam, czy mam zaznaczyc czy odznaczyc
   for(i=0; i<el.length; i++)
   {
      if(el[i].className.match(findClass) && el[i].type=='checkbox' && el[i].disabled==false)
      {
         el[i].checked=ch;
      }
   }
}
function checkAll(findId, findClass)
{
   el = $_(findId).getElementsByTagName('input');
   for(i=0; i<el.length; i++)
   {
      if(el[i].className.match(findClass) && el[i].type=='checkbox')
      {
         if(el[i].checked==true)return true;
      }
   }
   return false;
}
function checkMessageForm()
{
   if(!checkAll('pupils-list', 'p-chk') && !checkAll('users-list', 'u-chk'))
   {
      alert('Wybierz przynajmniej jednego adresata.');
      return false;
   }
   if($_('subject').value=='')
   {
      alert('Wpisz temat informacji.');
      return false;
   }
   if($_('message-content').value=='')
   {
      alert('Wpisz treść informacji.');
      return false;
   }
}
function alertForSave()
{
   $_('save-button').style.backgroundImage = 'url(grafika/button.red.100.25.png)';
   $_('save-button').style.fontWeight = 'bold';
}
function checkMark(ob)
{
   mark = ob.value;
   if (marks.toString().indexOf(mark)===-1)
   {
      ob.style.backgroundColor = 'red';
      alert('Niepoprawny format oceny.');
      return false;
   }
   ob.style.backgroundColor = 'transparent';
   return true;
}

