var thisDb = 'bhpv2.nsf';function setActiveStyleSheet(title) {  var i, a, main;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++)	 if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;          for(i=0; (a = document.getElementsByTagName("link")[i]); i++)	 if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))		if(a.getAttribute("title") == title) a.disabled = false;}function getActiveStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");  }  return null;}function getPreferredStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1       && a.getAttribute("rel").indexOf("alt") == -1       && a.getAttribute("title")       ) return a.getAttribute("title");  }  return null;}function dS(){   var q = location.href.toString();   q = q.substring(q.indexOf('&q=')+3);  var gs = new ax('/' + thisDb + '/(Search)?SearchView&Count=1000&Query=(' + q + ')', function(op, stat) { 	 var ops = document.getElementById('searchResults');	 op = op.substring(op.indexOf('<div id="searchTitle">'), op.indexOf('</form>'));	 op = op.replace('<div id="searchTitle">', '<div id="searchTitle" class="b_db c_wh b"><div class="ip">');	  	 op = op.replace('<div id="search">', '</div><div id="search" class="b_lg"><div class="ip">');	 op = op.replace(/%PAGE%/g, '<img alt="Page" class="nb" src="/icons/vwicn001.gif" />').replace(/%NEWS%/g, '<img alt="News" src="/icons/vwicn028.gif" class="nb" />').replace(/%FILE%/g, '<img alt="File" src="/icons/vwicn005.gif" class="nb" />');	 ops.innerHTML = op + '</div>';	 var sr = document.getElementById('search');	 if(sr.innerHTML=='') sr.innerHTML = 'There were no matching results ...'; }).dG(); gs = null;}window.onload = function(e) {  var cookie = readCookie("style");  var title = cookie ? cookie : getPreferredStyleSheet();  setActiveStyleSheet(title);  if(window.location.toString().toLowerCase().indexOf('bhp-399') > -1) dS();}window.onunload = function(e) {  var title = getActiveStyleSheet();  createCookie("style", title, 365);}var cookie = readCookie("style");var title = cookie ? cookie : getPreferredStyleSheet();setActiveStyleSheet(title);var sa = false;function s(){	if(sa == false){		var m=document.getElementById('b_search');		var b = document.getElementById('b_sb');		if(m.value=='' || m.value.indexOf('Search our') > -1){			alert('Please enter a search query ...');		}else{ 			sa = true;			m.className = 'searching';			var w= window.location.toString();					// Google hook 			                var t = new ax('/home.nsf/pages/search+unavailable?opendocument&rnd='+Math.random(),					function(o, s){						if(s==200)							location.href = ('/bhpv2.nsf/Pages/BHP-399?opendocument&q=' + m.value);						else												location.href = ('http://search.brent.gov.uk/search?q=' + m.value +'&entqr=0&ud=1&sort=date%3AD%3AL%3Ad1&output=xml_no_dtd&oe=UTF-8&ie=UTF-8&client=bhp_frontend&proxystylesheet=bhp_frontend&site=bhp');								});			t.dG();					}	}}function checkCR(evt) {         var evt  = (evt) ? evt : ((event) ? event : null);         var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);         var w = window.location.toString();        if ((evt.keyCode == 13) && (w.indexOf("search.brent.gov.uk")>0)) {doSearch(); return false;}        if ((evt.keyCode == 13) && (w.indexOf("10.17.220.200")>0)) {doSearch(); return false;}        if ((evt.keyCode == 13) && (node.type=="text") && (node.id=='b_search')) { 	        if(document.getElementById('b_search')) s();             return false;        }else return true; } document.onkeypress = checkCR;function ax(url, cb, opts) {    var r = init();    r.onreadystatechange = pR;    function init(){ if (window.XMLHttpRequest) return new XMLHttpRequest(); else if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");};    function pR () { if (r.readyState == 4) { if (cb) cb(r.responseText, r.status, opts);  r=null; } };    this.dG = function() {r.open("GET", url, true);r.send(null); };    this.dP = function(body) { r.open("POST", url, true); r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); r.send(body);};}function cx(op){	var ief = true;	if (window.ActiveXObject){ xd = new ActiveXObject("Microsoft.XMLDOM"); xd.async=false;	 }else if (document.implementation && document.implementation.createDocument){	 	  xd= document.implementation.createDocument("","",null); ief = false;	 }else alert('Your browser is not compatible with this system, please upgrade to the latest version ...');  	if(ief) xd.loadXML(op); else{ var oR = new DOMParser();xd = oR.parseFromString(op, "text/xml");	}		return xd;}function ms_clear(o, b, t){	if(!b) if(o.value==t)	o.value = '';	if(b) if(o.value=='')	o.value = t;}function createCookie(name,value,days) {                if (days) {                                 var date = new Date();                                 date.setTime(date.getTime()+(days*24*60*60*1000));                                 var expires = "; expires="+date.toGMTString();                }                else var expires = "; expires=30/30/3000";                document.cookie = name+"="+value+expires+"; path=/";}function readCookie(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 eraseCookie(name) {        createCookie(name,"",-1);}
