/****************************************************

	PGATour.com Omniture Implementation (PAGE CATEGORIZATION)

	This file is first responsible for categorizing each page and assiging the appropriate
	pre-staging vars for Omniture.  Within this file also lies a function, populateMetricsData(),
	which appends the collected data from the pre-staging vars to the necessary Omniture variables.
	The code will live as a complement to the s_code.js provided by Omniture.
	
	Table of Contents
	
	1. Initialization
	Helper Functions
	Populate Omniture Variables
	Page Categorization
********************************************************/
	


/*******************************************************
*****			Initilization			 *******
*******************************************************/

//initializing path_array: prepares the URL to be parsed
var pathname = window.location.pathname.substring(1);
if (pathname.charAt(pathname.length - 1) == "/") {pathname += "index.html";}
var path_array = pathname.split('/');
var pL = path_array.length;

//Initializing the metrics json: holds data to be sent to Omniture
var metrics = {
	server: 	window.location.host,
	channel:	null,
	section: 	null,
	subsection:	null,
	pageName:	null,
	pageType:	null,
	traffic:	{
					prop2:  null,
					prop3:  null,
					prop5:  null,
					prop7:  null,
					prop8:  null,
					prop9:  null,
					prop11: null,
					prop12: null,
					prop13: null,
					prop14: null,
					prop15: null,
					prop16: null,
					prop17: null,
					prop18: null,
					prop19: null,
					prop22: null,
					prop24: null,
					prop25: null,
					prop26: null,
					prop29: null,
					prop30: null,
					prop31: null,
					prop32: null,
					prop37: null,
					prop38: null,
					prop39: null,
					prop40: null,
					prop42: null,
					prop43: null,
					prop44: null,
					prop47: null
				},
	conversion:	{
					event1:  null,
					event2:  null,
					event3:  null,
					event5:  null,
					event6:  null,
					event9:  null,
					event10: null,
					event11: null,
					event12: null, 
					event13: null, 
					event14: null, 
					event15: null, 
					event16: null, 
					event17: null, 
					event18: null, 
					event19: null, 
					event20: null, 
					eVar20: null, 
					eVar37: null,
					eVar38: null,
					eVar39: null,
					eVar40: null,
					eVar42: null,
					eVar43: null,
					eVar44: null,
					eVar47: null
				},
	hierarchy:	{
					hier1: null,
					hier2: null,
					hier3: null
				}
};

var tourneyId, tourID = null;
var tourName = {	r: 'PGA Tour',	s: 'Champions Tour',	h: 'Nationwide Tour',	none: 'No Tour'};
var playoffsTID = ['r060', 'r027', 'r505', 'r028'];
var wgcTID = ['r470', 'r473', 'r476'];
var specialTID = {
	presidentscup: 'President\'s Cup', 
	masters: 'Masters', 
	openchampionship: 'Open Championship', 
	usopen: 'U.S. Open', 
	pgachampionship: 'PGA Championship'
};

//Initializing useful regular expressions
var yearRegExp = /20\d{2}/; //regular expression to check for a year
var tidRegExp = /[r|s|h]\d{3}/g; //regular expression to check for a tournament id

var devServerList = ['jcmsdev8:93', 'jcmsdev8.turner.com:93'];
var refServerList = ['jcmsref1:93', 'jcmsref1.turner.com:93', 'beta.pgatour.com', 'webref2:93','webref2.turner.com:93'];
var prodServerList = ['jcmsprod1:93', 'jcmsprod1.turner.com:93', 'pgatourpreview:93', 'pgatourpreview.turner.com:93'];

/******************************************************
*****			END: Initilization			 *******
*******************************************************/

/*******************************************************
*****		Populate Omniture Vars			 *******
*******************************************************/

//When this function is called, the page data that is stored is set to the Omniture variables.
function populateMetricsData(){
	s.server = metrics.server;
	s.pageType = metrics.pageType;

	s.pageName = (metrics.pageName !== null) ? metrics.pageName : s.getPageName();
	s.channel = metrics.channel;
	
	s.hier1 = metrics.hierarchy.hier1;
	s.hier2 = metrics.hierarchy.hier2;
	s.hier3 = metrics.hierarchy.hier3;
	
	s.prop1 = metrics.traffic.prop1;
	s.prop2 = metrics.traffic.prop2;
	s.prop3 = metrics.traffic.prop3;
	s.prop5 = metrics.traffic.prop5;
	s.prop7 = metrics.traffic.prop7;
	s.prop8 = metrics.traffic.prop8;
	s.prop9 = metrics.traffic.prop9;
	s.prop11 = metrics.traffic.prop11;
	s.prop12 = metrics.traffic.prop12;
	s.prop13 = metrics.traffic.prop13;
	s.prop14 = metrics.traffic.prop14;
	s.prop15 = metrics.traffic.prop15;
	s.prop16 = metrics.traffic.prop16;
	s.prop17 = metrics.traffic.prop17;
	s.prop18 = metrics.traffic.prop18;
	s.prop19 = metrics.traffic.prop19;
	s.prop22 = metrics.traffic.prop22;
	s.prop24 = metrics.traffic.prop24;
	s.prop25 = metrics.traffic.prop25;
	s.prop26 = metrics.traffic.prop26;
	s.prop29 = metrics.traffic.prop29;
	s.prop30 = metrics.traffic.prop30;
	s.prop31 = metrics.traffic.prop31;
	s.prop32 = metrics.traffic.prop32;
	s.prop37 = metrics.traffic.prop37;
	s.prop38 = metrics.traffic.prop38;
	s.prop39 = metrics.traffic.prop39;
	s.prop40 = metrics.traffic.prop40;
	s.prop42 = metrics.traffic.prop42;
	s.prop43 = metrics.traffic.prop43;
	s.prop44 = metrics.traffic.prop44;
	s.prop47 = metrics.traffic.prop47;
	s.prop48 = metrics.traffic.prop48;
}

/*******************************************************
*****		END: Populate Omniture Vars		 *******
*******************************************************/

/*******************************************************
*****		Helper Functions				 *******
*******************************************************/

function readCookiesInformation() {

	// regUserFlag and regUserId
	var authid = getCookieValue("authid");
	var regUserFlag = (authid != null) ? 'Registered' : 'Casual';
	var regUserId = (authid != null) ? authid : null;

	// check highlighted players
	var lb_saved_highlights = getCookieValue("lb_saved_highlights");
	var lb_highlights = getCookieValue("lb_highlights");
	var playersHighlighted = (lb_saved_highlights != null || lb_highlights != null) ? 'Has Highlighted Players' : 'No Highlighted Players';
	
	metrics.traffic.prop14 = regUserFlag;
	metrics.traffic.prop19 = regUserId;

}

function getCookieValue(searchName) {
	var cookies = document.cookie.split( ';' );
	var cookieHolder = '';
	var cookieName = '';
	var cookieValue = '';
	var cookieFound = false;
	for ( i = 0; i < cookies.length; i++ )
	{
		cookieHolder = cookies[i].split( '=' );
		cookieName = cookieHolder[0].replace(/^\s+|\s+$/g, '');	
		if ( cookieName == searchName )
		{
			cookieFound = true;
			cookieValue = unescape( cookieHolder[1].replace(/^\s+|\s+$/g, '') );
			return cookieValue;
			break;
		}
		cookieHolder = null;
		cookieName = '';
	}
	if ( !cookieFound )
	{
		return null;
	}
}
function strReplaceChar(oldChar, newChar, thisString)
{
	var newString = "";
	for (var n = 0; n < thisString.length; n++)
	{
		newString += (thisString.charAt(n) == oldChar) ? newChar : thisString.charAt(n);
	}
	return newString;
}

function capitalizeThis(str) {
	val = str;
	newVal = '';
	val = val.split(' ');
	for(var c=0; c < val.length; c++) {
		newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
	}
	return newVal.substring(0, (newVal.length-1));
}

function getTourFromTID(tid){	

	if (tid.search(tidRegExp) > -1 ){
		return tourName[tid.substring(0,1)]; 
	}
	else{
		return tourName.r;
	}

}

function toObj(a)
{
  var newObj = {};
  for(var i=0;i<a.length;i++)
  {
    newObj[a[i]]='';
  }
  return newObj;
}

function translatePage(page, section)
{
  var pageLength = page.length;
  var extLoc = pageLength - 5;

  if (section == 'courses'){
  	page = (page == 'index.html') ? 'Overview' : page;
  }
  
  else if (section == 'tournaments' && (page =='index.html' || page == 'pro-am.html' )){
  switch(page){
  	case 'index.html':
		page = 'Homepage';
		break;
	case 'pro-am.html':
		page = 'Pro-Am';
		break;
  }
  return page;
  }

	  page = ( page.indexOf('.html') > -1 ) ? page.substring(0,extLoc) : page;
	  page = ( page.indexOf('-') > -1) ? strReplaceChar('-', ' ', page) : page;
	  page = ( page.indexOf('_') > -1) ? strReplaceChar('_', ' ', page) : page;

  return capitalizeThis(page);
}

function getBlogAuthor(author){
	var blogger = new Array(
		'Tiger Woods', 'Charles Warren', 'David Toms', 'Heath Slocum', 'John Rollins', 
		'Brett Quigley', 'Davis Love III', 'Carl Pettersson', 'Davis Love III', 'Trevor Immelman',
		'Charles Howell III', 'Lucas Glover', 'Daniel Chopra', 'Chip Beck', 'Brandt Snedeker'
	);
	var blogAuthor;
	for(i=0; i<blogger.length; i++){
		if(author.indexOf(blogger[i]) > -1) {
			blogAuthor = blogger[i];
			break;
		}
		else{ blogAuthor='Player Undefined'};
	}
	return blogAuthor;
}
function setStatsMetricsVars(tour, year, id){
	tourID = tour;
	var currYear = new Date().getFullYear();
	var statYear = (year == 'current' ) ? currYear : year;
	var statID = id;	

	metrics.traffic.prop16 = tourID;
	metrics.traffic.prop26 = statID;
	metrics.hierarchy.hier1N = 'Competition' + '/' + tourName[tourID] + '/' + 'Stats' + '/' + statID + '/' + statYear;
	metrics.hierarchy.hier2N = 'Stats' + '/' + statID + '/' + tourName[tourID] + '/' + statYear;
	metrics.pageNameX = 'pgatour' + ':' + tourID + ':' + 'stats' + ':' + 'info' + ':' + statID + ':' + statYear;

}


function pageQuery( q ) {
 if( q.length > 1 ) this.q = q.substring( 1, q.length );
 else this.q = null;
 this.keyValuePairs = new Array();
 if( q ) {
  for( var i = 0; i < this.q.split( "&" ).length; i++ ) {
   this.keyValuePairs[i] = this.q.split( "&" )[i];
  }
 }
 this.getKeyValuePairs = function() { return this.keyValuePairs; }
 this.getValue = function( s ) {
  for( var j = 0; j < this.keyValuePairs.length; j++ ) {
   if( this.keyValuePairs[j].split( "=" )[0] == s )
   return this.keyValuePairs[j].split( "=" )[1];
  }
  return false;
 }
 this.getParameters = function() {
  var a = new Array( this.getLength() );
  for( var j = 0; j < this.keyValuePairs.length; j++ ) {
   a[j] = this.keyValuePairs[j].split( "=" )[0];
  }
  return a;
 }
 this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString( key ){
 var page = new pageQuery( window.location.search ); 
 return unescape( page.getValue( key ) ); 
}

/*******************************************************
*****		END: Helper Functions				 *******
*******************************************************/


/*******************************************************
*****		Page Categorization			 *******
*******************************************************/

/**********		Standard pages 			********/
if ( metrics.server in toObj(devServerList) || metrics.server in toObj(refServerList) || metrics.server in toObj(prodServerList) || metrics.server == 'www.pgatour.com' ){ 

	var i = 0;
	
	//base of the pageName
	metrics.pageName = "pgatour";
	//set metrics.pageName
	for (i=0; i < pL; ++i) {
		metrics.pageName += ':'+path_array[i];
	}
	
	//set metrics.traffic.prop1-3
	for (i = 0; i < pL; ++i) {
		if(pL > 3) {break;}
		var prop = 'prop'+(i+1);
		metrics.traffic[prop] = path_array[i];
	}
	
	//TOUR Homepage
	if (path_array[0] == '' || path_array[0] == 'index.html' || (path_array[0] == 'r' && path_array[1] == 'index.html' || path_array[1] == '') ){
		metrics.pageName = 'pgatour:r:index.html';
		
		//Traffic vars
		metrics.traffic.prop1 = 'Homepage';
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName.r + '/'  + metrics.traffic.prop1;
		metrics.hierarchy.hier2 = 'Homepage' + '/' + tourName.r;
		metrics.channel = '';
	}
	
	//Champions Homepage
	else if ( (path_array[0] == 's' && path_array[1] == 'index.html' || path_array[1] == '') ){
		metrics.pageName = 'pgatour:s:index.html';
		
		//Traffic vars
		metrics.traffic.prop1 = 'Homepage';
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName.s + '/'  + metrics.traffic.prop1;
		metrics.hierarchy.hier2 = 'Homepage' + '/' + tourName.s;
		metrics.channel = '';
	}
	
	//Nationwide Homepage
	else if ( (path_array[0] == 'h' && path_array[1] == 'index.html' || path_array[1] == '') ){
		metrics.pageName = 'pgatour:h:index.html';
		
		//Traffic vars
		metrics.traffic.prop1 = 'Homepage';
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName.h + '/'  + metrics.traffic.prop1;
		metrics.hierarchy.hier2 = 'Homepage' + '/' + tourName.h;
		metrics.channel = '';
	}
	
	//Tournaments
	else if (path_array[0] == 'tournaments' ){
		
		//Check to see if it is a regular tournament (if it has a tourney id [ex. r002])
		if (path_array[1].search(tidRegExp) > -1){

			tourneyId = path_array[1];
			
			metrics.traffic.prop17 = tourneyId;
			metrics.section = 'Tournaments';
			
			metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + translatePage(path_array[2], path_array[0]);	
			metrics.hierarchy.hier2 = metrics.section + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
			metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + metrics.section + '/' + translatePage(path_array[2], path_array[0]);
			
			if (path_array[2] == 'news'){
				metrics.hierarchy.hier1 += '/' + 'Archive';
				metrics.hierarchy.hier2 = metrics.section + '/' + translatePage(path_array[2], path_array[0]) + '/' + 'Archive' + '/' + tourneyId;
				metrics.hierarchy.hier3 += '/' + 'Archive';
			}		
		}
		//END regular tournaments

		//Special Tournaments
		if(path_array[1] in specialTID){

			tourneyId = specialTID[path_array[1]];
			metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + translatePage(path_array[2], path_array[0]);	
			metrics.hierarchy.hier2 = 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
			metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]);
			
		}
		//END Special Tournaments
		
		//Playoff Tournaments
		if (path_array[1] in toObj(playoffsTID)){
				
			metrics.section = 'Playoffs';
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Events' + '/' + metrics.section + '/' + 'Tournaments';
		
		}
		//END Playoff Tournaments
		
		//Company Page - tournament tickets
		else if (path_array[1] == 'tickets'){
			metrics.section = 'Company';
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + metrics.section + '/' + 'Corporate' + '/' + 'Tournament Tickets';
		}

	}
	
	//Major Microsites
	else if (path_array[0] in specialTID ){
		
		tourneyId = specialTID[path_array[0]];
		metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + translatePage(path_array[2], path_array[0]);	
		metrics.hierarchy.hier2 = 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
		metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]);		
		
	}
	//END Major Microsites
	
	//END Tournaments
	
	//Explore the Course
	else if (path_array[0] == 'courses'){
			
		tourneyId = path_array[1];
		metrics.traffic.prop17 = tourneyId;
		metrics.section = 'Tournaments';
					
		metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + 'Explore the Course' + '/' + translatePage(path_array[2], path_array[0]);			
		metrics.hierarchy.hier2 = metrics.section + '/' + 'Explore the Course' + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
		metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + metrics.section + '/' + 'Explore the Course' + '/' + translatePage(path_array[2], path_array[0]);

		if ( ( path_array[2].indexOf('hole') > -1) ){
			metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + 'Explore the Course' + '/' + 'Holes' + '/' + translatePage(path_array[2], path_array[0]);			
			metrics.hierarchy.hier2 = metrics.section + '/' + 'Explore the Course' + '/' + 'Holes' + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
			metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + metrics.section + '/' + 'Explore the Course' + '/' + 'Holes' + '/' + translatePage(path_array[2], path_array[0]);
		}

	}
	//END Explore the Course
	
	//Stats
	else if( (path_array[0] == 'r' || path_array[0] == 's' || path_array[0] == 'h') && path_array[1] == 'stats' ){

		tourID = path_array[0];
		var statId, statYear;
		
		metrics.traffic.prop16 = tourID;
		metrics.section = 'Stats';
			
		if( path_array[2].search(/\d{4}/) > -1){//This is an archived stats page (pre-2008).
			statId = translatePage(path_array[3]);
			statYear = path_array[2];
				
			metrics.traffic.prop26 = statId;	
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + statId + '/' + statYear;
			metrics.hierarchy.hier2 = metrics.section + '/' + statId + '/' + tourName[tourID] + '/' + statYear;
		}
		
		else if( path_array[2] == 'info' ){ //This is a post-2008 stats page
			statId = window.location.search;
			if ( statId.indexOf('&') > -1 )	statId = statId.substring(0, statId.indexOf('&'));			
			statId = statId.substr(1);
			statYear = '2008';
	
			setStatsMetricsVars(tourID, statYear, statId);
			metrics.traffic.prop26 = statId;
		}
						
		
		
		if (path_array[2] == 'index.html') {
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + 'Index Page';
			metrics.hierarchy.hier2 = metrics.section + '/' + 'Index Page' + '/' + tourName[tourID];
		}

	}

	//END: Stats
	
	//Schedule Pages
	else if( (path_array[0] == 'r' || path_array[0] == 's' || path_array[0] == 'h') && path_array[1] == 'schedule' ){
		
		tourID = path_array[0];
						
		metrics.section = 'Schedule Page';
		metrics.traffic.prop16 = tourID;
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section;
		metrics.hierarchy.hier2 = metrics.section + '/' + tourName[tourID];

	}
	//END: Schedule Pages
	
	//Leaderboard Pages
	
		//Main Leaderboard
		else if( (path_array[0] == 'r' || path_array[0] == 's' || path_array[0] == 'h') && path_array[1] == 'leaderboard' ){
			
			tourID = path_array[0];
			tourneyId = lb_id; //lb_id from LB page
			metrics.traffic.prop16 = tourID;
			metrics.traffic.prop17 = tourneyId;
			metrics.section = 'Live Scoring';
			
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + 'Basic Leaderboard' + '/' + 'Main Leaderboard';
			metrics.hierarchy.hier2 = metrics.section + '/' + 'Basic Leaderboard' + '/' + 'Main Leaderboard' + '/' + tourName[tourID] + '/' + tourneyId;
			metrics.hierarchy.hier3 = tourName[tourID] + '/' + 'Tournaments' + '/' + 'Basic Leaderboard' + '/' + 'Main Leaderboard';
		}
		
		//Generic and Alt Leaderboard
		else if( (path_array[0] == 'leaderboards') && (path_array[1] == 'current') && (path_array[2].search(tidRegExp) > -1) ){
			
			var lbPage;
			tourID = path_array[2].substring(0,1);
			tourneyId = path_array[2];

			metrics.traffic.prop16 = tourID;
			metrics.traffic.prop17 = tourneyId;
			
			if(path_array[3] == 'alt-1.html') lbPage = 'Alternate Leaderboard';
			if(path_array[3] == 'index.html') lbPage = 'Generic Leaderboard';
			
			metrics.section = 'Live Scoring';
			
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + 'Basic Leaderboard' + '/' + lbPage;
			metrics.hierarchy.hier2 = metrics.section + '/' + 'Basic Leaderboard' + '/' + lbPage + '/' + tourName[tourID] + '/' + tourneyId;
			metrics.hierarchy.hier3 = tourName[tourID] + '/' + 'Tournaments' + '/' + 'Basic Leaderboard' + '/' + lbPage;
		}
		
	//END:Leaderboard Pages
	
	//Players Index Pages
	else if( (path_array[0] == 'r' || path_array[0] == 's' || path_array[0] == 'h') && path_array[1] == 'players' ){
		
		tourID = path_array[0];
		
		metrics.section = 'Players';
		metrics.traffic.prop16 = tourID;
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + 'Index Page';
		metrics.hierarchy.hier2 = metrics.section + '/' + 'Index Page' + '/' + tourName[tourID] ;
		metrics.hierarchy.hier3 = tourName[playerTour] + '/' + metrics.section + '/' + 'Index Page';
	}
	//END:Players Index Pages
	
	//Players
	else if(path_array[0] == 'players'){
			
		var playerTour = tour;
		var plStatYear = 'get this!';
		var playerID = id_path.substr(1).split('/');
		playerID = playerID[0] + playerID[1] + playerID[2];

		metrics.traffic.prop18 = playerID;
		var url = ( window.results ) ? results[2] : null; //the results array is embedded on players stats pages
			
		var playersPage = {
			index: 	'Profile',
			media:	'Media Guide',
			streak:	'Streaks',
			career: 'Career Details',
			stats:	'Complete Stats',
			results:	'Results',
			perform:	'FedExCup Performance',
			scorecards:	'Archived Scorecards'
		}
		
		metrics.section = 'Players';
		
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[playerTour] + '/' + metrics.section + '/' + playerID + '/' + playersPage[url] + '/' + plStatYear;
		metrics.hierarchy.hier2 = metrics.section +  '/' + playersPage[url] + '/' + playerID;
		metrics.hierarchy.hier3 = tourName[playerTour] + '/' + metrics.section + '/' + playerID + '/' + playersPage[url];
		
		if (  (!window.location.search) ) url = 'index';
		
		if (url == 'media' || url == 'index' ){
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[playerTour] + '/' + metrics.section + '/' + playerID + '/' + playersPage[url];
			metrics.hierarchy.hier2 = metrics.section +  '/' + playersPage[url] + '/' + playerID;
			metrics.hierarchy.hier3 = tourName[playerTour] + '/' + metrics.section + '/' + playerID + '/' + playersPage[url];
		}
		
		if (path_array[4] == 'scorecards'){
			url = path_array[4];
			tourID = path_array[6].substring(0,1);
			tourneyId = translatePage(path_array[5]);
			metrics.traffic.prop16 = tourID;
			metrics.traffic.prop17 = tourneyId;
			
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + 'Live Scoring' + '/' + 'Scorecards' + '/' + playerID;
			metrics.hierarchy.hier2 = 'Live Scoring' +  '/' + 'Scorecards' + '/' + tourName[tourID] + '/' + tourneyId + '/' + playerID;
			metrics.hierarchy.hier3 += '/' + tourneyId;
		}

	}
	//END:Players
	
	//Company & Corporate Pages
	else if (path_array[0] == 'company'){
		
		var company_sales = ['marketing_online','marketing_title_sponsor','marketing_official_marketing_partnership','partners','marketing_retail','licensees'];
		var company_corp = ['about_us','executive_bios','productions','online_staff','giving','internships','employment_policy', 'benevolent', 'contactus'];
		var company_online = ['tos','privacy'];
		
		metrics.section = 'Company';

		var companyPage = {
			tos: 				'Terms of Service',
			privacy: 			'Privacy Policy',	
			marketing_online: 	'Online Advertising and Promotion', 
			partners: 			'Corporate Partners',
			licensees: 			'Licensees',
			marketing_retail: 	'Retail Licensing',
			marketing_official_marketing_partnership: 'Official Marketing Partners',
			marketing_title_sponsor: 'Title Sponsors',
			about_us: 			'About PGA TOUR',
			executive_bios: 	'Commissioners Office',
			productions: 		'PGA TOUR Productions',
			online_staff: 		'Online Staff',
			giving: 			'TOUR Charities',
			internships: 		'Internships',
			benevolent:			'Volunteer',
			employment_policy: 	'Employment Policies',
			contactus: 			'Contact Us'
		}
		
		var url = path_array[1].substring(0, (path_array[1].length - 5));
		
		if (url in toObj(company_sales)) metrics.subsection = 'Sales and Marketing';
		else if (url in toObj(company_corp) ) metrics.subsection = 'Corporate';
		else if (url in toObj(company_online) ) metrics.subsection = 'Online';
	
		
		metrics.hierarchy.hier1 = (path_array[1] == 'index.html') ? 'Site Based Features' + '/' + metrics.section + '/' + 'Index Page' : 'Site Based Features' + '/' + metrics.section + '/' + metrics.subsection + '/' + companyPage[url];
		
	}
	//END: Company & Corporate Pages
	
	//Q-School
	else if(path_array[0] == 'qschool'){
		
		metrics.section = 'Q-school';
		tourID = 'r';
		
		var qschoolPage = translatePage(path_array[1]);
		metrics.traffic.prop16 = tourID;
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Events' + '/' + tourName[tourID] + '/' + metrics.section;
		
		if ( (path_array[1].indexOf('tee-times') > -1) || (path_array[1].indexOf('field') > -1) || (path_array[1].indexOf('leaderboard') > -1)){
			metrics.hierarchy.hier1 += '/' + qschoolPage;
		}
	
	}
	//END: Q-School
	
	//Playoffs
	else if(path_array[0] == 'playoffs'){
		
		var playoffPage = translatePage(path_array[1]);
		
		metrics.section = 'Playoffs';
		
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Events' + '/' + metrics.section;
		
		if( (path_array[1].indexOf('tournaments.html') > -1) || (path_array[1].indexOf('about.html') > -1) || (path_array[1].indexOf('stats') > -1)){
			metrics.hierarcy.hier1 += '/' + playoffPage;
		}
	
	}
	//END: Playoffs
	
	//Stories
	
	else if( path_array[0].search(yearRegExp) > -1){

		var storySlug = null;
		
		metrics.traffic.prop11 = PGAArticleAuthor;
		metrics.traffic.prop12 = PGAArticleTitle;
		metrics.traffic.prop13 = PGAArticleDate;
		metrics.traffic.prop31 = 'Article';
		
		//Tournament Stories
		if( path_array[1] == 'tournaments' && path_array[2].search(tidRegExp) > -1){
			
			tourneyId = path_array[2];
			metrics.traffic.prop17 = tourneyId;

			tourID = path_array[2].substring(0,1);
			metrics.traffic.prop16 = tourID;

			storySlug = path_array[5];
			metrics.section = 'Tournaments';
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + tourneyId + '/' + 'News' + '/' + storySlug;
			metrics.hierarchy.hier2 = metrics.section + '/' + 'News' + '/' + storySlug + '/' + tourneyId;
			metrics.hierarchy.hier3 = tourName[tourID] + '/' + metrics.section + '/' + 'News' + '/' + storySlug;
		}
		//END: Tournament Stories
				
		//QSchool Stories
		else if( path_array[1] == 'qschool' ){
			
			storySlug = path_array[4];
			metrics.section = 'Qschool';
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Events' + '/' + tourName.r + '/' + metrics.section + '/' + 'News' + '/' + storySlug;
		}
		
		//Blogs
		else if(path_array[1] == 'blogs'){
			//Players
			if(path_array[2] == 'players'){
				metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'Blogs' + '/' + 'Players' + '/' + getBlogAuthor(PGAArticleAuthor);
			}
			else if(path_array[2] == 'bythenumbers'){
				metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'Blogs' + '/' + 'By The Numbers';
			}
			
			
		}
		//END: Blogs
		
		//Tour Insider
		else if(path_array[1] == 'tourinsider'){
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'TOUR Insider';
		}
		//END: Tour Insider
	}
	
	else if(path_array[0] == 'story' && path_array[1].search(/\d{7}/) > -1){//Pre-2007 Story
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'News' + '/' + 'Pre-2007';
		metrics.traffic.prop31 = 'Article';
	}
	
	//END: Stories
	
	//Tourlife
	else if (path_array[0] == 'tourlife' && ( path_array[1] == 'instruction' || path_array[1] == 'travel' || path_array[1] =='equipment') ){
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'TOURLife' + '/' + capitalizeThis(path_array[1]);
	}
	//END: Tourlife
	
	//Science of Golf
	else if(path_array[0] == 'scienceofgolf'){
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + translatePage(path_array[0]);
	}
	//END: Science of Golf
	
	///Special Offers
	else if(path_array[0] == 'promotions' || path_array[1] == 'specialoffers'){
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'Promotions' + '/' + 'Special Offers';		
	}
	//END: Special Offers
	
	//Multimedia
		
		//Swingplex
		else if( path_array[0] == 'swingplex' ){
	
			metrics.section = 'Swingplex';
			playerID = path_array[1] + path_array[2] + path_array[3];
			metrics.traffic.prop18 = playerID;
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + metrics.section + '/' + playerID;
		
		}
		//END:Swingplex
		
		//TV Times
		else if( path_array[0] == 'tv-times' ){
		
			metrics.section = 'TV Times';
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + metrics.section;
			
		}
		//END: TV Times
		
		//Video
		else if( path_array[0] == 'video' ){
		
			metrics.section = 'Video';
			metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + metrics.section;
			
		}
		//END: Video
		
		else if (path_array[0] == 'multimedia'){
		
			//Wireless
			if( path_array[1] == 'wireless' ){
		
				metrics.section = 'Wireless';
				metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + metrics.section;
			
			}
			//END: Wireless
			
			//Podcasts
			if( path_array[1] == 'podcasts' ){
		
				metrics.section = 'Podcasts';
				metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + 'Audio' + '/' + metrics.section;
			
			}
			//END: Podcasts
			
			//XM Network
			if( path_array[1] == 'audio' && path_array[2] == 'pgatournetwork' ){
		
				metrics.section = 'XM Network';
				metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Multimedia' + '/' + 'Audio' + '/' + metrics.section;
			
			}
			//END: XM Network
			
		}
		
	//END: Multimedia
	
	//News Archive
	else if (path_array[0] == 'news' ){
				
		metrics.section = 'News';
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + metrics.section + '/' + 'Archive';
		
	}
	
	else if( path_array[0] == 'story' && path_array[1] == 'archive' && path_array[2].search(/[r|s|h]/) >-1 ){
		
		tourID = path_array[2];
		metrics.section = 'News';
		metrics.traffic.prop16 = tourID;
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + metrics.section + '/' + tourName[tourID];
		
	}
	//END: News Archive
	
	//Live golf 
	else if ( path_array[0] == 'livegolf' ){
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'Live Golf';
	}
	//END: Live golf
	
	//Live@ Player
	else if ( path_array[0] == 'liveat' && path_array[1].search(/20\d{2}/) > -1){
		tourneyId = path_array[2];
		tourID = path_array[2].substring(0,1);
		metrics.traffic.prop16 = tourID;
		metrics.traffic.prop17 = tourneyId;
		
		metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + 'Tournaments' + '/' + tourneyId + '/' + 'Live@ Player';
		metrics.hierarchy.hier2 = 'Tournaments' + '/' + 'Live@ Player' + '/' + tourneyId;
		metrics.hierarchy.hier3 = tourName[tourID] + '/' + 'Tournaments' + '/' + 'Live@ Player';
	}
	//END: Live@ Player
	
	
	//Members Services Pages
	else if (path_array[0] == 'member_services'){

		var msPage = translatePage(path_array[1]);

		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Interactive' + '/' + msPage;
		
	}
	//END: Members Services Pages
	
}
/********		END: Standard pages 			********/

//World Golf Championships 
else if( metrics.server == 'www.worldgolfchampionships.com' ){
	if (path_array[0] == 'index.html' ){
		metrics.section = 'World Golf Championships';
		metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Events' + '/' + metrics.section + '/' + 'Index Page';
	}
	
	//Tournaments
	else if (path_array[0] == 'tournaments' ){
		
		//Check to see if it is a regular tournament (if it has a tourney id [ex. r002])
		if (path_array[1].search(tidRegExp) > -1){

			tourneyId = path_array[1];
			
			metrics.traffic.prop17 = tourneyId;
			metrics.section = 'Tournaments';
			
			metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + translatePage(path_array[2], path_array[0]);	
			metrics.hierarchy.hier2 = metrics.section + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
			metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + metrics.section + '/' + translatePage(path_array[2], path_array[0]);
			
			if (path_array[2] == 'news'){
				metrics.hierarchy.hier1 += '/' + 'Archive';
				metrics.hierarchy.hier2 = metrics.section + '/' + translatePage(path_array[2], path_array[0]) + '/' + 'Archive' + '/' + tourneyId;
				metrics.hierarchy.hier3 += '/' + 'Archive';
			}		
		}
		//END regular tournaments
		
	}
	
	//END Tournaments
	
	else if( path_array[0].search(yearRegExp) > -1){

		var storySlug = null;
		
		metrics.traffic.prop11 = PGAArticleAuthor;
		metrics.traffic.prop12 = PGAArticleTitle;
		metrics.traffic.prop13 = PGAArticleDate;
		metrics.traffic.prop31 = 'Article';
		
		//Tournament Stories
		if( path_array[1] == 'tournaments' && path_array[2].search(tidRegExp) > -1){
			
			tourneyId = path_array[2];
			metrics.traffic.prop17 = tourneyId;

			tourID = path_array[2].substring(0,1);
			metrics.traffic.prop16 = tourID;

			storySlug = path_array[5];
			metrics.section = 'Tournaments';
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + tourneyId + '/' + 'News' + '/' + storySlug;
			metrics.hierarchy.hier2 = metrics.section + '/' + 'News' + '/' + storySlug + '/' + tourneyId;
			metrics.hierarchy.hier3 = tourName[tourID] + '/' + metrics.section + '/' + 'News' + '/' + storySlug;
		}
		//END: Tournament Stories

	}
		
}
//END: World Golf Championships 

//Search Pages
else if( metrics.server == 'search.pgatour.com' ){
	metrics.hiearchy.hier1 = 'Site Based Features' + '/' + 'Interactive' + '/' + 'Search';
	metrics.traffic.prop29 = s.getQueryParam('query');	//search terms
	metrics.traffic.prop29.toLowerCase();
	metrics.traffic.prop30 = '';	//the number of search results
}
//END: Search Pages

//Majors Microsites


else if( metrics.server == 'www.majorchampionships.com' ){
	
	if( path_array[0].search(yearRegExp) > -1){

		var storySlug = null;
		
		metrics.traffic.prop11 = PGAArticleAuthor;
		metrics.traffic.prop12 = PGAArticleTitle;
		metrics.traffic.prop13 = PGAArticleDate;
		metrics.traffic.prop31 = 'Article';
		
		
		//Tournament Stories
		if( path_array[1] == 'tournaments' && path_array[2].search(tidRegExp) > -1){
			
			tourneyId = path_array[2];
			metrics.traffic.prop17 = tourneyId;

			tourID = path_array[2].substring(0,1);
			metrics.traffic.prop16 = tourID;

			storySlug = path_array[5];
			metrics.section = 'Tournaments';
			metrics.hierarchy.hier1 = 'Competition' + '/' + tourName[tourID] + '/' + metrics.section + '/' + tourneyId + '/' + 'News' + '/' + storySlug;
			metrics.hierarchy.hier2 = metrics.section + '/' + 'News' + '/' + storySlug + '/' + tourneyId;
			metrics.hierarchy.hier3 = tourName[tourID] + '/' + metrics.section + '/' + 'News' + '/' + storySlug;
		}
		//END: Tournament Stories

	}
	
	else if (path_array[0] in specialTID && path_array[1].search(yearRegExp) > -1){
		
		tourneyId = specialTID[path_array[0]];
		metrics.hierarchy.hier1 = 'Competition' + '/' + getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + tourneyId +'/' + translatePage(path_array[2], path_array[0]);	
		metrics.hierarchy.hier2 = 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]) + '/' + tourneyId;
		metrics.hierarchy.hier3 = getTourFromTID(tourneyId) + '/' + 'Tournaments' + '/' + translatePage(path_array[2], path_array[0]);		
		
	}

}
//END Majors Microsites		

else if( metrics.server == 'fantasy.pgatour.com' ){
	var fantasyGame, fantasyPageType, gameID;
	
	if(path_array[0] == 'golf'){
		fantasyPageType = 'Info Pages';
		switch (path_array[1]){
			case 'pgapickem':
				fantasyGame = 'pick \'em';
				break;
			case 'salarycapcup':
				fantasyGame = 'Salary Cap Cup';
				break;
			default:
				fantasyGame = 'Game Undefined';
				break;
		}
	} 
	
	else if(path_array[0] == 'scripts' && window.location.search.indexOf('game') > -1 ){
		gameID = queryString('game');
		fantasyPageType = 'Game Play Pages';
		switch(gameID){
			case '30':
				fantasyGame = 'pick \'em';
				break;
			case '31':
				fantasyGame = 'Salary Cap Cup';
				break;
			default:
				fantasyGame = 'Game Undefined';
				break;
		}
	}
	metrics.hierarchy.hier1 = 'Site Based Features' + '/' + 'Franchise' + '/' + 'Fantasy' + '/' + fantasyGame + '/' + fantasyPageType;
	
}


/*******************************************************
*******		END: Page Categorization	        ********
*******************************************************/
