$.bind.load(function()
{
	$.browser.ie6 = ($.browser.msie && $.browser.version < 7);
});


$.msg = function(txt,type,timeout,container)
{
	var is_body = container.length==0,
		appendto = is_body?$("body"):container;
	$("#messages").remove();
	var box = $("<div id='messages' class='"+type+"-message' />").html(nl2br(txt)).appendTo(appendto).css({opacity:0.1});
	var but = $("<a href='' class='close'></a>")
				.bind('click',function(){box.fadeTo(300,0.1,function(){$(this).hide();});return false;}).appendTo(box);
	
	if(is_body)
	box.css({marginTop:'-'+Math.floor(box.outerHeight()/2)+'px'}).addClass("messages-fly").fadeTo(200,1);
	else
	box.parent().show().end().fadeTo(200,1);
	
	if(timeout)
	{
		setTimeout(function()
		{
			box.fadeTo(300,0.1,function(){$(this).remove();});
		},2000);
	}
	return;

};

$.msg.close = function()
{
	$("#messages").fadeTo(300,0.1,function(){$(this).remove();});
};


