
function init () {
//debug	alert('foo');
	oL ('loc');
	stripe ('stripe', 'even');
}

// This function is run from body.onload()
// It writes the page's URL into the given element id and squirts the
function oL (id) {
	if (document.getElementById) {
		var addrX;
		if (document.URL.search (/ecosse|donibristle|bozec/) != -1) {
			addrX = '<br /> Donibristle Laboratory, Fleming Building, Donibristle Industrial Estate, Dalgety Bay, Dunfermline, Fife.&nbsp; KY11 9HZ<br />email: <b>enquiry@yorkemc.co.uk</b> :: tel: <b>+44 (0)1383 825057</b> :: fax: <b>+44 (0)1383 825396</b>';
		} else if (document.URL.search (/cpd|training/) != -1) {
			addrX = '<br /> Continuing Professional Development Unit, York EMC Services, Market Square,<br /> University of York, Heslington, York.&nbsp; YO10 5DD<br />email: <b>cpd@yorkemc.co.uk</b> :: tel: <b>+44 (0)1904 434440</b> :: fax: <b>+44 (0)1904 434434</b>';
		} else if (document.URL.search (/bristol|mulkerrin/) != -1) {
			addrX = '<br /> Bristol Laboratory, Gladstone House, Gladstone Drive,<br /> Soundwell, Bristol.&nbsp; BS16 4RU<br />email: <b>enquiry@yorkemc.co.uk</b> :: tel: <b>+44 (0)117 9870044</b> :: fax: <b>+44 (0)117 9870055</b>';
		} else if (document.URL.search (/castleford|ryan/) != -1) {
			addrX = '<br /> Castleford Laboratory, Three Lane Ends Business Centre, Methley Road, Castleford, West Yorkshire.&nbsp; WF10 1PN<br />e-mail: <b>enquiry@yorkemc.co.uk</b> :: tel: <b>+44 (0)1977 731173</b> :: fax: <b>+44 (0)1977 603181</b>';
		} else if (document.URL.search (/vacancies/) != -1) {
			addrX = ' Market Square, University of York, Heslington, York.&nbsp; YO10 5DD<br />email: <b>jobs@yorkemc.co.uk</b> :: tel: <b>+44 (0)1904 434440</b> :: fax: <b>+44 (0)1904 434434</b>';
		} else {
			addrX = ' Market Square, University of York, Heslington, York.&nbsp; YO10 5DD<br />email: <b>enquiry@yorkemc.co.uk</b> :: tel: <b>+44 (0)1904 434440</b> :: fax: <b>+44 (0)1904 434434</b>';
		}
		var bar;
		var txt = '<img src="/img/yes-sm.png" alt="YES" /> :: The URL for this page is: <a href="#">' +document.URL + '</a>';
		var addr = 'Copyright &copy; 2003-9 York EMC Services.' + addrX;
		bar = document.getElementById (id);
		if (bar) {
			bar.innerHTML = txt;
			bar.className='skip';
		} else {
			var hdr = document.getElementById ('middlebox');
			if (hdr) {
				var fc = hdr.firstChild;
				var wurl = document.createElement ('div');
				var ins = hdr.insertBefore (wurl, fc);
				ins.setAttribute ('id', id);
				ins.className = 'skip';
				ins.innerHTML = txt;
			}
		}
		var address;
		address = document.getElementById ('address');
		if (address) {
			address.innerHTML = txt;
		} else {
			var body = document.getElementsByTagName ('body');
//			var foot = document.getElementById ('foot');
			if (body) {
//debug	alert ('foo');
				var addy = document.createElement ('div');
				body[0].appendChild (addy);
//				foot.appendChild (addy);
				addy.setAttribute ('id', 'address');
				addy.className = 'onlyprint';
				addy.innerHTML = addr;
			}
		}
	}
}

// This changes the src attr of the given element id
// Used for swapping images onmouseover, etc
function cI (id, file) {
  var foo;
  foo = document.getElementById (id);
  foo.src = file;
}

// This works around a bug in Mozilla - see
// https://bugzilla.mozilla.org/show_bug.cgi?id=97283
// call from onmouseover() of a div styled with overflow: {scroll|auto}
function fixScroll (div) {
  var s = div.scrollTop;
  div.childNodes[1].focus();
  div.scrollTop = s;
}

// stripe created after seeing David F Miller's
// http://www.alistapart.com/articles/zebratables/
// - solving a slightly different problem, y'see.
// Mark Tyndall <moz_en-gb@tyndall.org.uk>
function stripe (clsName, evenRowClass) {
// requires this function
	if (!document.getElementsByTagName)
		return;

// obtain a list of tables in the document
	var tables = document.getElementsByTagName ('table');
//	alert (tables.length + ' tables found');
	var pattern = new RegExp (clsName);
	for (var i = 0; i < tables.length; i++) {

		// find if the table's class matches the one we want
		if (pattern.test (tables[i].className)) {
			// re-start row switching for each table
			var even = true;

			// get all the table bodies (NB - retrieves exactly the number
			// of "tbody"s specified in the source - zero or more)
			var tbods = tables[i].getElementsByTagName ("tbody");
			if (tbods.length == 0) {
				tbods[0] = tables[i];
			}
//			alert ('Table ' +i+ ': ' + tbods.length + ' tbodies found');
			for (var j = 0; j < tbods.length; j++) {
				// retrieve all the "tr"s
				var trs = tbods[j].getElementsByTagName ('tr');
				for (var k = 0; k < trs.length; k++) {
					if (even) {
//						alert (k + ' row in ' +i+ 'th table.');
						if (trs[k].className.length) {
						    trs[k].className += ' ' + evenRowClass;
						} else {
							trs[k].className = evenRowClass;
						}
					}
					even = !even;
				}
			}
		}
	}
}

// shows one element, hides another
function swapClick (elemToHide, elemToShow) {
	var btns = document.getElementById (elemToHide);
	var swf  = document.getElementById (elemToShow);
	btns.style.display = 'none';
	swf.style.display = 'block';
}

//
function selectProd() {
	if (!document.location || !document.getElementById) {
		return;
	}
	var q = document.location.search.substring (1);
	var e = document.getElementById (q);
	if (undefined != e) {
		e.setAttribute ('checked', true);
	}
}
