var PapayaAdtech = {

  bannerCode : 'hob',

  _groupId : null,
  _timestamp : null,
  
  outputBanner : function(cuId, csId, userSex, userAge) {
    var bannerScript = 'http://adserver.adtech.de/addyn|3.0|59|' +
      cuId + '|0|' + csId +
      '|ADTECH;loc=100;target=_blank;key=' +
      this.bannerCode + '_' + userSex +  '_' + userAge +
      ';kvsite=' + this.bannerCode +
      ';kvsex=' + userSex +  
      ';kvage=' + userAge +
      ';grp=' + this.getGroupId() +
      ';misc=' + this.getTimestamp();
  
    document.write('<'+'script type="text/javascript" src="' + bannerScript + '"></' + 'script>');
  },
  
  getGroupId : function() {
    if (!this._groupId) {
      var currentDate = new Date();
      this._groupId = Math.round(currentDate.getTime() / 1000);
    }
    return this._groupId;
  },
  
  getTimestamp : function() {
    if (!this._timestamp) {
      var currentDate = new Date();
      var Y = currentDate.getYear();
      var m = currentDate.getMonth() + 1;
      var d = currentDate.getDate();
      var H = currentDate.getHours();
      var i = currentDate.getMinutes();
      var s = currentDate.getSeconds();
      var ms = currentDate.getMilliseconds();
      
      this._timestamp = '';
      if (Y > 1000) {
        this._timestamp += Y.toString();
      } else if (Y > 100) {
        this._timestamp += (1900 + Y).toString();
      } else {
        this._timestamp += '20' + Y.toString();   
      }
      this._timestamp += '.';
      if (m < 10) {
        this._timestamp += '0' + m.toString();
      } else {
        this._timestamp += m.toString();   
      }
      this._timestamp += '.';
      if (d < 10) {
        this._timestamp += '0' + d.toString();
      } else {
        this._timestamp += d.toString();   
      }
      this._timestamp += '.';
      if (H < 10) {
        this._timestamp += '0' + H.toString();
      } else {
        this._timestamp += H.toString();   
      }
      this._timestamp += '.';
      if (i < 10) {
        this._timestamp += '0' + i.toString();
      } else {
        this._timestamp += i.toString();   
      }
      this._timestamp += '.';
      if (s < 10) {
        this._timestamp += '0' + s.toString();
      } else {
        this._timestamp += s.toString();   
      }
      this._timestamp += '.' + ms.toString();
    }
    return this._timestamp;
  }  
}