function ajax_postform(fn,fi)
{
  var obj = new Object();
  var he;
  var parr = new Array();
  var i;
  var s;
  var property;
  var injection;
  var fntpl = /^f[0-9a-f]{7}$/;

  for (property in parr) parr[property] = '078da1e86a9b8caaf7d63afcac843b15';

  if (!fntpl.test(fn)) { alert('Wystąpił błąd!'); return; }
  parr['number'] = fi;
  parr['dynamicform'] = fn;
  for (i=0; ; i++)
  {
    if (typeof(document.forms[fn].elements[i])=="undefined") break;
    he = document.forms[fn].elements[i];
    if (he.id.length < 10) continue;
    if (he.id.substr(0,9) != fn + '_') continue;
    key = he.id.substr(9);
    if (he.id.substr(9)=='injection')
    {
      injection = he.value;
      continue;
    }
    if ((he.id.substr(9,5)=='ofck_') && (he.id.length==15))
    {
      parr[key] = FCKeditorAPI.GetInstance(he.id).GetXHTML();
      continue;
    }
    switch(he.type)
    {
      case 'radio':
      case 'checkbox':   if (he.checked) parr[key] = 1; else parr[key] = 0; break;
      case 'hidden':
      case 'text':
      case 'password':
      case 'textarea':
      case 'select-one': parr[key] = he.value; break;
    }
  }

  advAJAX.post({ url: "index.php?page=ajaxentry",
                 parameters : parr,
                 onInitialization : function() { },
                 onSuccess : function(obj)
                 {
                   i = -1;
                   s = obj.responseText;
                   if (s.length > 1)
                   {
                     if (s.substr(1,1)=='|')
                     {
                       if ((s.substr(0,1)=='1') || (s.substr(0,1)=='2') || (s.substr(0,1)=='5')) i = s.indexOf('|',2); else i = 0;
                       if (i>=0)
                       {
                         switch(s.substr(0,1))
                         {
                           case '0': alert(s.substr(2));
                                     break;
                           case '1': alert(s.substr(2,i-2));
                                     document.getElementById(fn + '_' + s.substr(i+1)).focus();
                                     break;
                           case '2': alert(s.substr(2,i-2));
                                     document.location.href = s.substr(i+1);
                                     break;
                           case '3': document.location.href = s.substr(2);
                                     break;
                           case '4': document.getElementById(injection).innerHTML = s.substr(2);
                                     break;
                           case '5': alert(s.substr(2,i-2));
                                     document.getElementById(injection).innerHTML = s.substr(i+1);
                           case '9': break;
                            default: i = -1;
                                     break;
                         }
                       }
                     }
                   }
                   if (i<0) alert('Wystąpił błąd!');
                 },
                 onError : function(obj)
                 {
                   alert("Błąd. Numer błędu: " + obj.status);
                 }
               });
}

function ajax_linkclickandgo(id)
{
  var obj = new Object();

  advAJAX.post({ url: "index.php?page=ajaxentry",
                 parameters : { id : id, number: 7 },
                 onInitialization : function() { },
                 onSuccess : function(obj) { },
                 onError : function(obj) { }
               });
}

function InvisiblePrefix(o,p)
{
  var j = p.length;
  if (typeof(o.id) != "undefined") if (o.id.substr(0,j) == p) o.style.display = 'none';
  if (o.hasChildNodes()) for (var i=0; i < o.childNodes.length; i++) InvisiblePrefix(o.childNodes[i],p);
}

