/**
 * jQuery.inlineTips
 * Copyright (c) 2007 James Guerin - nocopy(at)gmail(dot)com
 * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 * Date: 10/05/2007
 *
 * @projectDescription Easy Inline Tips.
 * Compatible with jQuery 1.2, tested on Firefox 2.0.0.7, and IE 6, both on Windows.
 *
 * @author James Guerin
 * @version 1.0
 **/
jQuery.fn.pause = function(ms) { return this.animate({ right: "+=1px" }, ms); };

(function( $ ){
	$.fn.inlineTip = function( tiparray, tipindex, settings ){
		settings = settings || {
				randomTip : true,
				rotateTip : true
			};	
			
		removeTip = function(){
			$(this).empty();
		};
		return this.each(function(){
			if($(this+":parent")){
					$(this).empty();
				}
				if(!settings.randomTip){
					if(tipindex){
						$(this).append('<p class="inlinetip"><strong>TIP:</strong> '+tiparray[tipindex]+'</p>');
						$(".inlinetip").animate({ backgroundColor: "#FFF6BF" }, 1000).pause(10000).animate({ backgroundColor: "#F2F2F2", opacity: 'toggle'}, 500, removeTip);		
					}	
					else{
						$(this).append('<p class="inlinetip"><strong>TIP:</strong> '+tiparray[0]+'</p>');
						$(".inlinetip").animate({ backgroundColor: "#FFF6BF" }, 1000).pause(10000).animate({ backgroundColor: "#F2F2F2", opacity: 'toggle'}, 500, removeTip);		
					}
				}
				else{
					var randomTipIndex = Math.round((tiparray.length-1)*Math.random())
					$(this).append('<p class="inlinetip"><strong>TIP:</strong> '+tiparray[randomTipIndex]+'</p>');
					$(".inlinetip").animate({ backgroundColor: "#FFF6BF" }, 1000).pause(10000).animate({ backgroundColor: "#F2F2F2", opacity: 'toggle'}, 500, removeTip);
				}
		});
	};
})( jQuery );

