pollen = {

    /*
    Load the image at URL src. Once it's loaded optionally call the callback function.
    The callback should take two parameters: the image URL (src) and the
    image itself.
    */
    loadImage: function(src, callback) {
        var img = new Image();
        if (callback) {
            img.onload = function() {callback(src, img);}
        }
        img.src = src;
    },

    /*
    Replace the input submit button with an image.
    */
    replaceButtonWithImage: function(e, imageSrc) {

        if(typeof(e) == 'string') {
            e = document.getElementById(e);
        }

        imageLoaded = function(src, img) {
            e.style.backgroundImage='url('+src+')';
            e.style.border='solid 0px red';
            e.style.padding = '0px';
            e.style.width= img.width+'px';
            e.style.height= img.height+'px';
            e.value = '';
        }
        
        var is_safari = (document.childNodes) &&
            (!document.all) &&
            (!navigator.taintEnabled) &&
            (!navigator.accentColorName) ? true:false;
        if (is_safari) {
            return;
        }
        
        pollen.loadImage(imageSrc, imageLoaded);
    }
}


