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 mailSmall(name, dom, tl, params, text)
{
	var s = e(name,dom,tl);
  var displaytext = s;
	if (text != '') displaytext = text;
	document.write('<a href="'+m_+s+params+'">'+displaytext+'</a>');
}

function mailBig(name, dom, tl, params)
{
	var s = e(name,dom,tl);
	document.write('<a href="'+m_+s+params+'">'+s+'</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,'.');
}

function openWin(imgSrc, imgWidth, imgHeight, imgTitle)
{
  var imgWindow = window.open('','','width='+imgWidth+',height='+imgHeight+',status=no,resizable=no,scrollbars=no');

  imgWindow.document.open();
  imgWindow.document.write('<html><head><title>' + imgTitle + '</title>');
  imgWindow.document.write('<style>#img { position: absolute; left: 0px; top: 0px; } </style></head>');
  imgWindow.document.write('<body bgcolor="#FFEEBB" marginheight="0" marginwidth="0">');
  imgWindow.document.write('<div id="img"><img src=' + imgSrc + '></div>');
  imgWindow.document.write('</body></html>');
  imgWindow.document.close();
}

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

  // Multimap 1:25,000
  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','','');

  // Multimap 1:10,000
  else if (mapType == 3) 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=10000','','');

  // 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','','');
}

function openMap2(postcode, title, scale)
{
  var mapWindow = "";

//  if (scale == 0) return 'http://www.bbc.co.uk';

  // Multimap 1:25,000
//  if (scale == 1) mapWindow = window.open('http://www.multimap.com/map/browse.cgi?local=h&amp;scale=25000&amp;title=' + title + '&amp;pc=' + postcode + '&amp;icon=x',title,'');

  // Multimap 1:10,000
//  else if (scale == 2) mapWindow = window.open('http://www.multimap.com/map/browse.cgi?local=h&amp;scale=10000&amp;title=' + title + '&amp;pc=' + postcode + '&amp;icon=x',title,'');
 if (scale == 1) {
 mapWindow = 'http://www.multimap.com/map/browse.cgi?local=h&amp;scale=10000&amp;title=' + title + '&amp;pc=' + postcode + '&amp;icon=x<br />';
 document.write(mapWindow);
 }
	document.write('postcode='+postcode+', title='+title+', scale='+scale);
}