document.write(" \
<link rel=\"stylesheet\" href=\"https://www.leafbuyer.com/cannawidget/css/wSelect.css?v=071018\" /> \
<link rel=\"stylesheet\" href=\"https://www.leafbuyer.com/cannawidget/css/widget.css?v=110619\" /> \
<link rel=\"stylesheet\" href=\"https://www.leafbuyer.com/cannawidget/voice/css/widget.css?v=100619\" />	<link rel=\"stylesheet\" href=\"https://www.leafbuyer.com/css/jquery-ui.css\" /> \
<link href=\"https://fonts.googleapis.com/css?family=Montserrat:300,400,700\" rel=\"stylesheet\"> \
<style> \
.lbmclearfix { } \
.lbmclearfix::after { content:\"\"; clear:both; display:table; } \
.lbmwidget { \
	border-radius: 0; \
	min-width:300px; \
    width: 100%; \
	color: #000; \
	background-color: #f5f6f7; \
	border: none; \
	padding: 0; \
	-webkit-box-shadow: 0px 0px 8px 0px rgba(207,207,207,1); \
	-moz-box-shadow: 0px 0px 8px 0px rgba(207,207,207,1); \
	box-shadow: 0px 0px 8px 0px rgba(207,207,207,1); \
} \
.lbmwidget img { \
	width:initial; \
	display:inline-block; \
} \
.lbmtitle-wrapper img { \
	width:300px; \
	max-width:95%; \
} \
.lbmcanvas { \
	-webkit-border-radius: 0; \
	-moz-border-radius: 0; \
	border-radius: 0; \
	border: none; \
	background-color: initial; \
	margin:0; \
	padding:10px 0 0; \
} \
.lbmwidget-coupon { \
	border-top: none; \
	border-bottom: none; \
	margin: 5px; \
	background-color: #fff; \
	border-radius: 3px; \
	-webkit-box-shadow: 0px 0px 5px 0px rgba(207,207,207,1); \
	-moz-box-shadow: 0px 0px 5px 0px rgba(207,207,207,1); \
	box-shadow: 0px 0px 5px 0px rgba(207,207,207,1); \
} \
.lbmcoupon-logo { \
	vertical-align:top; \
	margin: 0 10px 0 5px; \
} \
.lbmcoupon-heading { \
	width:100%; \
	line-height:25px; \
	margin-top:5px; \
} \
.lbmcoupon-title { \
	font-family: 'Montserrat', sans-serif; \
	font-weight: 700; \
	font-size:16px; \
	color:#1e355e; \
} \
.lbmcoupon-text { \
	font-family: 'Montserrat', sans-serif; \
	font-weight: 400; \
	font-size:14px; \
	max-height:35px; \
	color:#1e355e; \
} \
.lbmcoupon-text.horizontal { \
	max-height:59px; \
} \
.lbmcoupon-body { \
	line-height:initial; \
} \
.lbmcoupon-type { \
	text-align:center; \
	vertical-align:top; \
	width:66px; \
	height:100%; \
	margin:0; \
	color:#fff; \
	display:inline-block; \
	font-size:12px; \
} \
.lbmcoupon-type img { \
	width:22px; \
	display:inline-block; \
} \
.lbmcoupon-type.horizontal { \
	width:86px; \
	padding-top:20px; \
} \
.lbmview-offer { \
	margin-top:2px; \
	line-height:16px; \
	margin:5px 0 5px \
} \
.green { \
    background:#a4cd39; \
} \
.blue { \
    background:#0063a8; \
} \
.lbmarrow-leftright { \
	display:table-cell; \
	vertical-align:middle; \
//	padding:0 5px; \
	min-width:22px \
} \
.lbmscroll-button.right { \
	text-align:right; \
	margin:0 25px 0 0; \
} \
.lbmscroll-button.center { \
	text-align:center; \
	margin:0; \
} \
.lbmnav { \
	height:60px; \
} \
</style> \
<script> \
var	inFrame = (self != parent); \
	if (typeof ga === 'undefined') \
	{ \
		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ \
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), \
				m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) \
			})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); \
	} \
	ga('create','UA-45851918-8',{ 'name':'leafbuyer' }); \
	ga('leafbuyer.send','event','voice.toke','widget:embed','widget:-:widget:embed:' + document.location.hostname.replace(/^w+\./,'') + ':45ec858A.toke'); \
	if (typeof lbcf == 'function') \
		lbcf('embed'); \
	var	overlayTopOffset = 0; \
</script> \
<script> \
!function(f,b,e,v,n,t,s) \
{ \
	if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)}; \
	if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; \
	n.queue=[];t=b.createElement(e);t.async=!0; \
	t.src=v;s=b.getElementsByTagName(e)[0]; \
	s.parentNode.insertBefore(t,s)}(window,document,'script', \
		'https://connect.facebook.net/en_US/fbevents.js'); \
	fbq('init', '425581231346962'); \
	fbq('track', 'PageView'); \
</script> \
<noscript> \
	<img height=\"1\" width=\"1\" src=\"https://www.facebook.com/tr?id=425581231346962&ev=PageView &noscript=1\"/> \
</noscript> \
<div id=\"lbmdynamic\" style=\"display:block\"></div> \
<span id=\"lbmruler\" style=\"visibility:hidden; text-wrap:none\"></span> \
<div id=\"lbmwidget\" class=\"lbmwidget\"> \
	<div style=\"padding:10px; display:block; width:auto; text-align:center\"> \
		<div id=\"lbmheader\" class=\"lbmclearfix\"> \
<div class=\"lbmtitle-wrapper\" style=\"float:left\"> \
				<div style=\"display:table-cell; vertical-align: middle\"> \
					<img src=\"https://www.leafbuyer.com/cannawidget/images/header.png\"> \
</div> \
			</div> \
<div id=\"lbmfilters\" class=\"lbmfilters\" style=\"float:left; margin:15px 0 0\"> \
				<div class=\"lbmfilter\"> \
					<select id=\"lbmcity\" name=\"city\"> \
					</select> \
				</div> \
				<div class=\"lbmfilter\"> \
					<select id=\"lbmvtype\" name=\"vtype\"> \
					</select> \
				</div> \
</div> \
</div> \
<div class=\"lbmcanvas\" id=\"lbmcoupons-wrapper\"> \
			<div id=\"lbmcoupons\"></div> \
		</div> \
		<div class=\"lbmscroll-buttons\" style=\"display:none; vertical-align:middle; padding:0 5px; width:16px\"> \
			<img src=\"https://www.leafbuyer.com/cannawidget/images/up-arrow.png\" id=\"coupon_prev\" alt=\"\" style=\"cursor:pointer; margin:0 0 0 0\"> \
			<br><br> \
			<img src=\"https://www.leafbuyer.com/cannawidget/images/down-arrow.png\" id=\"coupon_next\" alt=\"\" style=\"cursor:pointer; margin:0 0 0 0\"> \
		</div> \
</div> \
<div class=\"lbmnav-buttons small\" style=\"display:none; text-align:center\"> \
		<div style=\"display:inline-block; max-width:45%\"> \
<a href=\"javascript:;\" onclick=\"lbmPopupSignup(false)\"><img src=\"https://www.leafbuyer.com/cannawidget/images/deal-alert-small.png?v=1\" alt=\"\" style=\"cursor:pointer; max-width:100%\"/></a> \
</div> \
		<div style=\"display:inline-block; max-width:45%\"\"> \
			<a href=\"https://www.leafbuyer.com/deals/dispensaries\" target=\"_blank\"><img src=\"https://www.leafbuyer.com/cannawidget/images/view-deals-small.png?v=1\" alt=\"\" style=\"max-width:100%\"></a> \
		</div> \
	</div> \
<div class=\"lbmnav blue\"> \
<div class=\"lbmnav-buttons large\" style=\"display:none; float:left; width:70%\"> \
<a href=\"javascript:;\" onclick=\"lbmPopupSignup(false)\"><img src=\"https://www.leafbuyer.com/cannawidget/images/deal-alert-large.png?v=3\" alt=\"\" style=\"cursor:pointer; margin:15px 5px 0 5px\"/></a> \
<a href=\"https://www.leafbuyer.com/deals/dispensaries\" target=\"_blank\"><img src=\"https://www.leafbuyer.com/cannawidget/images/view-deals-large.png?v=2\" alt=\"\" style=\"margin:15px 0 0\"/></a> \
		</div> \
<div class=\"lbmnav-app-thin\" style=\"width:100%; text-align:center\"> \
			<a href=\"https://www.leafbuyer.com/app\" target=\"_blank\"><img src=\"https://www.leafbuyer.com/cannawidget/images/app-signup-btn.jpg\" style=\"\"></a> \
		</div> \
		<div class=\"lbmnav-app-wide\"> \
			<div class=\"lbmnav-app\" style=\"float:left; width:50%; text-align:center\"> \
				<a href=\"https://www.leafbuyer.com/app\" target=\"_blank\"><img src=\"https://www.leafbuyer.com/cannawidget/images/app-signup-btn.jpg\" style=\"max-width:300px; width:90%; margin:10px auto; text-align:center\"></a> \
			</div> \
			<div class=\"lbmnav-logo\" style=\"float:right; width:50%\"> \
				<a href=\"https://www.leafbuyer.com\" title=\"Leafbuyer.com\" target=\"_blank\"><img alt=\"\" src=\"https://www.leafbuyer.com/cannawidget/images/poweredby.png\" style=\"float:right; margin-top:10px\"></a> \
			</div> \
		</div> \
	</div> \
</div> \
<!-- URI >> /cannawidget.jsp --> \
<div id=\"lbmwoverlay\" class=\"lbmwidget-overlay\"> \
  <div id=\"lbmwoverlay-contents\"> \
	<div id=\"lbmcouponpanel\" style=\"display:none\"> \
  	<div id=\"lbmdesktop\"> \
	<div class=\"lbmcoupon-tools lbmwide lbmclearfix\"> \
	  <div id=\"sharing\" class=\"lbmsharing\"> \
		<a href=\"javascript:;\" onclick=\"lbmHideOverlay()\" class=\"lbmcoupon-close\"><img src=\"https://www.leafbuyer.com/images/modal-close.png\" width=\"22\" height=\"22\" border=\"0\"></a> \
        <a href=\"\" id=\"couponlinkurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#2a76dc; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\"></a> \
<a href=\"javascript:;\" id=\"coupontextalert\" onclick=\"lbmPopupSignup(true)\" class=\"text-icon\" style=\"display:none; float:right; margin:-11px 10px 0 15px\"><img src=\"https://www.leafbuyer.com/img/icons/text-profile.png\" style=\"width:100px\"></a> \
<a href=\"\" id=\"couponrecurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#6FB2E1; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\">REC PRE-ORDER</a> \
		<a href=\"\" id=\"couponmedurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#6FB2E1; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\">MED PRE-ORDER</a> \
		<a class=\"lbmprint\" href=\"javascript:lbmPopupPrint(false)\">print</a> \
	  </div> \
	  <div id=\"lbmpopupcoupon\" class=\"lbmcoupon lbmbig lbmclearfix\"> \
		<div class=\"lbmcoupon-header\"> \
		  <div><h3 id=\"couponheading\" class=\"lbmresizable\"></h3></div> \
		</div> \
		<div class=\"lbmtable lbmpricebar\"> \
		  <div class=\"lbmrow\"> \
			<div id=\"couponrange\" class=\"lbmcell lbmdiscount\"></div> \
			<div id=\"couponpercentage\" class=\"lbmcell lbmdiscount\"></div> \
			<div id=\"couponpricecell\" class=\"lbmcell\"> \
			  <div class=\"lbmtitle lbmoriginal\" id=\"couponoriginal\"></div> \
			  <div class=\"lbmtitle lbmsale\" id=\"couponsale\"></div> \
			</div> \
			<div id=\"couponquantitycell\" class=\"lbmcell\"> \
			  <div class=\"lbmtitle\">Quantity</div> \
			  <div id=\"couponweight\" class=\"lbmvalue\"></div> \
			</div> \
			<div id=\"couponthccbdcell\" class=\"lbmcell\"> \
			  <div id=\"couponthccbdtitle\" class=\"lbmtitle\"></div> \
			  <div id=\"couponthccbd\" class=\"lbmvalue\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmclearfix lbmtable lbmdescription\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell lbmcol50\"> \
			  <div id=\"coupontext\" class=\"lbmtext\"></div> \
			  <div id=\"coupondisclaimer\" class=\"lbmdisclaimer\"></div> \
			</div> \
			<div class=\"lbmcell lbmlogo lbmcol50\"> \
			  <div class=\"lbmtextcenter\"><img id=\"couponlogo\" class=\"lbmcouponlogo\" src=\"\"></div> \
			  <div id=\"couponvendor\" class=\"lbmtextcenter\"></div> \
			    <div id=\"couponwebsite\" class=\"lbmtextcenter\" style=\"margin:10px 0\"> \
			      <a href=\"https://eaze.co/2hwAGRe\" target=\"_blank\" style=\"background-color:#2a76dc; color:#fff; padding:5px 15px; border-radius:5px; text-align:center\">visit website</a> \
			    </div> \
			  <div id=\"couponlink\" class=\"lbmtextcenter\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmfooter lbmclearfix\"> \
		  <div class=\"lbmcol20 lbmleft\"> \
			<div id=\"couponexpires\"></div> \
		  </div> \
		  <div class=\"lbmcol80 lbmright\"> \
			<span id=\"couponaddr\" class=\"lbmtextright\"></span> | <span id=\"couponphone\" class=\"lbmtextright\"></span> \
		  </div> \
		</div> \
		<div id=\"couponmedrecdel\" class=\"lbmmedrecdel lbmtextcenter\"></div> \
		<div id=\"couponbarcode\" class=\"lbmtextcenter\"></div> \
	  </div> \
	  <div class=\"lbmterms\"> \
		<div class=\"lbmdisclaimer\" style=\"font-size:10px\">This advertisement is for customer reference only and has no value and is not intended to be exchanged for any product. Leafbuyer (Leafbuyer Technologies, Inc) is not responsible for the content of any advertisement. All advertisements are the sole responsibility of the vendor publishing the advertisement. If an advertisement is not valid, please contact the vendor directly as errors may have been made in the creation of the advertisement. This advertisement is only intended to be viewed by those of legal age and in the state/local area where the product is legally open for sale. Additionally, all state and local laws and restrictions apply to all advertisements. Void where prohibited.</div> \
	  </div> \
	</div> \
	</div> \
  	<div id=\"lbmmobile\" class=\"lbmmobile\"> \
	<div class=\"lbmcoupon-tools lbmnarrow lbmclearfix\"> \
	  <div id=\"sharing\" class=\"lbmsharing\" style=\"overflow:hidden; padding-bottom:0\"> \
		<a href=\"javascript:;\" onclick=\"lbmHideOverlay()\" class=\"lbmcoupon-close\"><img src=\"https://www.leafbuyer.com/images/modal-close.png\" width=\"22\" height=\"22\" border=\"0\"></a> \
        <a href=\"\" id=\"couponlinkurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#6FB2E1; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\"></a> \
<a href=\"javascript:;\" id=\"coupontextalert\" onclick=\"lbmPopupSignup(true)\" class=\"text-icon\" style=\"display:none; float:right; margin:-6px 10px 0 15px\"><img src=\"https://www.leafbuyer.com/img/icons/text-profile.png\" style=\"width:100px\"></a> \
<a href=\"\" id=\"couponrecurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#6FB2E1; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\">REC PRE-ORDER</a> \
		<a href=\"\" id=\"couponmedurl\" target=\"_blank\" style=\"float:right; display:inline-block; margin:-5px 5px; 0 0; background-color:#6FB2E1; color:#fff; height:30px; line-height:30px; padding:0 10px; border-radius:2px;\">MED PRE-ORDER</a> \
	  <a class=\"lbmprint\" href=\"javascript:lbmPopupPrint(true)\">print</a> \
	  </div> \
<img id=\"lbmcoupon-image\" style=\"display:none\" /> \
	  <div id=\"lbmcoupon-contents\" class=\"lbmcoupon lbmsmall lbmclearfix\"> \
		<div class=\"lbmcoupon-header\"> \
		  <div><h3 id=\"couponheading\" class=\"lbmcouponheading lbmresizable\"></h3></div> \
		</div> \
		<div class=\"lbmtable lbmpricebar\"> \
		  <div class=\"lbmrow\"> \
			<div id=\"couponpercentage\" class=\"lbmcell lbmdiscount\"></div> \
			<div id=\"couponpricecell\" class=\"lbmcell\"> \
			  <div class=\"lbmtitle lbmoriginal\" id=\"couponoriginal\"></div> \
			  <div class=\"lbmtitle lbmsale\" id=\"couponsale\"></div> \
			</div> \
			<div id=\"couponquantitycell\" class=\"lbmcell\"> \
			  <div class=\"lbmtitle\">Quantity</div> \
			  <div id=\"couponweight\" class=\"lbmvalue\"></div> \
			</div> \
<!-- \
			<div id=\"couponthccbdcell\" class=\"lbmcell\"> \
			  <div id=\"couponthccbdtitle\" class=\"lbmtitle\"></div> \
			  <div id=\"couponthccbd\" class=\"lbmvalue\"></div> \
			</div> \
--> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix lbmdescription\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell\"> \
			  <div id=\"coupontext\" class=\"lbmtext\" style=\"height:initial; max-height:initial\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell\"> \
			  <div id=\"coupondisclaimer\" class=\"lbmdisclaimer\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell\"> \
				<div id=\"couponmedrecdel\" class=\"lbmtextcenter\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell lbmlogo\"> \
			  <div class=\"lbmtextcenter\"><img id=\"couponlogo\" class=\"lbmcouponlogo\" src=\"\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell lbmvendor\"> \
			  <div id=\"couponvendor\" class=\"lbmtextcenter\"></div> \
			  <div class=\"lbmtextcenter\"><span id=\"couponaddr\"></span><br><span id=\"couponphone\" class=\"lbmtextright\"></span></div> \
			  <div id=\"couponlink\" class=\"lbmtextcenter\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell\"> \
			  <div id=\"couponexpires\" class=\"lbmexpires lbmtextcenter\"></div> \
			</div> \
		  </div> \
		</div> \
		<div class=\"lbmtable lbmclearfix\"> \
		  <div class=\"lbmrow\"> \
			<div class=\"lbmcell lbmtextcenter\"> \
			  <a href=\"https://www.leafbuyer.com\" target=\"blank\"><img src=\"https://www.leafbuyer.com/images/widget-footer.png\" border=\"0\" alt=\"Visit LeafBuyer.com\"></a> \
			</div> \
		  </div> \
		</div> \
	  </div> \
	  <div class=\"lbmterms\"> \
		<div class=\"lbmcol lbmdisclaimer\"><a href=\"javascript:null(void)\" onclick=\"jQuery('#lbmfineprint').toggle()\">legal notice</a><p id=\"lbmfineprint\">This advertisement is for customer reference only and has no value and is not intended to be exchanged for any product. Leafbuyer (Leafbuyer Technologies, Inc) is not responsible for the content of any advertisement. All advertisements are the sole responsibility of the vendor publishing the advertisement. If an advertisement is not valid, please contact the vendor directly as errors may have been made in the creation of the advertisement. This advertisement is only intended to be viewed by those of legal age and in the state/local area where the product is legally open for sale. Additionally, all state and local laws and restrictions apply to all advertisements. Void where prohibited.</p></div> \
	  </div> \
	</div> \
	</div> \
	</div> \
<style> \
#lbmwoverlay .lbmsignupform { \
	width:100%; \
} \
#lbmwoverlay .lbmpanel * { \
	font-size:14px; \
} \
#lbmwoverlay .lbmpanel { \
 	display:none; \
	padding:10px; \
	max-width:400px; \
 } \
#lbmwoverlay .lbmpanel input[type=\"text\"], \
#lbmwoverlay .lbmpanel select { \
	border:solid #d0d0d0 2px; \
	border-radius:3px; \
	font-size:14px; \
	max-width:80%; \
	height:25px; \
} \
#lbmwoverlay .lbmpanel input[type=\"button\"] { \
	width:100px; \
	background-color:rgb(129,35,23); \
	color:#fff; \
	border-radius:5px; \
	text-align:center; \
} \
#lbmwoverlay .lbmsignup-fields { \
	position:absolute; \
	top:0; \
	margin:210px 4% 0; \
} \
#lbmwoverlay .lbmsignup-row { \
	margin:10px 0 0; \
} \
#lbmwoverlay .lbmsignup-box { \
	border:solid #9ccc51 1px; \
	padding:5px; \
	margin:0 0 10px; \
	display:table-cell; \
} \
#lbmwoverlay .lbmsignup-input { \
	border-width:0 !important; \
	height:20px !important; \
} \
#lbmwoverlay .button { \
	color: #fff; \
	font: 14px lato,Arial,Helvetica,sans-serif; \
	text-transform: uppercase; \
	cursor: pointer; \
	border: 0; \
	border-radius: 3px; \
	-webkit-appearance: none; \
	padding:8px; \
} \
@media (max-width:375px) and (orientation:portrait) { \
	#lbmwoverlay .lbmsignup-fields { \
		margin:52% 6% 0; \
	} \
	#lbmwoverlay .lbmsignup-row { \
		margin:10px 0 0; \
	} \
	#lbmwoverlay .lbmsignup-box { \
		margin:0 0 5px; \
	} \
} \
@media (max-width:320px) and (orientation:portrait) { \
	#lbmwoverlay .lbmsignup-row { \
		margin:5px 0 0; \
	} \
} \
</style> \
<script> \
var	lbmCouponID = -1, currentWidgetID = ''; \
function lbmPopupCoupon(id,v,wid) \
{ \
	lbmCouponID = id; \
	currentWidgetID = wid; \
	_lbvendor = v; \
	_lbcoupon = lbmGetCoupon(id, wid).attributes.couponID; \
	ga('leafbuyer.send','event','voice.toke','widget:lightbox','widget:-:widget:lightbox:'+_vendor+':'+_lbvendor); \
	ga('leafbuyer.send','event','voice.toke','widget:lightbox-coupon','widget:-:widget:lightbox:'+_vendor+':'+_lbvendor+':'+_lbcoupon); \
	ga('leafbuyer.send','event','voice.toke','tracker','widget:-:widget:tracker:'+_vendor+':'+_lbvendor+':'+_lbcoupon); \
	lb('click','coupon:lightbox:'+_lbvendor+':'+_lbcoupon+':'+lat+':'+lng); \
	if (typeof lbcf == 'function') \
		lbcf('lightbox'); \
	if (inFrame) \
	{ \
		window.open(\"https://www.leafbuyer.com/profile.lbn?vid=\" + v.replace(/.*?:/,'') + \"&cid=\" + _lbcoupon, \"_blank\"); \
		return; \
	} \
	lbmUpdateCoupon(id,wid); \
	jQuery('#lbmsignuppanel').hide(); \
	jQuery('#lbmcouponpanel').show(); \
	lbmShowOverlay(); \
	lbmResize(false); \
	jQuery('#lbmwidget'+wid+' .lbmresizable').each(function(index,value) { \
		if (jQuery(this).is(':visible')) \
			while (pixels(jQuery(this)) > jQuery(this).width()) \
				jQuery(this).css('font-size', \
					(jQuery(this).css('font-size').replace(/[^0-9]/g,'') - 1) + 'px'); \
	}); \
	jQuery('#lbmcoupon-image').html('').hide(); \
	jQuery('#lbmcoupon-contents').show(); \
} \
var	dispensaryPopup = false; \
function lbmPopupSignup(isDispensary) \
{ \
	if (typeof(isDispensary) === 'undefined') \
		isDispensary = false; \
	dispensaryPopup = isDispensary; \
	if (isDispensary) \
	{ \
		jQuery('#lbmsignup-image').attr('src','https://www.leafbuyer.com/cannawidget/images/vendorpopup-v2.png'); \
		jQuery('#lbmsignup').css('grid-template-areas','var(--grid2)'); \
	} \
	else \
	{ \
		jQuery('#lbmsignup-image').attr('src','https://www.leafbuyer.com/cannawidget/images/dealpopup-v2.png'); \
		jQuery('#lbmsignup').css('grid-template-areas','var(--grid1)'); \
	} \
	jQuery('#lbmtcpa1text').text( isDispensary ? _lbvendor.replace(/:.*/,\"\") : \"Leafbuyer - including regarding its marketing partners - \"); \
	jQuery('#lbmtcpa1email').text( isDispensary ? _lbvendor.replace(/:.*/,\"\") : \"Leafbuyer\"); \
	jQuery('#lbmsignuppanel').show(); \
/* \
	var	phoneOffset = jQuery('#lbmphone-row').offset().top, \
		emailOffset = jQuery('#lbmemail-row').offset().top; \
	if (isDispensary) \
	{ \
		jQuery('#lbmsignup-image').attr('src', jQuery('#lbmsignup-image').attr('src').replace(/signuppopup.*?.png/,'signuppopup.png')); \
		if (phoneOffset > emailOffset) \
		{ \
			jQuery('#lbmphone-row').offset({ top: emailOffset }); \
			jQuery('#lbmemail-row').offset({ top: phoneOffset }); \
		} \
		jQuery('#lbmsignupemail').prop('placeholder','email (optional)'); \
		jQuery('#lbmsignup-cbox').show(); \
	} \
	else \
	{ \
		jQuery('#lbmsignup-image').attr('src', jQuery('#lbmsignup-image').attr('src').replace(/signuppopup.*?.png/,'signuppopup-lb.png')); \
		if (emailOffset > phoneOffset) \
		{ \
			jQuery('#lbmphone-row').offset({ top: phoneOffset }); \
			jQuery('#lbmemail-row').offset({ top: emailOffset }); \
		} \
		jQuery('#lbmsignupemail').prop('placeholder','email address'); \
		jQuery('#lbmsignup-cbox').hide(); \
	} \
*/ \
	jQuery('#lbmcouponpanel').hide(); \
	lbmShowOverlay(); \
	lbmResize(); \
} \
function lbmTestSignup() \
{ \
	var	checked = true; \
	jQuery('div[class^=\"lbmsignup-tcpa\"] input[type=\"checkbox\"]').each(function() { \
		if (! jQuery(this).is(':checked')) \
		{ \
			checked = false; \
			return; \
		} \
	}); \
	if (checked) \
		jQuery('.lbmsignup-submit').removeClass('inactive'); \
	else \
		jQuery('.lbmsignup-submit').addClass('inactive'); \
} \
function lbmDoSignup() \
{ \
	var	email = jQuery('#lbmsignupemail').val().toLowerCase().trim(), \
		phone = jQuery('#lbmsignupphone').val().trim(); \
	if (! email.match(/.*@.*\.[a-z]{2,}/)) \
	{ \
		if (! dispensaryPopup || email.length != 0) \
		{ \
			alert(\"Email address does not appear to be valid.\"); \
			jQuery('#lbmsignupemail').focus(); \
			return; \
		} \
	} \
	if (phone.length < 10) \
	{ \
		alert(\"Phone number does not appear to be valid (expecting 10 digits).\"); \
		jQuery('#lbmsignupphone').focus(); \
		return; \
	} \
	if (email.length != 0) \
	{ \
		jQuery.ajax({ \
			type: \"GET\", \
			url: \"https://www.leafbuyer.com/php/signup.php?email=\" + email +\"&phone=\" + phone +\"&zip=\" + jQuery('#lbmsignupzip').val() +\"&source=voice\", \
			success: function(response) { \
				jQuery('#lbmsignuppanel #signup').hide(); \
				jQuery('#lbmsignuppanel #signup-complete').show(); \
				ga('leafbuyer.send','event','newsletter','signedup','widget:oth'); \
			} \
		}); \
	} \
	var	textAlertData = { type:'create_member', source:'cannawidget', merchant_token:'', vendor_id:'', phone:'', email:'', firstname:'', lastname:'', include:'' }; \
	var	keys = Object.keys(textAlertData); \
	for (var i = 0; i < keys.length; i++) \
	{ \
		if (textAlertData[keys[i]] != '') \
			continue; \
		if (jQuery('#lbmsignup' + keys[i]).is(':checkbox')) \
			textAlertData[keys[i]] = jQuery('#lbmsignup' + keys[i]).is(':checked'); \
		else \
			textAlertData[keys[i]] = jQuery('#lbmsignup' + keys[i]).val(); \
	} \
	if (dispensaryPopup) \
	{ \
		textAlertData['merchant_token'] = lbmGetCoupon(lbmCouponID, currentWidgetID).vendor.key; \
		textAlertData['vendor_id'] = lbmGetCoupon(lbmCouponID, currentWidgetID).vendor.vendorID; \
	} \
	jQuery.ajax({ \
		type: \"POST\", \
		url: \"https://www.leafbuyer.com/php/createLoyaltyMember.php?t=\" + (new Date()).getTime(), \
		data: textAlertData, \
		success: function(response) { \
			setTimeout( function() { lbmHideOverlay(); jQuery('#lbmsignup').toggle(); jQuery('#lbmsignup-complete').toggle(); }, 3000); \
			ga('leafbuyer.send','event','textalert','complete','widget:oth:complete:'+_lbvendor); \
		}, \
		complete: function(response) { \
			setTimeout( function() { jQuery('#lbmsignup').toggle(); jQuery('#lbmsignup-complete').toggle(); }, 500); \
			setTimeout( function() { lbmHideOverlay('signup'); }, 5000); \
			console.log(response); \
		} \
	}); \
} \
function lbmResizeSignupPopup() \
{ \
} \
</script> \
<style> \
	body { \
		--grid1: \
			\"email email\" \
			\"mobile zip\" \
			\"tcpa1 tcpa1\" \
			\"tcpa2 tcpa2\" \
			\"tcpa3 tcpa3\" \
			\"button button\"; \
		--grid2: \
			\"mobile zip\" \
			\"email email\" \
			\"tcpa1 tcpa1\" \
			\"tcpa2 tcpa2\" \
			\"tcpa3 tcpa3\" \
			\"button button\"; \
	} \
	.lbmsignup-fields { \
		position:absolute; \
		top:0; \
		margin:200px 3% 0; \
	} \
	.lbmsignup-row { \
		margin:10px 0 0; \
	} \
	.lbmsignup-box { \
		border:solid #9ccc51 1px; \
		padding:5px; \
	} \
	.lbmsignup-box input[type='text'] { \
		min-height:initial !important; \
		height:20px !important; \
		padding:5px !important; \
	} \
	.lbmsignup-input { \
		border-width:0 !important; \
		height:20px !important; \
	} \
	.lbmsignup-email { \
		grid-area: email; \
	} \
	.lbmsignup-mobile { \
		grid-area: mobile; \
	} \
	.lbmsignup-zip { \
		grid-area: zip; \
	} \
	.lbmsignup-tcpa1 { \
		font-size: 11px !important; \
		grid-area: tcpa1; \
	} \
	.lbmsignup-tcpa1 span { \
		font-size: 11px !important; \
	} \
	.lbmsignup-tcpa2 { \
		font-size: 11px !important; \
		grid-area: tcpa2; \
	} \
	.lbmsignup-tcpa2 a{ \
		font-size: 11px !important; \
	} \
	.lbmsignup-tcpa3 { \
		font-size: 11px !important; \
		grid-area: tcpa3; \
	} \
	.lbmsignup-submit { \
		grid-area: button; \
		color: #0064a7; \
		background: #9ccc51 !important; \
		text-align: center !important; \
	} \
	.lbmsignup-submit.inactive { \
		background: #afafaf !important; \
		cursor: default !important; \
	} \
	.lbmsignup-container { \
		max-width:355px; \
		margin:0 20px 20px 10px; \
		display: grid; \
		grid-gap:10px; \
		grid-template-columns: 70% 30%; \
		grid-template-rows: auto; \
		grid-template-areas: var(--grid1); \
	} \
</style> \
	<div id=\"lbmsignuppanel\" class=\"lbmpanel lbmclearfix\" style=\"max-width:800px\"> \
		<div class=\"lbmcontent\" style=\"padding:0\"> \
			<div style=\"margin:0 auto\"> \
				<div id=\"close\" style=\"position:absolute; z-index:1000; top:15px; right:10px\"><a href=\"javascript:;\" onclick=\"lbmHideOverlay(); jQuery('#signup').show(); jQuery('#signup-complete').hide()\"><img src=\"https://www.leafbuyer.com/images/modal-close.png\" width=\"22\" height=\"22\" border=\"0\" alt=\"close lightbox\"></a></div> \
				<div style=\"display:table; margin:0 auto\"> \
<img id=\"lbmsignup-image\" src=\"https://www.leafbuyer.com/cannawidget/images/dealpopup-v2.png?v=0.1\" style=\"max-width:100%; height:auto\" alt=\"Deal Alert Signup\"> \
					<div id=\"lbmsignup\" class=\"lbmsignup-container\" style=\"width:97%\"> \
						<div class=\"lbmsignup-email lbmsignup-box\"> \
							<input type=\"text\" name=\"lbmsignupemail\" id=\"lbmsignupemail\" placeholder=\"email address\" class=\"lbmsignup-input\" onfocus=\"jQuery(this).parent().css('border-color','#0063a7')\" onblur=\"jQuery(this).parent().css('border-color','')\"> \
						</div> \
						<div class=\"lbmsignup-mobile lbmsignup-box\"> \
							<input type=\"text\" name=\"lbmsignupphone\" id=\"lbmsignupphone\" placeholder=\"mobile phone\" class=\"lbmsignup-input\" onfocus=\"jQuery(this).parent().css('border-color','#0063a7')\" onblur=\"jQuery(this).parent().css('border-color','')\"> \
						</div> \
						<div class=\"lbmsignup-zip lbmsignup-box\"> \
							<input type=\"text\" name=\"lbmsignupzip\" id=\"lbmsignupzip\" placeholder=\"zip code\" class=\"lbmsignup-input\" onfocus=\"jQuery(this).parent().css('border-color','#0063a7')\" onblur=\"jQuery(this).parent().css('border-color','')\"> \
						</div> \
						<div class=\"lbmsignup-tcpa1\"> \
							<input type=\"checkbox\" id=\"lbmtcpa1\" onchange=\"lbmTestSignup()\"> By checking the box and signing up, you consent to receive informational and marketing text messages from <span id=\"lbmtcpa1text\"></span> sent using an automated dialer to the wireless number you provided above. Your consent is not required to make a purchase. You also agree to receive promotional emails from <span id=\"lbmtcpa1email\"></span>. \
						</div> \
						<div class=\"lbmsignup-tcpa2\"> \
							<input type=\"checkbox\" id=\"lbmtcpa2\" onchange=\"lbmTestSignup()\"> By checking the box and signing up, you agree to the <a href=\"https://www.leafbuyer.com/termsofuse\" target=\"_blank\">Terms of Use</a> and <a href=\"https://www.leafbuyer.com/privacypolicy\" target=\"_blank\">Privacy Policy</a>. \
						</div> \
						<div class=\"lbmsignup-tcpa3\"> \
							You may opt-out of texts any time by replying STOP. You may opt-out of emails by clicking the UNSUBSCRIBE link in any promotional email you receive from us or by replying to any promotional email you receive from us and including UNSUBSCRIBE in the subject line. \
						</div> \
						<div class=\"lbmsignup-submit inactive button btn\" onclick=\"lbmDoSignup()\">Sign Me Up</div> \
					</div> \
					<div id=\"lbmsignup-complete\" class=\"lbmsignup-fields\" style=\"display:none; font-size:16px; text-align:center; padding:0 20px\"> \
						<br><br> \
						Thanks for signing up for the Leafbuyer Deal Alerts. \
					</div> \
				</div> \
			</div> \
		</div> \
	</div> \
</div> \
</div> \
");

var	_debug = (document.location.href.match(/.*\/leafbuyer/) != null);
var	isDynamic = false;

var _coupons = [], _types = [], _subtypes = [];
var _vendor = document.location.host + ':45ec858A.toke',
	_lbvendor = '', initialize = false;
var	lat = null, lng = null;

function lb(e, d)
{
	jQuery.ajax({
		url: "https://www.leafbuyer.com/proxy/tracker.lbn?e=" + e + "&d=" + d,
		type: 'GET',
		complete: function(response) {
		},
		success: function(response) {
		}
	});
}

function lbmSetCoupon(c, i, wid)
{

	_coupons[i] = c;
	
}

function lbmGetCoupon(i, wid)
{

	return _coupons[i];
	
}

function lbmUpdate(init, wid)
{
	if (wid == null)
		wid = '';

	if (isDynamic && wid == '')
		return;

	initialize = init;

	jQuery('#lbmwidget'+wid+' #lbmloading').show();
	jQuery('#lbmwidget'+wid+' #lbmnonefound').hide();
	jQuery('#lbmwidget'+wid+' .caroufredsel_wrapper').css('visibility','hidden');

	var	type = jQuery('#lbmwidget'+wid+' #lbmvtype').val(),
		mode = jQuery('#lbmwidget'+wid+' #lbmstype').val(),
		vtype = null,
		ptype = null,
		url = "https://www.leafbuyer.com/proxy/widgetsearch.lbn?vid=45ec858A.toke&init=" + init;

	if (typeof(mode) === 'undefined')
		mode = 'business';

	if (lat != null && lng != null)
		url += "&lat=" + lat + "&lng=" + lng;

	if (mode == 'business')
	{
		if (type != null)
		{
			vtype = type.split(":")[0];
			ptype = type.split(":")[1];

			url += (jQuery('#lbmwidget'+wid+' #lbmcity').val() != null ? "&city=" + jQuery('#lbmwidget'+wid+' #lbmcity').val() : '') + (vtype != null ? "&vtype=" + vtype : "") + (ptype != null ? "&ptype=" + ptype : "");
		}
	}
	else if (mode == 'name')
		url += (jQuery('#lbmwidget'+wid+' #lbmvendorID').val() != null ? "&vendorID=" + jQuery('#lbmwidget'+wid+' #lbmvendorID').val() : '');

	url += "&t=" + (new Date()).getTime(),

	jQuery.ajax({
		url: url,

		success: function(data) {
			lbmUpdateCallback(data, wid);
		}
	});
}

var	types = new Array();

function lbmUpdateCallback(xml, wid)
{
	var	id = (wid != null ? wid : '');
//console.log("parsing");
	try
	{
		var xmla = xml2array(xml);

//console.log("done");
		var	root = xmla.rsp,
			filters = root.filters,
			coupons = root.coupons;	

		jQuery('#lbmwidget'+id+' #lbmcoupons').html('');

		if (typeof(filters) != 'undefined')
		{
//console.log("processing filters");
			var	list = filters.cities;

			for (var i = 0; i < list.attributes.count; i++)
			{
				var	city = (list.attributes.count == 1 ? list.city : list.city[i]);

				if (city.attributes.typeIDs == '')
					continue;

				types[city.value] = city.attributes.typeIDs.split(/,/);

				jQuery('#lbmwidget'+id+' #lbmcity').append(jQuery('<option/>', { 
					value: city.value,
					text : city.value.replace(/,.*/,'') 
				}));
			}

			if (list.attributes.closest != null)
				jQuery('#lbmwidget'+id+' #lbmcity'+' option[value="' + list.attributes.closest + '"]').prop('selected',true);

			if (jQuery('#lbmwidget'+id+' #moredeals').length != 0)
			{
				if (list.attributes.city != null && list.attributes.state != null)
					jQuery('#lbmwidget'+id+' #moredeals').attr('href','/deals/dispensaries/' + list.attributes.state + '/' + list.attributes.city.replace(/ /,'+'));
				else
					jQuery('#lbmwidget'+id+' #moredeals').attr('href','/deals-near-me');;
			}

			if (lat == null && lng == null)
			try
			{
				lat = list.attributes.lat;
				lng = list.attributes.lng;
			}
			catch (e)
			{}

			list = filters.types;

			for (var i = 0; i < list.attributes.count; i++)
			{
				var	item = (list.attributes.count == 1 ? list.type : list.type[i]),
					type = item.attributes.name;

				_types[i] = type;
				_subtypes[i] = new Array();

				for (var j = 0; j < item.attributes.count; j++)
				{
					var	subtype = item.subtype[j];
					_subtypes[i][j] = subtype;
				}
			}

			jQuery('#lbmwidget'+id+' #lbmcity').trigger('change', [ id, false ]);
		}

		destroyCarousel(id);

		var	html = '';

		html += '<style>';
		html += '	.lbmapp-border { padding:5px; height:45px; border:solid #a4cd39 3px }\n';
		html += '	.lbmapp-click { color:#a4cd39; font-size:10px }\n';
		html += '	.lbmapp-new { color:#000; font-size:18px }\n';

		if (jQuery('.lbmwidget').width() < 350)
		{
			html += '	.lbmapp-border { padding:2px; height:45px }';
			html += '	.lbmapp-new { font-size:16px }';

			html += '	.lbmcoupon-signup { line-height:15px; }\n';
			html += '	.lbmcoupon-signup-btn { float:left; margin:15px auto; width:40%; }\n';
		}

		html += '</style>';

		jQuery('#lbmwidget'+id).prepend(html);

		html = '';
//console.log("processing coupons");
		for (var i = 0; i < coupons.attributes.count; i++)
		{
			var	coupon = (coupons.attributes.count == 1 ? coupons.coupon : coupons.coupon[i]);
//console.log(coupon.product + ' > ' + coupon.vendor.name);
			if (i > 0)
			{
				// this logic make sure that no two vendor locations' coupons
				// appear next to each other regardless of how the locations
				// have been ordered

				if (coupon.vendor.name.toLowerCase().substring(0,Math.min(5,coupon.vendor.name.length)) == coupons.coupon[i - 1].vendor.name.toLowerCase().substring(0,Math.min(5,coupons.coupon[i - 1].vendor.name.length)))
				{
					for (var j = i + 1; j < coupons.attributes.count; j++)
					{
						if (coupon.vendor.name.toLowerCase().substring(0,Math.min(5,coupon.vendor.name.length)) != coupons.coupon[j].vendor.name.toLowerCase().substring(0,Math.min(5,coupons.coupon[j].vendor.name.length)))
						{
							var	c1 = coupon, c2 = coupons.coupon[j];

							coupons.coupon[i] = c2;
							coupons.coupon[j] = c1;

							coupon = coupons.coupon[i];
							break;
						}
					}
				}

				if (i % 8 == 4)
				{
					html += '<div class="lbmwidget-coupon" style="overflow:hidden; text-align:center" onclick="window.open(\'https://www.leafbuyer.com/app\',\'_blank\')">';

					html += '	<img src="https://www.leafbuyer.com/cannawidget/images/app-icon.png" style="position:relative; float:left">';
					html += '	<div style="margin:5px"><div class="lbmapp-border"><div class="lbmapp-click">CLICK HERE FOR THE</div><div class="lbmapp-new">NEW LEAFBUYER APP</div></div></div>';

					html += '</div>';
				}

				if (i % 8 == 0)
				{
					html += '<div class="lbmwidget-coupon" style="overflow:hidden; text-align:center" onclick="lbmPopupSignup(false)">';
					html += '	<div class="lbmcoupon-signup">Get Exclusive Deals<br>in your Inbox!</div>';
					html += '	<div class="lbmcoupon-signup-btn">SIGN UP NOW</div>';
/*
					}
					else
					{
//						html += '<div style=\"margin-top: 7px\">';
						html += '<div>Get Exclusive Deals in your Inbox!</div>';
						html += '<div class=\"lbmcoupon-signup-btn\" style=\"float:none; margin:3px auto 10px;\">SIGN UP NOW</div>';
//						html += '</div>';
					}
*/
					html += '</div>';
				}

			}

			lbmSetCoupon(coupon, i, wid);

			var	maxlen = 1000,
				name = coupon.vendor.name.replace(/&apos/g,'\\&apos');

			html += '<div id="coupon_' + coupon.attributes.couponID + '" class="lbmwidget-coupon" onclick="lbmPopupCoupon(' + i + ',\'' + name + ':' + coupon.vendor.vendorID + '\', ((_id = jQuery(this).closest(\'.lbmwidget\').attr(\'id\').replace(/.*(_\\d+)/,\'$1\')).match(/_\\d+/) ? _id : \'\'))">';

			html += '	<div class="lbmcoupon-logo"><img src="https://www.leafbuyer.com/vendors/' + coupon.vendor.vendorID + '/thumblogo.png"></div>';
			html += '	<div class="lbmcoupon-body">';
			html += '		<div class="lbmcoupon-heading">';
			html += '			<div class="lbmcoupon-title">' + coupon.product + '</div>';
			html += '		</div>';

			var	text = coupon.text.replace(/(<br>)+/gi,' ').replace(/<a.*?>/i,'').replace(/<\/a>/i,'');

			html += '		<div class="lbmcoupon-text">' + (text.length > maxlen ? text.substring(0, maxlen).replace(/ [^ ]+$/,'') +  '...' : text) + '</div>';
			html += '	</div>';
			html += '	<div class="lbmcoupon-type ' + (i % 2 == 0 ? 'green' : 'blue') + '">';
			html += '		<div class="lbmview-offer">';
			html += '			VIEW OFFER';
			html += '		</div>';
			html += '		<div>';

			if (coupon.medical == 'true')
				html += '			<img src="https://www.leafbuyer.com/cannawidget/images/med-icon.png">';
			if (coupon.retail == 'true')
				html += '			<img src="https://www.leafbuyer.com/cannawidget/images/rec-icon.png">';

			html += '		</div>';
			html += '	</div>';
	
			html += '</div>';
		}

		jQuery('#lbmwidget'+id+' #lbmcoupons').html(html);

		buildCarousel(id);

		if (coupons.attributes.count == 0)
		{
			jQuery('#lbmwidget'+id+' #lbmloading').hide();
			jQuery('#lbmwidget'+id+' #lbmnonefound').show();
		}
	
		jQuery('#lbmwidget'+id+' .caroufredsel_wrapper').css('visibility','visible');
	
		jQuery('#lbmwidget'+id+' #lbmloading').hide();
	}
	catch (e)
	{
		jQuery.ajax({
			url: 'https://www.leafbuyer.com/cw-error?m=' + e.message.replace(/ /g,'+')
		});
	}
}

function pixels(el)
{
	var ruler = jQuery('#lbmruler').css('font', el.css('font')).css('white-space','nowrap').html(el.html());
	return ruler.width();
}

function viewProfile()
{
	ga('leafbuyer.send','event','voice.toke','widget:profile','widget:-:widget:profile:'+_vendor);
	ga('leafbuyer.send','event','voice.toke','widget:profile','widget:-:widget:profile:'+_lbvendor);
}

function lbmUpdateCoupon(id, wid)
{
	id = lbmCouponID;

	var	active = jQuery('#lbmdesktop'),
		inactive = jQuery('#lbmmobile');

	if (jQuery('#lbmmobile').css('display') != 'none')
	{
		active = jQuery('#lbmmobile');
		inactive = jQuery('#lbmdesktop');
	}

	jQuery(inactive).find("*").each(function() {
		if (typeof(jQuery(this).attr("id")) != 'undefined')
			jQuery(this).attr('id',
				'_' + jQuery(this).attr('id').replace(/^_/,''));
	});

	jQuery(active).find("*").each(function() {
		if (typeof(jQuery(this).attr("id")) != 'undefined')
			jQuery(this).attr('id',
				jQuery(this).attr('id').replace(/^_/,''));
	});

	var	cxml = lbmGetCoupon(id, wid),
		fontsize = 28,
		tgt = jQuery(active).attr('id');

	if (typeof(cxml.vendor.recurl) != 'undefined')
		jQuery('#' + tgt + ' #couponrecurl').attr('href',cxml.vendor.recurl);
	if (typeof(cxml.vendor.medurl) != 'undefined')
		jQuery('#' + tgt + ' #couponmedurl').attr('href',cxml.vendor.medurl);
	if (typeof(cxml.vendor.linkurl) != 'undefined')
	{
		jQuery('#' + tgt + ' #couponlinkurl').attr('href',cxml.vendor.linkurl);
		jQuery('#' + tgt + ' #couponlinkurl').text(cxml.vendor.linktext);
	}

	jQuery('#' + tgt + ' #couponheading').css('font-size',fontsize+'px').html(cxml.product);

	jQuery('#' + tgt + ' #couponheading').html(cxml.product);

	if (cxml.display == 'range')
	{
		jQuery('#' + tgt + ' #couponrange').html(cxml.lowPrice.replace(/\.00/,'') + " - " + cxml.highPrice.replace(/\.00/,''));
	}

	if (typeof(cxml.percentage) != 'undefined')
		jQuery('#' + tgt + ' #couponpercentage').html(Math.floor(cxml.percentage) + "% Off");
	if (typeof(cxml.originalPrice) != 'undefined')
		jQuery('#' + tgt + ' #couponoriginal').html((jQuery('#lbmdesktop').length != 0 ? "Original " : "") + cxml.originalPrice.replace(/\.00/,''));
	if (typeof(cxml.salePrice) != 'undefined')
		jQuery('#' + tgt + ' #couponsale').html((jQuery('#lbmdesktop').length != 0 ? "Sale " : "") + cxml.salePrice.replace(/\.00/,''));
	if (typeof(cxml.quantity) != 'undefined')
		jQuery('#' + tgt + ' #couponweight').html(cxml.quantity);

	jQuery('#' + tgt + ' #coupontext').html(cxml.text);
	jQuery('#' + tgt + ' #coupondisclaimer').html(cxml.disclaimer);
	jQuery('#' + tgt + ' #couponexpires').html(cxml.expires != '' ? "Expires " + cxml.expires : "No expiration");
	jQuery('#' + tgt + ' #couponvendor').html(cxml.vendor.name);
	jQuery('#' + tgt + ' #couponlink').html('<a href="https://www.leafbuyer.com/' + cxml.vendor.typename + '/' + cxml.vendor.state + '/' + cxml.vendor.city + '/' + cxml.vendor.pathname + '" target="_blank" rel="nofollow" onclick="viewProfile()">View all our deals on Leafbuyer.com</a>');
	jQuery('#' + tgt + ' #couponlogo').attr('src','https://www.leafbuyer.com/vendors/' + cxml.vendor.vendorID + '/logo.png?t=' + (new Date()).getTime());
	jQuery('#' + tgt + ' #couponaddr').html(cxml.vendor.addr1 + ', ' + (cxml.vendor.addr2.length != 0 ? cxml.vendor.addr2 + ', ' : '') + cxml.vendor.city + ', ' + cxml.vendor.state);
	jQuery('#' + tgt + ' #couponphone').html(cxml.vendor.phone);

	jQuery('#' + tgt + ' #couponmed').hide();
	jQuery('#' + tgt + ' #couponrec').hide();
	jQuery('#' + tgt + ' #coupondel').hide();
	jQuery('#' + tgt + ' #couponmedrecdel').html('');

	if (cxml.vendor.medical == 'true')
		jQuery('#' + tgt + ' #couponmed').show();
	if (cxml.medical == 'true')
		jQuery('#' + tgt + ' #couponmedrecdel').html('Medical Only');

	if (cxml.vendor.retail == 'true')
		jQuery('#' + tgt + ' #couponrec').show();
	if (cxml.retail == 'true')
		jQuery('#' + tgt + ' #couponmedrecdel').html('Recreational Only');

	if (cxml.medical == 'true' && cxml.retail == 'true')
		jQuery('#' + tgt + ' #couponmedrecdel').html('Medical or Recreational');

	if (cxml.vendor.delivery == 'true')
		jQuery('#' + tgt + ' #coupondel').show();

	jQuery('#' + tgt + ' #couponwebsite').hide();

	if (cxml.vendor.vendorID == 6968)
		jQuery('#' + tgt + ' #couponwebsite').show();

	jQuery('#' + tgt + ' #couponbarcode').hide();
	jQuery('#' + tgt + ' #couponbarcode').html('');

	if (cxml.barcode != null)
	{
		jQuery('#' + tgt + ' #couponbarcode').show();
		jQuery('#' + tgt + ' #couponbarcode').html('<img src="https://www.leafbuyer.com/vendors/' +
			cxml.vendor.vendorID + '/barcodes/' + cxml.barcode + '.png" class="lbmbarcode" onerror="jQuery(\'#' + tgt + ' #couponbarcode\').css(\'height\',\'0px\'); jQuery(this).hide()">');
	}

	var	title = null, value = null;
	var	thc = (typeof(cxml.thc) != 'undefined' ? cxml.thc : null),
			cbd = (typeof(cxml.cbd) != 'undefined' ? cxml.cbd : null);

	jQuery('#' + tgt + ' #couponthccbdcell').hide();

	if (thc != null || cbd != null)
	{
		if (cxml.type == 1)
		{
			if (thc != null && cbd != null)
			{
				title = "THC / CBD Levels";
				value = thc + " / " + cbd;
			}
			else if (thc != null)
			{
				title = "THC Level";
				value = thc;
			}
			else if (cbd != null)
			{
				title = "CBD Level";
				value = cbd;
			}

			if (title != null && value != null)
			{
				jQuery('#' + tgt + ' #couponthccbdtitle').html(title);
				jQuery('#' + tgt + ' #couponthccbd').html(value);

				jQuery('#' + tgt + ' #couponthccbdcell').show();
			}
		}
	}

	jQuery('#' + tgt + ' #couponrange').hide();
	jQuery('#' + tgt + ' #couponpercentage').hide();
	jQuery('#' + tgt + ' #couponpricecell').hide();
	jQuery('#' + tgt + ' #couponoriginal').hide();
	jQuery('#' + tgt + ' #couponsale').hide();
	jQuery('#' + tgt + ' #couponquantitycell').hide();
	jQuery('#' + tgt + ' #couponrecurl').hide();
	jQuery('#' + tgt + ' #couponmedurl').hide();
	jQuery('#' + tgt + ' #couponlinkurl').hide();
	jQuery('#' + tgt + ' #coupontextalert').hide();

	if (typeof(cxml.vendor.recurl) != 'undefined')
		jQuery('#' + tgt + ' #couponrecurl').show();
	if (typeof(cxml.vendor.medurl) != 'undefined')
		jQuery('#' + tgt + ' #couponmedurl').show();
	if (typeof(cxml.vendor.linkurl) != 'undefined')
		jQuery('#' + tgt + ' #couponlinkurl').show();
	if (typeof(cxml.vendor.key) != 'undefined')
		jQuery('#' + tgt + ' #coupontextalert').show();

	if (cxml.display == 'range')
	{
		jQuery('#' + tgt + ' #couponrange').show();
	}

	if (typeof(cxml.percentage) != 'undefined')
		jQuery('#' + tgt + ' #couponpercentage').show();

	if (typeof(cxml.originalPrice) != 'undefined')
	{
		jQuery('#' + tgt + ' #couponoriginal').show();
		jQuery('#' + tgt + ' #couponpricecell').show();
	}

	if (typeof(cxml.salePrice) != 'undefined')
	{
		jQuery('#' + tgt + ' #couponsale').show();
		jQuery('#' + tgt + ' #couponpricecell').show();
	}

	if (typeof(cxml.quantity) != 'undefined')
		jQuery('#' + tgt + ' #couponquantitycell').show();

	if (cxml.vendor.city.match(/(boulder|garden city)/i))
		jQuery('#' + tgt + ' #lbmpopupcoupon').addClass('lbmnodashes');
	else
		jQuery('#' + tgt + ' #lbmpopupcoupon').removeClass('lbmnodashes');
}

function lbmResize(redraw)
{
	if (! jQuery('#lbmwoverlay').is(':visible'))
		return;

	var	isMobile = (jQuery('#lbmmobile').css('display') != 'none');

	if (typeof(redraw) !== "undefined" && redraw)
		lbmUpdateCoupon();

	jQuery('#lbmwoverlay-contents').css('height','initial');
	jQuery('#lbmwoverlay-contents').css('overflow-y','visible');
	jQuery('#lbmwoverlay-contents').css('width','initial');
	jQuery('#lbmwoverlay-contents').css('overflow-x','visible');

if (isMobile)
{
	jQuery('#lbmwoverlay-contents').css('padding','0');
	jQuery('#lbmwoverlay-contents').css('margin','0');
	jQuery('#lbmwoverlay .lbmcoupon-tools.lbmnarrow').css('width','96%');
}

	if (jQuery('#lbmwoverlay-contents').height() > jQuery(window).height() - 44)
	{
//		jQuery('#lbmwoverlay-contents').height(jQuery(window).height() - 44);
//		jQuery('#lbmwoverlay-contents').css('top','10px');
//		jQuery('#lbmwoverlay-contents').css('overflow-y','scroll');
	}
if (isMobile)
{
	jQuery('#lbmwoverlay-contents').height('calc(100% - ' + (overlayTopOffset + 4) + 'px)');
	jQuery('#lbmwoverlay-contents').css('top', overlayTopOffset);
	jQuery('#lbmwoverlay-contents').css('overflow-y','scroll');
}
	if (jQuery('#lbmwoverlay-contents').width() > jQuery(window).width() - 44)
	{
//		jQuery('#lbmwoverlay-contents').width(jQuery(window).width() - 44);
//		jQuery('#lbmwoverlay-contents').css('left','10px');
//		jQuery('#lbmwoverlay-contents').css('overflow-x','scroll');
	}
if (isMobile)
{
	jQuery('#lbmwoverlay-contents').width('calc(100% - 5px)');
	jQuery('#lbmwoverlay-contents').css('left','0');
	jQuery('#lbmwoverlay-contents').css('overflow-x','scroll');
}
}

var cpopup = null;

function lbmPopupPrint(mobile)
{
	ga('leafbuyer.send','event','voice.toke','widget:print','widget:-:widget:print:'+_vendor+':'+_lbvendor);
	ga('leafbuyer.send','event','voice.toke','widget:print-coupon','widget:-:widget:print:'+_vendor+':'+_lbvendor+':'+_lbcoupon);
	lb('click','coupon:print:'+_lbvendor+':'+_lbcoupon+':'+lat+':'+lng);

	if (mobile)
	{

		return;
	}

	if (cpopup == null || cpopup.closed)
		cpopup = window.open();

	var doc = cpopup.document;

	var html = '<html><head>';

	html += '<link rel="stylesheet" href="https://www.leafbuyer.com/cannawidget/css/widget.css" />';
	html += '<link rel="stylesheet" href="https://www.leafbuyer.com/cannawidget/voice/css/widget.css" />';

//	html += '<link rel="stylesheet" href="https://www.leafbuyer.com/css/voice.css" />';
	html += '<link href="//fonts.googleapis.com/css?family=Lato:400,700,700italic" rel="stylesheet" type="text/css">';

	html += '<script type="text/javascript" src="https://www.leafbuyer.com/js/vendor/jquery.js"><\/script>';
	html += '<script>';
	html += '	jQuery(window).on("load", function(e) { jQuery("#lbmwoverlay").css("display","block").css("background-image","none"); setTimeout( function() { window.print(); window.close(); }, 100); } );';
	html += '<\/script>';
	html += '<\/head>';
	html += '<body>';
	html += '<div id="lbmwoverlay">' + jQuery('#lbmwoverlay-contents').html().replace(/"lbmsharing"/g,'"lbmsharing" style="visibility:hidden"').replace(/"lbmmobile">/,'"lbmmobile" style="visibility:hidden">') + '<\/div>';

	html += '<\/body>';
	html += '<\/html>';

	doc.write(html);
	doc.close();

	cpopup.focus();
}

var	resizeTimer = null;

function destroyCarousel(wid)
{
	jQuery('#lbmwidget'+wid+' #lbmcoupons').trigger("destroy");
}

var	BEFORE = 1,
	AFTER = 2,
	BEFORE_AFTER = 3;

function lbmResizeCoupons(wid, beforeAfter)
{
		var	extra = 0;

		extra = 15 + (jQuery('#lbmwidget'+wid+' .lbmscroll-buttons').is(':visible') ? jQuery('#lbmwidget'+wid+' .lbmscroll-buttons').outerWidth(true) : 0);


	if (beforeAfter == BEFORE || beforeAfter == BEFORE_AFTER)
	{
		var	_width = jQuery('#lbmwidget' + wid).width();

		if (_width <= 320)
		{
			jQuery('#lbmwidget' + wid + ' .lbmcoupon-title').css('line-height','20px').height(60).css('font-size','14px').css('overflow','hidden').css('white-space','initial').css('text-overflow','initial');
			jQuery('#lbmwidget' + wid + ' .lbmcoupon-text').hide();
		}


		jQuery('#lbmwidget'+wid+' .lbmcoupon-body').each( function() {
			jQuery(this).outerWidth(jQuery('#lbmwidget'+wid+' #lbmheader').outerWidth(true) - jQuery(this).prev().outerWidth(true) - jQuery(this).next().outerWidth(true) - extra);
		});
	}

	if (beforeAfter == AFTER || beforeAfter == BEFORE_AFTER)
	{

	jQuery('#lbmwidget'+wid+' .caroufredsel_wrapper,#lbmwidget'+wid+' #lbmcoupons').outerWidth(jQuery('#lbmwidget'+wid+' #lbmheader').width() - extra);

	extra += 20;

	jQuery('#lbmwidget'+wid+' .lbmcoupon-body').each( function() {
		jQuery(this).outerWidth(jQuery('#lbmwidget'+wid+' #lbmheader').outerWidth(true) - jQuery(this).prev().outerWidth(true) - jQuery(this).next().outerWidth(true) - extra);
	});

	jQuery('#lbmwidget'+wid+' .caroufredsel_wrapper').height(jQuery('#lbmwidget'+wid+' .lbmwidget-coupon').outerHeight(true) * numVisible - (parseInt(jQuery('#lbmwidget'+wid+' .lbmwidget-coupon').css('margin-top')) + parseInt(jQuery('#lbmwidget'+wid+' .lbmwidget-coupon').css('margin-bottom'))));

	}
}

var	numVisible = 3;

function buildCarousel(wid)
{
	if (! jQuery.fn.carouFredSel)
	{
		setTimeout(function() { buildCarousel(wid) }, 100);
		return;
	}

	var	num = jQuery('#lbmwidget'+wid+' #lbmmobile').css('display') != 'none' ? 3 : 5;

	numVisible = num;

	lbmResizeCoupons(wid, BEFORE);

	jQuery('#lbmwidget'+wid+' #lbmcoupons').carouFredSel({

		direction:"up",
		items: { visible:num },
	
		scroll:{ items:1, pauseOnHover:'immediate-resume' },
		auto:{ play:true,timeoutDuration:2000 },
		prev:{ button:'#lbmwidget'+wid+' #coupon_prev', key:'up' },
		next:{ button:'#lbmwidget'+wid+' #coupon_next', key:'down' },
		debug: true
	});

	lbmResizeCoupons(wid, AFTER);
}

var	searchTerm = "",
	primary = "",
	wid = "";

function lbmResizeWidget(wid)
{
	if (typeof wid === 'undefined' || wid == null)
		wid = '';

	var	_width = jQuery('#lbmwidget' + wid).width();

	jQuery('#lbmwidget' + wid + ' #coupon_prev').parent().css('margin-top','initial');

	jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','intitial');
	jQuery('#lbmwidget' + wid + ' .lbmcanvas').css('display','block');
	jQuery('#lbmwidget' + wid + ' .lbmscroll-buttons').css('display','none');
	jQuery('#lbmwidget' + wid + ' .lbmtitle-wrapper').css('float','left');

	if (_width < 435)
	{
		if (_width > 320)
		{
			jQuery('#lbmwidget' + wid + ' .lbmcanvas').css('display','table-cell');
			jQuery('#lbmwidget' + wid + ' .lbmscroll-buttons').css('display','table-cell');
		}

		jQuery('#lbmwidget' + wid + ' .lbmtitle-wrapper').css('float','initial');
		jQuery('#lbmwidget' + wid + ' .lbmtitle-image').css('height','50px');
	}
	else
	{
		if (_width > 435 && _width < 570)
		{
			jQuery('#lbmwidget' + wid + ' .lbmtitle-wrapper').css('margin','-5px 0 0');
			jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','10px 0 0');
		}
		else
		{
			jQuery('#lbmwidget' + wid + ' .lbmtitle-wrapper').css('margin','-20px 0 0');
			jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','15px 0 0');
		}

//		jQuery('#lbmwidget' + wid + ' .lbmcoupon-body').width(jQuery('#lbmwidget' + wid + ' .lbmcoupon-body').width() - 50);
		jQuery('#lbmwidget' + wid + ' .lbmcanvas').css('display','table-cell');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-buttons').css('display','table-cell');
		jQuery('#lbmwidget' + wid + ' .lbmfilters').css('float','initial');
	}

	if (_width < 440)
		jQuery('#lbmwidget' + wid + ' .lbmfilters').css('float','');

	jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.small').hide();
	jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.large').hide();

	if (_width < 500)
	{
		jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.small').show();
		jQuery('#lbmwidget' + wid + ' .lbmnav-logo').css('float','none').css('width','100%').css('text-align','center');
		jQuery('#lbmwidget' + wid + ' .lbmnav-logo img').css('float','initial');
	}
	else
	{
//		jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.large').show();
		jQuery('#lbmwidget' + wid + ' .lbmnav-logo').css('float','right').css('width','30%').css('text-align','initial');
		jQuery('#lbmwidget' + wid + ' .lbmnav-logo img').css('float','right');
	}

	if (_width >= 570)
	{
		jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','20px 0 0');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').removeClass('center');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').addClass('right');
	}
	else if (_width >= 435)
	{
//		jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','15px 0 0');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').removeClass('center');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').addClass('right');
	}
	else
	{
		jQuery('#lbmwidget' + wid + ' .lbmfilters').css('margin','0 0 0');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').removeClass('right');
		jQuery('#lbmwidget' + wid + ' .lbmscroll-button').addClass('center');
	}

	if (_width < 320)
		jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.small').css('max-width','100%');
	else
		jQuery('#lbmwidget' + wid + ' .lbmnav-buttons.small').removeAttr('max-width');
}

var	_interval = setInterval( function() {
	if (jQuery('#lbmwidget' + wid).length != 0)
	{
		clearInterval(_interval);
		lbmResizeWidget();
	}
}, 500);

window.addEventListener('resize', function() {
	lbmResizeWidget(wid);
	setTimeout(function() { lbmResizeCoupons(wid, BEFORE_AFTER); }, 500);
}, false);

function lbmOnLoad()
{
	if (jQuery('#lbmwidget').width() >= 400)
	{
		jQuery('.lbmnav-app-thin').hide();
		jQuery('.lbmnav-app-wide').show();
	}
	else
	{
		jQuery('.lbmnav-app-thin').show();
		jQuery('.lbmnav-app-wide').hide();
	}

	var	searchItem = null;

	jQuery('#lbmwoverlay').on('hide', function() {

		jQuery('input[id^="lbmsignup"]').val('');
		jQuery('#lbmsignup').show();
		jQuery('#lbmsignup-complete').hide();

		lbmCouponID = -1;
	});

	jQuery('.lbmwidget #lbmsearch').autocomplete({
		open: function() {
			searchItem = null;
		},
		source: function( request, response ) {
			searchTerm = request.term;

			var	l1,l2,
				reStartsWith = new RegExp( "^" + jQuery.ui.autocomplete.escapeRegex(request.term).replace(/ /g,' *'), "i" ),
				reContainsNotStarts = new RegExp( ".+" + jQuery.ui.autocomplete.escapeRegex(request.term).replace(/ /g,' *') + ".*", "i" ),
				reContains = new RegExp( ".*" + jQuery.ui.autocomplete.escapeRegex(request.term).replace(/ /g,' *') + ".*", "i" );

			l1 = jQuery.map( clients, function( item ) {
				if (reStartsWith.test( item.label ) ||
					reStartsWith.test( item.label.replace(/[^a-z 0-9]/gi,'') ))
				{
					return { label: item.label, vid: item.value }
				}
			});

			l2 = jQuery.map( clients, function( item ) {
				if (reContainsNotStarts.test( item.label ) ||
					reContainsNotStarts.test( item.label.replace(/[^a-z 0-9]/gi,'') ))
				{
					return { label: item.label, vid: item.value }
				}
			});

			response(l1.concat(l2));
		},
		select: function( e, ui ) {
			var	id = jQuery(this).closest('.lbmwidget').attr('id').match(/.*_\d+/);

			if (id == null || ! id.match(/_\d+/))
				id = "";

			jQuery('#lbmwidget'+id+' #lbmvendorID').val(ui.item.vid);
			jQuery('#lbmwidget'+id+' #search').val(ui.item.label);
			searchItem = ui.item;
		},

		close: function( e, ui ) {
			var	id = jQuery(this).closest('.lbmwidget').attr('id').match(/.*_\d+/);

			if (id == null || ! id.match(/_\d+/))
				id = "";

			if (searchItem != null)	// item selected from list
			{
				jQuery('#lbmwidget'+id+' #lbmstype').val('name');
				jQuery('#lbmwidget'+id+' #lbmvendorID').val(searchItem.vid);

				lbmUpdate(false, id);

				jQuery('#lbmwidget'+id+' #lbmsearch').blur();
			}
			else
				searchTerm = '';
		},
		minLength: 3,
		autoFocus: true
	});

	jQuery('select').on('keydown', function(e){
		if(e.keyCode === 38 || e.keyCode === 40) { //up or down
			e.preventDefault();
			return false;
		}
	});

	var	_timer = setInterval(function() {
		if (jQuery('#lbmwoverlay #lbmwoverlay-contents').length != 0)
		{
			var	done = false;

			jQuery('#lbmwoverlay').each( function() {
				var	o = jQuery(this).detach();

				if (! done)
					jQuery(document.body).append(o);

				done = true;
			});
			clearInterval(_timer);
		}
	}, 500);

	jQuery('#lbmwoverlay').on("show", function () {
		jQuery('.lbmwidget #lbmcoupons').trigger('stop', true);
//console.log('show popup');
	});
	jQuery('#lbmwoverlay').on("hide", function () {
		jQuery('.lbmwidget #lbmcoupons').trigger('play', true);
//console.log('show popup');
	});

	jQuery('.lbmwidget #lbmcity').on('change', function(event, id, update) {
		var	id = jQuery(this).closest('.lbmwidget').attr('id').replace(/.*(_\d+)/,'$1');

		if (id == null || ! id.match(/_\d+/))
			id = "";

		if (typeof update === "undefined")
			update = true;

		jQuery('#lbmwidget'+id+' #lbmvtype').find('option').remove();

		for (var i = 0; i < _types.length; i++)
		{
			if (_subtypes[i].length == 0)
				continue;

			jQuery('#lbmwidget'+id+' #lbmvtype').append(jQuery('<option/>', { 
				value: _types[i].split(':')[1] + ':0',
				text : _types[i].split(':')[0]
			}));

			var	added = false, found = false;

			for (var j = 0; j < _subtypes[i].length; j++)
			{
				var	ptype = _subtypes[i][j],
					value = ptype.replace(/.*:/,''),
					text = ptype.replace(/:.*/,'');

				if (jQuery.inArray(value, types[jQuery('#lbmwidget'+id+' #lbmcity option:selected').val()]) == -1)
					continue;

				found = true;
				added = true;

				jQuery('#lbmwidget'+id+' #lbmvtype').append(jQuery('<option/>', { 
					value: _types[i].replace(/.*:/,'') + ':' + value,
					text : '-' + text
				}));
			}

			if (! added && ! found)
				jQuery('#lbmwidget'+id+' #lbmvtype'+' option:last').remove();
		}

		if (jQuery('#lbmwidget'+id+' #lbmcity option:selected').val().match(/.*[,:]ca/))
			jQuery('#lbmwidget'+id+' #lbmvtype option:contains("shops")').text("collectives").wSelect('change');
		else
			jQuery('#lbmwidget'+id+' #lbmvtype option:contains("collectives")').text("shops").wSelect('change');

		jQuery('#lbmwidget'+id+' #lbmvtype option:eq(0)').prop('selected', true);	// shops

		jQuery('#lbmwidget'+id+' #lbmvtype').wSelect('reset').wSelect();

		jQuery('#lbmwidget'+id+' #lbmstype').val('business');

		if (update)
			lbmUpdate(false, id);

		jQuery('#lbmwidget'+id+' #lbmcity').wSelect();
		jQuery('#lbmwidget'+id+' .wSelect').css('width','120px');
		jQuery('#lbmwidget'+id+' .wSelect').css('margin-bottom','5px');
	});

	jQuery('.lbmwidget #lbmvtype').change(function() {
		var	id = jQuery(this).closest('.lbmwidget').attr('id').replace(/.*(_\d+)/,'$1');

		if (id == null || ! id.match(/_\d+/))
			id = "";

		jQuery('#lbmwidget'+id+' #lbmstype').val('business');
		lbmUpdate(false, id);
	});

	var	wid = '';

	jQuery('#lbmwidget'+wid).css('visibility','visible');
	
	if (jQuery('#lbmmobile').css('display') != 'none' && navigator.geolocation)
	{
		navigator.geolocation.getCurrentPosition(function(position) {
			lat = position.coords.latitude;
			lng = position.coords.longitude;

			lbmUpdate(true, wid);
		},
		function(error) {
			lbmUpdate(true, wid);
		});
	}
	else

	lbmUpdate(true, wid);

	jQuery(window).resize(function() {
		clearTimeout(resizeTimer)
		resizeTimer = setTimeout(lbmResize,500);
	});
}

var	onLoadCalled = false,
	checkAttempts = 0,
	loadjQuery = (self != parent);

if (loadjQuery)
{
var e = document.createElement("script");
e = document.createElement("script");
e.type="text/javascript";
e.src = "https://www.leafbuyer.com/js/vendor/jquery.js";
document.getElementsByTagName("head")[0].appendChild(e);
}

function lbmCheckjQuery()
{
	if (typeof jQuery === "undefined")
		setTimeout(lbmCheckjQuery, 100);
	else if (! onLoadCalled)
	{
		onLoadCalled = true;

		jQuery(window).on('load', function(e) {
			jQuery('#lbmwidget'+primary+' span.jcf-select').remove();
		});

		// load jQuery-dependent plugins

		var e = document.createElement("script");

		e = document.createElement("script");
		e.type="text/javascript";
		e.src = "https://www.leafbuyer.com/js/jquery-ui.min.js";
		document.getElementsByTagName("head")[0].appendChild(e);

		e = document.createElement("script");
		e.type="text/javascript";
		e.src = "https://www.leafbuyer.com/js/widget.js?v=112818";
		document.getElementsByTagName("head")[0].appendChild(e);

		e = document.createElement("script");
		e.type="text/javascript";
		e.src = "https://www.leafbuyer.com/js/widgetdropdowns.js?d=_20200106";
		document.getElementsByTagName("head")[0].appendChild(e);

		lbmCheckjQueryUI();
	}
}

function lbmCheckjQueryUI()
{
	if (checkAttempts > 10)
	{
		jQuery('#lbmwidget'+primary+'').parent().hide();
		return;
	}

	if (typeof jQuery.ui === "undefined" ||
		typeof jQuery.fn.wSelect === "undefined")
	{
		setTimeout(lbmCheckjQueryUI, 500);
		checkAttempts++;
	}
	else
		lbmOnLoad();
}

function lbmGetWidgetID()
{
	return '';
}
	
lbmCheckjQuery();

function nagmon() {}	/* DO NOT REMOVE - NAGIOS CHECKS THIS */

