Regarding your second requirement - you might be able to utilise the onerror event, ie. <img onerror="some javascript;"...
Update:
You could also try iterating through document.images
in the dom. There is a complete
boolean property which you might be able to use. I don't know for sure whether this will be suitable, but might be worth investigating.