var tld_ = new Array()
tld_[0] = "com";
tld_[1] = "org";
tld_[2] = "net";
tld_[3] = "ws";
tld_[4] = "info";
tld_[10] = "co.uk";
tld_[11] = "org.uk";
tld_[12] = "gov.uk";
tld_[13] = "ac.uk";

var topDom_ = 13;
var m_ = "mailto:";
var a_ = "@";
var d_ = ".";

function mail(name, dom, tl, alt, display)
{
	if (display=="") display = e(name,dom,tl);
	document.write('<a href="'+m_+e(name,dom,tl)+'" alt="'+alt+'">'+display+'</a>');
}

function mailSimple(name, dom, tl)
{
	if (display=="") display = e(name,dom,tl);
	document.write('m_+e(name,dom,tl)');
}

function mailYellow(name, dom, tl, params, text)
{
	var s = e(name,dom,tl);
  var displaytext = s;
	if (text != '') displaytext = text;
	document.write('<a class="yellow" href="'+m_+s+params+'">'+displaytext+'</a>');
}

function e(name, dom, tl)
{
	var s = name+a_;
	if (tl!=-2)
	{
		s+= dom;
		if (tl>=0) s += d_+tld_[tl];
	}
	else s += swapper(dom);
	return s;
}

function swapper(d)
{
	var s = "";
	for (var i=0; i<d.length; i+=2)
		if (i+1==d.length) s += d.charAt(i);
		else s += d.charAt(i+1)+d.charAt(i);
	return s.replace(/\?/g,'.');
}

if (document.images) {
	blank = new Image();
	blank.src = "images/blank_bell.gif";
	bell = new Image();
	bell.src = "images/bell.gif";
}

function bellPress(id_number) {
	if (document.images) {
		document.images[id_number].src = bell.src;
	}
}

function bellUp(id_number) {
	if (document.images) {
		document.images[id_number].src = blank.src;
	}
}

function openWin(imgSrc, imgWidth, imgHeight, imgTitle, imgCopyright, newColour, bottom)
{
  var colour = "#000000";
  if (newColour == 0) colour = "#000000";  // black
  else if (newColour == 1) colour = "#ffffff";  // white
  else if (newColour == 2) colour = "#1177ee";  // blue
  else if (newColour == 3) colour = "#ffff55";  // yellow

  textTop = 8;
  if (bottom == 1) textTop = imgHeight-22;
  if (bottom == 2) textTop = imgHeight-35;

  var imgWindow = window.open('','','width='+imgWidth +',height='+imgHeight+',status=no,resizable=no,scrollbars=no');
  
  if (imgCopyright == '© Paul Brown') imgCopyright = '© ' + mail3return("web","lacr",11,"","Paul Brown");

  imgWindow.document.open();
  imgWindow.document.write('<html><head><title>' + imgTitle + '</title>');
  imgWindow.document.write('<style>#img { position: absolute; left: 4px; top: 4px; }');
  imgWindow.document.write('#cop { position: absolute; left: 8px; top: ' + textTop + 'px; }');
  imgWindow.document.write('.small { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color:' + colour + '; font-size: 8pt; }</style></head>');
  imgWindow.document.write('<body bgcolor="#FFFFFF" marginheight="0" marginwidth="0">');
  imgWindow.document.write('<div id="img"><img src=' + imgSrc + '></div>');
  imgWindow.document.write('<div id="cop"><p class="small">' + imgCopyright + '</p></div>');
  imgWindow.document.write('</body></html>');
  imgWindow.document.close();
}

function openMap(xRef, yRef, mapType)
{
  var mapWindow = "";

  // Multimap
  if (mapType == 1) mapWindow = window.open('http://www.multimap.com/map/browse.cgi?X=' + xRef + '&Y=' + yRef + '&width=700&height=400&client=public&gride=' + xRef + '&gridn=' + yRef + '&scale=25000','','');

  // Street Map
  else if (mapType == 2) mapWindow = window.open('http://www.streetmap.co.uk/streetmap.dll?grid2map?X=' + xRef + '&amp;Y=' + yRef + '&amp;arrow=Y&amp;zoom=3','','');
}