﻿// -----------------------------------------------------------------------------
//    POPUP WINDOW : REL EXTERNAL LINK SCRIPT
// -----------------------------------------------------------------------------

 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


/* This is our current popup function - parts of the site still use it, so I need to keep it */

function acpopup(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
window.open(strURL, '', strOptions);
}


/* new accessible, unobtrusive popup code */

function windowLinks() {                      
    if(!document.getElementsByTagName) {      
         return;                              
    }
	
    var anchors = document.getElementsByTagName("a"); 
    for (var i = 0; i < anchors.length; i++) {        
         var anchor = anchors[i];                     
         var relIndex = anchor.rel;                   
		 if (relIndex){                               
		 var relSplit = relIndex.split("|");          
		 
/* XHTML compliant target attribute */

		 if (relSplit[0] == "external") {       
            anchor.target = "_blank";           
			anchor.className = "external";      
			anchor.title = "Load in new window: "+ anchor.href;  
			
/* Elegantly degrading window code */

   			} else if (relSplit[0] == "popup") {      
			anchor.className = "popup";              
			anchor.title = "Loads in a Popup Window"; 
			anchor.popupWidth = relSplit[1];          
			anchor.popupHeight = relSplit[2];         
	        anchor.onclick = function() {acpopup(this.href,'console',this.popupWidth,this.popupHeight);return false;};
			}
		}
	  }
} 

addLoadEvent(function() {
	windowLinks();	
	//otherFunctions();
	//goHere();
});
  

