if (document.location.hash.indexOf('proxy_h_ff') > -1) {  hash = document.location.hash.replace(/proxy_/i, '');  top.location.hash = hash;  top.HistMan.cHash = hash;  top.HistMan.doCallback();}    var ff_apikey       = '46041f5ac41c6f2a';  var ff_wait_text    = 'Loading local content now...';  var current_domain  = window.location.href.toLowerCase().match(/(https?:\/\/[^\/]+)/)[1];  var ff_domain       = 'http://www.francisfrith.com';  var ff_country      = 'UK';  var ff_partner      = '';  var ff_container_id = 'ff_container_' + ff_apikey;  var ff_init_url     = (ff_search ? '/search/results/' + ff_search : '/counties/');  var ff_fragment     = 1;  ga_domain = current_domain.replace(/https?\:\/+|www\.|\.com/g,'');  if (ga_domain === 'frithlocal') {ga_domain = 'frithlocal.com/' + window.location.href.toLowerCase().replace(/https?:\/+[^\/]+\/?/,'').match(/[\w]+/);}  var ff_ga_hash      = '=&n=FPN&m=API&s=' + escape(ff_partner);  var ff_init_hash    = 'h_ff_' + ff_fragment + ff_ga_hash;  var ff_transport;           var container;  var _gaq;       function ffTransport(page_url) {      this.fullUrl = ff_domain + page_url  + (page_url.match(/\?/) ? '&' : '?') + 'apikey=' + ff_apikey + '&no_cache=' + new Date().getTime();      this.headLoc = top.document.getElementsByTagName("head")[0];      this.scriptId = 'FrithTransportScript';  }  ffTransport.prototype.buildScriptTag = function () {      this.scriptObj = top.document.createElement("script");      this.scriptObj.setAttribute("type", "text/javascript");      this.scriptObj.setAttribute("charset", "utf-8");      this.scriptObj.setAttribute("src", this.fullUrl);      this.scriptObj.setAttribute("id", this.scriptId);  };  ffTransport.prototype.removeScriptTag = function () {      if (top.ff$(this.scriptId)) {this.headLoc.removeChild(top.ff$(this.scriptId));}  };  ffTransport.prototype.addScriptTag = function () {      this.removeScriptTag();      this.headLoc.appendChild(this.scriptObj);  };  function ffAddContainer() {      if (ff$(ff_container_id)) {return ff$(ff_container_id);}      var container_div = top.document.createElement('div');      container_div.setAttribute('id', ff_container_id);      container_div.setAttribute('class', 'ff_container');      container_div.innerHTML = '<div style="padding:10px; font-size:11px; color:#555;">' + ff_wait_text + '<img src="http://www.francisfrith.com/fpn/assets/images/spinner.gif" style="margin: 3px 5px -3px 5px; border: 0px;" />' + '</div>';      var caller = top.ff$('ff_script_' + ff_apikey);      caller.parentNode.insertBefore(container_div, caller);      ffCss();      return container_div;  }  function ffResponseObservers() {      try{          var links = ff$('ff_container_' + ff_apikey).getElementsByTagName("a");          for (i=0;i<=links.length-1;i=i+1) {            a = links[i];            a.href = a.href.replace(current_domain, ff_domain);            if (a.href.match(/^\/.*?/)) {a.href = ff_domain + a.href;}                            a.onclick = ffLinkHandler;          }      }      catch(e) { alert('Link observers failed: ' + e); }  }  function ffLinkHandler(event) {      if (!event) {var event = window.event;}            if (event.target) { a = event.target; }      else if (event.srcElement) { a = event.srcElement; }            a1 = a;      if (a.nodeName !== 'A') {          a = a.childNodes[0];          if (a) {            if (a.nodeName !== 'A') {a = a1.parentNode;}          }          if (!a) {a = a1.parentNode;}          else if (a.nodeName !== 'A') {a.parentNode;}      }      if (document.getElementsByTagName('BASE').length > 0)      {        var base = document.getElementsByTagName('BASE')[0].href;        if (base.substring(base.length-1, base.length) === '/') {base = base.substring(0,base.length-1);}        a.href = a.href.replace(base, 'http://www.francisfrith.com');      }      if (ffHasClassName(a, 'ff_post')) {        ffStop(event);        a.blur();        ffPostData();      }            if (ffHasClassName(a, 'ff_external')) {          a.target = "_blank";          //Append explicit Google Analytics referer tracking:          if (a.href.indexOf('partner=') === -1 && a.href.indexOf('ff_ga_hash=') === -1) {a.href = a.href + (a.href.indexOf('?')>-1 ? '&' : '?') + 'partner=' + ff_country + '&ff_ga_hash' + ff_ga_hash;}                    ff_container.innerHTML = '<div id="ff_updating" style="width:250px;"><div>Taking you to the Francis Frith site to give you further information...</div></div>' + ff_container.innerHTML;                    setTimeout("var updater = ff$('ff_updating');ff_container.removeChild(updater);ffResponseObservers();", 1000);          return;      }          else {                ffStop(event);        a.blur();                if (ff$('FrithTransportScript') && ff$('ff_updating')) {            ff$('ff_updating').childNodes[0].innerHTML = 'Loading.....';            return false;        }            var o = a.href.replace(/file\:\/\/\/?/,'');        h = o.replace('http://','');        h = h.replace('www.francisfrith.com','');            ff_fragment++;              var histObj = {            hash: 'ff_' + ff_fragment,            arg: h,            callback: 'ffGetContent'        };        HistMan.register(a, histObj);        ff_container.innerHTML = '<div id="ff_updating"><div>Loading...</div></div>' + ff_container.innerHTML;              var c_top = ffContainerTop(ff_container).left;        if (c_top < 0) {window.scrollTo(0,0);}     }  }  function ffQuestion() {    var eData = ff$('ff_question_email').value;    var qData = ff$('ff_question_text').value;        if (eData === '' || qData ==="") {return;}        var qUrl  = 'http://www.francisfrith.com/fpn/api/supports/question.asp';    ff$('ffqform').innerHTML = '<div id="ff_updating"><div>Sending Enquiry...</div></div>';        var qReq = new JSONscriptRequest(qUrl+"?e="+eData+"&q="+qData);    qReq.buildScriptTag();    qReq.addScriptTag();        setTimeout("ff$('ffqform_content').innerHTML = '<p style=\"font-size: 1.2em;\"><strong>Your message has been sent!</strong></p>'",1500);  }  function ffContainerTop( el ) {      var _y = 0;      while( el && !isNaN( el.offsetTop ) ) {          _y += el.offsetTop - el.scrollTop;          el = el.parentNode;      }      return { left: _y };  }  function ffStop(e) {    if(!e) {e        = window.event;}    e.cancelBubble  = true;    e.returnValue   = false;    if (e.stopPropagation) {      e.stopPropagation();      e.preventDefault();    }    return false;  }  function ffHasClassName(element, strClass)   {      if (element.className)      {          var arrList = element.className.split(' ');          var strClassUpper = strClass.toUpperCase();          for (var i = 0; i < arrList.length; i++)          {              if (arrList[i].toUpperCase() === strClassUpper)              {                  return true;              }          }      }      return false;  }  function ffCss() {      var css;      if (ff_apikey) {        if (!ff$('frith_css')) {          css = top.document.createElement('link');          css.setAttribute('rel', 'stylesheet');          css.setAttribute('id', 'frith_css');                    css.setAttribute('href', ff_domain + '/fpn/api/' + ff_apikey + '.css');          css.setAttribute('type', 'text/css');          css.setAttribute('media', 'all');          css.setAttribute('charset', 'utf-8');          top.document.getElementsByTagName('head')[0].appendChild(css);        }      }  }  function ffGetContent(url) {    ff_transport = new ffTransport(url);    ff_transport.buildScriptTag();    ffGa(url);    ffReferrer(url);    ff_transport.addScriptTag();  }  function ffCallback(json) {    if (json.responseText.match(/Error:\s.*?/i) !== null) {        top.ff_container.innerHTML = 'Sorry, an error occurred whilst fetching your requested content.  Please go back a page and try again.<br />If this error persists, please let us know via email at <b>technical.support' + '@' + 'francisfrith'+'.c' + 'om</b>.';    } else {        var content_error_text = '<strong>No local content was found.<\/strong><br \/><br /><br />Technical note: It could be ' + 'that either the location information was not passed to Frith in the expected format, ' + 'or this location is outside the bounds of Frith\'s coverage. You should also check that ' + 'the Frith JavaScript is intact.';        var a_id = 'h_ff_' + ff_fragment;        top.ff_container.innerHTML = ((json.responseText === '') ? content_error_text : '<a name="' + a_id +'" id="' + a_id +'"></a>' + json.responseText);        ffResponseObservers();    }    if (ff_transport) {ff_transport.removeScriptTag();}  }  function ffLoader() {	//if (!ff$(ff_container_id) && !self.src) {	if (!top.document.getElementById(ff_container_id)) {	    ff_container = ffAddContainer();	    HistMan.start();	    var el = null;	    var histObj = {	        hash: 'ff_' + ff_fragment,	        arg: ff_init_url,	        callback: 'ffGetContent'	    };	    HistMan.register(el, histObj);	}  }   function ffGa(url) {    var ff_api_referrer = decodeURIComponent(ffReadCookie("ff_api_referrer"));    var unique_tracker = new Date().getTime()*Math.random()*100000;        _gaq = _gaq || [];    _gaq.push(['ff_'+ unique_tracker +'._setAccount','UA-295442-1']);    _gaq.push(['ff_'+ unique_tracker +'._setDomainName','none']);    _gaq.push(['ff_'+ unique_tracker +'._setAllowHash',false]);    _gaq.push(['ff_'+ unique_tracker +'._setReferrerOverride',ff_api_referrer]);    _gaq.push(['ff_'+ unique_tracker +'._setAllowLinker',true]);    _gaq.push(['ff_'+ unique_tracker +'._setAllowAnchor',true]);    _gaq.push(['ff_'+ unique_tracker +'._setCampSourceKey', 's']);    _gaq.push(['ff_'+ unique_tracker +'._setCampNameKey', 'n']);    _gaq.push(['ff_'+ unique_tracker +'._setCampMediumKey', 'm']);     _gaq.push(['ff_'+ unique_tracker +'._setCustomVar',1,'apiKey',ff_apikey,1]);    _gaq.push(['ff_'+ unique_tracker +'._setCustomVar',2,'partnerId','7438',1]);    _gaq.push(['ff_'+ unique_tracker +'._setCustomVar',3,'accountName','Www.bromsgroveonline.com',1]);    _gaq.push(['ff_'+ unique_tracker +'._setCustomVar',4,'siteId','',1]);    _gaq.push(['ff_'+ unique_tracker +'._trackPageview',url]);    if (!ff$('ff_ga')) {      var ga = document.createElement('script');      ga.src = 'http://www.google-analytics.com/ga.js';      ga.setAttribute('id', 'ff_ga');      ga.setAttribute('async', 'async');      document.documentElement.firstChild.appendChild(ga);    }  }  function fftrackingurl() {}  function ffReferrer(url) {    window.location.href.toLowerCase().match(/https?:\/\/([^\/]+)\/?/)[1].replace(/www\.|\.com/g,'');    document.cookie = "ff_api_referrer="+encodeURIComponent('' + ff_domain + url.match(/([^#]+)/)[0].replace('///', '/'))+"; path=/";  }      function ff$(element) {    return (document.getElementById(element) ? document.getElementById(element) : false);  }  function ffReadCookie(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 "";  }      var HistMan = function () {                var registry    = {};          var pHash       = '';          var unique_id = new Date().getTime()*Math.random()*100000;          var scriptUri   = ff_domain + '/fpn/api/history?r='+unique_id;          var callback    = '';          return {              cHash: '',              start: function (fn) {                  HistMan_loaded = true;                  callback = 'ffGetContent';                  cHash = HistMan.getHash();                  pHash = '';                  if (!document.all) {                      HistMan.watch();                  } else {                      if (!window.location.hash || window.location.hash.indexOf('h_ff') === -1) {window.location.hash = ff_init_hash;}                      HistMan.proxy();                      HistMan.add(cHash);                      HistMan.watch();                  }              },              proxy: function() {                if (ff$('ff_proxy')) { return; }                var ifrm = document.createElement('iframe');                    ifrm.width       = '1';                    ifrm.height      = '1';                    ifrm.frameBorder = '0';                    ifrm.name        = 'ff_proxy';                    ifrm.id          = 'ff_proxy';                    ifrm.src         = scriptUri;                    document.body.appendChild(ifrm);              },              watch: function() {                setInterval(function (pe) {                    cHash = HistMan.getHash();                    if (pHash != cHash) {                        pHash = cHash;                        HistMan.doCallback();                    }                }, 100);              },              register: function (element, obj) {                  var key = (obj.hash) ? obj.hash : obj.arg;                  if (registry[key]) {throw 'Tried to register a key that already exists!';}                  registry[key] = {                      arg: obj.arg,                      callback: (obj.callback || false)                  };                  HistMan.add(key);              },              add: function (key) {                  if (!key) {return;}                  if (!document.all) {window.location.hash = 'h_' + key + ff_ga_hash;}                  else {                    if (!ff$('ff_proxy')) {                      HistMan.proxy();                      HistMan.add(key);                      return;                    }                    else {                      ff$('ff_proxy').src = scriptUri + "&hash=" + key + escape(ff_ga_hash) + '&ref=' + escape(window.location.href);                    }                  }              },              doCallback: function (arg) {                  var obj = registry[HistMan.getHash()];                  var cb_url;                  if (obj) {                      cb_url = (arg || obj.arg);                  } else {                      cb_url = (ff_init_url);                  }                  ffGetContent(cb_url);              },              getHash: function () {                  if (window.location.hash) {                    return window.location.hash.match(/ff_[0-9]+/)[0].replace('#h_', '');                  }              }          };      }();window.onload = ffLoader;
