var mt = new String()

mt = 'a' + 'i' + 'l'
mt = 'm' + mt 
mt = mt + 't' + 'o' + ':'

function getCp(tag) {
	var kSetU
	var enValU
	var vi
	var ki
	var ret = new String()
	var itm = cp[tag]
	if (typeof(itm) != 'undefined') {
		kSetU = unescape(itm[0])
		enValU = unescape(itm[1])
		ki = 0;
		for (vi = 0; vi < enValU.length; vi++) {
			ret += String.fromCharCode(kSetU.charCodeAt(ki) ^ enValU.charCodeAt(vi));
			if ((++ki) >= kSetU.length) ki = 0
		}
	} else {
		ret = ''
	}
	return ret
}

function isAnchor(a) {
	var ret = false
	if (typeof(a) == 'object') {
		if (a.nodeName == 'A') {
			ret = true
		}
	}
	return ret
}

function openMtUrl(a, tag) {
	if (isAnchor(a)) {
		if (a.isRevealed) {
			window.location = mt + getCp(tag)
		}
	}
	return true
}

function revealMt(a, tag) {
	if (isAnchor(a)) {
		if (a.childNodes.length == 0) {
			a.appendNode(document.createTextNode(getCp(tag)))
		} else {
			a.childNodes[0].nodeValue = getCp(tag)
		}
		a.prevWindowStatus = window.status
		window.status = buildGotoInstruction(tag)
		a.isRevealed = true
	}
	return true
}

function restoreMt(a, tag) {
	if (isAnchor(a)) {
		window.status = a.prevWindowStatus
		a.isRevealed = false
		if (a.childNodes.length != 0) {
			a.childNodes[0].nodeValue = buildHoverInstruction(tag)
		}
	}
	return true	
}

function buildHoverInstruction(tag) {
	return "Mouse over to reveal"
}

function buildGotoInstruction(tag) {
	return "Click to send email"
}

function insertContactPoint(tag, className) {
	var ret = new String()
	ret = '<' 
			+ 'a href="javascript:void(0);"'
			+ ' onMouseOver="return revealMt(this,\''+ tag + '\');"'
			+ ' onClick="return openMtUrl(this,\'' + tag + '\');"'
			if (className) {
				ret += ' class="' + className + '"'
			}
			ret += '>'
			ret += buildHoverInstruction(tag)
			ret += '<' + '/a' + '>'
	document.write(ret)
}

function insertContactPoint_OLD(tag, className) {
	var ret = new String()
	ret = '<' 
			+ 'a href="javascript:void(0);"'
			+ ' onMouseOver="return revealMt(this,\''+ tag + '\');"'
			+ ' onMouseOut="return restoreMt(this,\'' + tag + '\');"'
			+ ' onClick="return openMtUrl(this,\'' + tag + '\');"'
			if (className) {
				ret += ' class="' + className + '"'
			}
			ret += '>'
			ret += buildGotoInstruction(tag)
			ret += '<' + '/a' + '>'
	document.write(ret)
}

