/* eGR JS v2.0 Dec-2006 */var ie=document.all?1:0var ff =document.getElementById&&!document.all?1:0var maxMyEntries = 10;var flag = 0;var cookieName = "MyEGR";var ctName = "myBox";var opName = "myBoxInner";var bx = false;var tout;var df = document.forms[0];var totDocs = 0;var myMessageText = '<font style="font-size:11px;">The <i>My eGR</i> folder lets you store 10 links to your most used pages. Click <font color=#DD0000>Add this page to "My eGR"</font> on any page to save the link. Please select a destination from the list below, or click "remove" to delete an entry ...</font>'function $() {  var elements = new Array();  for (var i = 0; i < arguments.length; i++) {    var element = arguments[i];    if (typeof element == 'string')      element = document.getElementById(element);    if (arguments.length == 1)       return element;    elements.push(element);  }  return elements;}function qS(key){	var q = window.location.search.substring(1);	var p = q.split('&');	for(x=0; x<p.length;x++){		var pair = p[x].split('=');		if(pair[0] == key) return pair[1];	}}/* Searches */function doSearch(s){ if(s == '')	 { 			alert('Please enter a search query ...'); 			return false;  	 }  	 else if(s.toLowerCase() == 'brent') 	 { 		alert('Searches for Brent have been disabled ...'); 		return false;	}      else	{            window.location='/egr.nsf/SearchAll?SearchView&Query=(' + s + ')&SearchOrder=1&SearchWV=TRUE&SearchThesaurus=FALSE&SearchFuzzy=FALSE&Start=1&Count=20'; return false;	}    }/* My eGR */function openMyBox(opt, preRun) {	var box = $(ctName);	var divs = box.getElementsByTagName('div');	if(bx == false || opt == true){		readMyCookie();		for(d=0; d<divs.length; d++) divs[d].style.cssText = 'visibility:visible';		if(preRun) eval(preRun);		box.style.cssText = 'display:block;';		bx = true;	}else{		for(d=0; d<divs.length; d++) divs[d].style.cssText = 'visibility:hidden';		box.style.cssText = 'display:none;';		bx = false;	}}function setMyCookie(){	var topCookie = 0;	var jumpEntry = 0; 	for (var i = 1; i <= maxMyEntries; i++)		if (document.cookie.indexOf(cookieName + i) >= 0) topCookie = i;  	if (topCookie >= maxMyEntries)		alert('You\'ve already added ' + maxMyEntries + ' pages to My EGR - please remove some entries before adding any more ...');	else	{		jumpEntry = (topCookie + 1);		document.cookie=cookieName + jumpEntry + "=" + location.href + "|||" + document.title + "; expires=Monday, 04-Apr-2040 05:00:00 GMT; path=/";		urlstring=window.location.pathname.slice(0,window.location.pathname.lastIndexOf('nsf'));		openMyBox(true, 'showTab(\'myBox\', \'mbtab1\', \'myBoxInner\');');	}}function readMyCookie(){	var cookieStart = 0;	var cookieEnd = 0;	var concan="";	var tempStrip;	var theURL = new Array (maxMyEntries);	for (var i = 1; i <= maxMyEntries; i++)	{ 		cookieStart = document.cookie.indexOf(cookieName + i);		if (cookieStart >= 0)		{			cookieEnd = document.cookie.indexOf(";", cookieStart);			if (cookieEnd < 0) cookieEnd = document.cookie.length;						tempStrip = document.cookie.substring(cookieStart, cookieEnd);			theIndex = tempStrip.substring(tempStrip.indexOf(cookieName)+7, tempStrip.indexOf('='));			theURL[i] = tempStrip.substring(tempStrip.indexOf('=')+1, tempStrip.indexOf('|||'));			theTitle = tempStrip.substring(tempStrip.indexOf('|||')+3, tempStrip.length);			concan = concan + '<div><a href="javascript:removeMyEntry(\''+cookieName+i+'\');">remove</a>&nbsp;<a href="'+theURL[i]+'">'+ theTitle + '</a></div>';			flag = 1;		}	}	if (flag == 1)		flag = 0;	else		concan = "You have no saved entries ...";			$(opName).innerHTML = myMessageText + '<br><br><div id="scrollMyBox">' + concan + '</div>';	showTab('myBox', 'mbtab1', 'myBoxInner');}function removeMyEntry(tag){  	document.cookie= tag + "=" + location.href + "|||" + document.title + "; expires=Monday, 04-Apr-1970 05:00:00 GMT; path=/";	readMyCookie();}/* My Defaults */function readMyDefs(){	//Do LA	selectValue("LA", df.Fav_LA);		//Do Supplier	selectValue("Supplier", df.Fav_Supplier);		//Do Product	selectValue("Product", df.Fav_Product);		//Do Group	selectValue("Group", df.Fav_Group);}function selectValue(ix, selectBox){	cookieStart = document.cookie.indexOf(ix);	if(cookieStart >= 0){		cookieEnd = document.cookie.indexOf(";", cookieStart);		if(cookieEnd < 0){cookieEnd = document.cookie.length;}			var value = document.cookie.substring(cookieStart+1+ix.length, cookieEnd)		for(x = 0; x < selectBox.options.length; x++)		{			if(selectBox.options[x].value == value){				selectBox.options[x].selected = true;			}		}	}}function addDefault(tag, data){	cookDate = (data != "No Default")? "2040":"1970";	document.cookie= tag + "=" + data + "; expires=Monday, 04-Apr-" + cookDate + " 05:00:00 GMT; path=/";}function flashTxt(txt, aDiv){		if(flash == flashTot)		{			window.clearInterval(tID);			aDiv.innerHTML = '';			tID = '';			flash = 0;		}		else		{			if(aDiv.innerHTML == '')			{				aDiv.innerHTML = txt;				flash++;			}			else			{				aDiv.innerHTML = '';			}		}}function doDefaults(){	addDefault('LA', df.Fav_LA[df.Fav_LA.selectedIndex].value);	addDefault('Supplier', df.Fav_Supplier[df.Fav_Supplier.selectedIndex].value);	addDefault('Product', df.Fav_Product[df.Fav_Product.selectedIndex].value);	addDefault('Group', df.Fav_Group[df.Fav_Group.selectedIndex].value);	$('processed').innerHTML = procTxt;	if(!tID)	{		flash = 0;		tID = window.setInterval("flashTxt(procTxt, $('processed'))",400);		}}/* Tabbing */function showTab(inp, tab, oup, trig){	if(trig) eval(trig);	zone = $(inp);	cRows = zone.getElementsByTagName('div');	for(x=0; x<cRows.length; x++){		if(cRows[x].className=='contentRow'){			var rows = cRows[x].getElementsByTagName('div');			if(cRows[x].id == oup)				cRows[x].style.display = 'block';			else				cRows[x].style.display = 'none';					}		if(cRows[x].className == "tabOff" || cRows[x].className == "tabOn"){			if(cRows[x].id == tab)				cRows[x].className = "tabOn";			else				cRows[x].className = "tabOff";		}	}	}/* Row Cols */function prepareView(elm, view, classA, classB){	v = $(view);	if(v){		cRows = v.getElementsByTagName('div');		for(x=0; x<cRows.length; x++)			if(cRows[x].className.indexOf(elm) >= 0)				cRows[x].className = x%2?classA:classB;	}}/* View Handler */function viewCount(view, vS, vC, cat, wv){	v = (view.indexOf('&View=')==-1?view:view.substring(view.indexOf('&View=')+6, view.length)) + '?ReadViewEntries&ExpandView&Count=10000' + (cat?'&RestrictToCategory='+cat:'');//alert(v);	if(view.indexOf('&View=')!=-1) 		view += '&RestrictToCategory=' + cat;	else		view += '?OpenView';			var sCall = new AJAXInteraction(v, function(op, stat){			tag = op.toLowerCase().indexOf('toplevelentries');		totDocs = op.substring(tag+17, op.indexOf('"', tag+17));		ct = totDocs / vC;		adt = (ct == Math.floor(ct))?0:1;		totPage = Math.floor(ct) + adt;		cP = (Math.floor(vS / vC) + 1);		var pC = new Array;				if((vS + vC) >= totDocs){			$('nLink').innerHTML = "Next >";			$('nLinkL').innerHTML = "Next >";		}				if(totDocs != '.0'){			if(!wv){				dropBuild = '<select class="pageDrop" id="pageDrop" onChange="window.location=this.options[this.selectedIndex].value;">'				view = view.indexOf('SCV')!=-1?view.replace('RestrictToCategory', 'Category'):view;				view = view.indexOf('Start=')!=-1?view.substring(0, view.indexOf('&Start=')):view;				for(x=1; x<=totPage;x++) dropBuild += '<option value="' + view + '&Start=' +  ((vC*x) + 1 - vC) + '&Count=' + vC  + '">' + x;				dropBuild += '</select>'							$('nCount').innerHTML = "Page " + dropBuild + " of " + totPage + " (" + totDocs + " records)";				$('pageDrop').selectedIndex = cP-1;			}else{				$('nCount').innerHTML = totDocs + " records";			}		}	}); 	sCall.doGet();}function cView(z){	v = $(z);	if(v)		if(v.innerHTML.indexOf('>No documents found</') > -1)			v.innerHTML = '<br><span class="noViewData">Sorry, there is no data available for this request ...</span>';}/* AJAX */function AJAXInteraction(url, callback, opt) {    function processRequest () {      if (req.readyState == 4) {          if (callback) callback(req.responseText, req.status, opt);           req=null;      }    }         var req = init();    req.onreadystatechange = processRequest;            function init() {      if (window.XMLHttpRequest)        return new XMLHttpRequest();      else if (window.ActiveXObject)        return new ActiveXObject("Microsoft.XMLHTTP");    }            this.doGet = function() {		req.open("GET", url, true);		req.send(null);    }        this.doPost = function(body) {      req.open("POST", url, true);      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      req.send(body);    }}/* XML Handling */function XMLHandler(op, stat, retFunc){	if(stat == 200){		var xmlDoc = createXML(op);		errors = xmlDoc.getElementsByTagName('error');		if(errors.length == 0){			var glb = this;			var doIt = glb[retFunc];			doIt(xmlDoc);		}else			handleError(errors[0].firstChild.text + ' (Line : ' + errors[0].getAttribute('line') + ')');				}else{		 handleError('ERROR ' + stat + ' : Your server returned an error.\n\nAn administrator has been notified of the problem, but please still log a call for assistance ...');	 	}		}function createXML(op){	var ief = true;	if (window.ActiveXObject){		  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");		  xmlDoc.async=false;	 }else if (document.implementation && document.implementation.createDocument){	 	  xmlDoc= document.implementation.createDocument("","",null); 		  ief = false;	 }else		  handleError('ERROR : Your browser is not compatible with this system.\n\nPlease contact  your Administrator ...');   		   	if(ief)		xmlDoc.loadXML(op);	else{		var oParser = new DOMParser();		xmlDoc = oParser.parseFromString(op, "text/xml");	}			  errors = xmlDoc.getElementsByTagName('error');         	 if(errors.length == 0)             return xmlDoc      else         handleError(errors(0).firstChild.text + ' (Line : ' + errors(0).getAttribute('line') + ')'); }function findPosX(obj) {         var curleft = 0;         if (obj.offsetParent)                 while (obj.offsetParent)                 {                         curleft += obj.offsetLeft                         obj = obj.offsetParent;                 }         else if (obj.x)                 curleft += obj.x;         return curleft; } function findPosY(obj) {         var curtop = 0;         if (obj.offsetParent)                 while (obj.offsetParent)                 {                         curtop += obj.offsetTop                         obj = obj.offsetParent;                 }         else if (obj.y)                 curtop += obj.y;         return curtop; } var egb;BookMark = function(){               this._url = window.location.toString().replace('www.brent.gov.uk', 'www.egovregister.org');               this._title = document.title;			this._registerEvents();};BookMark.prototype._registerEvents = function(){                var elts = ['digg', 'delicious', 'technorati', 'reddit', 'stumbleupon'];                                 for(var e in elts){                	am = elts[e].toString();                	if(document.addEventListener)                         $(elts[e]).addEventListener('onclick', function(e) { egb._popUpWindow(this.id); return false; },false);                     else                     	$(elts[e]).onclick = function(e) { egb._popUpWindow(this.id); return false; }                 };};BookMark.prototype._popUpWindow = function(service){                var servUrl;                var o = new Object();                switch(true){                                 case service == "delicious":                                 servUrl = "http://del.icio.us/post?v=4&noui&jump=close&url=" + this._url + "&title=" + this._title;                                 break;                                                                  case service == "digg":                                 servUrl = "http://digg.com/remote-submit?phase=2&url=" + this._url + "&title=" + this._title;                                 break;                                                                                                    case service == "reddit":                                 servUrl = "http://reddit.com/submit?url=" + this._url + "&title=" + this._title;                                 break;                                                                  case service == "technorati":                                 servUrl = "http://www.technorati.com/faves?add=" + this._url;                                 break;                                                                  case service == "stumbleupon":                                 servUrl = "http://www.stumbleupon.com/submit?url=" + this._url + "&title=" + this._title;                                 break;                                                                  default:                                 break;                                                 };                window.open(servUrl, service, 'width=700');};