/******************************************************************************
* Classe XitiDocTracker
*
* @author antoine rodes
* @since  080725
*/
XitiDocTracker = function() // Void
	/**
	* Ppt d'instance / Constructeur.
	*/
	{
		/**
		* Ppt d'instance.
		*/
		this.aXitiConfig = null;
		
		/**
		* Constructeur.
		*/
		
		var serverName = document.location.hostname;
		var serverPort = document.location.port;
		if( (serverPort != "") && (serverPort != "80") )
		{
			serverName = serverName + ":" + serverPort;
		}
		
		// A compléter pour tous les sites...
		var aXitiConfigList = 
		[
			["www.sanofi.com",							"158967", "http://logi7.xiti.com/hit.xiti",		"1"],
			["en.sanofi.com",							"158967", "http://logi7.xiti.com/hit.xiti",		"2"],
			["gtysvmtridd1:8010",						"199463", "http://logi7.xiti.com/hit.xiti",		"18"],
			["gtysvmtridd1:8011",						"199463", "http://logi7.xiti.com/hit.xiti",		"19"],
			
			["","","",""]
		];
		
		for(var i=0; i<aXitiConfigList.length; i++)
		{
			if(aXitiConfigList[i][0] == serverName)
			{
				this.aXitiConfig = aXitiConfigList[i];
				break;
			}
		}
		
		if(null != this.aXitiConfig)
		{
			this._addPdfLinkListener();
		}
	}
	var X = XitiDocTracker.prototype;  // Raccourci.
	
	/**
	* Fixe sur tous les liens pointant vers un fichier PDF
	* un gestionnaire d'évènement onclick qui appelle la
	* méthode écouteur de l'évènement _onClickPdfLink.
	*/
	X._addPdfLinkListener = function() // Void
	{
		
		var iLinkNum 	= document.links.length;
		var Xiti_this	= this;
		
		for(var i=0; i<iLinkNum; i++)
		{
			if(document.links[i].pathname.search( /\.pdf/ ) != -1)
			{
				document.links[i].onclick = function()
				{
					return Xiti_this._onClickPdfLink(this);
				};
			}
		}
	}
	/**
	* Méthode écouteur de l'évènement onclick des liens pointant vers un fichier PDF.
	* Récupère les paramètres nécessaire à la fonction xiti "xt_clic" et appelle
	* celle-ci.
	*
	* @param Link_x Lien pointant vers un fichier PDF qui a été cliqué.
	*/
	X._onClickPdfLink = function(Link_x) // Boolean
	{
		
		var sFileName	= Link_x.pathname.slice(Link_x.pathname.lastIndexOf ( "/" ) + 1,
												Link_x.pathname.lastIndexOf ( ".pdf" ) );
		if (sFileName.search ( "_tcm" ) != -1)
		{
			sFileName	= sFileName.slice(0, sFileName.indexOf ( "_tcm" ));
		}
		var sUrl		= Link_x.href;
		var bNewWindow	= ( Link_x.target == "_blank" ) ? 1 : null;
		
		//----
		
		var type = 'C';
		var section = this.aXitiConfig[3];
		var page = sFileName;
		var x1 = 'T';
		var x2 = sUrl;
		var x3 = bNewWindow;
		
		this.xt_med (type,section,page,x1,x2,x3);
		
		//----
		
		return false;
	}
	/**
	* Méthode fournie par xiti.
	* 
	* xt_med('C','#S2#','doc','T')
	*/
	X.xt_med = function(type,section,page,x1,x2,x3,x4,x5) // Void
	{
		xt_img = new Image();
		xtdate = new Date();
		xts = screen;
		xt_ajout = (type=='F') ? '' : (type=='M') ? '&a='+x1+'&m1='+x2+'&m2='+x3+'&m3='+x4+'&m4='+x5 : '&clic='+x1;
		Xt_im = this.aXitiConfig[2] + '?s=' + this.aXitiConfig[1] + '&s2='+section;
		Xt_im += '&p='+page+xt_ajout+'&hl=' + xtdate.getHours() + 'x' + xtdate.getMinutes() + 'x' + xtdate.getSeconds();
		if(parseFloat(navigator.appVersion)>=4)
		{Xt_im += '&r=' + xts.width + 'x' + xts.height + 'x' + xts.pixelDepth + 'x' + xts.colorDepth;}
		xt_img.src = Xt_im;
		//window.alert(Xt_im);
		if ((x2 != null)&&(x2!=undefined)&&(type=='C'))
		{ if ((x3=='')||(x3==null)) { document.location = x2} else {xfen = window.open(x2,'xfen',''); xfen.focus();}}
		else
		{return;}
	}
X = null;
/*****************************************************************************/

