var BOOKMARK={};BOOKMARK.max=max_bookmark,BOOKMARK.checkLocalStorage=function(){return"object"==typeof localStorage},BOOKMARK.storeLocalStorage=function(r,e){return 0!=BOOKMARK.checkLocalStorage()&&localStorage.setItem(r,JSON.stringify(e))},BOOKMARK.getLocalStorage=function(r){return void 0!==typeof r&&(0!=BOOKMARK.checkLocalStorage()&&(r in localStorage!=!1&&JSON.parse(localStorage[r])))},BOOKMARK.getStored=function(){var r=BOOKMARK.getLocalStorage("bookmark");return 0==r?[]:typeof r!=typeof[]?[]:r},BOOKMARK.find=function(r){return 0!=BOOKMARK.checkLocalStorage()&&BOOKMARK.getStored().indexOf(r)},BOOKMARK.remove=function(r,e){if(0==BOOKMARK.checkLocalStorage())return!1;var a=BOOKMARK.getStored(),o=a.indexOf(r);return-1===o||(a.splice(o,1),BOOKMARK.storeLocalStorage("bookmark",a),!1!==e&&jQuery.post(ajaxurl,{action:"bookmark_remove",id:r}),!0)},BOOKMARK.push=function(r){if(0==BOOKMARK.checkLocalStorage())return alert(ts_lang.bookmark_browser_not_supported),!1;if(isNaN(r))return!1;var e=BOOKMARK.getStored();return e.length>=BOOKMARK.max?(e=e.slice(-BOOKMARK.max),BOOKMARK.storeLocalStorage("bookmark",e),alert(ts_lang.bookmark_max_item_reached),!1):-1!==e.indexOf(r)||(e.unshift(r),BOOKMARK.storeLocalStorage("bookmark",e),jQuery.post(ajaxurl,{action:"bookmark_push",id:r}),!0)},BOOKMARK.check=function(){var r=jQuery("div.bookmark[data-id]");if(r.length<1)return!1;var e=r.get(0).getAttribute("data-id");if(isNaN(e))return!1;var a=BOOKMARK.find(e);return isNaN(a)||-1===a?(r.html(` ${ts_lang.bookmark_bookmark_label}`),r.removeClass("marked"),!1):(r.html(` ${ts_lang.bookmark_bookmarked_label}`),r.addClass("marked"),!0)},BOOKMARK.listener=function(){var r=jQuery("div.bookmark[data-id]");if(r.length<1)return!1;r.on("click",function(){var r=this.getAttribute("data-id");return!isNaN(r)&&(-1===BOOKMARK.find(r)?BOOKMARK.push(r):BOOKMARK.remove(r),BOOKMARK.check(),!0)})},jQuery(document).ready(function(){BOOKMARK.check(),BOOKMARK.listener()});