jQuery(document).ready(function(){
	/* Compter le nombre de propriétés d'un objet */
	var countProperties = function (obj) {
	    var count = 0;
	    for(var prop in obj) {
	        if(obj.hasOwnProperty(prop))
	            count = count + 1;
	    }
	    return count;
	}
	
	/* Menu page static - Cache les bordures au hover */
	var nextElm;
	var indexElm;
	var previousElm;
	var backgroundValue;
	jQuery('.header .header-cms-nav-content .right-nav > li').hover(
		function() {
			indexElm = jQuery('.header .header-cms-nav-content .right-nav > li').index(this);
			previousElm = indexElm - 1;
			previousElm = jQuery('.header .header-cms-nav-content .right-nav > li:eq('+previousElm+')');
			if (previousElm.hasClass('separator')) {
				backgroundValue = previousElm.css('background');
				previousElm.css('background', 'transparent');
			} else {
				previousElm = null;
			}
			nextElm = indexElm + 1;
			nextElm = jQuery('.header .header-cms-nav-content .right-nav > li:eq('+nextElm+')');
			if (nextElm.hasClass('separator')) {
				backgroundValue = nextElm.css('background');
				nextElm.css('background', 'transparent');
			} else {
				nextElm = null;
			}
		},
		function() {
			if (previousElm) {
				previousElm.css('background', backgroundValue);
			}
			if (nextElm) {
				nextElm.css('background', backgroundValue);
			}
		}
	);

	/* FORGOT PASSWORD */
	var displayPopinForgotPassword = false;
	jQuery('.open-forgotpassword').click(function(){
		if (!displayPopinForgotPassword) {
			jQuery('.customer-account-forgotpassword').slideDown(300);
			jQuery('.customer-account-forgotpassword .inner-box').fadeIn(500);
			displayPopinForgotPassword = true;
		} else {
			jQuery('.customer-account-forgotpassword .inner-box').fadeOut(100);
			jQuery('.customer-account-forgotpassword').slideUp(200);
			displayPopinForgotPassword = false;
		}
		return false;
	});
	jQuery('.close-forgotpassword').click(function(){
		jQuery('.customer-account-forgotpassword .inner-box').fadeOut(100);
		jQuery('.customer-account-forgotpassword').slideUp(200);	
		return false;
	});
	
	/* Ajoute la class "on" sur le separator avant le dernier element du breadcrum */
	jQuery('.hierarchie .on:last').prev('.separator').addClass('on');
	
	// Information relais kiala
	jQuery('.checkout-shipping-method .titre a.cluetip_method').cluetip({
		local: true, 
		width: 330, 
		positionBy:'mouse', 
		arrows: false,
		leftOffset: -175,
		topOffset: 20
	});
	
	jQuery('a.popin-right').cluetip({
		attribute: 'href',
		width: 350,
		positionBy:'fixed',
		leftOffset: -100,
		topOffset: 106
	});
	
	jQuery('.ql-button').hover(function(){
		jQuery(this).css('background-image','url('+SKIN_URL+'/images/achat_rapide_hover.png)');
	}, function(){
		jQuery(this).css('background-image','url('+SKIN_URL+'/images/achat_rapide.png)');
	});
});

