/**
 * Obsluga wywolan ajaxowych na stronie
 */
function AjaxPage() {
  var pg = new Object();

  /**
   * Parametry strony
   */
  pg.parameters = new Object();

  /**
   * URL strony
   */
  pg.url = null;
  
  /**
   * ustawienia URLa strony
   */
  pg.setUrl = function(url) {
    pg.url = url;
  }
  
  /**
   * przypisanie parametru
   */
  pg.setParam = function(paramName, paramValue) {
    pg.parameters[paramName] = paramValue;
  }
  
  /**
   * skasowanie parametrow
   */
  pg.unsetParams = function() {
    pg.parameters = new Object();
  }

  /**
   * przeladowanie wybranego boxa
   */
  pg.reloadBox = function(boxId) {
    AjaxRequest.post(
      {
      "url":pg.url
      ,"parameters":pg.parameters
      ,"onSuccess":function(req){ document.getElementById(boxId).innerHTML=req.responseText; }
      ,"onError":function(req){ alert("Error!\nStatusText="+req.statusText+"\nContents="+req.responseText); }
      //,"onLoading":function(){ document.getElementById(boxId).className = "transOn"; }
      //,"onLoaded":function(){ document.getElementById(boxId).className = "transOff"; }
      }
    );
  }

  return pg;
}
  

/**
 * zaladownie urla do boxa
 */
function ajaxGet(boxId, urlString) {
    AjaxRequest.get(
      {
      "url":urlString
      ,"onSuccess":function(req){ document.getElementById(boxId).innerHTML=req.responseText; }
      ,"onError":function(req){ document.getElementById(boxId).innerHTML=""; }
      }
    );
}
