if (jQuery) (function($){ 
$.extend($.fn, {
	
	isEmpty : function(){
		return (this === null) || (this == undefined) || (this == '');
	},
	
	isObject : function() {
	/*--------------------------------------------------
	  Returns true for DOM Objects and {1:2, 3:4} but
	  returns false for [1,2,3]
	--------------------------------------------------*/
		var obj = $(this).get(0);
		return ((!$(this).isEmpty()) && (((typeof(obj) == 'object') && (typeof(obj.length) !== 'number')) || (obj.tagName != undefined)));
	},
	
	isArray : function() {
	/*--------------------------------------------------
	  Returns true  for [1,2,3]
	  Returns false for {1:2, 3:4}
	  Safari has problems with this.. so we include functions & objects
	--------------------------------------------------*/
		var obj = $(this).get(0);
		//return ((typeof(obj) == 'object') && (typeof(obj.length) == 'number'));
		return ((!$(this).isEmpty()) && ((typeof(obj) == 'object') || (typeof(obj) == 'function')) && (typeof(obj.length) == 'number') && (obj.tagName == undefined));
		//return ((this != undefined) && (typeof(this.length) == 'number'));
	},
	
	isString : function() {
		var obj = $(this).get(0);
    	return (typeof(obj) == 'string');
	},
	
	isForm : function() {
		var obj = $(this).get(0);
		return (($(this).isObject()) && (!$(obj.elements).isEmpty()) || (obj == '[object HTMLFormElement]'));
	},
	
	popup : function (locator) {
	/*------------------------------------------------------------
		usage: $(this).popup(['by',] event|DOMElement);
		displays a popup window and sets its location near locator
		relation tells how menuID will be positioned near locator:
			'above'
			'below' (default)
			'left'
			'right'
	-------------------------------------------------------------*/
		//if (locator == undefined) locator = relation;
		if (locator != undefined){
			var c = $(locator).xy();
			$(this).css('left',c.x+"px");
			$(this).css('top',c.y+"px");
		}
		$(this).css('display', 'block');
		return $(this);
	},
	xy : function(){
	/*------------------------------------------------------------
	 Attempts to return the x,y coordinates of the object.
	 this can be a DOMElement or an event (returns mouse pos)
	-------------------------------------------------------------*/
		/*var r = {x:0,y:0};
		var o = $(this).offset();
		r.x=o.left;
		r.y=o.top;
		return r;*/
		if ((this.x != undefined) && (this.y != undefined)) return this;
		var obj = $(this).get();
		var posx = posy = 0;
		if (obj.offsetLeft != undefined) {
			do {
				posx += obj.offsetLeft;
				posy += obj.offsetTop;
			} while (obj = obj.offsetParent);
		} else if ($(this).attr('pageX') != undefined) {
			posx = $(this).attr('pageX');
			posy = $(this).attr('pageY');
		} else if ($(this).attr('clientX') != undefined) {
			posx = $(this).attr('clientX') + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = $(this).attr('clientY') + document.body.scrollTop  + document.documentElement.scrollTop;
		}
		return {x:posx,y:posy};
	}

});

})(jQuery);