function Tzolkin(t){
  this.template = t;
  this.date = new Date();

  year = this.date.getYear();
  if(year < 2000) {
    year += 1900;
  }
  this.year = year;

  this.month = this.date.getMonth() + 1;
}

Tzolkin.url_cgi = $$('script')[$$('script').length - 1].src.replace(/javascripts\/tzolkin\.js$/, 'call.cgi');

Tzolkin.prototype.advanceMonth = function(num){
  this.date.setMonth(this.date.getMonth() + num);
  year = this.date.getYear();
  if(year < 2000) {
    year += 1900;
  }
  this.year = year;
  this.month = this.date.getMonth() + 1;
}

Tzolkin.prototype.getCalendar = function(){
  var calendar = '';
  var _year = this.year; 
  var _month= this.month; 
  var _template = this.template; 
  var pars = $H({
    year: _year,
    month: _month,
    template: _template
  }).toQueryString();

  new Ajax.Request(
      Tzolkin.url_cgi,
      {
        parameters: pars,
        asynchronous: false,
        onComplete: function(res){
          calendar = res.responseText;
        }
      }
  );

  return calendar;
}


