Case = Behavior.create({
  initialize: function() {
    this.text = this.element.getAttribute('title');
    this.tip = $div({ id : 'tooltip' }, this.text);
	this.url = this.element.getAttribute('href');
  },
  onmousemove: function(e) {
   document.body.appendChild(this.tip);
   this.tip.style.left = e.pointerX()-200 + 'px';
   this.tip.style.top =  e.pointerY()-100 + 'px';
  },
  onmouseout: function(e) {
  	this.tip.remove();
  },
  onclick: function(e) {
  	window.open(this.url, 'case_popup', 'width=532, height=580, scrollbars=yes, menubar=yes, location=no, resizable=yes');
	e.stop();
  },
  onmouseover: function(e) {
    this.element.title = '';
  }
});

Link = Behavior.create({
  initialize: function() {
	this.url = this.element.getAttribute('href');
	this.rel = this.element.getAttribute('rel');
  },
  onclick: function(e) {
  	if (this.rel == 'opener') {
      if (opener != null) {
        opener.location.href = this.url;
        e.stop();
      }
	}
  }
});

Event.addBehavior({ 
  'a.case' : Case
});

Event.addBehavior({ 
  'a' : Link
});
