//****************************************
// this function is used to create an array of functions to execute upon page load
//
// to register an event with the onloader, si

function add_load_event(func){
	var oOldOnLoad = window.onload;
	if(typeof window.onload != 'function'){
			window.onload=func;
	}
	
	else {
		window.onload=function(){
			oOldOnLoad();
			func();
		}
	}//alert("loader action added");
}


//****************************************
// 


//****************************************
//this function scans through all anchors and maintains an array of anchors with the 
// rel attribute set to 'external'
// when any of the anchors stored in the array are clicked, the href URI will open in an 
// external window

function register_external_links(){
	if(!document.getElementsByTagName){
		return false;
	}
	var oAnchors = document.getElementsByTagName("a");
	for(var i=0; i<oAnchors.length; i++){
			var oAnchor = oAnchors[i];
			if(oAnchor.getAttribute("href") && oAnchor.getAttribute("rel")==("external")){
				var sLink = oAnchor.getAttribute("href");
				/*if(sLink.substr(-4)==".pdf"){
					return true;
				}
				else{*/
					oAnchor.target="_blank";
				//alert('external link '+oAnchor.href);
				//}
			}
			else if(oAnchor.getAttribute("href") && oAnchor.getAttribute("rel")==("presspop")){
				var sDocument = oAnchor.getAttribute("href");
				var sTitle=oAnchor.getAttribute("title");
				//alert('popup link detected\n ready to open '+sDocument +' in a window!');
				oAnchor.onclick = function (){
				var oPresswindow =window.open('/press/pressholder.php?presstitle='+this.title+'&press='+this.href, 'presswindow', 'height=580,width=710,status=no,toolbar=no,resizable=yes,scrollbars=yes');
				oPresswindow.focus();
				return false;
				};
			
			}
	}
}

add_load_event(register_external_links);