function makeBlackAndWhite(img){

	var parent = img.up('a');
	var imgurl = img.readAttribute("src");

	var img_width = img.readAttribute("width");
	var img_height = img.getHeight("height");

	if ( img_width > 0 ){
		parent.setStyle({ height: img_height+"px", width: img_width+"px" });
	}

	parent.setStyle({display: 'block', position: 'relative'});

	parent.update('');

	new Ajax.Updater(parent, '/cm/data/worthers/scripts/ajax.bwandcolourimage.php', {
		parameters: { imgurl: imgurl }
	});

}


function worthersUiInit(scope){

	scope.select('a img').each( function(img){

		if ( img.readAttribute("class") != "doNotBW" ){
			makeBlackAndWhite(img);
		}

	});

}


document.observe("dom:loaded", function() {

	$$('body').each(function(elt){
		worthersUiInit(elt);
	});

});
