// JavaScript Document

$.get("/content/student/glossary/glossary.xml", function(glossXML){

	var $gloss = $(glossXML);	//store the XMLHTTPRequest from $get in a jQuery object
	
	/////////////////////////////////////////
	$("dfn")		//find <dfn> elements in page
		.each(function(){
			
			var $this = $(this);
			
			var termString = $.trim($this.text());
			var safeString = termString.toLowerCase();
			
			var dfnText = $gloss.find('term[@name^="' + termString + '"], term[@name^="' + safeString + '"]').text();
			
			$this
				.attr("title", function(){
					return (this.innerHTML + "|" + dfnText);
				})
				.css({
					borderBottom: '1px dotted #666',
					cursor: 'help'
				})
				.cluetip({
					splitTitle: '|',
					positionBy: 'mouse',
					width: 370,
					leftOffset: 30,
					cluetipClass: 'jtip'
				});
		});
	/////////////////////////////////////////

}, "xml");

