//-----------------------------
// Auteur	: Raynald Bertrand
// Date		: 2007-07-09
//-----------------------------

function OmnitureVariables(){

	this.s_account = 'cnotvaprod,cnocanoeglobalprod';
	this.mainsection = 'prise2';
	this.affiliate = '';
	this.sectionLevel2 = MyGenericTagVar.sectionLevel2;
	this.sectionLevel3 = MyGenericTagVar.sectionLevel3;
	this.sectionLevel4 = '';
	this.sectionLevel5 = '';
	this.language = 'fr';
	this.division = 'tva';
	this.linkInternalFilters = 'javascript:,canoe.com';
	this.linkExternalFilters = '';
	this.linkLeaveQueryString = true;
	this.trackExternalLinks = false;
	this.prop22 = 'entertainment';
	this.srcsite = 'tva';
	this.networkid = 'can';

	//--> Pour Bypasser les cgi des sites statiques, au besoin on hardcode SwitchCgi
	if (!SearchString(document.location.href.toLowerCase(), "mod-bin") || !SearchString(document.location.href.toLowerCase(), "cgi-bin")) {	
		this.SwitchCgi = true;
	} else {
		this.SwitchCgi = false;
	}

	//-----------------------------------------	
	this.pageName = GetPageName(this.language);
	this.server = this.networkid + '.' + this.language + '.' + this.division + '.' + this.mainsection;

	// this.om_acount --> hard code in TagOmniture.js same for all site
	// this.om_pageType --> will be hard code empty in TagOmniture.js 
}

//-----------------------------
// Retourne le PageName sous la forme suivante :
// 
// s.pageName = "<pname short>:<slevel 4>:<slevel 3>:<slevel 2>:<slevel1>:<website name>"
// <website name> = nom de domaine et sous-domaine
//-----------------------------

function GetPageName(lang) {

  var doc_href = document.location.href.toLowerCase();	
  var doc_host = document.location.host.toLowerCase();
  var doc_pathname = document.location.pathname.toLowerCase();

  var url_racine_param = doc_href.split("?");

  //---------------------------
  // remove WWW[x]. du doc_host
  // ex. www2.canoe.com -> canoe.com
  //---------------------------
  
  var reg = new RegExp(/www\d?./);
  doc_host = doc_host.replace( reg, '') ;
			  
  var racine = (doc_host != '' || navigateur == 'Netscape') 
			 ? doc_pathname.split('/') : doc_pathname.split(/&&/);
  
  var condition = racine.length;
  var page_full = racine[condition - 1].toLowerCase();
  var page_short = racine[condition - 1].toLowerCase().split('.');
  
  //------------------------------------------------------------------
  // EX. repertoire_ori = "/Archive/TestSiteCatalyst/2007/08/voiture/"
  // devient "/Archive/TestSiteCatalyst/voiture/"
  //------------------------------------------------------------------
  var repertoire_ori = doc_pathname.replace(page_full, ''); 
  var repertoire_clean = "/";
  var repertoire_index = doc_pathname.replace(page_full, '').split('/');
  
  //------------------------------------------------------------------------------------
  // Strip les repertoires numeriques si archive est ON ainsi que le repertoire archives
  // et conserve 5 repertoires au total donc 1 channel + 4 repertoires
  //------------------------------------------------------------------------------------
  var is_archive = SearchString(doc_href, "archive");
  var NbClean=0;
  if (is_archive)
  {
		for (i = 1; i <= repertoire_index.length-2; i++)
			{
				if (!IsNumeric(repertoire_index[i]) & !SearchString(repertoire_index[i], "archive"))
				{
					repertoire_clean = repertoire_clean + repertoire_index[i] + "/"
					NbClean++;
					if (NbClean > 4) {
						break;
					}

				}
			}
  } else {			 
	  repertoire_clean = repertoire_ori;
  }

  //-----------------------------------------------------------------
  // Construit la string des repertoires reverse via repertoire_clean
  //-----------------------------------------------------------------
  var repertoire_clean_index = repertoire_clean.split('/');
  var reverse_repertoire_clean=""
  for (i = repertoire_clean_index.length-2; i >=1; i--) {
	reverse_repertoire_clean = reverse_repertoire_clean + ':' + repertoire_clean_index[i];
  }	
		  
  //-----------------------------------------------
  // SET PageName
  //-----------------------------------------------  
	if (page_short[0] == '') {
		if(lang ='fr') {
			return 'index'+reverse_repertoire_clean+":"+doc_host;	
		} else {
			return 'home'+reverse_repertoire_clean+":"+doc_host;		
		} 
	} else {
		return page_short[0]+reverse_repertoire_clean+":"+doc_host;		
	}
  
  //return(1);	
}

var MyOmnitureVariables  = new OmnitureVariables();