function Updater() {
	
	this.linkspane = document.getElementById(arguments[0]);
	this.links = [];
	this.paneid = arguments[1];
	this.type = 'offer'; // domyślny typ tabów (taby dla oferty)
	var self = this;
	
  this.prepareTabs = function() {
     var links = this.linkspane.getElementsByTagName('a');
      this.links = links;
      for (i=0; i<links.length; i++) {
         links[i].onclick = function(){return false;}
         if (window.attachEvent)
            links[i].attachEvent('onclick',this.switchPane)
         else
            links[i].addEventListener('click',this.switchPane,false);

     }
  }
   this.switchPane = function(e) {
    
    var cur = e.srcElement ? e.srcElement : (e.target ? e.target : this);
    var addr = self.getUrl(cur) + '/nref/1';
    $("#"+self.paneid).load(addr,{},function () {
                    for (var s in self.links) {
                        self.links[s].className = self.links[s].href == cur.href ? 'active':'';                      
                     }
                   }
    );
    
    return false;
  }
  
  this.setTabsType = function(ttype) {
    switch (ttype) {
      case 'offer':
            this.type = 'offer';
            break;
      case 'user':
            this.type = 'user';
            break;
      default:
            break;
    }
  }
 
  this.getUrl = function(elm) {
  
    var href = elm.href;
    var rel = elm.rel;
    var id;
    var part = href.substr(0,href.indexOf(this.type+'/')+this.type.length+1);
     
      // find id
     var det = href.split('/');
     for (i=1; i<det.length; i++) {
          if (det[i-1] == 'id') {
              id = det[i];
              break;
          }
      }
      return part+rel+'/id/'+id
      
  }

		
};


