function Forum_quotePost(nPostId) {
  // append source to content
  if($('#content')) {
    var sC = $('#p'+nPostId).html();
    sC = sC.replace(/<blockquote>/ig, '[cytat]').replace(/<\/blockquote>/ig, '[/cytat]');
    sC = sC.replace(/<cite>/ig, '[osoba]').replace(/<\/cite>/ig, '[/osoba]');
    sC = sC.replace(/<.*>/ig, '');
    $.trim(sC);
    $('#content').val($('#content').val() + '[osoba]' + $('#u'+nPostId).text() + ' napisał(a):[/osoba]\n[cytat]' + sC + '[/cytat]\n');
  }
  Forum_jumpContent();
}

function Forum_jumpContent() {
  // scroll to form
  $(document).scrollTop($('#fform').position().top);
  // set focus to content
  if($('#content')) {
    $('#content').focus();
  }
}

function Forum_checkPage(nMax, nInp) {
  return (nInp < 0 || nInp > nMax) ? false : true;
}

function Forum_checkContent(oC, oT) {
  return (
    Forum_checkNoEmpty(oT, 'Proszę wpisać tytuł wątku.')
    && Forum_checkNoEmpty(oC, 'Proszę wypełnić treść komentarza.')
  );
}

function Forum_checkNoEmpty(oC, sM) {
  if(oC) {
    var sC = oC.value;
    sC = $.trim(sC);
    if('' == sC) {
      if(sM) {
        window.alert(sM);
      }
      oC.focus();
      return false;
    }
  }
  return true;
}

function Forum_clrDef(oC, sD) {
  if(oC) {
    var sC = oC.value;
    $.trim(sC);
    if(sD == sC) {
       oC.value = '';
    }
  }
  return true;
}

function Forum_remove(oForm, nPostId) {
  if(oForm && oForm.post_id && confirm('Na pewno usunąć komentarz?')) {
    oForm.post_id.value = nPostId;
    oForm.submit();
  }
}

function Forum_accessDenied() {
  window.alert('Opcja dostępna tylko dla zalogowanych.');
  return false;
}

 