/* auctionnudge.com (v2024.4.0) by morehawes.ca */

function AN_Item_JS(){var AN=null;var head=null;var request_endpoint=null;var request_params={};var container=null;var last_js=null;var max_pages=null;this.init=function(params={}){AN=this;AN.config={target_div_id:'auction-nudge-items',request_params:{},template_html:'',item_html:'',page_active:false,page_show_next:false,page_show_prev:false,cats_output:false,search_box:false,theme_css_asset:'',theme_js_asset:''};AN.update_config(params);AN.head=document.getElementsByTagName('head')[0];AN.request_endpoint='https://www.auctionnudge.com/feed/item/js';AN.disclosure_html='<div style="position:initial !important;display:block !important;margin:10px 0 !important;opacity:1 !important;height:initial !important;color:#222 !important;background: rgba(255,255,255,0.8) !important;scale:1 !important"><span style="display:inline-block !important;padding:0 3px;border:1px solid black;color:black;font-weight:normal;line-height:1.5em;background:#f5f5f5;border-radius:2px;scale:1 !important">Ad</span>&nbsp;Clicking an item will take you to eBay, who may pay a referral commission if a purchase is made.</div>';AN.listen(window,'load',AN.ready);}
this.update_config=function(params={}){for(i in params){if(typeof AN.config[i]!=='undefined'){AN.config[i]=params[i];}}}
this.ready=function(){AN.container=document.getElementById(AN.config.target_div_id);if(AN.container===null){AN.console_error('Container #'+AN.config.target_div_id+' not found.');return false;}
if(AN.config.request_params.theme!=='unstyled'){if(AN.container.className.indexOf('auction-nudge-items')===-1){AN.container.className+=' '+'auction-nudge-items';}
AN.container.className+=' theme-'+AN.config.request_params.theme;}
AN.add_template_html(AN.config.template_html);AN.add_item_html(AN.config.item_html);if(AN.config.page_active){AN.setup_pagination();AN.page_links('next',AN.config.page_show_next);}
if(AN.config.cats_output){AN.setup_cats(AN.config.cats_output);}
if(AN.config.search_box){AN.setup_search();}
if(AN.config.theme_css_asset){AN.add_asset('css',AN.config.theme_css_asset);}
if(AN.config.theme_js_asset){AN.add_asset('js',AN.config.theme_js_asset);}
AN.ready_callback();}
this.update=function(params={}){AN.update_config(params);AN.show_loading(false);if(AN.config.item_html){AN.add_item_html(AN.config.item_html);}else{AN.handle_items_end();}
AN.update_callback(AN.config.page_show_prev,AN.config.page_show_next);}
this.console_error=function(text=''){console.log('Auction Nudge Error: '+text+'');}
this.add_template_html=function(html){if(location.host.indexOf('ebay')!=-1||location.host.indexOf('paypal')!=-1){html='<p><strong>Auction Nudge Error</strong><br />Your items can not load because the website hostname contains a disallowed keyword.</p>';}
AN.container.innerHTML=html;AN.item_wrap=AN.container.getElementsByClassName('an-item-wrap')[0];}
this.add_item_html=function(html){AN.item_wrap.innerHTML=html;}
this.create_element=function(type,attr,content){var ele=document.createElement(type);for(key in attr){ele.setAttribute(key,attr[key]);}
if(content){if(typeof content=='object'){ele.appendChild(content);}else{ele.innerHTML=content;}}
return ele;}
this.listen=function(ele,event,callback){if(typeof ele!=='object'){AN.console_error('Element not found');return false;}
switch(event){case'load':if(typeof ele.addEventListener!="undefined"){ele.addEventListener("load",callback,false);}else if(typeof ele.attachEvent!="undefined"){ele.attachEvent("onload",callback);}else{if(ele.onload!=null){var old_onload=ele.onload;ele.onload=function(e){old_onload(e);e[callback]();};}else{ele.onload=callback;}}
break;default:if(typeof ele.addEventListener!="undefined"){ele.addEventListener(event,callback,false);}else if(typeof ele.attachEvent!="undefined"){ele.attachEvent('on'+event,callback);}
break;}}
this.add_asset=function(type,url){var e_type='';switch(type){case'css':e_type='link';var styles=AN.head.getElementsByTagName(e_type);for(i=0;i<styles.length;i++){if(url===styles[i].href){return false;}}
var attr={'type':'text/css','rel':'stylesheet','href':url};break;case'js':e_type='script';var scripts=AN.head.getElementsByTagName(e_type);for(i=0;i<scripts.length;i++){if(url===scripts[i].src){return false;}}
var attr={'type':'text/javascript','src':url};break;}
AN.head.appendChild(AN.create_element(e_type,attr,''));}
this.request_items=function(){AN.show_loading(true);var request=AN.build_request();AN.perform_request(request);}
this.build_request=function(){AN.config.request_params.action='update';var request=AN.request_endpoint;for(key in AN.config.request_params){request+='/'+key+'/'+AN.config.request_params[key];}
return request;}
this.perform_request=function(request){if(AN.last_js){AN.head.removeChild(AN.last_js);}
var attr={'type':'text/javascript','src':request};var add_js=AN.create_element('script',attr,'');AN.head.appendChild(add_js);AN.last_js=add_js;}
this.ready_callback=function(){if(typeof window.auction_nudge_loaded=='function'){auction_nudge_loaded(AN.config);}}
this.update_callback=function(page_show_prev,page_show_next){if(typeof AN.update_pagination=='function'){AN.update_pagination(page_show_prev,page_show_next);}
if(typeof window.an_item_resize=='function'){an_item_resize();}
if(typeof window.auction_nudge_loaded=='function'){auction_nudge_loaded();}}
this.show_loading=function(loading){if(loading){AN.container.className+=' an-loading';}else{AN.container.className=AN.container.className.replace(/( )?an-loading/g,'');}}}
var AN_Item_items=new AN_Item_JS();AN_Item_items.init({target_div_id:'auction-nudge-items',request_params:{"target":"items","action":"init","theme":"responsive","page":"1","img_size":"120","cats_output":"dropdown","search_box":false,"show_logo":"1","lang":"english","SellerID":"mistersewvacinc","siteid":"0","MaxEntries":"999"},template_html:'<div id=\"an-item-wrap\" class=\"an-item-wrap\"></div>',item_html:'<p class=\"no-items\">No items found.</p>',page_active:false,page_show_next:false,cats_output:'',search_box:false,theme_css_asset:'',theme_js_asset:''});