﻿function PopupPic(bigPic,title,w,h) {
if (w>500 || h>500){
var winl = (screen.width - 500) / 2;
var wint = (screen.height - 500) / 2;
var smarty_hack = 'head';
var hpercent = 500 / h;
var neww = (hpercent * w) + 20;
newWindow = window.open('','title','height=520,width='+neww+',top='+wint+',left='+winl+',resizable=0,scrollbars=0'); 
newWindow.document.write('<html><head><title>'+title+'</title>'); 
newWindow.document.write('<meta http-equiv="content-type" content="text/html; charset=UTF-8" />'); 
newWindow.document.write('<style type="text/css"></style><!-- html, body {margin: 0px; background-color: #000;} -->'); 
newWindow.document.write('<!--'+smarty_hack+'-->'); 
newWindow.document.write('<p><img height=500 alt="'+title+'" src="'+bigPic+'" /></p>'); 
newWindow.document.write('</body></html>'); 
newWindow.document.close(); 
newWindow.focus();  
} else { 
var winl = (screen.width - w) / 2; 
var wint = (screen.height - h) / 2; 
var smarty_hack = 'head'; 
newWindow = window.open('','title','height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=0,scrollbars=0'); 
newWindow.document.write('<html><head><title>'+title+'</title>'); 
newWindow.document.write('<meta http-equiv="content-type" content="text/html; charset=UTF-8" />'); 
newWindow.document.write('<style type="text/css"></style><!-- html, body {margin: 0px; background-color: #000;} -->'); 
newWindow.document.write('<!--'+smarty_hack+'-->'); 
newWindow.document.write('<p><img alt="'+title+'" src="'+bigPic+'" /></p>'); 
newWindow.document.write('</body></html>'); 
newWindow.document.close(); 
newWindow.focus(); }
}



var extLinks = function() {
   if (!document.getElementsByTagName) return;
   var allLinks = document.getElementsByTagName("a");
   var browser=navigator.appName;
   var b_version=navigator.appVersion;
   var version=parseFloat(b_version);

   
   for(i=0;i<allLinks.length;i++)
   {
   	  var thisLink = allLinks[i].href;
   	  var extLinks = new Array;
   	  if((thisLink.substring(0, 5) == 'http:' || thisLink.substring(0, 6) == 'https:') && thisLink.indexOf('turnersfallsriverculture') == -1)
   	  {
   	  
   	  	  //allLinks[i].setAttribute('onclick', null);
   	  	  
   	  	  if(browser=='Microsoft Internet Explorer' && version<7)
   	  	  {
   	  	  		allLinks[i].setAttribute('onclick', function(){
    			
    				var winId = 'win';
        			var newWin = window.open(this.href, winId);
        			newWin.focus();
        			return false;
		  		});
   	  	  }
   	  	  else 
   	  	  {
   	  	  
	   	  	  	allLinks[i].addEvent('click', function(){
	    				var winId = 'win';
	        			var newWin = window.open(this.href, winId);
	        			newWin.focus();
	        			return false;
			  	});
		  }
   	  }
   }
}



window.onload = extLinks;