/**
 *   jQuery Plugin "Flash" 1.0.1
 *   -------------------------------------------
 *   jquery.flash.js
 *   jquery.flash.css
 *   
 *   Copyright (c) 2009 hokuken
 *   http://hokuken.com/
 *   
 *   created  : 2009-06-02
 *   modified : 2009-07-10 bug fixed
 *   
 *   Flash displaies information box to document for few second.
 *   You must write css #flash{...}
 *   You define some mode and write css #flashMode{...}
 *   jQuery Corners Plugin (http://www.malsup.com/jquery/corner/) enabled
 *
 *   Usage :
 *     $.flash("message", {mode:"warn", fadeInSp:500, fadeOutSp:500, lasting:1000})
 *
 *     in css file...
 *     #flashWarn {...}  
 *   
 */

(function() {
    jQuery.flash = function(msg, option) {
    	if (msg.toString().length == 0) return;
		
		option = jQuery.extend({
			mode: "",//flash mode: string
			corners: "round 10px",//corners plugin parametor
			css: {}, //flash's style
			fadeInSp: 500,//fade in speed: number only
			fadeOutSp: 500,//fade out speed
			lasting: 1000//lasting time for display
		}, option);
		
		var mode = (option.mode.length > 1)? option.mode.substr(0,1).toUpperCase() + option.mode.substr(1): option.mode;
		var id = "flash" + mode;
		var $div = jQuery('<div id="'+ id +'">'+ msg +'</div>').css(option.css);
		
		$div
		.each(function(){
			try {
				jQuery(this).corners(option.corners);
			} catch (e) {}
		})
		.appendTo("body")
		.fadeIn(option.fadeInSp, function(){
			setTimeout(function(){
				$div.fadeOut(option.fadeOutSp);
				setTimeout(function(){$div.remove()}, option.fadeOutSp);
			},
			option.lasting
		);});
		
		return;
	};
})(jQuery);
