// File to put jQuery extended functions written by us
// hxwiki:systems:web_development_systems:common_javascript

$.fn.selected = function( i ) {
	if (	this.length ) {
		if (	i ) {
			try {
				this[0].selectedIndex = i;
			} catch(e) { }
		}
		return this[0].selectedIndex;
	}
};

$.fn.addOption = function(text,val,active) { 
	return $(this).each(
		function() { 
			try {
				var optionObj = new Option( text, val );
				var optionRank = this.options.length;
				this.options[optionRank] = optionObj;
				if(active) {
					this.selectedIndex=optionRank;
				}
			} catch(e) { }
		} 
	)
};

$.fn.populate = function(types, values) {
	return $(this).each(
		function() {
			types=types.split(",");
			values=values.split(",");
			$(this).empty();
			for(var i=0;i<types.length;i++) {
				$(this).addOption(types[i], values[i]);
			}
		}
	)
};

jQuery.extend(jQuery.expr[':'], {
	containsCI : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
} ); 

// Actually not putting sort in here, moving it to jquery.sort.js
