var App = {

    
    init : function() {
        
        var tEffect = 200;
        
        
        //on recherche la taille de la zone d'affichage
        
        var zzz = 100;
        
        var w = $(window);
        var wh = w.height();
        var ww = w.width();
        
        //on soustrait quelques pixel par sécurité
        //var wh = wh - 50;
        //var ww = ww - 50;
        
        var bg = ['red','yellow','cyan','blue', "green"];
        var bgL = bg.length;
        
        var op = 0.8 //opacity
        
        //alert ( wh + " x " + ww + " l " + bgL );
        
        /*
        //autohide des champs de détails e-mail
        var ah1 = $("#autohide1");
        ah1.hide();
        
        //apparition du détail des emails au passage sur l'asterisque
        
        $("#hider1").hover( function(){
            ah1.show();        
        }, function() {
            ah1.hide();    
        });
        */
        
        
        //on commence par placer le formulaire au millieu de la page
        
        var f = $('#form');
        var ft = (wh - f.height()) / 2 ; 
        var fl = (ww - f.width()) / 2 ; 
        
        
        f.css({
            'top' : ft + "px",
            'left' : fl + "px"
        });
        
        f.draggable({ containment: 'window' });
        
        f.find("span").click( function() {
            f.hide('puff',tEffect);
        });
  
        
        
        f.hover( function() {
            zzz += 1;
            f.css({
                'z-index' : zzz
            });    
        }, function() {
            /*
            f.css({
                'z-index' : 0
            });
            */
            
        });
        
        
        
        
        //on boucle sur la liste de tous les post
        $('.post').each( function() {
                  
            //on cache le this...
            var t = $(this);
            
            t.draggable({ containment: 'window' });
            
            t.css({
                //'position' : 'absolute' ,
                //'opacity' : op ,
                'top' : Math.floor( Math.random() * (wh - t.height() ) ) + "px" ,
                'left' : Math.floor( Math.random() * (ww - t.width() ) ) + "px"
                
            });
                   
            //au click sur l'élément, on le cache
            
            t.find("span").click( function() {
                t.hide('puff',tEffect);
            });
            
            
            //au hover, il devient plus lisible et passe au premier plan...
            
            
            t.hover(function() {
                zzz += 1;
                t.css({
                    'z-index' : zzz
                    //'opacity' : 1
                });
                /*
                t.find(".b1").css({
                    'background-image' : 'url(images/box3.png)'
                });
                */
                
                t.find(".b1").addClass('b1Hover');
                
                
            }, function() {
                
                /*
                t.css({
                    'z-index' : 0 
                    //'opacity' : op 
                });
                */
                
                /*
                t.find(".b1").css({
                    'background-image' : 'url(images/box1.png)'
                });
                */
                t.find(".b1").removeClass('b1Hover');
                
                
            });
            
            
            
            
        });
        
    }
}


$(document).ready( function() { App.init(); } );
