//*********************************************************

// Suivi statistique

//*********************************************************

//************************************************************************//
//Fonction générique pour le suivi d'événement dans GA                    //
//									  //
//Params: categorie(obligatoire), action(obligatoire), label(optionnel)   //
//Les paramètres correspondent à l'arborescence des événements dans GA:   //
//le label x sous l'action y de la catégorie z (voir GA)                  //
//L'objet pageTracker doit avoir préalablement été créé (plugin struts).  //
//************************************************************************//
function saveStats(categorie, action) {	 
	var argv=saveStats.arguments;
	var argc=saveStats.arguments.length;
	var label=(argc > 2) ? argv[2] : null;

	//------------------------------------------------------------//
	// Début de code personnalisé : variables personnalisées pour //
	//				le site des Casinos	      //
	//------------------------------------------------------------//
	var lCasino="";
	if (location.href.indexOf("/lacleamy/") != -1){		
		lCasino = "Lac-Leamy";
	}else if (location.href.indexOf("/montreal/") != -1){
		lCasino = "Montreal";
	}else if (location.href.indexOf("/charlevoix/") != -1){
		lCasino = "Charlevoix";
	}else if (location.href.indexOf("/mont-tremblant/") != -1){
		lCasino = "Tremblant";
	} else {
		lCasino = "SCQ";
	}
	
	action += " - " + lCasino;
			
	var lLangue;
	if (location.href.indexOf("/en/") == -1){		
		lLangue = "_fr";
	} else {
		lLangue = "_en";
	}	
	
	if(label!=null){
		label += lLangue;
	}
	//------------------------------------------------------------//
	// Fin de code personnalisé                                   //
	//------------------------------------------------------------//
	
	//alert("categorie=" + categorie + "; action=" + action + "; label=" + label);
	
	if (typeof pageTracker != "undefined") {
		((label==null) ? (pageTracker._trackEvent(categorie, action)) : (pageTracker._trackEvent(categorie, action, label)))
	}    	

//	if(typeof(_gaq)!="undefined"){
//		((label==null) ? (_gaq.push(['_trackEvent',categorie,action])) : (_gaq.push(['_trackEvent',categorie,action,label])))	
//	}

}

//************************************************************************//
//                  Fonction de suivi dans Rythmyx                        //
//   Code presque 100% personnalisé selon la zone à appliquer le suivi    //
//************************************************************************//
function suiviStatsRythmyx(page){
	var $ = jQuery.noConflict();
	jQuery(document).ready(function($) {
	
		//------------------------------------------------------------//
		// Début de code personnalisé                   	      //
		//------------------------------------------------------------//
		// Section à recréer pour chaque page ayant du contenu Rythmyx // 
		/*
		if(page=="accueil"){

			$("div#zonepromo div.promo").click(function() {
				var position = $("div#zonepromo").find("div.promo").index(this);
				var label = $("div.promo:eq(" + position + ")").find("span").html();

				saveStats("Zone promo","Accueil",label);
			});
		}
		*/
		//------------------------------------------------------------//
		// Fin de code personnalisé                                   //
		//------------------------------------------------------------//
	});
}

//************************************************************************//
//       ----- Fonction de suivi statistique pour vidéos Flash -----      //
//************************************************************************//
function statsFlash(fin,accueil,nom){
	var action = "";
	var label = nom;
	
	if(fin){
		action = "Complete";
	}else{
		action = "Demarre";
	}
	
	if(accueil){
		label+="_accueil";
	}else{
		label+="_thumbnail";
	}
	
	saveStats("Video",action,label);
}

//************************************************************************//
//        ----- Fonction générique de suivi statistique -----             //
//            Fonction STANDARD qui monitore les évenements               //
//************************************************************************//
function suiviStats(){
	var $ = jQuery.noConflict();
	jQuery(document).ready(function($) {
		$(".suiviGA").click(function() {
			var categorie="";
			var action="";
			var label=null;
			
			switch(this.id){
			
			//------------------------------------------------------------//
			// Zone de définition des variables de suivi hardcodées       //
			//------------------------------------------------------------//
				case 'promo-navette':
					categorie="Promotion";
					action="click";
					label="navette";
					break;
			//------------------------------------------------------------//
			// Fin des variables de suivi  			              //
			//------------------------------------------------------------//
				default:
				break;
			}
			
			if(categorie!="" && action!=""){
				saveStats(categorie,action,label);
			}
		});
	});
}

