$(document).ready(function() {
    var items = document.getElementsByTagName('span');
	for(var i = 0; i < items.length; i++) {
	    if(items[i].className == 'construct-contact') {
			var str = items[i].getAttribute('title');
			items[i].removeAttribute('title');
			var frags = str.split(",");
			
			if(frags.length >= 3) {
				constructContact(items[i], frags);
			}
		}
	}
});

function constructContact (span, args) {
	var email = args[0]+"@"+args[1]+"."+args[2];
	var name = args[3];
	var title = args[4];
	var phone = args[5];

	if(title.length) { name = name + ', ' + title; }
	if(!name.length) { name = email; }

	var contact = "<a href='mailto:"+email+"'>"+name+"</a>";
	if(phone != null) {
		contact = contact + ' - ' + phone;
	}
	span.innerHTML = contact;
};

function writemail(a,b,c,d){
	if (d){
		the_string = "<a href='mailto:"+a+"@"+b+"."+c+"'>"+d+"</a>";
	} else {
		the_string = "<a href='mailto:"+a+"@"+b+"."+c+"'>"+a+"@"+b+"."+c+"</a>";
	}
	return (the_string);
};

function writemail2(a,b,c,d){
	the_string = "<a href='mailto:"+a+"@"+b+"."+c+"'>"+d+"</a>";
	return (the_string);
};