// Popup
function popUp (thisURL) { 
	if (document.getElementById) { 
	    // Set the width of your shared popup window here
		thisclass = thisURL.className;
		var finddash = thisclass.indexOf("-") + 1;
		var winheight = thisclass.substr(finddash);
		var winwidth = thisclass.substring(0, finddash - 1);
		width = parseInt(winwidth) + 20;
		height = parseInt(winheight) + 20;
		newwin = window.open(thisURL.href, "popUp", "resizable,width="+width+",height="+height+"");
		newwin.focus();
		return false; 
	} else { 
		return true; 
	} 
}

// This script adds the popup functionality to all links with a class of popup
function popLinks(){
	if (!document.getElementsByTagName) return null;
	var anchors = document.getElementsByTagName("a");
	for(var i=0; i < anchors.length; i++){
		var a = anchors[i];
		var thisclass = a.className;
		if ((thisclass.indexOf("popup") != -1)) { 
			var findunderscore = thisclass.indexOf("_") + 1;
		  	var winparams = thisclass.substr(findunderscore);
		  	a.className = winparams;
		  	
			//a.setAttribute("title","This link will open in a new window with a width and height of "+ winparams +".");  
			thistitle = a.title;
			a.setAttribute("title",thistitle + "  - This link will open in a new window.");  
		  
		 	 // Change the width/height of the popup window below, if you wish
		  	a.onclick = function() { return popUp(this); }
		}
	  }
}

window.onload = function(){
  popLinks();
}
