/* xxx
 * create xxx
 * by xxx
 * autor @ Miroslav Kovar
 * developed for Pilot.cz
 * usage: xxxx
 */
var ajax = new Class({
  Implements: Options,

  options: {
    method: 'get',
    encoding: 'utf-8'
  },
  
  initialize: function(type, options)
  {    
    this.setOptions(options);
    var part = new Array();
        part = this.options.url.split('.php');
    
    // console.log(this.options.url);
    
    if (this.options.url.test('.php'))
    {
      this.options.url  = part[0]+'.t'+$time()+$random(0,100)+'.php'+part[1];
    }
    
    // alert(this.options.url);
    // console.log('ajax: '+this.options.url);
    // console.log('ajax: '+part);

    if (type == 'html')
    {
      this.html();
    }
    if (type == 'json')
    {
      this.json();
    }
  },
  html: function(){
    
    $extend(this.options, {
      onComplete: function (responseTree, responseElements, responseHTML, responseJavaScript) {
        this.options.update.set('html', responseHTML);
      }
    });
    
    this.request = new Request.HTML(this.options);  
  },
  json: function(){
    this.request = new Request.JSON(this.options);
  },
  get: function(options){
    this.request.get(options);
  },
  send: function(options){
    this.request.send(options);
  },
  post: function(options){
    this.request.post(options);
  }   
});
