download image first, then apply fadeIn

download image first, then apply fadeIn

i have this code that works
  1. <head>
  2. <script type="text/javascript">
  3. $(function () {
  4. var img = new Image();
  5. $(img).load(function () {
  6. $(this).hide();
  7. $('#divContent').append(this);
  8. $(this).fadeIn();
  9. }).attr('src', 'images/main.jpg');
  10. });
  11. </script>
  12. </head>
  13. <body>
  14. <div id="divContent"></div>
  15. </body>
but this code limits 1 image and the name of the image is placed inside the js function. 
my question is: 
can i alter this code or can someone share an idea to write a more generic version so that i can download the image first THEN apply some jQuery to it like:
  1. <head>
  2. <script type="text/javascript">
  3. $(function () {
  4. var img = new Image();
  5. $(img).load(function () {
  6. $(this).hide();
  7. $('#divContent').append(this);
  8. $(this).fadeIn();
  9. }).attr('src', 'APPLY TO THE DIV HERE');
  10. });
  11. </script>
  12. </head>
  13. <body>
  14. <div id="divContent"><img src="images/main.jpg" /></div>
  15. </body>