
var ffview=
{
    
/**
 * 
 * @param {Object} linkElement  
 * @param {Object} thumbNameFn function to convert thumb URLs into URLS for the large images
 */
initialize:
    function(linkElement)
    {
        
        console.debug("initialize %x", linkElement);

        try    
        {
    
            var imgElement=linkElement.getElementsByTagName("img")[0];
            
            if (!imgElement)
                throw "No image element found.";
                     
            var src=ff.dom.getAttribute( linkElement, "href");
            var img=ffview.Image(src);                    
            img.title=ff.dom.getAttribute( imgElement, "alt");
            
            ff.event.add(linkElement, "click", img.onCreate);
        }
        catch(e)
        {
            log.error(e);        
        }        
    }, 

Image:
    function(src)       
    {
        var self;        
        return self = {            
        closeButton: null,       
        close:
            function()
            {
                ff.event.add(this.closeButton, "click", this.onClose);                

                var container=this.closeButton.parentNode;
                document.body.removeChild(container);
            },        
        
        onCreate:
            function(ev)
            {
                try
                {
                    document.body.appendChild(
                        DIV({"class":"ffvimg"},
                            DIV({"class":"title"},
                            self.closeButton = SPAN({"class":"closeButton"},"x")),
                            self.title,
                            IMG({"src": src})) );
                    
                    ff.event.add(self.closeButton, "click", self.onClose);
                }
                catch(e)
                {
                    console.error(e);
                }                
                ff.event.preventDefault(ev);
            },
        onClose:
            function(ev)
            {                
                self.close();
            },
        };        
    },
transform:
    function(image)
    {
        // add a click event handler         
        ff.event.add(link, "click", this.onCreate);
        self.close(this);
    },        
};

ff.dom.init(window);
ff.event.onload(function()
{
    console.debug("onload");
    // intialize every <a class="ffshow"><img src="..."/></a>   
    ff.forElement("a", "ffshow", ffview.initialize);
});
