function photobar_load()
{
	var photosEle = document.getElementById( 'photos' );
	if( !photosEle )
		return;
	
	var linkList = photosEle.getElementsByTagName( 'a' );
	for( var i = 0; i < linkList.length; ++i )
	{
		var link = linkList[ i ];
		var imgSrc = link.href;
		
		link.onclick = photobar_createClickHandler( imgSrc );
	}
}

function photobar_createClickHandler( imgSrc )
{
	return function()
	{
		photobar_openImageWindow( imgSrc );
		return false;
	};
}

function photobar_unload()
{
	var photosEle = document.getElementById( 'photos' );
	if( !photosEle )
		return;
	
	var linkList = photosEle.getElementsByTagName( 'a' );
	for( var i = 0; i < linkList.length; ++i )
		linkList[ i ].onclick = null;
}


var g_photobar_imgWindow = '';
function photobar_openImageWindow( destination )
{
	if( !g_photobar_imgWindow.closed && g_photobar_imgWindow.location )
		g_photobar_imgWindow.location = destination;
	else
	{
		g_photobar_imgWindow = window.open( destination, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=530,height=405" );
		if( !g_photobar_imgWindow.opener )
			g_photobar_imgWindow.opener = self;
	}
	
	// Bring the window to the foreground.
	if( g_photobar_imgWindow.focus )
		g_photobar_imgWindow.focus();
}