/** Gestion des évenements pour Google Analytics **/
jQuery(function() {

/* exemple : un sélecteur css pour sélectionner l'élément, sur lequel on observe l'événement click qui déclenche le tracking google */
//$$('div.element').observer("click", function() { _gaq.push(['_trackEvent', 'Addonline', 'test', 'test']) });

	
	/*****************  Charte  *****************/
	//  * layer compte client : affichage
	jQuery("#header li.lien_compte").mouseover(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Survol', 'Layer compte client - Affichage']);
	});
	
	//  * layer compte client : clics sur les liens s'identifier
	jQuery('#ga_lien_identification').click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer compte client - Identification']); 
	});	
	
	
	//  * layer compte client : créer un compte
	jQuery('#ga_creer_compte').click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer compte client - Création compte']); 
	});
	
	//  * layer compte client : oublié/perdu	
	jQuery("#header a.achat").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer compte client - Perte MDP']); 
	});
		
	// * layer panier : affichage
	jQuery("#header a.lien_panier").mouseover(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Survol', 'Layer panier - Affichage']);
	});
		
	// * layer panier : liens accès au panier
	jQuery("#header a.lien_panier").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer panier - Accès panier']); 
	});
			
	// * layer ajout article au panier : continuer mes achats
	jQuery('#ajout_au_panier').click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer ajout article - Continuer achats']); 
	});
	
	// * layer ajout article au panier : continuer mes achats
	jQuery('#valid_commande').click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer ajout article - Valider commande']); 
	});
	
	// * derniers articles vus : clic sur un lien de type dernier article vu
	jQuery("#dernier_produits a").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Encart derniers articles vues']);
	});
	
	// * newsletter : clic sur inscription (page acceuil)
	jQuery("#formgnews button").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Newsletter inscription']);
	});
	
	// * newsletter : clic sur inscription (page email non valide)
	jQuery('#ga_btn_insci_newsletter').click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Newsletter inscription']);
	});
		
	

	/*****************  Moteur de Recherche :  *******************/
	// * moteur de recherche : utilisation combo marques
	jQuery('#idselectmarque').change(function() {	
		_gaq.push(['_trackEvent', 'Moteur interne', 'Menu déroulant', 'Moteur - Menu marques']);
	});

	// * moteur de recherche : utilisation combo rayons
	jQuery('#idselectrayon').change(function() {
		_gaq.push(['_trackEvent', 'Moteur interne', 'Menu déroulant', 'Moteur - Menu rayons']);
	});
	
	// * moteur de recherche : utilisation combo couleur
	jQuery('#idselectcouleur').change(function() {
		_gaq.push(['_trackEvent', 'Moteur interne', 'Menu déroulant', 'Moteur - Menu couleur']);
	});
	
	// * moteur de recherche : clic sur recherche
	jQuery("form[name~=frecherche] button").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Layer panier - Affichage']);
	});
	
	// * moteur de recherche : clic sur recherche avancée
	jQuery("form[name~=frecherche] a").click(function() {
		_gaq.push(['_trackEvent', 'Charte', 'Clic', 'Moteur - Recherche avancée']);
	});
	
	
	
	/*******************  - Layer Mini fiche produit :  *****************/
	
	jQuery("a.btn_gris url_produit").click(function() {
		_gaq.push(['_trackEvent', 'Layer Mini fiche produit', 'Clic', 'Layer Mini fiche produit - Accès']);
	});
	
	jQuery('#comparer_vignette_produit').click(function() {	
		_gaq.push(['_trackEvent', 'Layer Mini fiche produit', 'Clic', 'Layer Mini fiche produit - Accès']);
	});
	
	jQuery('#quickcouleur').mouseover(function() {	
		_gaq.push(['_trackEvent', 'Layer Mini fiche produit', 'Survol', 'Layer Mini fiche produit - Changement couleur']);
	});
	
	
	
	/*****************  Page produit  *****************/
	//  * changement de couleur
	jQuery("div.carre_couleur").click(function() {	
		_gaq.push(['_trackEvent', 'Page produit', 'Survol', 'Page produit - Changement couleur']);
	});
	
	//  * changement de vue
	jQuery("div.conteneur_vu a").click(function() {	
		_gaq.push(['_trackEvent', 'Page produit', 'Survol', 'Page produit - Changement vues']);
	});

	//  * zoom : accès au zoom
	jQuery("div.image_produit a").click(function() {	
		_gaq.push(['_trackEvent', 'Page produit', 'Clic', 'Page produit - Zoom accès']);
	});
	
	// * zoom : changement de vue
	// flash
	
	// * zoom : utilisation des boutons +/-
	// flash
	
	
	//  * clic sur les liens communautaires Facebook
	jQuery("div.reseaux a.facebook").click(function() {	
		_gaq.push(['_trackEvent', 'Page produit', 'Clic', 'Page produit - Partage Facebook']); 
	});
	
	//  * clic sur les liens communautaires Twitter
	jQuery("div.reseaux a.twitter").click(function() {	
		_gaq.push(['_trackEvent', 'Page produit', 'Clic', 'Page produit - Partage Twitter']); 
	});
	
	// * Accès à l'avis des clients
	jQuery('#note_page_produit').click(function() {
		_gaq.push(['_trackEvent', 'Page produit', 'Clic', 'Page produit - Avis client accès']);  
	});
	
	// * Clic sur donner votre avis
	jQuery('#donner_note_page_produit').click(function() {
		_gaq.push(['_trackEvent', 'Page produit', 'Clic', 'Page produit - Donner son avis']); 
	});
		
	
	
	/*****************  Page panier : :  *****************/
	// * Changement de couleur
	jQuery('#nouveauNumCouleur').change(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Menu déroulant', 'Page panier - Changement couleur']);
	});
	
	// * Modification de quantité
	jQuery("div.article input[name=quantite]").change(function() {	
		_gaq.push(['_trackEvent', 'Page panier', 'Clic', 'Page panier - Modification quantité']);
	});
	
	// * Suppression de produit
	jQuery("button.buttonsupprimer").mousedown(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Clic', 'Page panier - Suppression produit']);
	});
	
	// * Changement de pays
	jQuery('#codePays').change(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Menu déroulant', 'Page panier - Changement pays']); 
	});
	
	// * Modification du mode de livraison
	jQuery('#typeRelais').change(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Menu déroulant', 'Page panier - Mode de livraison']);
	});
	
	// * Utilisation d'un code avantage
	jQuery("#codepromo button").click(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Clic', 'Page panier - Code avantage']); 
	});

	// * Clic sur le bouton iAdvize
	jQuery("#button_offline a.operator_status_button").click(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Clic', 'Page panier - Iadvise']);
	});
	
	// * Accès quicklook
	jQuery("#btquicklook").click(function() {
		_gaq.push(['_trackEvent', 'Page panier', 'Clic', 'Page panier - Quicklook']);
	});	
	
	/*****************  - Page paiement :  *****************/
    // * Modification du mode de livraison
	jQuery("div.relais_colis a").click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Mode de livraion']);
	});
	
    // * Modification de l'adresse (adresse liv)
	jQuery("#lien_modif a").click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Modification adresse']);
	});
	
    // * Modification de l'adresse (adresse fact)
	jQuery("div.adresse_fac a").click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Modification adresse']);
	});
	
    // * Modification du message cadeau
	jQuery('#msg_colis').click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Modification message']);
	});
	
    // * Choix du paiement et validation
	jQuery("input[name=modePaiement]").click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Modification paiement']);
	});
	
    // * Validation
	jQuery("a.fin_commande").click(function() {
		_gaq.push(['_trackEvent', 'Page paiement', 'Clic', 'Page paiement - Validation']);
	});
	
	
	
	/*****************  Page confirmation de commande :  *****************/
    // * Clic sur les liens Facebook
	jQuery("#ga_fb_partager_commande").click(function() {
		_gaq.push(['_trackEvent', 'Page confirmation de commande', 'Clic', 'Page commande - Partage Facebook']);
	});
	
	// devenir fan (supprimé)

	/*****************  Compte client :  *****************/
    // * Clics sur les onglets
	jQuery("#lien_h ul li").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Clics onglets']);
	});
	
    // * Clic sur le détail d'une commande
	jQuery("tr[id^=ligne_commande_]").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Détail commande']);
	});
	
    // * Modification de l'adresse
	jQuery("#bloc2 a").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Modification adresse']);
	});
	
    // * Ajouter un commentaire/note
	jQuery("a[id^=commenter_produit_]").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Commentaires']);
	});
	
    // * Modifier les centres d'intérêts
	jQuery("#affichage_interets a").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Centres Intérêts']);
	});
		
    // * Modifier les abonnements
	jQuery("#affichage_newsletter a").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Abonnements']);
	});
	
    // * Ajouter les produits d'une liste d'achats au panier
	jQuery("#bloc_centre #panier a").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Produit liste mis au panier']);
	});

    // * Actions sur les produits en alertes prix
	jQuery("#listes a.jeveux").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Actions produit en alerte prix']);
	});	
	
    // * Envoie de Parrainage
	jQuery("#parrainageForm div.btn").click(function() {
		_gaq.push(['_trackEvent', 'Page compte client', 'Clic', 'Compte client - Envoie parrainnage']);
	});
	 
	//------------------ formulaire de compte client----------------------------------------
	//formulaire de création : type de civilité / type="radio" / test sur les values statiques
	jQuery('[name="typeCivilite"]').change(function() {
		if(jQuery(this).val() == 'particulier') {
			_gaq.push(['_trackPageview','/formCompteClient/typeCiviliteParticulier']);
		} else {
			_gaq.push(['_trackPageview','/formCompteClient/typeCiviliteProfessionnel']);
		}
	});

	//formulaire de création : avatar / type="file"
	jQuery('[name="avatar"]').change(function() {
		_gaq.push(['_trackPageview','/formCompteClient/fichierAvatar']);
	});

	//formulaire de création : civilité / type="select"
	jQuery('#selectCivilite').change(function() {
		_gaq.push(['_trackPageview','/formCompteClient/civiliteChangement']);
	});

	//formulaire de création : nom / type="text"
	jQuery('#nom').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/nom']);
		}
	});

	//formulaire de création : prénom / type="text"
	jQuery('#prenom').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/prenom']);
		}
	});

	//formulaire de création : siret / type="text"
	jQuery('#siret').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/siret']);
		}
	});

	//formulaire de création : adresse 1 / type="text"
	jQuery('#adresse1').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/adresse1']);
		}
	});

	//formulaire de création : adresse 2 / type="text"
	jQuery('#adresse2').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/adresse2']);
		}
	});
	
	//formulaire de création : adresse 3 / type="text"
	jQuery('#adresse3').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/adresse3']);
		}
	});

	//formulaire de création : code postal  / type="text"
	jQuery('#cp').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/codePostal']);
		}
	});

	//formulaire de création : ville  / type="text"
	jQuery('#ville').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/ville']);
		}
	});

	//formulaire de création : date de naissance  / type="text"
	jQuery('#dateNaissance').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/dateDeNaissance']);
		}
	});

	//formulaire de création : code pays  / type="select"
	jQuery('#codePays').change(function() {
		_gaq.push(['_trackPageview','/formCompteClient/codePaysChangement']);
	});

	//formulaire de création : téléphone de domicile  / type="text"
	jQuery('#telDomicile').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/telephoneDomicile']);
		}
	});

	//formulaire de création : téléphone portable  / type="text"
	jQuery('#telPortable').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/telephonePortable']);
		}
	});

	//formulaire de création : téléphone de travail  / type="text"
	jQuery('#telTravail').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/telephoneTravail']);
		}
	});

	//formulaire de création : email  / type="text"
	jQuery('#email').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/email']);
		}
	});

	//formulaire de création : mot de passe  / type="text"
	jQuery('#password').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/motDePasse']);
		}
	});

	//formulaire de création : email de parrain  / type="text"
	jQuery('#emailParrain').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formCompteClient/emailParrain']);
		}
	});

	//formulaire de création : news Letter / type="radio" / test sur les values statiques
	jQuery('[name="newsLetterPromo"]').change(function() {
		if(jQuery(this).val() == "true") {
			_gaq.push(['_trackPageview','/formCompteClient/newsLetterOui']);
		} else {
			_gaq.push(['_trackPageview','/formCompteClient/newsLetterNon']);
		}
	});

	//------------------ formulaire Paiement Ogone ----------------------------------------
	//formulaire Paiement Ogone : type de paiement  / type="select"
	jQuery('#typeCarte').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/typeCarteChangement']);
	});

	//formulaire Paiement Ogone : numéro de la carte  / type="text"
	jQuery('#numCarte').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formPaiementOgone/numeroCarte']);
		}
	});

	//formulaire Paiement Ogone : date d'xpiration partie mois  / type="select"
	jQuery('#dateExpirationMois').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/dateExpirationMois']);
	});

	//formulaire Paiement Ogone : date d'xpiration partie année  / type="select"
	jQuery('#dateExpirationAnnee').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/dateExpirationAnnee']);
	});

	//formulaire Paiement Ogone : cryptogramme  / type="text"
	jQuery('#cryptogramme').blur(function() {
		if(this.value != '') {
			_gaq.push(['_trackPageview','/formPaiementOgone/cryptogramme']);
		}
	});
	
	//formulaire Paiement Ogone : jour de la date de naissance  / type="select"
	jQuery('#dateNaissanceJour').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/jourDateNaissance']);
	});

	//formulaire Paiement Ogone : mois de la date de naissance  / type="select"
	jQuery('#dateNaissanceMois').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/moisDateNaissance']);
	});

	//formulaire Paiement Ogone : année de la date de naissance  / type="select"
	jQuery('#dateNaissanceAnnee').change(function() {
		_gaq.push(['_trackPageview','/formPaiementOgone/anneeDateNaissance']);
	});
		
});

//	appel de la fonction de trackEvents pour ajouter les evenements (googleAnalytics) des element du layer apreçu rapide produit
// TODO evol: jamais appelée
function saveGaEvents()	{
	
	/** Gestion des évenements pour Google Analytics **/
	// * quickview : changement de produit
	jQuery('#bouton_suivant').click(function() {		
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Clic', 'Quickview - Changement produit']);
	});
		
	// * quickview : changement de produit
	jQuery('#bouton_precedent').click(function() {
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Clic', 'Quickview - Changement produit']);
	});
		
	// * quickview : clic sur les onglets
	jQuery('#onglet_informations_quicklook').click(function() {
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Clic', 'Quickview - Onglets']);
	});

	// * quickview : clic sur les onglets
	jQuery('#onglet_description_quicklook').click(function() {
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Clic', 'Quickview - Onglets']);
	});
		
	// * quickview : ajout au panier
	jQuery('#commanderQuickLook').click(function() {	
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Clic', 'Quickview - Ajout panier']);
	});
		
	// * quickview : changement de vue
	jQuery("form[name^=formQuickLayer] div[class^=apercus] a").mouseover(function() {
		_gaq.push(['_trackEvent', 'Mini fiche produit', 'Survol', 'Quickview - Changement de vues']);
	});
	
}

