// Goes through all links on the page and determines if they are to files by
// checking their file extension.  If they are not web pages, the appropriate 
// icon is added to the link.

function addLinkIcons() {
	var iconBefore = false;  // If true, the icon shows before the text.  False = after.
	var lnks = document.links;
	var i;
	for(i=0; i<lnks.length; i++) {
		var l = lnks[i];
		var txt = l.innerHTML;
		var loc = (l.href + "").toLowerCase();
		if (loc.charAt(loc.length-1)=="/"){
				loc=loc+"index.htm";
		};  // if ends in "/"
		var parts = loc.split(".");
		var typ = (parts[parts.length-1]).toLowerCase();
		var iconCode = "";
		
		if ((l.target.toLowerCase() == "_blank")&&(l.className != "noIcon")) {
			//l.innerHTML += "<img class=\"icon\" src=\"../imagenes/ms_ie_1.jpg\" border=\"0\">";
			iconCode = "<img class=\"icon\" src=\"../imagenes/smextlink.gif\" height=\"9\" width=\"16\" style=\"padding-right:4px;\" border=\"0\" alt=\"This link opens a new browser window.\">";
		};  // if link opens in a new window
		
		switch(typ) {
			case "htm":
			case "html":
			case "asp":
			case "aspx":
				
				break;
			case "chm":
				iconCode = "<img class=\"icon\" src=\"../imagenes/chm.gif\" height=\"17\" width=\"16\" border=\"0\" alt=\"This requires The Windows Help System.\">";
				//l.target = "_blank";
				break;
			case "zip":
				 iconCode = "<img class=\"icon\" src=\"../imagenes/zip.gif\" height=\"21\" width=\"22\" border=\"0\" alt=\"This requires WinZip or a similar file decompression utility.\">";
				//l.target = "_blank";
				break;
			case "doc":
			case "dot":
				iconCode = "<img class=\"icon\" src=\"../imagenes/word.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"This requires MS Word.\">";
				//l.target = "_blank";
				break;
			case "pdf":
				iconCode = "<img class=\"icon\" src=\"../imagenes/pdf.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"This requires Adobe Acrobat Reader.\">";
				//l.target = "_blank";
				break;
			case "xls":
			case "xlw":
			case "xlt":
			case "xla":
			case "csv":
				iconCode = "<img class=\"icon\" src=\"../imagenes/excel.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"This requires MS Excel.\">";
				//l.target = "_blank";
				break;
			case "ppt":
			case "ppa":
			case "pps":
				iconCode = "<img class=\"icon\" src=\"../imagenes/powerpoint.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"This requires MS Powerpoint.\">";
				//l.target = "_blank";
				break;
			case "vso":
			case "vsd":
				iconCode = "<img class=\"icon\" src=\"../imagenes/visio.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"This requires MS Visio.\">";
				//l.target = "_blank";
				break;
			case "asf":
			case "wma":
			case "wax":
			case "wmv":
			case "wmx":
			case "wvx":
			case "avi":
			case "wav":
			case "mpeg":
			case "mpg":
			case "mpe":
			case "m1v":
			case "mp2":
			case "mpv2":
			case "mp3":
			case "mpa":
			case "m3u":
			case "midi":
			case "mid":
			case "rmi":
			case "aiff":
			case "aif":
			case "aifc":
			case "au":
			case "snd":
			case "asx":
			case "wpl":
			case "wm":
			case "wmx":
			case "wmd":
			case "wmz":
			case "cda":
				iconCode = "<img class=\"icon\" src=\"../imagenes/media.gif\" height=\"18\" width=\"18\" border=\"0\" alt=\"This requires Windows Media Player.\">";
				//l.target = "_blank";
				break;
		};  // switch(typ)
		
		// If there is an icon to add, place it before or after the text as 
		// defined by iconBefore.
		if (iconCode.length>0) {
			if (iconBefore) {
				l.innerHTML = iconCode + "&nbsp;&nbsp;" + l.innerHTML;
			} else {
				l.innerHTML = l.innerHTML + "&nbsp;" + iconCode;
			};  // if iconBefore .. else
		};  // if iconCode >0
	};  // for i
};  // addLinkIcons()


