﻿$(document).ready(function () {
    jQuery("img.delayLoad").each(function () {
        var delaySpan = document.createElement("span");
        jQuery(this).wrap(delaySpan)
        .hide()

        // Simulate the mouse over the image, whcih will cause it to switch the img src
        .mouseover()

        // Remove the mouseover attribute (since we don't want to update the img src every time the user does a mouseover
        .removeAttr("onmouseover")

        // Simulate the mouse moving out of the image (To reset the image to its normal state)
        .mouseout()

        // Once the image is loaded, perform a function
        .load(function () {
            // Fade the image in
            // Remove the span by unwrapping the image
            jQuery(this).fadeIn().unwrap();
        });
    });
});
