/**
 * A utility belt of jquery functions.  Some of these functions are meant to extend certain jquery functionality.  IE fadeElement uses the jquery .fadeTo function but it checks first
 * to see if the browser supports opacity or not.  Some other functions are pure utility.  IE buildOptionsObject takes an array and returns an object that can be used to set many
 * options for certain ui events like draggable and sortable.  You must include the latest /jquery core js for this to work.
 *
 * @author Matt R.
 */

/**
 * Fade the passed in element if the current browser supports opacity.  IE currently does not support opacity.
 *
 * @param element DOM element
 * @param float opacity 1 = 100%
 * @param string|int speed
 */
function fadeElement(element, opacity, speed){
	if(jQuery.support.opacity){
		element.fadeTo(speed, opacity);
	}
}


/**
 * Get either the passed in items id or class.
 *
 * @param object item
 * @return string;
 */
function getItemStringName(item){
	var itemStringName = ((item).attr('id')) ? '#' + $(item).attr('id') : '.' + $(item).attr('class');

	return itemStringName;
}


/**
 * Create a javascript object with all of the options in it to be used when creating an element.
 *
 * @param array options
 * @return object
 */
function buildOptionsObject(options){
	if(options && options != '' && options != 'undefined'){
		var optionsLength = options.length;
		var newOptions = new Object();

		for(var k=0;k<optionsLength;k++){
			var option = options[k];
			var optionName = option[0];
			var optionValue = option[1];

			newOptions[optionName] = optionValue;
		}

		return newOptions;
	}
}