/*(function($){

	var d = null;

	$.fn.howdyBar = function(html) {  
		
		var div = $('<div class="howdybar" style="display: none" />')
			.html(html)
			.prependTo(document.body)
			.fadeTo('fast', 0.95);		
			
	};
	
})(jQuery);*/

$(document).ready(function() {

	$('div.howdybar').each(function() {
		
		var bar = this;
		
		setTimeout(function() { $(bar).slideDown(350).css('opacity', 0.96); }, 350);
		setTimeout(function() { $(bar).fadeTo('slow', 0.90); }, 3000); // for idiots
		
		var x = $('<div class="howdybar-close"><a href="#">close</a></div>')
		.prependTo(this)
		.find('a').click(function() {
			var that = this;
			$(this)
			.parent().hide()
			.parent().slideUp('fast', function() {
				$(this).remove();
			});
		});
		
		if ($(this).attr('autoclose') == 'yes') {
		
			setTimeout(function() {
				$(x).hide();
				$(bar).slideUp('slow', function() {
					$(this).remove();
				});
			}, 5000);
			
		}
		
		if ($(this).attr('autoclose') == 'yes' || $(this).hasClass('howdybar-error')) {
		
			$(this).click(function() {
				$(x).hide();
				$(bar).slideUp('fast', function() {
					$(this).remove();
				});
			});
			
		}
		
	});
	
});
