/* all functions below are copyrighted by Yard [yard@vp.pl]
   without permision to copy */
function $(id) {
    if(obj = document.getElementById(id))
        return obj;
    else return false;
}

function del(id) {
  $('del_id').value = id
  if(confirm("Na pewno usunąć ten wpis?"))
     return document.del.submit()
}

function edit(id) {
    $('edit_id').value = id
    return document.edit.submit()
}

function checkForm(form){
  for(var i = 1; i < form.elements.length; i++) {
    if(form.elements[i].value == '' && form.elements[i].name != 'www') {
      $('error_area').innerHTML = '<strong>wypelnij wszystkie pola!</strong>'
      return false
    }
  }
  return true
}

function toggle(id) {
  $(id).style.display = ($(id).style.display == 'none')? '' : 'none';
}

function goTo(href) {
  document.location.href = href;
}

function toggleNews(newsID) {
  obj = $('expandedNews' + newsID);
  ref = $('toggleNewsButton' + newsID);
  if (obj.style.display == 'none') {
    obj.style.display = '';
    ref.innerHTML = 'mniej';
  } else {
    obj.style.display = 'none';
    ref.innerHTML = 'więcej';
  }  
}

function echo(text) {
    $('dbgArea').innerHTML += '::' + text;
}

function print(text) {
    $('dbgArea').innerHTML = text;
}

var hlArray = new Array();
function hlForumRow(forumID, className) {
    if(className == null) {
        var className = 'hl_row';
    }
    
    //echo('costam');
    if($('forumlink' + forumID)) {
      $('forumlink' + forumID).className = 'forumlinkHovered';
      //print('done');
    } else {
      $('topictitle' + forumID).className = 'topictitleHovered';
    //print('done')
  }

    var i = 1;
    //print('viewForum' + forumID + '_' + i);
    //echo($('viewForum' + forumID + '_' + i) );
    while(cell = $('viewForum' + forumID + '_' + i)) {
        hlArray[i] = cell.className;
        cell.className = className;
        i++;
    }
}

function dehl(forumID) {
  
    if($('forumlink' + forumID))
      $('forumlink' + forumID).className = 'forumlink';
    else
      $('topictitle' + forumID).className = 'topictitle';
      
    var i = 1;
    while(cell = $('viewForum' + forumID + '_' + i)) {
        //echo(hlArray[i]);
        cell.className = hlArray[i];
        hlArray[i] = null;
        //$('dbgArea').innerHTML = 'viewForum' + forumID + i;
        i++;
    }
}