$(document).ready(function() {
	truncateLinks();
});


function addEvent(obj, evType, fn, useCapture){
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else alert("Handler could not be attached");
}

function addSlashes(str) {
	return str.replace("'","\'");
}

function truncateLinks() {
//	Looks for any URLs on the page that contain both cla.purdue.edu domain and an index.html reference and removes the index from the URL.
	var links = document.getElementsByTagName('a');
	for (var a=0; a<links.length; a++) {
		href = links[a].href;
		if (href.indexOf('cla.purdue.edu')>-1 && href.indexOf('/index.')>-1) {
			href = href.replace('index.html','');
			href = href.replace('index.htm','');
			href = href.replace('index.cfm','');
			href = href.replace('index.asp','');
			href = href.replace('index.php','');
			links[a].href = href;
		}
	}
}
