/* ========================================================================================

	OMNITURE CUSTOM CODE

	Primary Author: Mike Liu (mliu@acumensolutions.com)

	Last update: 10/11/2011 - RD



	This code is included on all TravelChannel.com pages.

   ======================================================================================== */





/*

	====================== BEGIN VARIABLE FUNCTIONS =========================

	buildPageName - builds s.pageName.  This logic is specific to travelchannel.com

	========================================================================

*/



/*

	FUNCTION rebuilds the s.pageName variable which is a friendlier reverse path of the sections,

	sub-sections and article name.  Can only be used once all other variables are set.

*/

var buildPageName = function () {

	// last used to avoid double-printing article/section

	var last = pName = "Home";

	try{

		// if there's only a domain, the page is "Home"

		if (urlVars.length <= 3) {

			return pName;

		}

		// check for a top channel

		if (s.prop15 && s.prop15 != "") {

			// append top channel

			last = s.prop15;

			pName = pName + ":" + s.prop15;



			// if this is a places/trips page, append destination data

			if (s.prop15 == "Travel_Guides") {

				if (s.prop40 && s.prop40 != "") {

					last = s.prop40;

					pName = pName + ":" + s.prop40;

				}

				if (s.prop41 && s.prop41 != "") {

					last = s.prop41;

					pName = pName + ":" + s.prop41;

				}

				if (s.prop42 && s.prop42 != "") {

					last = s.prop42;

					pName = pName + ":" + s.prop42;

				}

				if (s.prop43 && s.prop43 != "") {

					last = s.prop43;

					pName = pName + ":" + s.prop43;

				}

				// append destination subcategory if applicable

				if (s.prop21 && s.prop21 != "") {

					last = s.prop21;

					pName = pName + ":" + s.prop21;

				}

			} else if (s.prop15 == "Travel_Ideas") {

				// append sub-section 1 if applicable

				if (s.prop16 && s.prop16 != "" && urlVars.length > 5) {

					last = s.prop16;

					pName = pName + ":" + s.prop16;

				}

				// append sub-section 2 if applicable

				if (s.prop23 && s.prop23 != "") {

					last = s.prop23;

					pName = pName + ":" + s.prop23;

				}

				// append sub-section 3 if applicable

				if (s.prop24 && s.prop24 != "") {

					last = s.prop24

					pName = pName + ":" + s.prop24;

				}

			} else {

				// append sub-section 1 if applicable

				if (s.prop16 && s.prop16 != "" && urlVars.length > 5) {

					last = s.prop16;

					pName = pName + ":" + s.prop16;

				}

				// append sub-section 2 if applicable

				if (s.prop23 && s.prop23 != "") {

					last = s.prop23;

					pName = pName + ":" + s.prop23;

				}

				// append sub-section 3 if applicable

				if (s.prop24 && s.prop24 != "") {

					last = s.prop24;

					pName = pName + ":" + s.prop24;

				}

			}

		}



		// append articlename if not the same as prop21

		if (s.prop17 && s.prop17 != "" && s.prop17 != last) {

			pName = pName + ":" + s.prop17;

		}

	} catch(e) {



	}

	// strip underscores

	return removeUnderscores(pName);

}









/* ========================================================================================== */

/* ========================= START TRAVELCHANNEL.COM VARIABLES ============================== */

/* ========================================================================================== */



/*

	************** travelchannel.com url-based variables **************

	This section pertains only to the main www.travelchannel.com site.  Some variables are also set in off-site

	pages (s.prop16 subsection, s.prop17 article name) but the logic is different.

	*******************************************************************

*/

try {



	/* START PROP15 - top channel GLOBAL */

	if (urlVars.length > 4) {

		if (urlVars[3] == "Places_Trips") {

			// remove this element

			urlVars.splice(3,1);

		}

		if (location.host=="stg-newsearch.travelchannel.com" || location.host=="search.travelchannel.com") {

		s.prop15 = "Search";}

		else {s.prop15 = urlVars[3];}

	} else if (urlVars.length == 4) {

		// Add other custom top-channel level variables here

		switch (urlVars[3]) {

			case "Video":

				s.prop15 = "Videos_and_Photos";

				break;

			case "Schedule":

				s.prop15 = "tv_schedule";

				break;

		}

	} else if (urlVars.length <= 3) {

		// TC.com home level, no top channel

		if (location.host=="stg-newsearch.travelchannel.com" || location.host=="search.travelchannel.com") {

		s.prop15 = "Search";}

		else {s.prop15 = "Home"}

	}

	/* END PROP15 */



	/* PROP15 DETERMINES WHICH OTHER URL VARS ARE SET */

	var tempProp16, tempProp21, tempProp43;

	if (s.prop15 == "Destinations") {

		// set s.prop16 sub-section

		s.prop15 = "Travel_Guides";



		/* START PROP40 - DESTINATION Continent */

		tempProp16 = s.prop40 = urlVars[4];

		/* END PROP40 */



		/* START PROP41 - DESTINATION Country */

		s.prop41 = urlVars[5];

		/* END PROP41 */



		/* START tempPROP21, PROP42, PROP43 - DESTINATION sub-category, State, City */

		// Determine STATE only if Country = US/CAN

		if (s.prop41 == "United_States" || s.prop41 == "Canada") {

			if (urlVars.length > 8) {

				// subcategory after the city name

				tempProp21 = strip(urlVars[8]);

			}

			s.prop42 = urlVars[6];

			tempProp43 = strip(urlVars[7]);

		} else {

			// checks if there is another level of depth

			if (urlVars.length > 7) {

				// subcategory after the city name

				tempProp21 = strip(urlVars[7]);

			}

			// State does not apply, s.prop42 is not defined

			tempProp43 = strip(urlVars[6]);

		}

		s.prop43 = tempProp43;

		/* END tempPROP21, PROP42, PROP43 */

	} else if (s.prop15 == "Travel_Ideas") {

		// set s.prop16 sub-section

		tempProp16 = urlVars[4];



		/* START PROP31 - Destination Content type */

		s.prop31 = urlVars[4];

		/* END PROP31 */

	} else if (s.prop15 == "TV_Shows") {

	/* THIS SECTION PERTAINS TO TV_SHOWS */

		if (urlVars.length >= 5) {

			// set s.prop16 sub-section

			tempProp16 = urlVars[4];



			/* START PROP20 - content area subsection */

			s.prop20 = strip(urlVars[5]);

			/* END PROP20 */

		}

		/* START PROP18 - content area (=tv show) */

		s.prop18 = tempProp16; // equal to s.prop16 which hasn't been set yet

		/* END PROP18 */

	}



	/* START PROP16 - subsection 1 */

	s.prop16 = tempProp16;

	/* END PROP16 */



	/* START PROP21 - destination content type */

	s.prop21 = tempProp21;

	/* END PROP21 */



	/* START PROP23, PROP24 - sub-section 2 and 3 */

	if (urlVars.length > 6) {

		s.prop23 = urlVars[5];

	}



	if (urlVars.length > 7) {

		s.prop24 = urlVars[6];

	}

	/* END PROP23 and PROP24 */



	/* START PROP17 - article name GLOBAL */

	// getting last index of urlVars accounts for extra sub-directories

	// if urlVars.length <= 3, it is the homepage of the domain

	if (urlVars.length > 3) {

		s.prop17 = strip(urlVars[urlVars.length -1]);

	}

	/* END PROP17 */



	/* START PAGENAME */

	s.pageName = buildPageName();

	/* END PAGENAME */



	



	/*

		****************** NON-URL-based variables ******************

			s.prop28-30, 32-39 - Video/VCM properties

		*************************************************************

	*/

	

	if (typeof s.events == "undefined") {s.events="event1";}

	

	

	/* Search Parmeters */

	var tcHost=location.host;

	var tcPath=location.pathname;

	var tcHref=location.href;

	tcHost=tcHost.toLowerCase();

	tcPath=tcPath.toLowerCase();

	tcHref=tcHref.toLowerCase();

	

	if (tcHost == "search.travelchannel.com"  || tcHost == "stg-newsearch.travelchannel.com" || tcHost == "qa-newsearch.travelchannel.com") {

		s.pageName=tcHost + tcPath;		

		s.events="event1";

		s.prop12="TRV";

		s.eVar12=s.prop12;

		s.prop15="search";

		s.eVar15=s.prop15;

		s.channel="search";

		s.prop17="";

		s.eVar17=s.prop17;

		

		//No Results Page

		if (noSearchResults.indexOf("no results") != -1) {

			s.events=s.events + ",event5";

			s.prop19=searchTerms;

			s.eVar19=s.prop19;

			s.prop51=keyterm;

			s.eVar51=s.prop51;

			s.prop54="search:" + searchTerms;

			s.eVar54=s.prop54;

			s.prop55="no results:" + searchTerms;

			s.eVar55=s.prop55;

		}

		else {

			if (searchTerms != ""  && urlVars[5].indexOf("page-") == -1) {s.events=s.events + ",event5"; s.prop19=searchTerms; s.eVar19=s.prop19;}

			if (spotLight1 != "" || spotLight2 != "") {s.events=s.events + ",event28";}

			//s.prop19=searchTerms;

			//s.eVar19=s.prop19;

			s.prop51=keyterm;

			s.eVar51=s.prop51;

			s.prop52=dimensions;

			s.eVar52=s.prop52;

			s.prop53=dimensionValues;

			s.eVar53=s.prop53;

			s.prop54=filter;

			s.eVar54=s.prop54;

			s.prop55=noSearchResults;

			s.eVar55=s.prop55;

			s.prop59=spotLight1;

			s.eVar59=s.prop59;

			s.prop60=spotLight2;

			s.eVar60=s.prop60;

		}

	}

	//Topic Pages

	if (urlVars[3] == "topics") {

		s.pageName=tcHost+tcPath;

		s.prop15="topics";

		s.eVar15=s.prop15;

		s.channel="search";

		s.prop17="";

		s.eVar17=s.prop17;

		if (urlVars[4].indexOf("index.html") != -1) {

			s.prop16="topic index";

			s.events="event1";

		}

		else {

			s.prop16="topic page";

			s.eVar7=urlVars[4];

			s.events="event1,event32";

		}

		s.eVar16=s.prop16;

	}

	

	/* Sweeps */

if (tcHost.indexOf("api.scrippsnetworks.com") !=-1 || tcHref.indexOf("travelchannel.com/sweepstakes") !=-1) {

	/*var tcSweeps = "";

	if (urlVars.length >= 4) {

		if (urlVars[3] == "sweepstakes") {tcSweeps="true";} else {tcSweeps="false";}

	}*/

	

	var tcSweepsPage = (tcPath.indexOf("sweeps-1") > 0) ? "begin" : (tcPath.indexOf("sweeps-2") > 0) ? "registration" : (tcPath.indexOf("sweeps-3") > 0) ? "trivia-introduction" : (tcPath.indexOf("sweeps-4") > 0) ? "trivia-game" : (tcPath.indexOf("sweeps-5") > 0) ? "trivia-answer" : (tcPath.indexOf("sweeps-6") > 0) ? "instant-win" : (tcPath.indexOf("sweeps-7") > 0) ? "spread-the-word" : (tcPath.indexOf("sweeps-error") > 0) ? "already-registered" : (tcPath.indexOf("sweepstakes/rules") > 0) ? "rules" : (tcPath.indexOf("sweepstakes/faq") > 0) ? "FAQs" : (tcPath.indexOf("sweepstakes/winners") > 0) ? "winners" : (tcPath.indexOf("sweepstakes/prizes") > 0) ? "prizes" : (tcPath.indexOf("sweepstakes/confirmation") > 0) ? "confirmation" : "";

	if (tcSweepsPage != "") {

		s.pageName="sweepstakes:" + tcSweepsPage;

		s.prop17="sweeps-" + tcSweepsPage;

	}

	else {s.pageName="sweepstakes:home"; s.prop17="";}

	s.channel="sweepstakes";

	s.prop15="sweepstakes";

	s.prop16="travel_sweepstakes";

	s.prop23="";

	s.events="event1,event14";

	s.eVar15=s.prop15;

	s.eVar16=s.prop16;

	s.eVar17=s.prop17;

	s.eVar23=s.prop23;

	

	/*if (tcSweepsPage != "") {

		s.prop17="sweeps-" + tcSweepsPage;

		s.eVar17=s.prop17;

		if (tcSweepsPage == "instant-win") {s.events=s.events + ",event29";}

		else if (tcSweepsPage == "registration") {s.events=s.events + ",event30";}

		else if (tcSweepsPage == "spread-the-word") {s.events=s.events + ",event15";}

		else if (tcSweepsPage == "??") {s.events=s.events + ",event10";}

	}*/

	

	

}

	

	//mdManager integration

	//check for existence of mdManager

	if (typeof mdManager != "undefined") {

		var pageType = mdManager.getParameterString("Type");

		pageType = pageType.toLowerCase();

		if (pageType == "slideshow"  || pageType == "photo_gallery") {

			s.events="event1,event19";

		}

		s.pageName = mdManager.getParameterString("Url");

		s.pageName = s.pageName.toLowerCase();

		s.channel = mdManager.getParameterString("CategoryDspName");

		s.channel = s.channel.toLowerCase();

		s.prop5  = mdManager.getParameterString("SctnDspName");

		s.prop5 = s.prop5.toLowerCase();

		s.prop6  = mdManager.getParameterString("Title");

		s.prop7  = mdManager.getParameterString("Sponsorship");

		s.prop8  = mdManager.getParameterString("Classification");

		s.prop9  = mdManager.getParameterString("UniqueId");

		s.prop9 = s.prop9.toUpperCase();

		s.prop10 = pageType;

		s.prop15 = mdManager.getParameterString("CategoryDspName");

		s.prop16 = mdManager.getParameterString("SctnDspName");

		//s.prop17 needs to be set to slideshow name (e.g. "slideshow_tucson_sonoran_hot_dog_war") - set from url currently

		//s.prop23 needs to be set to subcategory2 (e.g. "food") - set from url currently

		//s.prop31 - set to travel ideas category (e.g. "food_and_drink")

		

		s.prop57 = mdManager.getParameterString("TalentName");

		s.prop57 = s.prop57.toLowerCase();

		s.prop50 = mdManager.getParameterString("DelvFrmt");

		s.prop50 = s.prop50.toLowerCase();

		

		s.prop3 = mdManager.getParameterString("AdKey1");

		s.prop4 = mdManager.getParameterString("AdKey2");

		s.prop58 = mdManager.getParameterString("Show_Abbr");

		s.prop61 = mdManager.getParameterString("Source");

		

		s.prop62 = mdManager.getParameterString("Country");

		s.prop63 = mdManager.getParameterString("State");

		s.prop64 = mdManager.getParameterString("City");

		s.prop65 = mdManager.getParameterString("Region");

		s.prop66 = mdManager.getParameterString("PointOfInterest");

		s.prop67 = mdManager.getParameterString("Interest");

		s.prop68 = mdManager.getParameterString("OriginalPubDate");



		if(mdManager.getParameterString("Role") == "PACKAGE") {s.events=s.events + ",event18";}

	}

	



	/* START PROP12 - Business unit */

	if (!s.prop12) {

		s.prop12 = "TRV";

	}

	/* END PROP12 */



	/* START PROP13 - reserved/unused */

		// RESERVED/UNUSED

	/* END PROP13 */



	/* START PROP28-30 - video properties */

		// Comes automatically from video player

	/* END PROP28-30 */



	/* START PROP32-39 - video properties pulled from TMC */

		// Comes automatically from video player



	/* Set pageVCMID */

	if (typeof(pageVCMID) != "undefined") {

		if (pageVCMID != "") {

			s.prop39 = pageVCMID;

		}

	}

	/* END PROP32-39 */

} catch(e) {



}

/* ========================================================================================== */

/* =========================== END TRAVELCHANNEL.COM VARIABLES ============================== */

/* ========================================================================================== */
