jQuery.tips = function (text, options) {
	options = jQuery.extend({
		auto : true,
		location : ["center","top"],
		delay : 3000,
		load : false,
		padom : $(document.body),
		mask : false
		
	}, options);
	var csslimg = {
		"margin-top":"2px",
		"margin-right":"0px",
		"margin-bottom":"0px",
		"margin-left":"5px"
	};
	var cssload = {
		"margin-top":"2px",
		"margin-right":"0px",
		"margin-bottom":"0px",
		"margin-left":"5px"
	};
	
	if(options.mask)
	{
		var Mask = $('<div onmousedown="return false;" onmousemove="return false;" oncontextmenu="return false;"></div>');
		Mask.css({width:'100%', height:'100%', top:'0px', left:'0px', backgroundColor:'#fff', position:'absolute', opacity:0.5, zIndex:9999});
		options.padom.append(Mask);
	}

	var div = $('<div class="tips" style="width:auto;background-color: #3E9F3E;border: 2px solid #246B24;border-radius: 3px;-webkit-border-radius: 3px;-moz-border-radius: 3px;font-size: 16px;line-height: 30px;height: 30px;padding-right: 5px;padding-left: 5px;position: absolute;color: #FFF;padding-top: 0px;padding-bottom: 0px;" />');
	div.css({"z-index":"10005"});
	var ul = $('<ul />');
	var li = $('<li />');
	ul.append(li);
	li.html(text);
	var limg = $('<li />');
	limg.css(csslimg);
	ul.append(limg);
	var load = $('<li />');
	load
	.css(cssload)
	.append('<img src="/images/ui/load.gif" />');
	ul.append(load);
	div.append(ul);
	var divbox = $("<div />");
	divbox.append(div);
	options.padom.append(divbox);
	limg
	.append('<img src="/images/ui/tips.png" />')
	.hover(
		function(){$(this).find("img").attr({src:"/images/ui/tipsre.png"});},
		function(){$(this).find("img").attr({src:"/images/ui/tips.png"});}
	)
	.bind("click",function(){
		if(options.auto)
		{
			div.remove();
		}
		else
		{
			div.fadeOut("slow",function(){$(this).remove()});
		}
	});
	if(options.load)
	{
		load.css({display:""});
		limg.css({display:"none"});
	}
	else
	{
		load.css({display:"none"});
		limg.css({display:""});
	}
	switch (options.location[0])
	{
			case "center": 
				var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
			break;
			default:
				var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
			break;
	}
	switch (options.location[1])
	{
			case "top": 
				var top = "-3px";
			break;
			case "center": 
				var top = Math.floor(($(document.body).height() - div.height())/2) + "px";
			break;
			default: 
				var top = "-3px";
			break;
	}
	div.css({left:left,top:top});
	div.fadeIn("slow");
	if(options.auto) div.delay(options.delay).fadeOut("slow",function(){$(this).remove()});
	return {
		div:div,
		set:function(value)
		{
			$(div.find("li")[0]).html(value);
			switch (options.location[0])
			{
					case "center": 
						var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
					break;
					default:
						var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
					break;
			}
			switch (options.location[1])
			{
					case "top": 
						var top = "-3px";
					break;
					case "center": 
						var top = Math.floor(($(document.body).height() - div.height())/2) + "px";
					break;
					default: 
						var top = "-3px";
					break;
			}
			div.css({left:left,top:top});
		},
		location:function()
		{
			switch (options.location[0])
			{
					case "center": 
						var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
					break;
					default:
						var left = Math.floor(($(document.body).width() - div.width())/2) + "px";
					break;
			}
			switch (options.location[1])
			{
					case "top": 
						var top = "-3px";
					break;
					case "center": 
						var top = Math.floor(($(document.body).height() - div.height())/2) + "px";
					break;
					default: 
						var top = "-3px";
					break;
			}
			div.css({left:left,top:top});
		},
		close:function()
		{
			div.fadeOut("slow",function(){$(this).remove()});
			if(Mask)Mask.remove();
		},
		load:function(boo)
		{
			if(boo)
			{
				load.css({display:""});
				limg.css({display:"none"});
			}
			else
			{
				load.css({display:"none"});
				limg.css({display:""});
			}
		},
		click:function(fun){
			li.bind("click",function(dv){
				fun&&fun(dv);
			});
		}
	};
};

