var tz =''; function ml___getCacheBustValue(min, max) { return Math.floor(Math.random() * (max - min) + min); } var ml___iframeMessageStack = []; var params = ''; var geocoder; var geophrase = ''; var ml___tried = false; var ml___waiting = false; var ml___complete = false; var GM_Timeout; var ml___debug = false; var ml___address,ml___tld,ml___id; var ml___Itemid = 12097; var ml___view_override = ''; var ml___layout_override = ''; var linker; var ml___token = ''; var ml___cachebust = ml___getCacheBustValue(0,65536); var iframe_height = 950; var params_detected = 0; function addJavascript(jsname,pos,id) { var th = document.getElementsByTagName(pos)[0]; var s = document.createElement('script'); s.setAttribute('type','text/javascript'); s.setAttribute('src',jsname); if(id && id.length > 0){ //dont add it twice if(document.getElementById(id)){ return; } s.setAttribute('id',id); } th.appendChild(s); } //add our geocoding library addJavascript('https://code.metalocator.com/components/com_locator/assets/scripts/geocoder.js','head','ml___geocoder'); if(window.location.href.indexOf('?')){ var url = window.location.href.substr(window.location.href.indexOf('?') + 1,window.location.href.length); param_list = url.split('&'); var utm_vars = ['utm_source','utm_medium','utm_campaign','utm_content','utm_keyword']; for(var x=0; x < param_list.length; x++){ pair = param_list[x].split('='); if(pair[0] == 'ml___jsdebug'){ ml___debug=true; } if(pair[0].indexOf('ml___') == 0 || pair[0] == 'postal_code' || pair[0] =='radius' || pair[0]== 'keyword' || pair[0] == 'ml_location_override' || pair[0]== 'city' || pair[0]== 'state') { if(pair[0] == 'ml___postal_code'){ geophrase = pair[1]; } if(pair[0] == 'ml___token'){ ml___token = pair[1]; } pair[0] = ml_fixEncoding(pair[0].replace('ml___','')); if(pair[0] != 'framed' && pair[0] != 'Itemid' && pair[0] != 'layout1' && pair[0] != 'view1'){ params_detected = 1; params = params + '&' + pair[0] + '=' + pair[1]; } if(pair[0] == 'lead_id'){ params = params + '&ml___cachebust=' + ml___cachebust; } } else { if( utm_vars.indexOf( pair[0] ) >= 0 ) { params_detected = 1; params = params + '&' + pair[0] + '=' + pair[1]; } } } } if (typeof ml___height !== 'undefined') { iframe_height = ml___height; } function ml___refreshParams(){ if (typeof ml___lang !== 'undefined') { params = params + '&lang=' + ml___lang; } if (params_detected == 1) { params = params + '¶ms_detected=1'; } var installed_page = window.location.href; //var ml___tags = [3,4,5]; if (typeof ml___tags !== 'undefined' && ml___tags.constructor === Array) { for(var j = 0; j < ml___tags.length; j++){ params = params + '&tags[]=' + ml___tags[j]; } } //custom interface parameter overrides //var ml___options = {"show_map":"0"}; //Custom parameters //var ml___params = {"city":"Milwaukee","keyword":"smith"}; if (typeof ml___params !== 'undefined' && ml___params.constructor === Object) { for (var i in ml___params){ if(ml___params[i].constructor === Array){ for (var j = 0; j < ml___params[i].length; j++){ params = params + '&' + encodeURIComponent(i) + '[]=' + encodeURIComponent(ml___params[i][j]); } }else{ params = params + '&' + encodeURIComponent(i) + '=' + encodeURIComponent(ml___params[i]); } } } if (typeof ml___options !== 'undefined' && ml___options.constructor === Object) { params = params + '&_urlparams=' + encodeURIComponent(JSON.stringify(ml___options)); } } function ml___setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + ';secure' + expires + "; path=/"; } function ml___getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function ml___eraseCookie(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } ml___refreshParams(); function ml___replaceUrlParam(url,key, value) { if (!url) url = window.location.href; var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"), hash; if (re.test(url)) { if (typeof value !== 'undefined' && value !== null) return url.replace(re, '$1' + key + "=" + value + '$2$3'); else { hash = url.split('#'); url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, ''); if (typeof hash[1] !== 'undefined' && hash[1] !== null) url += '#' + hash[1]; return url; } } else { if (typeof value !== 'undefined' && value !== null) { var separator = url.indexOf('?') !== -1 ? '&' : '?'; hash = url.split('#'); url = hash[0] + separator + key + '=' + value; if (typeof hash[1] !== 'undefined' && hash[1] !== null) url += '#' + hash[1]; return url; } else return url; } } function ml___getUrlParam(url,name) { if (!url) url = location.href; name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); return results == null ? null : results[1]; } function ml___requestGeolocation(Itemid, sendFailedURLParameter){ navigator.geolocation.getCurrentPosition(function (position) { if(document.getElementById("locator_iframe" + Itemid) && document.getElementById("locator_iframe" + Itemid).src){ var newURL = ml___replaceUrlParam(document.getElementById("locator_iframe" + Itemid).src,'user_lat',btoa(position.coords.latitude)); newURL = ml___replaceUrlParam(newURL,'user_lng',btoa(position.coords.longitude)); document.getElementById("locator_iframe" + Itemid).src = newURL; console.log("MetaLocator: User provided permission for position, reloading"); } },function(){ if(sendFailedURLParameter === true){ var newURL = ml___replaceUrlParam(document.getElementById("locator_iframe" + Itemid).src,'user_rejected_geolocation',1); document.getElementById("locator_iframe" + Itemid).src = newURL; } console.log('MetaLocator: User rejected permission for position'); }); } function ml___requestGeolocationViaPostMessage(){ navigator.geolocation.getCurrentPosition(function (position) { var message = {}; message.user_lat = position.coords.latitude; message.user_lng = position.coords.longitude; message.accuracy = position.coords.accuracy; ml___iframeMessageStack.push(message); if(typeof(document.getElementById("locator_iframe12097").iFrameResizer) !== 'undefined'){ document.getElementById("locator_iframe12097").iFrameResizer.sendMessage(ml___iframeMessageStack); } console.log("MetaLocator: User provided permission for position"); },function(err){ var message = {}; message.user_position_rejected = 1; message.error = err; ml___iframeMessageStack.push(message); if(typeof(document.getElementById("locator_iframe12097").iFrameResizer) !== 'undefined'){ document.getElementById("locator_iframe12097").iFrameResizer.sendMessage(ml___iframeMessageStack); ml___iframeMessageStack = []; } console.log('MetaLocator: User rejected permission for position'); }); } function ml_fixEncoding (str) { return (str).replace(/%5B/ig, '[').replace(/%5D/ig, ']'); } function cleanSearch(s){ s = encodeURIComponent(s); s = s.replace(/'/g, "%27"); return s; } function ml___addLoadEvent(callback){ if(document.readyState != 'complete'){ return window.addEventListener ? window.addEventListener("load",callback,false) : window.attachEvent && window.attachEvent("onload",callback); }else if(typeof(callback) === 'function'){ callback(); } } function saveInstalledPageURL(){ try{ var page = encodeURIComponent(window.location.href); //loadXMLDoc('https://code.metalocator.com/index.php?option=com_locator&view=users&task=users.savereferrer&page='+page+'&Itemid=12097&format=raw&framed=1&tmpl=component'); }catch(e){ } } function clearGMTimeout(){ ml___complete = true; finalURL = 'https://code.metalocator.com/index.php?option=com_locator&view=directory&layout=combined&Itemid=12097&tmpl=component&framed=1&source=js'+params; //change the iframe src if it's different, this causes a flicker and reload if(document.getElementById("locator_iframe12097") !== null && ml___getUrlParam(document.getElementById("locator_iframe12097").src,'_ga') != ml___getUrlParam(finalURL,'_ga')){ if(ml___debug){ console.log("Updating IFRAME to " + finalURL + " from " + document.getElementById("locator_iframe12097").src); } document.getElementById("locator_iframe12097").src = finalURL; } if(ml___debug){ console.log('Done waiting'); console.log(document.referrer); console.log(window.location.href); } } function jsonCallback(json){ if(ml___debug){ console.log('JSON result was '); console.log(json); } var geocoded = true; if(typeof json.result != 'undefined' && typeof json.result.result != 'undefined'){ if(json.result.result != 1){ geocoded = false; } }else{ geocoded = false; if(typeof json.result != 'undefined'){ if(json.result != 1){ geocoded = false; } } } if(!geocoded){ if(ml___debug){ console.log('I have not seen this address before, geocoding' + ml___address); } codeAddress(ml___address,ml___tld,0,ml___Itemid); }else{ if(ml___debug){ console.log('No need to geocode, already done.'); } clearGMTimeout(GM_Timeout); } } function loadXMLDoc(url,address,tld,Itemid) { if(ml___debug){ console.log('Calling cross domain jsonp' + url); } var ml___scriptTag = document.createElement("script"); ml___scriptTag.type = "text/javascript"; ml___scriptTag.src = url; document.getElementsByTagName("head")[0].appendChild(ml___scriptTag) } function checkAddress(address,tld,Itemid){ ml___address=address; ml___tld=tld; ml___Itemid=Itemid; if(ml___debug){ console.log("Checking checkpostalcodep"); } //check if we have the search location var cachebust = new Date().getTime(); var url = "https://code.metalocator.com/index.php?option=com_locator&view=directory&format=raw&task=checkpostalcodep&tmpl=component&postal_code=" + address + '&Itemid=' + Itemid + '&framed=1&tld=' + tld + '&cachebust=' + cachebust; loadXMLDoc(url); } function codeAddress(address,tld,id,Itemid) { geocoder = new Geocoder({type:'arcgis'}); if(ml___debug){ console.log('Coding Address' + address); } try{ geocoder.geocode( { 'address': address,'region': tld ,'Itemid' : 12097,'framed' : 1 }, function(results, status) { if(ml___debug){ console.log('Coding Address: got response'); } if (status == geocoder.GEOCODER_OK) { var state = ''; var state_full = ''; var neighborhood = ''; var country = ''; var city = ''; var county = ''; var county_code = ''; var postal_code = ''; if(results[0].address_components){ if(results[0].address_components.length > 0){ for(var i=0; i < results[0].address_components.length; i++){ if(results[0].address_components[i].types.length > 0){ if(results[0].address_components[i].types[0] == 'administrative_area_level_1'){ state = cleanSearch(results[0].address_components[i].short_name); } if(results[0].address_components[i].types[0] == 'administrative_area_level_1'){ state_full = cleanSearch(results[0].address_components[i].long_name); } if(results[0].address_components[i].types[0] == 'administrative_area_level_2'){ county = cleanSearch(results[0].address_components[i].long_name); } if(results[0].address_components[i].types[0] == 'administrative_area_level_2'){ county_code = cleanSearch(results[0].address_components[i].short_name); } if(results[0].address_components[i].types[0] == 'locality'){ city = cleanSearch(results[0].address_components[i].short_name); } if(results[0].address_components[i].types[0] == 'postal_code'){ postal_code = cleanSearch(results[0].address_components[i].short_name); } if(results[0].address_components[i].types[0] == 'country'){ country = cleanSearch(results[0].address_components[i].short_name); } if(results[0].address_components[i].types[0] == 'neighborhood'){ neighborhood = cleanSearch(results[0].address_components[i].short_name); } } } } } if(ml___debug){ console.log('Coding Address: Got Result: OK'); } //geocode successful try{ if(ml___tried == false){ if(ml___debug){ console.log('Going to save the result for future use.'); } var save_link="https://code.metalocator.com/index.php?option=com_locator&method=auto&task=savegeocode&county="+county+"&country="+country+"&state_full="+state_full+"&state="+state+"&city="+city+"&county_code="+county_code+"&neighborhood="+neighborhood+"&lng="+results[0].geometry.location.lng+"&lat="+results[0].geometry.location.lat+"&postal_code=" + cleanSearch(postal_code) + "&zip=" + cleanSearch(address) + "&address=" + cleanSearch(address) + "&tld="+ tld +"&id=" + id + "&Itemid=" + Itemid + "&framed=1"; var iframe; iframe = document.createElement('iframe'); iframe.src = save_link; iframe.style.display = 'none'; iframe.title = 'Speed Queen Thailand - Where to buy (SF)'; iframe.onload = clearGMTimeout; if(iframe.addEventListener) { iframe.addEventListener('load', clearGMTimeout, false); }else if(iframe.attachEvent){ iframe.attachEvent('onload', clearGMTimeout); } document.body.appendChild(iframe); } }catch(e){ } ml___tried = true; }else{ if(ml___debug){ console.log('Coding Address: Got Result: Failed'); } //geocode failed, mark this point as failed try{ if(ml___tried == false){ var save_link="https://code.metalocator.com/index.php?option=com_locator&method=auto&task=savegeocode&geofailed=1&id=" + id + "&Itemid=" + Itemid + "&framed=1"; var iframe; iframe = document.createElement('iframe'); iframe.src = save_link; iframe.style.display = 'none'; iframe.onload = clearGMTimeout; iframe.title = 'Speed Queen Thailand - Where to buy (SF)'; if(iframe.addEventListener) { iframe.addEventListener('load', clearGMTimeout, false); }else if(iframe.attachEvent){ iframe.attachEvent('onload', clearGMTimeout); } document.body.appendChild(iframe); } }catch(e){ } ml___tried = true; } }); }catch(e){ if(ml___debug){ console.log('Coding Address: Caught exception' + e); } } }// end codeAddress function ml___getMetaLocatorScriptTag(){ //modern browsers if(typeof(document.currentScript) !== 'undefined'){ // our script was added to the head, we should not insert here. if(document.currentScript !== null && document.currentScript.parentElement && document.currentScript.parentElement.tagName === 'HEAD'){ // this is when we have a placeholder element, var ml___placeHolder = document.querySelector('[data-metalocator="locator"]'); if(typeof(ml___placeHolder) !== 'undefined' && ml___placeHolder !== null){ return ml___placeHolder; } return false; } return document.currentScript; } // older browsers without document.currentScript support (IE 11 and Opera Mini) var scripts = document.getElementsByTagName('script'); var ourScript = scripts[scripts.length - 1]; var src = ourScript.getAttribute('src'); if(typeof(src) === 'string' && src.toUpperCase().indexOf('METALOCATOR') >= 0 && src.toUpperCase().indexOf('COM_LOCATOR') >= 0){ return ourScript; } return ourScript; } // if document.write is enabled, and it hasn't been overridden, use it, otherwise use the newer insertafter method function ml___documentWrite(s){ if('1' == '1' && !(typeof(ml___options) !== 'undefined' && ml___options.constructor === Object && ml___options['enable_docwrite'] === '0')){ document.write(s); }else{ var lastScript = ml___getMetaLocatorScriptTag(); // fall back to document write if there is no element to append to, and document.write was not taken over if(!lastScript && document.write && document.write.name == 'write'){ document.write(s); } else { lastScript.insertAdjacentHTML("beforebegin", s); } } } function ml___addStyle(css){ head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ // This is required for IE8 and below. style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } } function ml___waitForElementToExist(selector) { return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { observer.disconnect(); resolve(document.querySelector(selector)); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } function ml___getScrollingElementCSSName(){ var cssName = 'body'; var element = document.scrollingElement || document.documentElement; if(typeof(element) !== 'undefined' && typeof(element.tagName) === 'string' && element.tagName.length > 0){ cssName = element.tagName.toLowerCase(); } return cssName; } function GM_wait12097() { if(ml___debug){ console.log('Calling GMWait'); } try{ }catch(e){ } if(ml___debug){ console.log('Geophrase was ' + geophrase); } //geocode any passed in geo-phrase //This was removed in favor of back-end "remote" geocoding, hence the && false if(geophrase.length > 0 && false){ if(ml___debug){ console.log('ml___waiting was ' + ml___waiting); } if(ml___waiting == false){ checkAddress(geophrase,'TH',12097); } }else{ ml___complete = true; } //wait for map library to load if(ml___complete == false ) { if(ml___debug){ console.log('Waiting...'); } ml___waiting = true; GM_Timeout = window.setTimeout(GM_wait12097,100); }else{ clearGMTimeout(); if(ml___debug){ console.log('Creating IFRAME'); } if(geophrase.length > 0){ ml___waitForElementToExist('#ml___wrapper12097').then(function(elm){ var ml___container = document.getElementById('ml___wrapper12097'); var ml___iframe = document.createElement("iframe"); ml___iframe.width = '100%'; ml___iframe.height = iframe_height; ml___iframe.id = 'locator_iframe12097'; ml___iframe.src = finalURL; ml___iframe.allowTransparency="true"; ml___iframe.frameBorder='no'; ml___iframe.allow='geolocation *; web-share *;'; ml___iframe.title='Speed Queen Thailand - Where to buy (SF)'; ml___iframe.onload = function (){ triggerIFRAMEResize(); }; if(ml___iframe.addEventListener) { ml___iframe.addEventListener('load', function (){ triggerIFRAMEResize(); }, false); }else if(ml___iframe.attachEvent){ ml___iframe.attachEvent('onload', function (){ triggerIFRAMEResize(); }); } if(ml___debug){ console.log('Inserting before'); } ml___container.appendChild(ml___iframe); }); } if(document.getElementById('locator_loading12097')){ document.getElementById('locator_loading12097').style.display='none'; } } } function ml___decorateFinalURL(url){ if(typeof(url) !== 'undefined'){ //remove any existing hash if(url.indexOf('#') >= 0){ url = url.split('#')[0]; } url = url + ml___getMLHash(); }else{ url = ''; } return url; } function ml___getMLHash(){ var hash = ''; try{ if(window.location.hash) { if(window.location.hash.indexOf('ml___') == 1){ hash = window.location.hash.replace(/ml___/,''); if(hash && hash.length > 0){ return hash; } } } }catch(e){ } return hash; } var iframe_height_attribute =''; var ml___mobile_breakpoint = '576'; var ml___mobile_breakpoint_plus_one = '577'; //add the scroll snap to the page //#locator_iframe12097{ -webkit-scroll-snap-type: mandatory; -webkit-scroll-snap-points-x: repeat(100%);} iframe_height_attribute = 'height="'+ iframe_height +'"'; var finalURL = 'https://code.metalocator.com/index.php?option=com_locator&view=directory&layout=combined&Itemid=12097&tmpl=component&framed=1&source=js'+params; finalURL = ml___decorateFinalURL(finalURL); ml___addLoadEvent(GM_wait12097); var loading12097 = '