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

function mailBig(name, dom, tl, params)
{
	var s = e(name,dom,tl);
	document.write('<a class="linkBlack" 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: 3px; top: 3px; } </style></head>');
  imgWindow.document.write('<body bgcolor="#0D74D5" 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','','');
}