
/**
 * Search box
 **/

$(function(){
    /**
     * Icone qui sort quand on passe le curseur dessus
     */
    $("#syndication a").hover(
            function () {
              if (!$(this).hasClass('iconhover')) {
                  $(this).addClass("iconhover");
              }
            },
            function () {
               if ($(this).hasClass('iconhover')) {
              $(this).removeClass("iconhover");
               }
            }
          );

    /**
     * Menu déroulant à gauche
     */
    $('#menu-point1').click(function(){
        var $this = $(this);
        var $next = $(this).next();
        var duration = 250;

        if ($next.is(':visible')) {
            $next.slideUp(duration);
        } else {
            $next.slideDown(duration);
        }
    });

    $('#search-button').click(function(){
        var $this = $(this);
        var duration = 200;

        if ($this.hasClass('on')) {
            // Fermeture
            $('#search form').fadeOut(duration, function(){
                $('#search').slideUp(duration, function(){
                    $this.removeClass('on');
                });
            });
        } else {
            // Ouverture
            $('#search form').hide();
            $('#search').slideDown(duration, function(){
                $('#search form').fadeIn(duration, function(){
                    $('#search-keyword').focus();
                });
            });

            $this.addClass('on');
        }
    }).unselectable();
});


/**
 * Plugin Jquery Unselectable
 * @author Samele Artuso <samuele.a@gmail.com>
 */

(function($) {
    $.fn.unselectable = function() {
        return this.each(function() {

            $(this)
                .css('-moz-user-select', 'none')        // FF
                .css('-khtml-user-select', 'none')      // Safari, Google Chrome
                .css('user-select', 'none');            // CSS 3

            if ($.browser.msie) {                       // IE
                $(this).each(function() {
                    this.ondrag = function() {
                        return false;
                    };
                });
                $(this).each(function() {
                    this.onselectstart = function() {
                        return (false);
                    };
                });
            } else if($.browser.opera) {
                $(this).attr('unselectable', 'on');
            }
        });
    };
})(jQuery);

/**
 * Utils functions
 */

function redirect(url) {
    document.location.href = url;
}


