// external links open in new window

function externalLinks()
{
	var anchors,i;
	
	anchors = document.getElementsByTagName('a');
	for (i=0;i<anchors.length;i++)
	{
		if (anchors[i].getAttribute('href') && anchors[i].className.match('external'))
		{
		anchors[i].target = "_blank";
		}
	}
}

// create pop-up if link is inside 'photos' id

function changeLinks()
{
	var ph,as,i,islink;
// grab all links, loop over them;
	ph=document.getElementById('photos')
	as=ph.getElementsByTagName('a');
	for(i=0;i<as.length;i++)
		{
// check which link has a rel attribute, and send this one to popup
			if(as[i].getAttribute('rel')!='')
			{
				as[i].onclick=function(){return(popup(this));};
				//ph[i].onkeypress=function(){return(popup(this));};
			}
		}
}


// new window pop-up for images 

function popup(o)
{
// open a new window with the location of the link's href
	var popWin=window.open(o.href,'newwin','resizable,top=10,height=625,width=625');
// focus popWin if it is sent behind a window
	if (window.focus) {popWin.focus()}
	return false;
}


// Run when page loads

if(document.getElementById && document.createTextNode)
{
	window.onload=function()
	{
	externalLinks();
	changeLinks();
	}
}
