// JavaScript Document
var spec= [
            ["\.doc$", "Click to load this Word document", "DOC"],
            ["\.dot$", "Click to load this Word document template", "DOT"],
            ["\.rtf$", "Click to load this Richtext document", "RTF"],
            ["\.ppt$", "Click to load this PowerPoint document", "PPT"],
            ["\.pps$", "Click to load this PowerPoint show", "PPS"],
            ["\.xls$", "Click to load this Excel document", "XLS"],
            ["\.pdf$", "Click to load this PDF file", "PDF"],
            ["\.swf$", "Click to display this FlashPaper file", "SWF"],
            ["\.avi$", "Click to play video", "MOV"],
            ["\.mov$", "Click to play video", "MOV"],
            ["\.mpeg$","Click to play video", "MOV"],
            ["\.mpg$","Click to play video", "MOV"],
            ["\.wmv$", "Click to play video", "MOV"],
            ["\.rm$",  "Click to play video", "MOV"]
];
//-----------------------------------------------------------------------
var externalInfo =   ["http://", "External Link", "external"];
jQuery(document).ready(function(){
    jQuery('/html/body//div[@class=node]//a').each(function(i){
        var $hr = jQuery(this).attr("href");

        if($hr != null){
        	$hr = $hr.toLowerCase();
            var $newVal ="";
            var $newCalss =""
            var $isExternal = false;

            jQuery.each( spec, function(i, n ){
                if($hr.match(n[0])!= null){
                    $newVal = n[1];
                    $newClass = n[2];
                }
            });

			// check to see if this link is external link
			if($hr.match(externalInfo[0])){
				$isExternal = true;
            }
			
			if($newVal.length > 0 ){
				// add google analytics code	
				   jQuery(this).click(function () { 
						pageTracker._trackPageview($hr)
					});
			}
						
            // internal files
 	        if($newVal.length > 0 && $isExternal == false){
    	    	this.title = $newVal;
                jQuery(this).attr("class", $newClass);
			}

            // external files
 	        if($newVal.length > 0 && $isExternal == true){
    	    	this.title = $newVal;
                jQuery(this).attr("class", externalInfo[2] + $newClass);
				jQuery(this).attr("target", "_blank");				                
			}

			// external links
			if($newVal.length <= 0 && $isExternal == true){
                jQuery(this).attr("class", externalInfo[2]);
				jQuery(this).attr("target", "_blank");				                
			}
        }
    });
 });

