/****************************************
 * 7.15.11 - NPA changes for tracking new app pages
 * 6.20.11 - changes for adv II product pages
 * 4.26.11 - changes for the pet specialty/mobile optimized page
 * Numeric Analytics Tagging Framework
 * v 2.2  Aug 1, 2010
****************************************/

try{
function nafTemplateObj(){//default template object that all objects are instantiated from
	this.setProperty = function(pName,pValue){
		this[pName] = pValue;
	}
	this.getProperty = function(pName){
		if(this[pName]){return this[pName];}else{return "";}
	}
}
var naf = new nafTemplateObj();//root framework object

//A private object that is used for configuration of the framework.  All properties should be set by code, not programatically so that proper framework functioning is assured
naf._config = {};
//Utilities object to hold the tools needed to transverse the DOM, set events, get elements etc.
naf.utils = {};
//Web Analytics Object
naf.wa = new nafTemplateObj(); 
//Voice of Customer Object for anything relating to surveying
// naf.voc = new nafTemplateObj(); 
//Customer Experience Management for anything relating to the customer experience
// naf.cem = new nafTemplateObj(); 

// ****************** START CONFIG *********************************
naf._config.getLocationtoSelf = function(){
	var myName = /(^|[\/\\])numericAnalyticsFramework\.js(\?|$)/;
	var scripts = document.getElementsByTagName("script");
	for (var i = 0; i < scripts.length; i++) {
	    var src1 = scripts[i].getAttribute("src");
	    if (src1) {
	      if (src1.match(myName)) {
	        src1 = src1.substring(0, src1.lastIndexOf("/")+1);
	        return src1; 
	      }
	    }
	}
}
naf._config.openScrpt = '<scr' + 'ipt language="JavaScript" type="text/javascript" src="';
naf._config.closeScrpt = '"></scr' + 'ipt>';
naf._config.baseUrl = naf._config.getLocationtoSelf();



// ****************** END CONFIG *********************************

// ****************** START UTILS *********************************
naf.utils.sanitizeUntrusted = function(s) {
 if(s){
	return s.replace(/(;)|(')|(<)|(>)|(=)|(\))|(\()/igm,'!');
  }
}

naf.utils.isEmpty = function(s){ return ((s == null) || (s.length == 0))}

naf.utils.isUndefined = function(s) { return (typeof s == "undefined")} 

naf.utils.getQueryParam = function(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return naf.utils.sanitizeUntrusted(results[1]);
}

naf.utils.isIE = (window.navigator.userAgent.indexOf("MSIE") > -1);

// ****************** END REQUIRED *****************************
// ******************  START PLUGINS *********************************
	

// Chip Cookie Object	
naf.utils.cookieIngredients=function(){
  //Constants
  this.chip_cookie_name = "BIGNUMERIC";
  this.name_value_delim = "~";
  this.cookie_delim = "|";
  // this.length = -1;
  // Example: this.chips = { "cookiename1":cookievalue1, "cookiename2": cookievalue2 };
  this.chips = {};
  // Adds a name/value pair to the cookie's value array params: n = name, v = value
	this.add = function(n,val){
		this.chips[n]=val;
	}
	// Remove the cookie named cname and its value from the chips.
	this.eat = function(cname){
		for(var key in this.chips){ 
			if(key.indexOf(cname) >= 0){
				delete this.chips[key];
			 	break;
			}
		} 
	}
	// Return the value of the cookie requested (cname). Loop through the hash and if the cookie name is one of the hash keys return it's value.
	this.read = function(cname){
		var tmp = "";
		for(var key in this.chips){ 
			if(key.indexOf(cname) >= 0){
			 	tmp = this.chips[key];
			 	return tmp;
			 	break;
			} 
		}
		return null;
	}
	// Takes the values of an existing chip cookie and populates the chipCookie object
	this.fill = function(str){
		var strArray = str.split(this.cookie_delim);
		for ( var i=0; i<strArray.length; ++i ){
			var namevalpair = strArray[i].split(this.name_value_delim);
			this.add(namevalpair[0],namevalpair[1]);
		}
		
	}
	// Returns name value pairs separated by the defined delimiters
	this.bake = function(){
		var tmpArray = new Array();
		 for(var key in this.chips){ 
		 		tmpArray.push(key + this.name_value_delim + this.chips[key]);
		 } 
		tmp = tmpArray.join(this.cookie_delim);
		return tmp;
	}
	// Returns how many chips are there?
		this.size = function(){
		var len =  0;
			    for (var k in this.chips)
			      len++;
		return len;
		}
};

// 	setChip(cookiename, cookievalue) : adds a name/value to the MEGA cookie. If the name already exists in the MEGA cookie it will overwrite its value.
naf.utils.setChip=function(cname, cval){ 
    var theChips = new naf.utils.cookieIngredients();
	var tmp = "";
	//The cookie already exists. Add a new value to it.
	if (naf.utils.getCookie(theChips.chip_cookie_name)){
			//Get the contents of the chip cookie
			tmp = naf.utils.getCookie(theChips.chip_cookie_name);
			theChips.fill(tmp);
			// add a new chip
			theChips.add(cname,cval);
			//Write the new cookie
 			naf.utils.setCookie(theChips.chip_cookie_name, theChips.bake());
		}else{
			// add the first chip
			theChips.add(cname,cval);
			//Write the new cookie
 			naf.utils.setCookie(theChips.chip_cookie_name, theChips.bake());
		}		
}

// getChip(cookiename) : returns the value of a chip
naf.utils.getChip=function(cname){
	var theChips = new naf.utils.cookieIngredients();
	var tmp = "";
		//The cookie already exists. Add a new value to it.
			if (naf.utils.getCookie(theChips.chip_cookie_name)){
				//Get the contents of the chip cookie
				tmp = naf.utils.getCookie(theChips.chip_cookie_name);
				theChips.fill(tmp);
				// add a new chip
				return theChips.read(cname);
			}else{
				return null;
			}		
}

// deleteChip(cookiename) : deletes a chip from the MEGA cookie. It does not delete the MEGA cookie
naf.utils.deleteChip=function(cname) {
	var theChips = new naf.utils.cookieIngredients();
	var tmp = "";
	// The big cookie exists
	if (naf.utils.getCookie(theChips.chip_cookie_name)){
		//Get the contents of the chip cookie
		tmp = naf.utils.getCookie(theChips.chip_cookie_name);
		theChips.fill(tmp);
		//Remove the chip from the cookie
		theChips.eat(cname);
		//Write the new cookie
	 	naf.utils.setCookie(theChips.chip_cookie_name, theChips.bake());
	}
}

naf.utils.setCookie=function(name, value, expires){
	var path = "/";
	
	domain = document.domain;
	dparts = domain.split(".");
	if (dparts.length == 3) {
	   rootDomain = dparts[1]+"."+dparts[2];
	} else {
	   rootDomain = domain;
	}
	
	var secure = false;
	var cookie = name + "=" + unescape(value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) +
	((rootDomain == null) ? "" : ("; domain=" + rootDomain)) +
	((secure == true) ? "; secure" : "");
	
	document.cookie = cookie;
}

naf.utils.getCookie = function(name){
	    var cookieValue = null;
	    if (document.cookie && document.cookie != '') {
	        var cookies = document.cookie.split(';');
	        for (var i = 0; i < cookies.length; i++) {
	            var cookie = cookies[i].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	            // Does this cookie string begin with the name we want?
	            if (cookie.substring(0, name.length + 1) == (name + '=')) {
	                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
	                break;
	            }
	        }
	    }
	    return naf.utils.sanitizeUntrusted(cookieValue);
}


//helper function to get an element by attribute and substring 
naf.utils.getElementsByAttributeSubstring = function(oElm, strTagName, strAttributeName, strAttributeValue){

	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("^" + strAttributeValue) : null;
	var oCurrent;
	var oAttribute;
	
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		
		//munge the function types for IE
		if(typeof oAttribute == 'function'){
			oAttribute = oAttribute.toString();
			var from = oAttribute.indexOf('{') + 2;
			var length = oAttribute.length - 1 - from;
			oAttribute = oAttribute.substr(from, length);
		}
		
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				var arrLength = arrReturnElements.length;
				if(arrLength > 0){
					arrReturnElements[arrLength+1] = oCurrent;
				}else{
					arrReturnElements[0] = oCurrent;
				}
			}
		}
	}
	return arrReturnElements;
}
naf.utils.getEventTarget = function(e){
	try {
		var targ = null;
		if (!e) {
			var e = window.event;
		}
		if (e.target) {
			targ = e.target;
		} 
		else if (e.srcElement) {
			targ = e.srcElement;
		}
		if (targ.nodeType == 3) {
			targ = targ.parentNode;
		}
		return targ;
	} catch(e) {return null;}
}
naf.utils.addEvent = function(func, El, evt){
	try{
		if(El.attachEvent){		
			El.attachEvent("on"+evt.toLowerCase(),func);
		}
		 if(El.addEventListener){
				El.addEventListener(evt.toLowerCase(),func,false);
		} 
		return this;
	}catch(e){}
}


 
//helper function to get element by classname and some string
naf.utils.getElementsByClassName = function(strClass, strTag, objContElm) {
	strTag = strTag || "*";
	objContElm = objContElm || document;
	var objColl = objContElm.getElementsByTagName(strTag);
	if (!objColl.length && strTag == "*" && objContElm.all)
		objColl = objContElm.all;
	var arr = new Array();
	var delim = strClass.indexOf('|') != -1 ? '|' : ' ';
	var arrClass = strClass.split(delim);
	for ( var i = 0, j = objColl.length; i < j; i++) {
		var arrObjClass = objColl[i].className.split(' ');
		if (delim == ' ' && arrClass.length > arrObjClass.length)
			continue;
		var c = 0;
		comparisonLoop: for ( var k = 0, l = arrObjClass.length; k < l; k++) {
			for ( var m = 0, n = arrClass.length; m < n; m++) {
				if (arrClass[m] == arrObjClass[k])
					c++;
				if ((delim == '|' && c == 1)
						|| (delim == ' ' && c == arrClass.length)) {
					arr.push(objColl[i]);
					break comparisonLoop;
				}
			}
		}
	}
	return arr;
}
// ******************  END UTILS *********************************

//*******************  Default Settings **************************
//metricData.currentSiteId = "PP";
//metricData.pageNameSeparator = " : ";
naf.setProperty('trackPage', 'true');
naf.setProperty('currentSiteId','PP');
naf.setProperty('pageNameSeparator',' : ');

if(location.href.toLowerCase().indexOf("/photo.aspx/uploadpersonalphoto") > -1){
	naf.setProperty('trackPage', 'false');
}

//Site Section Data Structure	 	 	 	 	 
naf.aSiteSectionData = [	 	 	 	 	 
 	{'urlCompareString':'petparents.com/','siteSection':'Universal','siteSectionAbbr':'UP'},
 	{'urlCompareString':'/account.aspx/','siteSection':'Universal','siteSectionAbbr':'UP'},
 	{'urlCompareString':'/show.aspx/dogs','siteSection':'Dogs','siteSectionAbbr':'DG'},
 	{'urlCompareString':'/show.aspx/cats','siteSection':'Cats','siteSectionAbbr':'CT'},
 	{'urlCompareString':'/show.aspx/horses','siteSection':'Horses','siteSectionAbbr':'HR'},
 	{'urlCompareString':'/community.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
 	{'urlCompareString':'/petparent.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
 	{'urlCompareString':'/ecard.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
  	{'urlCompareString':'/tools.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
  	{'urlCompareString':'/askanexpert.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
  	{'urlCompareString':'/findascanner.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/findavet.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/questionnaire.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/riskmap.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/video.aspx/','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/advantage-for-dogs','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/advantage-for-cats','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/feather-arrow','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/k9-advantix','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/profender','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/products','siteSection':'Products','siteSectionAbbr':'PD'},
   	{'urlCompareString':'/show.aspx/conditions-of-use','siteSection':'Universal','siteSectionAbbr':'UP'},
   	{'urlCompareString':'/show.aspx/privacy-statement','siteSection':'Universal','siteSectionAbbr':'UP'},
   	{'urlCompareString':'/show.aspx/imprint','siteSection':'Universal','siteSectionAbbr':'UP'},
   	{'urlCompareString':'/show.aspx/about-us','siteSection':'Universal','siteSectionAbbr':'UP'},
   	{'urlCompareString':'/contactus.aspx/','siteSection':'Universal','siteSectionAbbr':'UP'},
   	{'urlCompareString':'/show.aspx/site-map','siteSection':'Universal','siteSectionAbbr':'UP'},
    {'urlCompareString':'/petparent.aspx/register','siteSection':'Universal','siteSectionAbbr':'UP'},
    {'urlCompareString':'/photo.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
    {'urlCompareString':'/pet.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
    {'urlCompareString':'/appointment.aspx/','siteSection':'Community','siteSectionAbbr':'CM'},
    {'urlCompareString':'/show.aspx/question/','siteSection':'Tools','siteSectionAbbr':'TL'},  
    {'urlCompareString':'petparent.aspx/confirmation','siteSection':'Community','siteSectionAbbr':'CM'},
    {'urlCompareString':'/search.aspx','siteSection':'Search','siteSectionAbbr':'SR'},
    {'urlCompareString':'/specialoffersingup.aspx','siteSection':'Products','siteSectionAbbr':'PD'},
    {'urlCompareString':'/poochprotest','siteSection':'Microsite','siteSectionAbbr':'MS'},
    {'urlCompareString':'/show.aspx/pest-protection','siteSection':'Microsite','siteSectionAbbr':'MS'},
   	{'urlCompareString':'/show.aspx/problems','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/protecting-your-dog-from-pests','siteSection':'Tools','siteSectionAbbr':'TL'},
   	{'urlCompareString':'/show.aspx/protecting-your-cat-from-pests','siteSection':'Tools','siteSectionAbbr':'TL'},
	{'urlCompareString':'/newpetacquisition.aspx','siteSection':'Microsite','siteSectionAbbr':'MS'},
	{'urlCompareString':'/newpetacquisition.aspx/confirmation','siteSection':'Microsite','siteSectionAbbr':'MS'},
	{'urlCompareString':'/newpetacquisition.aspx/register','siteSection':'Microsite','siteSectionAbbr':'MS'}
 	];

//Site Sub Section Data Structure	 	 	 	 	 
naf.aSiteSubSectionData = [	 	 	 	 	 
 	{'urlCompareString':'petparents.com/','siteSubSection':'Home','siteSubSectionAbbr':'HP'},
 	{'urlCompareString':'/account.aspx/logon','siteSubSection':'Login','siteSubSectionAbbr':'LN'},	
 	{'urlCompareString':'/petparent.aspx/register','siteSubSection':'Sign Up','siteSubSectionAbbr':'SU'},
  	{'urlCompareString':'/account.aspx/forgotpassword','siteSubSection':'Forgot Password','siteSubSectionAbbr':'FP'},
  	{'urlCompareString':'/show.aspx/conditions-of-use','siteSubSection':'Conditions of Use','siteSubSectionAbbr':'CU'},
  	{'urlCompareString':'/show.aspx/privacy-statement','siteSubSection':'Privacy Statement','siteSubSectionAbbr':'PS'},	
  	{'urlCompareString':'/show.aspx/imprint','siteSubSection':'Imprint','siteSubSectionAbbr':'IP'},	
  	{'urlCompareString':'/show.aspx/about-us','siteSubSection':'About Us','siteSubSectionAbbr':'AU'},	
  	{'urlCompareString':'/contactus.aspx/index','siteSubSection':'Contact Us','siteSubSectionAbbr':'CU'},	
  	{'urlCompareString':'/show.aspx/dogs','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
  	{'urlCompareString':'/show.aspx/dogs/adopt-a-dog','siteSubSection':'Adopt-A-Dog','siteSubSectionAbbr':'AD'},	
  	{'urlCompareString':'/show.aspx/dogs/dog-health','siteSubSection':'Dog Health','siteSubSectionAbbr':'DH'},	
  	{'urlCompareString':'/show.aspx/dogs/dog-behavior','siteSubSection':'Dog Behavior','siteSubSectionAbbr':'DB'},	
  	{'urlCompareString':'/show.aspx/dogs/dog-lifestyle','siteSubSection':'Dog Lifestyle','siteSubSectionAbbr':'DL'},	
  	{'urlCompareString':'/show.aspx/cats','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
  	{'urlCompareString':'/show.aspx/cats/adopting-a-cat','siteSubSection':'Adopt-A-Cat','siteSubSectionAbbr':'AC'},	
  	{'urlCompareString':'/show.aspx/cats/cat-health','siteSubSection':'Cat Health','siteSubSectionAbbr':'CH'},	
  	{'urlCompareString':'/show.aspx/cats/cat-behavior','siteSubSection':'Cat Behavior','siteSubSectionAbbr':'CB'},	
  	{'urlCompareString':'/show.aspx/cats/cat-lifestyle','siteSubSection':'Cat Lifestyle','siteSubSectionAbbr':'CL'},		
  	{'urlCompareString':'/show.aspx/horses','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
  	{'urlCompareString':'/show.aspx/horses/adopting-a-horse','siteSubSection':'Adopt-A-Horse','siteSubSectionAbbr':'AH'},	
  	{'urlCompareString':'/show.aspx/horses/horse-health','siteSubSection':'Horse Health','siteSubSectionAbbr':'HH'},	
  	{'urlCompareString':'/show.aspx/horses/horse-behavior','siteSubSection':'Horse Behavior','siteSubSectionAbbr':'HB'},	
  	{'urlCompareString':'/show.aspx/horses/horse-lifestyle','siteSubSection':'Horse Lifestyle','siteSubSectionAbbr':'HL'},	
  	{'urlCompareString':'/community.aspx/index','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
  	{'urlCompareString':'/petparent.aspx/viewdashboard','siteSubSection':'My Profile','siteSubSectionAbbr':'MP'},	
  	{'urlCompareString':'/petparent.aspx/myfriends','siteSubSection':'My Friends','siteSubSectionAbbr':'MF'},	
  	{'urlCompareString':'/ecard.aspx/','siteSubSection':'Send eCard','siteSubSectionAbbr':'EC'},	
  	{'urlCompareString':'/tools.aspx/index','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
  	{'urlCompareString':'/askanexpert.aspx/','siteSubSection':'Ask a Vet','siteSubSectionAbbr':'AV'},	
  	{'urlCompareString':'/findascanner.aspx/','siteSubSection':'Find a Scanner','siteSubSectionAbbr':'FS'},	
  	{'urlCompareString':'/photo.aspx/','siteSubSection':'Photo Album','siteSubSectionAbbr':'PA'},
   	{'urlCompareString':'/pet.aspx/edit','siteSubSection':'Add a Pet','siteSubSectionAbbr':'AA'},	
   	{'urlCompareString':'/appointment.aspx/','siteSubSection':'Appointments','siteSubSectionAbbr':'AP'},	
   	{'urlCompareString':'/findavet.aspx/','siteSubSection':'Find a Vet','siteSubSectionAbbr':'FV'},	
   	{'urlCompareString':'/tools.aspx/viewpethealthchecklist','siteSubSection':'Checklist','siteSubSectionAbbr':'CL'},	
   	{'urlCompareString':'/questionnaire.aspx/dogchecklist','siteSubSection':'Checklist','siteSubSectionAbbr':'CL'},	
   	{'urlCompareString':'/questionnaire.aspx/catchecklist','siteSubSection':'Checklist','siteSubSectionAbbr':'CL'},	
   	{'urlCompareString':'/riskmap.aspx/','siteSubSection':'Riskmap','siteSubSectionAbbr':'RM'},	
   	{'urlCompareString':'/video.aspx/videolist','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/advantage-for-dogs','siteSubSection':'Video','siteSubSectionAbbr':'VD'},
   	{'urlCompareString':'/show.aspx/advantage-for-cats','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/feather-arrow','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/k9-advantix','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/profender','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
 	{'urlCompareString':'/show.aspx/products','siteSubSection':'Overview','siteSubSectionAbbr':'OV'},	
 	{'urlCompareString':'/show.aspx/products/advantage-ii-for-dogs','siteSubSection':'Advantage for Dogs','siteSubSectionAbbr':'AD'},	
 	{'urlCompareString':'/show.aspx/products/advantage-ii-for-cats','siteSubSection':'Advantage for Cats','siteSubSectionAbbr':'AC'},
 	{'urlCompareString':'/show.aspx/products/advantage-for-dogs','siteSubSection':'Advantage for Dogs','siteSubSectionAbbr':'AD'},	
 	{'urlCompareString':'/show.aspx/products/advantage-for-cats','siteSubSection':'Advantage for Cats','siteSubSectionAbbr':'AC'},	
 	{'urlCompareString':'/show.aspx/products/k9-advantix-for-dogs','siteSubSection':'K9 Advantix','siteSubSectionAbbr':'KA'},
 	{'urlCompareString':'/show.aspx/products/k9-advantix-ii','siteSubSection':'K9 Advantix','siteSubSectionAbbr':'KA'}, 		
 	{'urlCompareString':'/show.aspx/products/advantage-multi-for-dogs','siteSubSection':'Advantage Multi for Dogs','siteSubSectionAbbr':'AMD'},	
 	{'urlCompareString':'/show.aspx/products/advantage-multi-for-cats','siteSubSection':'Advantage Multi for Cats','siteSubSectionAbbr':'AMC'},	
 	{'urlCompareString':'/show.aspx/products/drontal-plus','siteSubSection':'Drontal Plus','siteSubSectionAbbr':'DP'},	
 	{'urlCompareString':'/show.aspx/products/profender','siteSubSection':'Profender','siteSubSectionAbbr':'PF'},	
 	{'urlCompareString':'/show.aspx/products/resq','siteSubSection':'resQ','siteSubSectionAbbr':'RQ'},	
 	{'urlCompareString':'/show.aspx/products/about-baytril-enrofloxacin-antibacterial','siteSubSection':'Baytril','siteSubSectionAbbr':'BT'},	
 	{'urlCompareString':'/show.aspx/products/baytril-otic','siteSubSection':'Baytril Otic','siteSubSectionAbbr':'BO'},	
 	{'urlCompareString':'/show.aspx/products/legend','siteSubSection':'Legend','siteSubSectionAbbr':'LG'},	
 	{'urlCompareString':'/show.aspx/products/marquis','siteSubSection':'Marquis','siteSubSectionAbbr':'MQ'},	
 	{'urlCompareString':'/error.aspx','siteSubSection':'Error','siteSubSectionAbbr':'ER'},
 	{'urlCompareString':'/petparent.aspx/viewdashboard/','siteSubSection':'View Profile','siteSubSectionAbbr':'VP'},
  	{'urlCompareString':'/show.aspx/question/','siteSubSection':'Question','siteSubSectionAbbr':'QU'},
  	{'urlCompareString':'petparent.aspx/confirmation','siteSubSection':'My Profile','siteSubSectionAbbr':'MP'},
  	{'urlCompareString':'petparent.aspx/editprofile','siteSubSection':'My Profile','siteSubSectionAbbr':'MP'},
  	{'urlCompareString':'/search.aspx','siteSubSection':'Search Results Overview','siteSubSectionAbbr':'SRO'},
   	{'urlCompareString':'category=','siteSubSection':'Search Results Category','siteSubSectionAbbr':'SRC'},
   	{'urlCompareString':'/specialoffersingup.aspx/','siteSubSection':'Special Offer Signup','siteSubSectionAbbr':'SOS'},
   	{'urlCompareString':'/poochprotest','siteSubSection':'Proximity','siteSubSectionAbbr':'PX'},
   	{'urlCompareString':'/show.aspx/pest-protection','siteSubSection':'PS-Mobile','siteSubSectionAbbr':'PSM'},	
   	{'urlCompareString':'/show.aspx/problems','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/protecting-your-dog-from-pests','siteSubSection':'Video','siteSubSectionAbbr':'VD'},	
   	{'urlCompareString':'/show.aspx/protecting-your-cat-from-pests','siteSubSection':'Video','siteSubSectionAbbr':'VD'},
	{'urlCompareString':'/newpetacquisition.aspx','siteSubSection':'NPA','siteSubSectionAbbr':'NPA'},
	{'urlCompareString':'/newpetacquisition.aspx/confirmation','siteSubSection':'NPA','siteSubSectionAbbr':'NPA'},
	{'urlCompareString':'/newpetacquisition.aspx/register','siteSubSection':'NPA','siteSubSectionAbbr':'NPA'}
 	];	 

/*
 * Load Current Hierarchal Data
 * Loads all the hierarchal data for the current page request
 */
naf.loadCurrentHierarchalData = function(aDataObj){
	if(typeof aDataObj == 'string'){
		alert("Must pass naf.loadHierarchalData() an array object, not a string");
		return false;
	}
	var bMatchFound = false;
	for(var i=0;i<aDataObj.length;i++){
		//if there is a string match of the array object, then set the values
		if(location.href.toLowerCase().indexOf(aDataObj[i].urlCompareString.toLowerCase()) > -1){
			for(var propertyName in aDataObj[i]){
				if(propertyName != 'urlCompareString'){
					this.setProperty('current'+propertyName.substring(0,1).toUpperCase()+propertyName.substring(1,propertyName.length),aDataObj[i][propertyName]);
					bMatchFound = true;
				}
			}		
		}
	}

	if(!bMatchFound){//no match found in the data map, so need to set default to Home Page and Overview
		for(var propertyName in aDataObj[0]){
			if(propertyName != 'urlCompareString'){
				if(propertyName.toLowerCase().indexOf('sitesection') > -1){	
					this.setProperty('current'+propertyName.substring(0,1).toUpperCase()+propertyName.substring(1,propertyName.length),propertyName.toLowerCase().indexOf('abbr') > -1? "HP" : "Home Page");
				}else if(propertyName.toLowerCase().indexOf('sitesubsection') > -1 && propertyName.toLowerCase().indexOf('sitesubsection2') < 0){
					this.setProperty('current'+propertyName.substring(0,1).toUpperCase()+propertyName.substring(1,propertyName.length),propertyName.toLowerCase().indexOf('abbr') > -1? "OV" : "Overview");
				}				
			}
		}	
	}
}

/*
 * Set Current Site Section
 * Sets the framework properties for currentSiteSection and currentSiteSectionAbbr
 */
naf.loadCurrentHierarchalData(naf.aSiteSectionData);

/*
 * Set Current Site Sub Section
 * Sets the framework properties for currentSiteSuSection and currentSiteSubSectionAbbr
 */
naf.loadCurrentHierarchalData(naf.aSiteSubSectionData);

//pet specialty mobile optimized page
if(location.href.toLowerCase().indexOf('/show.aspx/pest-protection') > -1){
	naf.setProperty( 'pageTitle','Pest Protection' );	
}
//poochprotest page titles
if(location.href.toLowerCase().indexOf('poochprotest') > -1){
	var tmpBCref = naf.utils.getElementsByAttributeSubstring(document,'div','class','siteBreadcrumbs');
	
	if(tmpBCref){
		var tmpPgTle = "";
		for(var j=0;j<tmpBCref.length;j++){
					
			if(naf.utils.isIE){
				//if the page title value is going to be the same as currentSiteSubSection, then it should be Overview
				if(tmpBCref[j] && tmpBCref[j].innerText.toLowerCase().indexOf('>') > -1 ){
					var bcSpans = tmpBCref[j].getElementsByTagName('span');
					for(var k=0;k<bcSpans.length;k++){
						if(bcSpans[k].innerText.toLowerCase().indexOf('>') > -1){
							tmpPgTle = bcSpans[k].innerText.substring(bcSpans[k].innerText.lastIndexOf(">")+2,bcSpans[k].innerText.length).replace(/^\s+|\s+$/g,"");
						}
					}
				}
			}else{	
						
				if(tmpBCref[j] && tmpBCref[j].textContent.toLowerCase().indexOf('>') > -1 ){
					var bcSpans = tmpBCref[j].getElementsByTagName('span');
					//alert(tmpBCref[j].getElementsByTagName('span')[0].textContent);
					for(var k=0;k<bcSpans.length;k++){
						if(bcSpans[k].textContent.toLowerCase().indexOf('>') > -1){
							tmpPgTle = bcSpans[k].textContent.substring(bcSpans[k].textContent.lastIndexOf(">")+2,bcSpans[k].textContent.length).replace(/^\s+|\s+$/g,"");				
						}
					}					
				}
			}
		}
		//test for a duplicate value repeated in the tmpPgTle variable, like Video Conferencing: Video Conferencing, and if found, then remove the duplicate
		if(tmpPgTle.indexOf(':') > 0 && tmpPgTle.substring(tmpPgTle.indexOf(':')).indexOf(tmpPgTle.substring(0,tmpPgTle.indexOf(':'))) > -1 ){
			tmpPgTle = tmpPgTle.substring(0,tmpPgTle.indexOf(':')).replace(/^\s+|\s+$/g,"");	
		}
		//remove odd spacing in breadcrumb value pulled
		
		if( tmpPgTle.toLowerCase() == naf.getProperty('currentSiteSubSection').toLowerCase() 				
					|| tmpPgTle.toLowerCase() == 'products'){
			naf.setProperty( 'pageTitle','Overview' );	
		}else if(tmpPgTle.length > 0){
			naf.setProperty( 'pageTitle',tmpPgTle );	
		}	
		//alert(tmpPgTle+": "+tmpPgTle.length+" - "+naf.getProperty('currentSiteSubSection2')+": "+naf.getProperty('currentSiteSubSection2').length);	
	}
	if(naf.getProperty('pageTitle').toLowerCase().indexOf('join') > -1 && location.pathname.toLowerCase().indexOf('/thankyou') > -1){
		naf.setProperty('pageTitle','Join-Complete');
	}
}
//Dogs Page Titles
if(location.href.toLowerCase().indexOf("/dogs/adopt-a-dog/") > -1 || location.href.toLowerCase().indexOf("/dogs/dog-health/") > -1 || location.href.toLowerCase().indexOf("/dogs/dog-behavior/") > -1 || location.href.toLowerCase().indexOf("/dogs/dog-lifestyle/") > -1){
	//naf.setProperty('pageTitle', document.title.substring(0,document.title.toLowerCase().indexOf("| petparents.com")-1));
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
}

//Cats Page Titles
if(location.href.toLowerCase().indexOf("/cats/adopting-a-cat/") > -1 || location.href.toLowerCase().indexOf("/cats/cat-health/") > -1 || location.href.toLowerCase().indexOf("/cats/cat-behavior/") > -1 || location.href.toLowerCase().indexOf("/cats/cat-lifestyle/") > -1){
	//naf.setProperty('pageTitle', document.title.substring(0,document.title.toLowerCase().indexOf("| petparents.com")-1));
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
}

//Horses Page Titles
if(location.href.toLowerCase().indexOf("/horses/adopting-a-horse/") > -1 || location.href.toLowerCase().indexOf("/horses/horse-health/") > -1 || location.href.toLowerCase().indexOf("/horses/horse-behavior/") > -1 || location.href.toLowerCase().indexOf("/horses/horse-lifestyle/") > -1){
	//naf.setProperty('pageTitle', document.title.substring(0,document.title.toLowerCase().indexOf("| petparents.com")-1));
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
}

//eCard Page Titles
if(location.href.toLowerCase().indexOf("/ecard.aspx/") > -1){
	//naf.setProperty('pageTitle', document.title);
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
}

if(location.href.toLowerCase().indexOf("/ecard.aspx/personalecard") > -1){
  naf.setProperty('pageTitle','Personal eCard');
}

//Ask a Vet Page Titles
if(location.href.toLowerCase().indexOf("/askanexpert.aspx/askquestion") > -1){
	naf.setProperty('pageTitle', 'Ask a Question');
}else if (location.href.toLowerCase().indexOf("/askanexpert.aspx/submitquestion") > -1) {	
	naf.setProperty('pageTitle', 'Thanks for Your Question');
}else if (location.href.toLowerCase().indexOf("/askanexpert.aspx/getarchivedquestions") > -1) {	
	naf.setProperty('pageTitle', 'All Questions');
}

//Checklist Page Titles
if(location.href.toLowerCase().indexOf("/questionnaire.aspx/dogchecklist") > -1){
	naf.setProperty('pageTitle', 'Pet Health Checklist - Dogs');
}else if (location.href.toLowerCase().indexOf("/questionnaire.aspx/catchecklist") > -1) {	
	naf.setProperty('pageTitle', 'Pet Health Checklist - Cats');
}else if (location.href.toLowerCase().indexOf("/questionnaire.aspx/submitquestion2") > -1) {
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	h2Title = h2Title;
	naf.setProperty('pageTitle', h2Title);
}

//Video Page Titles
if(location.href.toLowerCase().indexOf("/show.aspx/advantage-for-dogs") > -1){
	naf.setProperty('pageTitle', 'Dog Application Video for Advantage');
}else if (location.href.toLowerCase().indexOf("/show.aspx/feather-arrow") > -1) {	
	naf.setProperty('pageTitle', 'Advantage Topical Solution Commercial');
}else if (location.href.toLowerCase().indexOf("/show.aspx/k9-advantix-pooch-protest") > -1) {	
	naf.setProperty('pageTitle', 'K9 Advantix PoochProtest Commercial');
}else if (location.href.toLowerCase().indexOf("/show.aspx/k9-advantix") > -1) {	
	naf.setProperty('pageTitle', 'K9 Advantix Commercial');
}else if (location.href.toLowerCase().indexOf("/show.aspx/advantage-for-cats-application") > -1) {	
	naf.setProperty('pageTitle', 'Cat Application Video for Advantage');
}else if (location.href.toLowerCase().indexOf("/show.aspx/profender") > -1) {	
	naf.setProperty('pageTitle', 'Cat Endoscopy Video');
}else if (location.href.toLowerCase().indexOf("/show.aspx/problems") > -1) {	
	naf.setProperty('pageTitle', 'The Threat To Your Pet');
}else if (location.href.toLowerCase().indexOf("/show.aspx/protecting-your-dog-from-pests") > -1) {	
	naf.setProperty('pageTitle', 'Protecting Your Dog From Pests');
}else if (location.href.toLowerCase().indexOf("/show.aspx/protecting-your-cat-from-pests") > -1) {	
	naf.setProperty('pageTitle', 'Protecting Your Cat From Pests');
}

//Product Page Titles
if(location.href.toLowerCase().indexOf("/show.aspx/products/") > -1){
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
	
}

//Signup Page Titles
if(location.href.toLowerCase().indexOf("/petparent.aspx/registersuccess") > -1){
	naf.setProperty('pageTitle', 'Registration Complete');
}else if (location.href.toLowerCase().indexOf("/petparent.aspx/register") > -1) {	
	naf.setProperty('pageTitle', 'Registration Start');
}

//Sent to Friend Titles
if(location.href.toLowerCase().indexOf("/petparent.aspx/composesendpage") > -1 || location.href.toLowerCase().indexOf("/petparent.aspx/composemessage") > -1){
	naf.setProperty('pageTitle', 'Compose Message');
}else if (location.href.toLowerCase().indexOf("/petparent.aspx/sendmessage") > -1) {	
	naf.setProperty('pageTitle', 'Message Sent');
}

//Questions
if(location.href.toLowerCase().indexOf("/show.aspx/question/") > -1){
	var h2Title = document.getElementsByTagName("h2");
	var h2Title = h2Title[0].innerHTML.replace(/(([\u0127-\u9999])|(\&\#?\w+\;)|([\x80-\xFF]))/g,"");
	naf.setProperty('pageTitle', h2Title);
}

//Profile
if(location.href.toLowerCase().indexOf("petparent.aspx/editprofile") > -1){
	naf.setProperty('pageTitle', 'Edit Profile');
}else if (location.href.toLowerCase().indexOf("petparent.aspx/confirmation") > -1) {	
	naf.setProperty('pageTitle', 'Edit Profile Confirmation');
}

//Special Offer
if(location.href.toLowerCase().indexOf("/specialoffersingup.aspx") > -1){
	offer = unescape(location.href.substr());
	offer = offer.split("/");
	offer = offer[offer.length-1];
	if(offer.indexOf('&') > -1){
		offer = offer.substr(0,offer.indexOf('&'));
	}
	naf.setProperty('pageTitle', offer);
}

//New Pet Acquisition
if(location.href.toLowerCase().indexOf("/newpetacquisition.aspx") > -1){
	naf.setProperty('pageTitle', 'Pets Not Pests');
}
if(location.href.toLowerCase().indexOf("/newpetacquisition.aspx/register") > -1){
	naf.setProperty('pageTitle', 'Join');
}
if(location.href.toLowerCase().indexOf("/newpetacquisition.aspx/confirmation") > -1){
	naf.setProperty('pageTitle', 'Join-Complete');
}

//****************** End Default Settings ************************


/*
 * If no environment is set, then check for list of production domains and default to dev if not found
 */
if(!naf.getProperty('environment')){
	switch(location.hostname.toLowerCase()){
		case "www.petparents.com":
			naf.setProperty('environment','prod');
			break;
		case "petparents.com":
			naf.setProperty('environment','prod');
			break;
		default:
			naf.setProperty('environment','dev');
			break;
	}
}

naf._metricTranslation = function(){
	if(typeof metricData != "object"){ metricData = {}; }
	//loop through the metricData object setting naf name/value pairs
	for(var x in metricData){
		naf.setProperty(x,metricData[x]);
	}
	naf._loadBaseLibraries();
}


naf._loadBaseLibraries = function() {
	naf._loadScriptLibrary(naf._config.baseUrl +"s_code.js",  document.getElementsByTagName('head')[0], function(){naf._loadWidgets("omniture");});	
    naf._loadWidgets("floodlight");	
}


naf._loadScriptLibrary = function(src, targetElement, olFunction) {
	var library = document.createElement('script');
	library.type = 'text/javascript'; 
	library.src = src;
	if(typeof olFunction == 'function') {
		if(library.addEventListener) {
			library.addEventListener("load",olFunction,false);
		} else {
			olFunIE = olFunction.toString();
			var from = olFunIE.indexOf('{') + 1;
			var length = olFunIE.length - 1 - from;
			olFunIE = olFunIE.substr(from, length);
			library.onreadystatechange = function () {
				if (library.readyState == 'complete' || library.readyState == 'loaded') {
					library.onreadystatechange = null;
					eval(olFunIE);
				}
			}
		}
	}
	document.getElementsByTagName('head')[0].appendChild(library);
}


naf._loadWidgets = function(widget) {
	try{
		//load vendor widgets
		switch(widget){
			case "omniture":
				naf._loadScriptLibrary(naf._config.baseUrl +"omniWidget.js",  document.getElementsByTagName('head')[0]);
				break;
			case "google":
				naf._loadScriptLibrary(naf._config.baseUrl +"gaWidget.js",  document.getElementsByTagName('head')[0]);
				break;		
			case "floodlight":
				naf._loadScriptLibrary(naf._config.baseUrl +"flood/floodlightWidget.js",  document.getElementsByTagName('head')[0]);
				break;	
			default:
			   break;
		}
	}catch(e){}
}


naf._metricTranslation();


}catch(e){}
