var LeafThumbnail = new Class ({
    initialize : function () {
        this.contentArea = $('LeafContent');
        // hook into all the edit links
        $$('div.edit a').each( function (item) {
            item.addEvent('click', function(e) {
                var ev = new Event(e).stop();
                var contentArea = $('LeafContent');
                var url = this.getProperty('href');
                var sw = new StickyWinFxModal.Ajax({
                    url : url,
                    //draggable: true,
                    wrapWithStickyWinDefaultHTML : true,
                    relativeTo : $('LeafContainer'),
                    /*upper left corner of fxTarget */
                    position: 'upperRight',
                    offset: { 
                        x : 0,
                        y : 0
                    },
                    //width : contentArea.getComputedSize().width,
                    //height :  contentArea.getComputedSize().height,
                    modalOptions: {
                        'background-color':'#d6e1b9',
                        'opacity':.6
                    },
                    
                    stickyWinHTMLOptions : {
                        width : contentArea.getComputedSize().width
                    },    
                    onDisplay: function () {


                        // add on click event to the cancel button
                        var oFCKeditor = new FCKeditor('editcontent');
                        
                        // this is not needed because the closeSticky class was applied to the element
                        // add onclick event to the save button
                        $('save').addEvent('click', function (e) {
                            var ev = new Event(e).stop();
                            $('editContentForm').send({
                                onComplete : function() {
                                    $('LeafContent').innerHTML = $('editcontent').value;
                                }
                            });
                        });                        
                        // make the cancel button non propigating
                        $('cancel').addEvent('onclick', function (e) {
                            var ev = new Event(e).Stop();
                        });                    
                    }
                }).update();
            });
        }.bind(this));
    },
    
    updatecontent : function () {
        
    }
    
    
});

window.addEvent('domready', function(e) {
    var leafThumbnail = new LeafThumbnail();

});