(function($){
	var classes = {
		ok: 'good',
		error: 'bad',
		info: 'info'
	}
	var timeout;
	
	$.extend({
		messageShow: function(type, text){
			if($('#slidenotice_container').length < 1){
				$('body').append('<div id="slidenotice_container">'
					+ '<div style="top: 0;" class="' + classes[ type ] + '" id="notice">'
						+ '<p class="slidenotice_text">' + text + '</p>'
						+ '<span class="ico"></span>'
						+ '<a class="a_close" href="#"></a>'
					+ '</div>'
				+ '</div>');
				$('#slidenotice_container .a_close').click(function(){
					$.messageHide();
					return false;
				})
			} else {
				$('#slidenotice_container #notice').attr('class', classes[ type ]);
				$('#slidenotice_container .slidenotice_text').html(text);
			}
			$('#slidenotice_container > #notice').animate({
				top: 0
			}, 300);
			if ( ! $.isEmpty(timeout)){
				clearTimeout(timeout);
			}
			timeout = setTimeout($.messageHide, 4000);
		},

		messageOk: function(text){
			$.messageShow('ok', text);
		},
		messageError: function(text){
			$.messageShow('error', text);
		},
		messageInfo: function(text){
			$.messageShow('info', text);
		},

		messageHide: function(){
			$('#slidenotice_container > #notice').animate({
				top: '-200px'
			}, 200);
		}
	});
})(jQuery);
