/* -- flash.js --
 * Hide flash messages automatically
 * Created by Phill Sparks
 * @ http://milk-hub.net
 * -- -------- -- */

jQuery.fn.waitFadeOut = function(delay, timeout) {
	var obj = this;
	setTimeout(function() {$(obj).fadeOut(timeout)}, delay);
}

/* $(document).ready(...) */
$(function() {
	/* Initial Delay */
	var to = 1000;
	/* Fade out info messages first */
	$('.flash.highlight').each(function() {
		$(this).waitFadeOut(to += 2000, 1500);
	});
	/*  Fade out error messages next */
	$('.flash.error').each(function() {
		$(this).waitFadeOut(to += 2000, 1500);
	});
});
