/* é unicode */
function projet() {

	$("a.galerieRotary").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
	if ($('#recherche').val() != '' && $('#recherche').val() != ' ') {
		$('#recherche').css('background','#FFF');
	}
	
	$('#recherche').focus(function(){
		$(this).css('background','#FFF');
	});
	$('#recherche').blur(function(){
		if ($(this).val() == '' || $(this).val() == ' ') {
			$(this).css('background','#FFF url(see/bg_recherche.gif) 3px center no-repeat');
		}
	});
	
	menu_deroul();

}

function menu_deroul() {
	jQuery(function() {
	
    var $ = jQuery;
    // retarder
        $.fn.retarder = function(delay, method){
        var node = this;
        if (node.length){
            if (node[0]._timer_) clearTimeout(node[0]._timer_);
            node[0]._timer_ = setTimeout(function(){ method(node); }, delay);
        }
        return this;
    };
    
    // base rules
    $('#hornav').addClass('js-active');
    $('#hornav ul div', '#hornav').css('visibility', 'hidden');
		if (!$('#hornav li.current').length) $('#hornav li:first').addClass('active');     
    $('.menu>li', '#hornav').hover(
        function(){
            var ul     = $('div:first', this);
            if (ul.length){
                if (!ul[0].hei) ul[0].hei = ul.height();
                ul.css({height: 20, overflow: 'hidden'}).retarder(10, function(i){
                    i.css('visibility', 'visible').animate({height: ul[0].hei}, {duration: 350, complete : function(){ ul.css('overflow', 'visible'); }});
                });
            }
        },
        function(){
            var ul  = $('div:first', this);
            if (ul.length){
                var css = {visibility: 'hidden', height: ul[0].hei};
                ul.stop().retarder(0, function(i){ i.css(css); });
                
            }
        }
    );
    
    $('ul ul li', '#hornav').hover(
        function(){
            var ul     = $('div:first', this);
            if (ul.length){
                if (!ul[0].wid) ul[0].wid = ul.width();
                ul.css({width: 0, overflow: 'hidden'}).retarder(10, function(i){
                    i.css('visibility', 'visible').animate({width: ul[0].wid}, {duration: 200, complete : function(){ ul.css('overflow', 'visible'); }});
                });
            }
        },
        function(){
            var ul  = $('div:first', this);
            if (ul.length){
                var css = {visibility: 'hidden', width: ul[0].wid};
                ul.stop().retarder(0, function(i){ i.css(css); });
            }
        }
    );
	
	$('#hornav li:has(ul) > a').addClass('parent');
	//$('#hornav ul:empty').text("vide"); // select les line breaks
	
});

}
