//The script scans all the links on a page and lables them based on whether they link to a word, pdf, ppt files
//it also checks if the link is to an externel website and if it is, will lable it that way
//In all these cases, it changes the target of link to _blank

var yourURL = "vcu.edu/cte";
var httpURL = "http";

function fileLinks() {
    var fileLink;
	var MainContent = document.getElementById("MainContent");//scans links only inside the main content area

if (MainContent.getElementsByTagName('a')) {
        for (var i = 0; (fileLink = MainContent.getElementsByTagName('a')[i]); i++) {
            if (fileLink.href.indexOf('.pdf') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pdfLink';
            }
            if (fileLink.href.indexOf('.PDF') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pdfLink';
            }
            if (fileLink.href.indexOf('.doc') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'docLink';
            }
            if (fileLink.href.indexOf('.DOC') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'docLink';
            }
            if (fileLink.href.indexOf('.ppt') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pptLink';
            }
            if (fileLink.href.indexOf('.PPT') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pptLink';
            }
			else {if (fileLink.href.indexOf(httpURL) != -1 && fileLink.href.indexOf(yourURL) == -1) {
		          fileLink.setAttribute('target', '_blank');
				  fileLink.className = 'externalLink';}
			}
        }
    }
}
window.onload = function() {
    fileLinks();
}