/*
 * Using jQuery, check any comments against 
 * Flickr account.
 *
 * Wulf Forrester-Barker, 20070307
 */

$(document).ready(function() {

	var sInitial = '<img alt="Comment Link" title="Click here to add ';
	sInitial += 'a comment" src="http://www.web-den.org.uk/images/';
	sInitial += 'greenloader.gif"/></a>';
	sInitial += "<p>Checking for existing comments. Want ";
	sInitial += "to add something? Click on the picture to add ";
	sInitial += "a comment and join the conversation about this ";
	sInitial += "posting.</p>\n\n<p>(Nb. Yahoo! account required)</p>";

	// First pass expands sections
	$("div.flickrcomment").each(function(){
		var aFlickr = this.id.split("-");
		var sPicID = aFlickr[1];
		var sPicLink = '<a href="http://www.flickr.com/photos/wulf/'
		sPicLink += sPicID + '/">' + sInitial
		$(this).empty().append(sPicLink);
	});

	$("div.flickrcomment").each(function(){
		var aFlickr = this.id.split("-");
		var sPicID = aFlickr[1];
		$(this).load("http://www.web-den.org.uk/scripts/flickrgrab.php",
			{photo_id:sPicID},function(){
				$(this).show();
			}
		);
	});
});
