var jwNotify={};jwNotify.status=false;if(window.webkitNotifications){jwNotify.status=true;}
function requestingPopupPermission(callback){if((jwNotify.status)&&(jwNotify.options)&&(jwNotify.type))
window.webkitNotifications.requestPermission(callback);else
console.log('Error');}
function showNotification(){if(window.webkitNotifications.checkPermission()!=0){requestingPopupPermission(showNotification);}
else{if(jwNotify.type=='html'){if(jwNotify.options.url){var popup=window.webkitNotifications.createHTMLNotification(jwNotify.options.url);if(jwNotify.options.onclick)
popup.onclick=jwNotify.options.onclick;if(jwNotify.options.onshow)
popup.onshow=jwNotify.options.onshow;if(jwNotify.options.onclose)
popup.onclose=jwNotify.options.onclose;if(jwNotify.options.onerror)
popup.onerror=jwNotify.options.onerror;if(jwNotify.options.id)
popup.replaceId=jwNotify.options.id;popup.show();}}
else{if(jwNotify.options.image||jwNotify.options.title||jwNotify.options.body){var popup=window.webkitNotifications.createNotification(jwNotify.options.image,jwNotify.options.title,jwNotify.options.body);if(jwNotify.options.dir)
popup.dir=jwNotify.options.dir;if(jwNotify.options.onclick)
popup.onclick=jwNotify.options.onclick;if(jwNotify.options.onshow)
popup.onshow=jwNotify.options.onshow;if(jwNotify.options.onclose)
popup.onclose=jwNotify.options.onclose;if(jwNotify.options.onerror)
popup.onerror=jwNotify.options.onerror;if(jwNotify.options.id)
popup.replaceId=jwNotify.options.id;popup.show();}
else
console.log('not enough parameters');}
if(popup&&(jwNotify.options.timeout>0)){setTimeout(function(){popup.cancel();},jwNotify.options.timeout);jwNotify.options=null;jwNotify.type=null;}}}
jQuery.extend({jwNotify:function(options){var settings={image:null,title:null,body:null,timeout:5000,dir:null,onclick:null,onshow:null,onerror:null,onclose:null,id:null};if(options)
$.extend(settings,options);jwNotify.options=settings;jwNotify.type='normal';showNotification();},jwNotifyHTML:function(options){var settings={url:null,timeout:5000,onclick:null,onshow:null,onerror:null,onclose:null,id:null};if(options)
$.extend(settings,options);jwNotify.options=settings;jwNotify.type='html';showNotification();}});
