/**
 * ui-notice.js
 *
 * Alows easy user interface notification widgets (requires jquery)
 *
 * @author     		Dustin J. Czysz
 * @copyright  		Copyright Klovera, Inc.
 * @link      		http://klovera.com
 * @version 		1.0
 */

// ------------------------------------------------------------------------

/* Include CSS
---------------------------------------------------------------------------*/
var cssId = 'uiNotice';  // you could encode the css path itself to generate id..
if (!document.getElementById(cssId))
{
    var head  = document.getElementsByTagName('head')[0];
    var link  = document.createElement('link');
    link.id   = cssId;
    link.rel  = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://cdn.klovera.com/css/ui-notice.css';
    link.media = 'all';
    head.appendChild(link);
}

/* jQuery
---------------------------------------------------------------------------*/
$(function(){
	// add close text
	$('.notice.close').append('<span class="close">(click to close)</span>');
	
	// close action
	$('.notice.close').click(function() {
    	$(this).fadeSlideToggle();
  	});
  	
});

/*
fadeSlideToggle - can also be used with a trigger:
	$('#toggleTrigger').click(function() {
    	$('.item').fadeSlideToggle();
	});
*/
jQuery.fn.fadeSlideToggle = function(speed, easing, callback) {
  if (this.is(":hidden")) {
    return this.slideDown(speed, easing).fadeTo(speed, 1, easing, callback);
  } else {
    return this.fadeTo(speed, 0, easing).slideUp(speed, easing, callback);
  }
};


