function blockSpamBots() {
	$('a[href="mailto:"]').each(function() {
		alert($(this));
		var email = $(this).html();
		alert(email);
	})

}

/*
 * Runs through a document and converts all mailto links into thickbox links that
 * open a form that sends an email to the person clicked on
 *
 */
/*
function convertMailto() {
	var links = document.getElementsByTagName('a');
	for (var i = 0 ; i < links.length ; i++) {
		if(links[i].href.search(/mailto/) > -1) {
			var address = links[i].href.split(':')[1];
			links[i].className += ' thickbox';
			links[i].href = '/advancement/_common_files/email_form.php' + encodeURI('?email_to=' + address + '&TB_iframe=true&height=350&width=500');
			links[i].title = 'Send Email to ' + address;

		}
	}
}
*/
function convertMailto() {
	$('a').each(function() {
		if(this.rel == 'email') {
			var address = $(this).html();
			address = address.replace(/-at-/, '@').replace(/-dot-/, '.');
			$(this).html(address);
			$(this).attr({
				className: 'thickbox',
				href: '/advancement/_common_files/email_form.php' + encodeURI('?email_to=' + address + '&TB_iframe=true&height=350&width=500'),
				title: 'Send email to ' + address,
				rel: ''
			})
		};
	});
//	var links = document.getElementsByTagName('a');
//	for (var i = 0 ; i < links.length ; i++) {
//		if(links[i].rel == ('email')) {
//			var address = $(links[i]).html();
//			address = address.replace(/-at-/, '@').replace(/-dot-/, '.');
//			$(links[i]).html(address);
//			links[i].className += ' thickbox';
//			$(links[i]).attr({
//				href: '/advancement/_common_files/email_form.php' + encodeURI('?email_to=' + address + '&TB_iframe=true&height=350&width=500'),
//				title: 'Send email to ' + address,
//				rel: ''
//			})
//		}
//	}
}

function convertBioLinks() {
	var bioLinks = $('.biolink');
	if(bioLinks.length == 0) return;
	bioLinks.each(function() {
		link = $(this).attr('href');
		$(this).attr({href: link + 'TB_iframe=true&amp;width=400&amp;height=250', className: 'thickbox'});
	});
}

// Expands and collapses Faculty Expert Database list
function toggle_treelist(target) {
	var currentClass = target.parentNode.className;
	if(currentClass == 'collapsed') {
		target.parentNode.className = 'expanded';
	} else if(currentClass == 'expanded') {
		target.parentNode.className = 'collapsed';
	}
}

// Calculates T-Shirt Order form after entering values into the M, L, XL fields
function calculateOrder(f) {
	var quantity = 0;
	quantity += !isNaN(parseInt(f.medium.value)) ? parseInt(f.medium.value) : 0;
	quantity += !isNaN(parseInt(f.large.value)) ? parseInt(f.large.value) : 0;
	quantity += !isNaN(parseInt(f['x-large'].value)) ? parseInt(f['x-large'].value) : 0;

	if(quantity == 0) {
		f.subtotal.value = '';
		f.total.value = '';
	} else {
		f.subtotal.value = '$' + (quantity * 10) + '.00';
		f.total.value = '$' + ((quantity * 10) + 4) + '.00';
	}

}
