(function($){$.jNotify={defaults:{MinWidth : 200,
TimeShown : 1500, 
ShowTimeEffect : 200, 
HideTimeEffect : 200, 
LongTrip : 15,
HorizontalPosition :'right', 
VerticalPosition :'top', 
ShowOverlay : false,
ColorOverlay :'#000',
OpacityOverlay : 0.3
},
init:function(msg, options, id, callback){opts=$.extend({}, $.jNotify.defaults, options);if($("#"+id).length==0)
$Div=$.jNotify._construct(id, msg);WidthDoc=parseInt($(document).width());HeightDoc=parseInt($(document).height());posTop=$.jNotify.vPos(opts.VerticalPosition);posLeft=$.jNotify.hPos(opts.HorizontalPosition);if(opts.ShowOverlay && $("#jOverlay").length==0)
$.jNotify._showOverlay();$.jNotify._show(msg,function(result){if( callback ) callback(result);});},
_construct:function(id, msg){$Div=$("<div />");$Div
.attr('id', id)
.css({opacity : 0,minWidth : opts.MinWidth})
.html(msg)
.appendTo('body');return $Div;},
vPos:function(pos){switch(pos){case 'top':
var vPos=0;break;case 'center':
var vPos=parseInt((HeightDoc/2) - (parseInt($Div.outerHeight(true))/2));break;case 'bottom':
var vPos=parseInt(HeightDoc - parseInt($Div.outerHeight(true)));break;}
return vPos;},
hPos:function(pos){switch(pos){case 'left':
var hPos=0;break;case 'center':
var hPos=parseInt((WidthDoc/2) - (parseInt($Div.outerWidth(true))/2));break;case 'right':
var hPos=parseInt(WidthDoc - parseInt($Div.outerWidth(true)));break;}
return hPos;},
_show:function(msg,callback){$Div
.css({top: posTop,
left : posLeft
});$.jNotify._endAnimation($Div,callback);},
_showOverlay:function()
{var overlay=$("<div />");overlay
.attr('id', 'jOverlay')
.css({backgroundColor : opts.ColorOverlay,
opacity: opts.OpacityOverlay
})
.appendTo('body')
.show();},
_endAnimation:function(el,callback){switch (opts.VerticalPosition){case 'top':
el.animate({top: posTop+opts.LongTrip,
opacity:1
},opts.ShowTimeEffect)
.delay(opts.TimeShown)
.animate({top: posTop-opts.LongTrip,
opacity:0
},opts.HideTimeEffect,function()
{$(this).remove();if(opts.ShowOverlay && $("#jOverlay").length > 0)
$.jNotify._closeOverlay();if( callback ) callback(true);});break;case 'center':
el.animate({opacity:1
},opts.ShowTimeEffect)
.delay(opts.TimeShown)
.animate({opacity:0
},opts.HideTimeEffect,function()
{$(this).remove();if(opts.ShowOverlay && $("#jOverlay").length > 0)
$.jNotify._closeOverlay();if( callback ) callback(true);});break;case 'bottom' :
el.animate({top: posTop - opts.LongTrip,
opacity:1
},opts.ShowTimeEffect)
.delay(opts.TimeShown)
.animate({top: posTop+opts.LongTrip,
opacity:0
},opts.HideTimeEffect,function()
{$(this).remove();if(opts.ShowOverlay && $("#jOverlay").length > 0)
$.jNotify._closeOverlay();if( callback ) callback(true);});break;}},
_closeOverlay:function()
{$("#jOverlay").remove();},
_isReadable:function(id){if($('#'+id).length > 0)
return false;else
return true;}};jNotify=function(msg,options,callback){if($.jNotify._isReadable('jNotify'))
$.jNotify.init(msg,options,'jNotify', callback);};jSuccess=function(msg,options,callback){if($.jNotify._isReadable('jSuccess'))
$.jNotify.init(msg,options,'jSuccess',callback);};jError=function(msg,options,callback){if($.jNotify._isReadable('jError'))
$.jNotify.init(msg,options,'jError',callback);};})(jQuery);
