/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
}  

/* this is the main function that adds classes to links based on their type */
/* it's mainly meant to help IE along, as it does not understand the CSS2 selectors used */
function addClasses() {
	/* get all a elements - warning: this may be slow on big pages with lots of links! */
	elements = document.getElementsByTagName('a');
	/* loop through the array of elements */
	n_elements = elements.length;
	for (i = 0; i < n_elements; i++) {
		/* this is fairly kludgey...could probably be solved a lot cleaner with a nice associative array */
		switch (elements[i].getAttribute('type')) {
			case "application/pdf":
				elements[i].setAttribute('className','pdf');
				break;
			case "application/msword":
				elements[i].setAttribute('className','doc');
				break;
			case "video/quicktime":
				elements[i].setAttribute('className','qt');
				break;
		}
	}
}

/* add function to the page's onload handler */
addEvent (window,'load',addClasses)