/**
 * one45 Javascript functions using jquery
 * 
 */

 /**
  * Animates the background color of an element.
  * 
  * Fades from light-yellow to the original background color
  *
  * @param elem Element to highlight the background
  * @param time_delay (Optional) Duration to wait before removing the highlight
  * @param start_color (Optional) Color at the start of the animation
  * @param end_color (Optional)	Color at the end of the animation
  * 
  */
function timedHighlight(elem, time_delay, start_color, end_color)
{
	time_delay = (time_delay) ? time_delay : 2000;
	start_color = (start_color) ? start_color : '#FDFF64'; 
	end_color = (end_color) ? end_color : elem.css("background-color");
	
	elem.attr('style', 'background-color:' + start_color);
	elem.animate({backgroundColor: end_color}, time_delay, '', function(){elem.removeAttr('style')});
}

/**
 * return based implementation of break out of each() loop
 * use:
 *   return $['break'];
 */
jQuery['break'] = new Object();
jQuery.extend
({
	each: function(obj, fn, args)
	{
		if (obj.length == undefined)
		{
			for (var i in obj)
			{
				if (fn.apply(obj[i], args || [i, obj[i]] ) == jQuery['break'])
				{
					break;
				}
			}
		}
        else
        {
        	for (var i = 0; i < obj.length; i++)
        	{
        		if (fn.apply(obj[i], args || [i, obj[i]]) == jQuery['break'])
        		{
             		break;
             	}
             }
		}
		
		return obj;
     }
});