$().ready(function(){
    var dialog = new Ctrl_Dialog_Ajax({
        dialogClass: 'gallery',
        resizable: false,
        draggable: true,
        show: 'fade',
        hide: 'fade',
        autoLoad: false,
        width: 800,
        height: 600,
        position: ['center', 106]
        
    });
    //dialog.window.find('.ui-dialog-titlebar').hide();
    
    var ss;
    
    $('#nav-about-story a, #about-fade a.story, #nav-about-green a, #about-fade a.green').click(function(){
        dialog.setSrc(this.href + '?format=html', function(){
            ss = $('ul.images li', this.elem).slideshow({
                delay: 6000,
                autostart: false
            });
            /*
            var l = [];
            ss.elem.each(function(i){
                l.push('<a href="#slideshow-' + i +'">•</a>')
            });
            var lW = l.length * 17;
            l = $('<div id="index">'+ l.join('') +'</div>').css({width: lW, left: 400 - (lW/2)});
            l.find('a').click(function(){ ss.stop().to(this.hash.replace(/[^0-9]/gmi, '')); return false; }).eq(0).addClass('active');
            
            ss.elem.bind('slideshow-post-in', function(){ l.find('a').eq(ss.pointer).addClass('active').siblings().removeClass('active'); })
            */
            $('#gallery', this.elem).append($('<a id="next" href="#" title="Next Page">Next</a>').click(function(){ ss.stop().next(); return false; }).hide())
                                  .append($('<a id="prev" href="#" title="Previous Page">Back</a>').click(function(){ ss.stop().prev(); return false; }).hide())
                                  .hover(function(){ $('#next, #prev').fadeIn(); }, function(){ $('#next, #prev').fadeOut(); });
                                  //.append(l);
            
                        
            this.window.css({overflow: 'visible'});
        
            this.open(); 
        });
        
        return false;
    });    
    
    var over = $('#about-fade');
    if(over.length) {
        $('#content').hover(function(){ over.css('visibility', 'visible').fadeTo(400, 0.8); }, function() { over.fadeTo(400, 0, function() { $(this).css('visibility', 'hidden'); }); });
    }
    
});

