//////////////////////////////////////////////
//
// JavaScript Functions
//
// email.js: Generic functions for working with e-mails on web pages
//
//////////////////////////////////////////////


// generic function, compiles e-mail address and pop-up new email
// window with passed address added.
// prevents spam bots
function CreateMail(User, Domain)
{
//alert("boo")
	LocationString = "mailto:" + User + "@" + Domain
//alert(LocationString)
//alert(document.location.href)	
  document.location.href = LocationString
	
}

// Functions to creates (hopefully) spam proof e-mail address links.
// In all cases, Contents is the HTML to be included between the opening
// and closing tags.  If missing, the address is printed.
// In all cases, the string in ExtraCode is added to 
// the anchor tag after the href value.  If missing, nothing is added.

var charPeriod = '&#46;';

// Pass User and Host for User@Host.com
function WonderfulThingCom(User, Host, Contents, ExtraCode) {
	GenerateMailto(User, Host + charPeriod + 'com', Contents, ExtraCode);
}

// Pass User and Host for User@Host.net
function WonderfulThingNet(User, Host, Contents, ExtraCode) {
	GenerateMailto(User, Host + charPeriod + 'net', Contents, ExtraCode);
}

// Pass User and Host for User@Host.whatever
function WonderfulThing(User, Host, Contents, ExtraCode) {
	GenerateMailto(User, Host, Contents, ExtraCode);
}

// Pass User and Host for User@Host.co.uk
function WonderfulThingCoUk(User, Host, Contents, ExtraCode) {
	GenerateMailto(User, Host + charPeriod + 'co' + charPeriod + 'uk', Contents, ExtraCode);
}

function GenerateMailto(User, Domain, Contents, ExtraCode) {
	var charAtSign = '&#64;';
	var Address = User + charAtSign + Domain;
	
	document.write('<' + 'a' + ' ' + 'href="' + 'mail' + 'to:' + Address + '"');
	if (ExtraCode)
		document.write(" " + ExtraCode);
	document.write('>');
	if (Contents)
		document.write(Contents);
	else
		document.write(Address);
	
	document.write('</a>');
}
