function displayImage (source, referrer){
// 	alert(source);
	
	// parse the name of the image to display
	if (!source){
		alert ('Failed to load image.');
		return false;
	}
	var image = source.match(/[\w-]+\.(?:jpg|png|gif)/);
	var caption = source.replace(/<[\w\s\/\.="-]*>/, '');
	caption = escape(caption);
	
// 	alert(referrer);
    // pass along the referring page
    // the server will validate it
    var url = 'image.php?im='+image+'&cap='+caption+'&ref='+referrer;
    
	try {
		window.location =url;
	}
	catch (error){
		alert('Cannot show that image: ' + error);
	}
}