var tdbFavourites={};
(function(){tdbFavourites={selector:".tdb-favorite",cookieId:"tdb_favourites",cookieLifeTime:31536E7,items:[],init:function(){jQuery(tdbFavourites.selector).each(function(b){b=jQuery(b);tdbFavourites.addItem({$obj:b,prodId:b.data("post-id")})});jQuery("body").on("click",tdbFavourites.selector,function(b){b=jQuery(b.currentTarget);var c=b.data("post-id"),a=td_read_site_cookie(tdbFavourites.cookieId),d=0;"undefined"!==typeof a&&null!==a&&(d=a.split(",").filter(Boolean).length);jQuery(tdbFavourites.selector+
'[data-post-id="'+c+'"]').toggleClass("tdb-favorite-selected");var e=b.hasClass("tdb-favorite-selected");e?("undefined"!==typeof a&&null!==a?(a=a.split(","),-1===a.indexOf(c.toString())&&(a.push(c),td_set_cookies_life([tdbFavourites.cookieId,a.join(","),tdbFavourites.cookieLifeTime]))):td_set_cookies_life([tdbFavourites.cookieId,c,tdbFavourites.cookieLifeTime]),d++):("undefined"!==typeof a&&null!==a&&(a=a.split(","),c=a.indexOf(c.toString()),-1<c&&a.splice(c,1),td_set_cookies_life([tdbFavourites.cookieId,
a.join(","),tdbFavourites.cookieLifeTime])),d--);a=jQuery(".tdb-wmf-count");a.length&&a.text(d);"function"===typeof window.matchMedia&&window.matchMedia("(max-width: 767px)").matches&&!e&&(d=b.clone(!1),d.removeClass("tdb-favorite-selected"),b.replaceWith(d))}).on("click",'.td-del-book-btn[data-bookmark-type="tdb"]',function(b){b.preventDefault();b=td_read_site_cookie(tdbFavourites.cookieId);"undefined"!==typeof b&&null!==b&&(td_delete_site_cookie(tdbFavourites.cookieId),jQuery(tdbFavourites.selector).removeClass("tdb-favorite-selected"),
b=jQuery(".tdb-wmf-count"),b.length&&b.text("0"));location.reload()})},item:function(){},addItem:function(b){var c=new tdbFavourites.item,a=!0;a&&"undefined"!==typeof b.$obj?c.$obj=b.$obj:a=!1;a&&tdbFavourites.items.push(c)}}})();jQuery().ready(function(){tdbFavourites.init()});
