jQuery.fn.identify = function(prefix) {
	if (prefix==null){prefix = '';}
	var i = 0;
	return this.each(function() {
		if($(this).attr('id')) return;
		do { 
			i++;
			var id = prefix + '_' + i;
		} while($('#' + id).length > 0);            
		$(this).attr('id', id);            
	});
};


$.fn.focusNextInputField = function() {
	return this.each(
		function() {
			var fields = $(this).parents('form:eq(0),body').find('button,input,textarea,select');
			var index = fields.index( this );
			if ( index > -1 && ( index + 1 ) < fields.length ) {
				fields.eq( index + 1 ).focus();
			}
			return false;
		}
	);
};

$.fn.extractClassId = function(prefix)
{
	prefix = prefix==null?'id':prefix;
	var el = this[0];
	var re = new RegExp('(?:^|\\s)' + prefix + '-(\\w+)(?:\\s|$)');
	var match = el.className.match(re);
	//var match = el.className.match(/(?:^|\s)user-(\w+)(?:\s|$)/);
	return match ? match[1] : null;
};

$.fn.extractClassString = function(prefix) {
	prefix = prefix==null?'string':prefix;
	var el = this[0];
	var re = new RegExp('(?:^|\\s)' + prefix + '-([A-Za-z0-9\\+/=]+)(?:\\s|$)');
	var match = el.className.match(re);
	return match ? StringUtils.decode64(match[1]) : null;
};

$.fn.wait = function(time, type) {
	time = time || 1000;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};

$.fn.comboboxText = function()
{
	var this0, selectedIndex;
	return ((this0 = this[0]) && (selectedIndex = this0.selectedIndex) >= 0)
		? this0.options[selectedIndex].text
		: '';
};
