


jQuery.noConflict();



	//personnaliser un select
	
	function personalize_select(className,width,height){
	jQuery('.'+className).mSelect('',width,height);
	}
	
	

jQuery(document).ready(function($){
    // navigation
    // test if nav sublevels don't fit into main content width
    var navRight = $('.mp_navigation').width() + $('.mp_navigation').offset().left;
    $('.nav_menu > ul > li').each(function() {
        var itemPos = $(this).offset().left;
        var itemWidth = $(this).find('.dropdown_menu').outerWidth();
        var estimPos = itemPos + itemWidth;
        var diff = estimPos - navRight;
        if (diff >= 0) {
            $(this).find('.dropdown_menu').css('left', $(this).find('.dropdown_menu').offset().left - diff + 7);
        }
    });
    // navigation sublevels interaction
    $('.nav_menu > ul > li').mouseover(function() {
        $(this).find('.dropdown_menu').show();
        $(this).find('> a').addClass('hover');
    });
    $('.nav_menu > ul > li').mouseout(function() {
        $(this).find('.dropdown_menu').hide();
        $(this).find('> a').removeClass('hover');
    });
		
		
    $(".searchByAge").change(function(){
        var selectedValue = $(this).children(":selected").attr("value");
        if(selectedValue != 0) {
           $(location).attr('href', selectedValue);
           //document.location.href= selectedValue;
        }
        return false;
    });
	
	
    var searchTxt = "par mots clés, par marque, par réf.";
    $(".search").focus(function(){
        if($(this).attr("value") == searchTxt) {
    	    $(this).attr("value", '');
    	}
    });
    $(".search").blur(function(){
        if($(this).attr("value") == "") {
    	    $(this).attr("value", searchTxt);
    	}
    });
    $(".btn_search").click(function(){
        if ($('.search').attr('value') != searchTxt) {
            document.formSearch.submit();
        }
    });
    
	
	
	//Clear and re-fill form fields using jQuery
    jQuery("input:text").each(function(){jQuery(this).val(jQuery(this).attr("defaultValue"));});
    jQuery("input:text").focus(function() {if(jQuery(this).val()==jQuery(this).attr("defaultValue")) {jQuery(this).val("");}});
    jQuery("input:text").blur(function() {if(jQuery(this).val()=="") {jQuery(this).val(jQuery(this).attr("defaultValue"));}});
		
		
		
	
	
	//actions select personnalisés
	jQuery(".mSelect div.mOption:first").remove();
	jQuery(".mSelect div.mOption:last-child").css("border-bottom","1px solid #cfd3d5");
	
	jQuery('.mOption').click(function(){
								 link=jQuery(this).children('input').attr('value')
								 if(link!=0)$(location).attr('href', jQuery(this).children('input').attr('value'));
									})
	
	//design menus déroulants
	
	//jQuery('tr.middle_drop td.middle_drop_middle:first-child ul').css('border-right','1px dotted #484549');
	jQuery('tr.middle_drop td.middle_drop_middle:last-child').has('ul').css('border-left','1px dotted #484549');
	
	 
	
			
			
	//le clic sur body efface le survol de le login
	jQuery('body').click(function() {
	jQuery('div.monCompte div.leCompte div.liens_compte').css('display','none');
	jQuery('.basketinfo div.monCompte').removeClass('hover');
	});
	jQuery('div.monCompte').click(function(event){
     event.stopPropagation();
	});

	
	
});
