if (jQuery) (function($) {
    $.extend($.fn, {
        attachTextTip : function(tip_text){
            $(this).each(function() {
                var text = $(this);
                text.val(tip_text).css("color", "#b6b7b9");
                text.focus(function(){
                   if(this.value != tip_text){
                       this.style.color='#404040'
                   }else{
                       this.value = '';
                       this.style.color = '#404040'
                   }
                }).blur(function(){
                    if(this.value==''){
                        this.value = tip_text;
                        this.style.color='#b6b7b9'
                    }
                }).keydown(function(){
                    this.style.color = '#404040';
                });
            });
        }
    })
})(jQuery);

$.fn.getAncestor = function (expr) {
    var jo = this;
    while (jo && !jo.is(expr)) {
        jo = jo.parent();
    }
    return jo;
}
