/*
 * Copyright(c) 2009 Codehouse
 */
(function(){var e={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(h){var f="";var p,n,l,o,m,k,j;var g=0;h=e._utf8_encode(h);while(g<h.length){p=h.charCodeAt(g++);n=h.charCodeAt(g++);l=h.charCodeAt(g++);o=p>>2;m=((p&3)<<4)|(n>>4);k=((n&15)<<2)|(l>>6);j=l&63;if(isNaN(n)){k=j=64}else{if(isNaN(l)){j=64}}f=f+this._keyStr.charAt(o)+this._keyStr.charAt(m)+this._keyStr.charAt(k)+this._keyStr.charAt(j)}return f},decode:function(h){var f="";var p,n,l;var o,m,k,j;var g=0;h=h.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(g<h.length){o=this._keyStr.indexOf(h.charAt(g++));m=this._keyStr.indexOf(h.charAt(g++));k=this._keyStr.indexOf(h.charAt(g++));j=this._keyStr.indexOf(h.charAt(g++));p=(o<<2)|(m>>4);n=((m&15)<<4)|(k>>2);l=((k&3)<<6)|j;f=f+String.fromCharCode(p);if(k!=64){f=f+String.fromCharCode(n)}if(j!=64){f=f+String.fromCharCode(l)}}f=e._utf8_decode(f);return f},_utf8_encode:function(g){g=g.replace(/\r\n/g,"\n");var f="";for(var i=0;i<g.length;i++){var h=g.charCodeAt(i);if(h<128){f+=String.fromCharCode(h)}else{if((h>127)&&(h<2048)){f+=String.fromCharCode((h>>6)|192);f+=String.fromCharCode((h&63)|128)}else{f+=String.fromCharCode((h>>12)|224);f+=String.fromCharCode(((h>>6)&63)|128);f+=String.fromCharCode((h&63)|128)}}}return f},_utf8_decode:function(f){var g="";var h=0;var j=c1=c2=0;while(h<f.length){j=f.charCodeAt(h);if(j<128){g+=String.fromCharCode(j);h++}else{if((j>191)&&(j<224)){c2=f.charCodeAt(h+1);g+=String.fromCharCode(((j&31)<<6)|(c2&63));h+=2}else{c2=f.charCodeAt(h+1);c3=f.charCodeAt(h+2);g+=String.fromCharCode(((j&15)<<12)|((c2&63)<<6)|(c3&63));h+=3}}}return g}};var b=function(g,f){if(g){throw f}};var d=540;var a=700;var c=null;if(!window.Codehouse){window.Codehouse={}}c=window.Codehouse;if(!c.Locator){c.Locator={}}if(!c.Locator.Findnearest){c.Locator.Findnearest={}}c.Locator.Findnearest.Load=function(g){b(!g,"config can not be null");b(!g.domain,"domain can not be null");b(!g.name,"name can not be null");b(!g.element,"element can not be null");b(!g.element,"element can not be null");var j=document.createElement("iframe");j.setAttribute("frameBorder","0");j.setAttribute("width",g.width?g.width:d);j.setAttribute("height",g.height?g.height:a);j.setAttribute("scrolling","auto");var f="http://"+g.domain+"/Findnearest?customerName=";if(g.tipafriend&&g.tipafriend.embed){var m=window.location.search.length>0?window.location.search.replace("?","").split("&"):[];var l={};for(var h=0;h<m.length;h++){var k=m[h].split("=");l[k[0]]=(k.length>0?k[1]:null)}if(l.codehouse){f=e.decode(l.codehouse)}else{f+=g.name+"&tipafriend="+e.encode((g.tipafriend.url?g.tipafriend.url:window.location.href))}}else{f+=g.name}j.setAttribute("src",f);g.element.appendChild(j)}})();
