var scripts = {
	init: function () {
		// Overture POPUP
		/*jQuery('.popup_zoom').click(function () {
			// ouverture popup
			window.open(jQuery(this).attr('href'),'pop','top=100,left=100,width=458,height=641,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,directories=0');
			return false;
		});
		jQuery('.popup').click(function () {
			// ouverture popup
			if(jQuery(this).attr('href')) {
				window.open(jQuery(this).attr('href'),'pop','width=1024,height=800,toolbar=1,menubar=1,location=1,status=1,scrollbars=1,resizable=1,directories=1');
				return false;
			}
		});*/
	// Fermeture POPUP
    jQuery('.btnFermerPopup').click(function () {
    // Fermeture popup
     window.close();
    });
    
        if(jQuery('#closePopup').length > 0){
            jQuery('#closePopup').click(function(evt){
                window.close();
            });
        }

		// NAV de la section zoom sur les pages produit simple et double
		jQuery('#lien_zoom_haut').click(
			function () {
				jQuery('#conteneur_images_zoom').scrollTo( {top:'-=225px', left:'+=0'}, 800 );
				return false;
			}
		);
		jQuery('#lien_zoom_bas').click(
			function () {
				var cnt = jQuery('#conteneur_images_zoom');
				cnt.scrollTo( {top:'+=225px', left:'+=0'}, 800 );
				return false;
			}
		);
		jQuery('#conteneur_images_zoom a').click(function () {
			var url = jQuery(this).attr('href');
			jQuery('#produit').attr('src', url);
			return false;
		});
		
		
		// GESTION DES EVENEMENTS POUR LES PAGES PRODUIT simple et double
		jQuery('.legende_symbole_js').addClass('legende_symbole');
		jQuery('.legende_symbole_js').removeClass('legende_symbole_js');
		jQuery('.liste_symble a').hover(
			function () {
				//Entrer
				jQuery(this).parent().find('span').show();
			},
			function () {
				//Sortir
				jQuery(this).parent().find('span').hide();
			}
		);
		jQuery('.liste_symble a').click(function () {return false;});
		//BOUTON FERMER SUR Les pages produit simple et double
		jQuery('.masquer').hide();
		jQuery('#conteneur_zoom ul').css('height', '272px');
		jQuery('#conteneur_zoom ul').css('overflow', 'hidden');
		jQuery('.fermer').click(
			function () {
				if(jQuery(this).html() == 'Fermer') {
					jQuery(this).html('Infos produit');
					jQuery(this).removeClass('select');
					//Masquer les infos
					jQuery(this).parent().find('.fiche_prod_deroul').hide();
				} else {
					jQuery(this).html('Fermer');
					jQuery(this).addClass('select');
					//Afficher les infos
					jQuery(this).parent().find('.fiche_prod_deroul').show();
				}
				return false;
			}
		);
		
		// GESTION DU ROllhover sur les produits des pages catégories et autres...
		jQuery('.mea_gamme:not(.mea_gamme_simple) a').hover(
			function () {
				// entree
				// changement de l'image de fond
				var url = jQuery(this).find('img').attr('src');
				if(jQuery(this).find('img').attr('src')) {
					url = url.split('.jpg');
					url = url[0];
					url += "_hover.jpg";
					jQuery(this).find('img').attr('src', url);
					
					// Ajout des tailles dispos
					var texte = jQuery(this).find('img').attr('alt');
					jQuery(this).append('<div class="tailles_dispo">'+texte+'</div>');
					
					// Positionnement du cartouche
					var h_block = jQuery(this).find('.tailles_dispo').height();
					var pos_x = jQuery(this).find('img').css('left');
					//alert(pos_x);
					var hauteur = 173 - h_block - 6;
					jQuery(this).find('.tailles_dispo').css('top', hauteur+'px')
				}
			},
			function () {
				// sortie
				// On supprime le cartouche
				jQuery(this).find('.tailles_dispo').remove();
				
				// on rétabli l'image de fond
				var url = jQuery(this).find('img').attr('src');
				if(jQuery(this).find('img').attr('src')) {
					url = url.split('_hover.jpg');
					url = url[0];
					url += ".jpg";
					jQuery(this).find('img').attr('src', url);
				}
			}
		);
		
		 //* Gestion des infobulles *//
		var tempToolTipInner; // variable temporaire dans laquelle on stockera la valeur du alt
		var showToolTips = function() { // fonction qui affiche le toolTip
			var toolTipInner = jQuery(this).children().attr('alt').split("\\'").join("'");
			tempToolTipInner = toolTipInner;
			var toolTipHtml = '<div class="lavage_alt"><div class="code">';
			toolTipHtml += toolTipInner;
			toolTipHtml += '</div><div class="arrow"></div></div>';                                            
			jQuery(toolTipHtml).insertAfter(jQuery(this));
			var pos = Number(jQuery(this).attr("class").substring(4)) - 1;
			jQuery('.lavage_alt').css({
                    left: (30*pos)+'px'
            });
			jQuery(this).children().attr('alt',''); // on vide temporairement le alt pour pas qu’IE n’affiche l’infobulle par défaut
		}           
		var hideToolTips = function() { // fonction qui enlève le toolTip
			jQuery('.lavage_alt').remove();
			jQuery('.arrow').remove();
			var toolTipInner = jQuery(this).children().attr('alt');
			jQuery(this).children().attr('alt',tempToolTipInner);
		}

		// écouteurs en function du contexte pour lancer ou non les tooltips
		if (jQuery('.produit').length || jQuery('.edito').length || jQuery('.liste_symble').length) {
			jQuery('.liste_symble li').hover(showToolTips, hideToolTips);
		}
	}
}
jQuery(document).ready(
	scripts.init
);


var mtHost = (("https:" == document.location.protocol) ? "https://rainbowx" : "http://rainbow") + ".mythings.com";
var mtAdvertiserToken = "1159-100-fr";
document.write(unescape("%3Cscript src=\'" + mtHost + "/c.aspx?atok="+mtAdvertiserToken+"\' type=\'text/javascript\'%3E%3C/script%3E"));

function tagMyThingsMedia(reference,category,subcat,subcat1,prodname,price,oldprice,url,image){
	if(oldprice != ''){
		if (typeof(MyThings) != "undefined") {
		      MyThings.Track({
							EventType: MyThings.Event.Visit,
							Action: 1013,
							ProductId: reference,
							Category: category,
							SubCategory: subcat,
							SubCategory1: subcat1,
							ProductName: prodname,
							Price: oldprice,
							OldPrice: price,
							Currency: '€',
							Url:url,   
							ImageUrl: image
		      });
		}
	}else{
		if (typeof(MyThings) != "undefined") {
		      MyThings.Track({
							EventType: MyThings.Event.Visit,
							Action: 1013,
							ProductId: reference,
							Category: category,
							SubCategory: subcat,
							SubCategory1: subcat1,
							ProductName: prodname,
							Price: price,
							OldPrice: '',
							Currency: "€",
							Url:url,   
							ImageUrl: image
		      });
		}
	}

}