jQuery.fn.has = function(expr) {
  return this.find(expr).size();
}

jQuery.fn.id = function() {
  return this.attr('id');
}

jQuery.fn.numId = function() {
  return this.id().match(/^\D*(\d+)/)[1];
}


jQuery.fn.restize = function(method, confirmFnc) 
{
  return this.each(function() {
    var link = $(this);
    link.click(function() {
      var confirmation = !confirmFnc ? true : confirmFnc.bind(this)();

      if (confirmation) {
        var f = document.createElement('form'); 
        f.style.display = 'none'; 
        this.parentNode.appendChild(f); 
        f.method = 'POST'; 
        f.action = this.href;
        var m = document.createElement('input'); 
        m.setAttribute('type', 'hidden'); 
        m.setAttribute('name', '_method'); 
        m.setAttribute('value', method); 
        f.appendChild(m);
        f.submit();
      }
      
      return false;
    });
  });
}