$(document).ready(function(){
    /* choose language */
    var nav_delay = 1000;
    var nav_timer;
     function hideNav(jelement){
        if (typeof(jelement) == 'undefined'){
            jelement = $("ul.topnav");
        }else{
            jelement = $(jelement);
        }
        jelement.parent().find("ul.subnav").slideUp('slow').hide();
        
    }
    function resetTimerNav(){  
        clearTimeout(nav_timer);
    }
    $("ul.topnav>li>a").click(function() { //When trigger is clicked...  
        $("ul.topnav>li>a").parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
        //Following events are applied to the subnav itself (moving subnav up and down)  

        return false;
        //Following events are applied to the trigger (Hover events for the trigger)  
        }).hover(function() {
            
            $(this).addClass("subhover"); //On hover over, add class "subhover"  
        }, function(){  //On Hover Out 
            $(this).removeClass("subhover");
            //clearTimeout(nav_timer);
    });  
    
      
  
    $("ul.topnav").mouseenter(function() {
            if (typeof(nav_timer) != 'undefined'){ 
                clearTimeout(nav_timer);
            }
    });
    $("ul.topnav").mouseleave(function(){
            nav_timer = setTimeout(hideNav,200, [this]); 
            
        });  
  


    /* Connexion form */
    
    function setfocus(element){
        element.focus();
    }
    $(".connect>span").click(function() { //When trigger is clicked...  
        if (!$(this).hasClass('open')){
            return false;
        }
        var div_form = $(this).parent().find("div.ident-form");
        
        $(this).parent().find("div.ident-form").slideDown('fast', function(){setfocus(div_form.find('input[name=login]'));}).show(); //Drop down the subnav on cli
        //$(this).html('<a><?php print $intl_lang->_connexion;?></a>');
        
        
        $(this).addClass('open');
        
        return false;
        //Following events are applied to the trigger (Hover events for the trigger)  
        });
    $('.connect #forgot_btn').click(function(){
        $('#form_conn').hide();
        $('#forget').show();
        return false;
    });
    $('.door').click(function(){
        //Following events are applied to the subnav itself (moving subnav up and down)  
            $("div.ident-form").slideUp('fast').hide(); //Drop down the subnav on click  
            $(".connect>span").addClass('open');
            return false;
    });
    $('.connect #forgot_btn2').click(function(){        
        $('#forget').hide();
        $('#form_conn').show();
        return false;
    });
    
    
    /** box inscription **/
    $(document).ready(function(){
        $('.editeur_inscription').colorbox({href:'/membre/_block/form_preinscription.php',height:'640px',width:'1024px'
            //onClosed:function(){ document.location.href='../' }
        }); 
    });
  
}); 
