// temp
function getPackageForName(packageName) {
    var arr = packageName.split('.');

    var obj = window;
    for(var i=0; i<arr.length; i++) {
      if (typeof obj[arr[i]] == 'undefined') {
            obj[arr[i]] = {};
      }
      
      obj = obj[arr[i]];
    }

    return obj;
}

getPackageForName("com.forddirect.brandsites.metrics").NewMetricsTracker = function(){

	var storedPageName;
	var storedNameplate = "";
	var storedModelCategory = "";
	var storedModelYear = "";
	var storedBrand = "";

	var compareCategoryTabName;

	this.storeMacroData = function(pageName){
		storedPageName = pageName;
	};
	
	this.fireMacroData =function(){
		this.trackMacroData(storedPageName);
	};
	
	
	this.commonsVariableSet = function(){
	//Variables for - Omniture
	
	s.eVar12= this.modelYear();
	s.prop12= this.modelYear();
	
	s.hier1= this.siteLevel();
	
	s.eVar15= this.site();
	s.prop15= this.site();
	
	s.eVar4= this.userLanguage();
	s.prop4= this.userLanguage();
	
	s.eVar9=s.prop9='';
	s.eVar14= this.client();
	s.prop14= this.client();
	
	s.channel= this.siteSection();
	
	s.eVar16= this.nameplate();
	s.prop16= this.nameplate();
	};
	
	
	

	this.modelYear = function(){ 
		return __params.year;
	};

	this.modelCategory = function(){ 
		var segment = "";
		if (__params.segment) {
			segment = __params.segment.toLowerCase();
			if(segment == "trucks" || segment == "suvs" || segment == "cars" || segment == "crossovers"){
				segment = segment.substring(0,segment.length-1);
			}
		}	
		return segment; 
		
	};
	
	this.modelName = function(){
		return __params.modelName;	
	};

	this.userLanguage = function(){ 
		if(_widgets.context){
			return _widgets.context.UserContext.get("userLanguage");
		}
		return "defaultUserLanguage";
	};

	this.searchCurrentPageNumber = function(){ 
		return _widgets.context.SearchContext.get('page') + 1;
	};
	
	this.featureCategory = function(){
		return this.featureCategoryName();

//		var feature = _widgets.context.SelectedContext.get("feature");
//                if(feature.category === "") {
//                     return feature.category;
//                } else{
//                    var featureCategory = feature.category;
//                    return _widgets.context.AvailableContext.get("featuresCategoryTitles")[featureCategory].toLowerCase().replace(/ /,'');
//                }
	};

	this.featureCategoryName = function(){
		var feature = _widgets.context.SelectedContext.get("feature");
		if(feature.category === "") {
			return feature.category;
		} else{
			var featureCategory = feature.category;
			return _widgets.context.AvailableContext.get("featuresCategoryTitles")[featureCategory].toLowerCase().replace(/ /,'');
		}
	};

	this.featureName = function(){ 
		var feature = _widgets.context.SelectedContext.get("feature");
		
		if(feature.id === "") {
			return feature.id;
		} else{
			var featureId = feature.id;
			return _widgets.context.AvailableContext.get("featuresCategoryTitles")[featureId].toLowerCase();
		}
	};

	this.nameplate = function(){ 
		var returnValue = "";
		if(_widgets.context){
		var vehicleNameplate = _widgets.context.SelectedContext.get("nameplate");
		var metricsName = _widgets.context.SelectedContext.get("MetricsName");
		var make = this.getMake();
		switch(make){
				case "Ford":
				case "Mercury":
					if(vehicleNameplate){
						// vehicle nameplate is not undefined
						returnValue = make.toLowerCase() + " " + vehicleNameplate.toLowerCase();
					}
					break;
				case "Lincoln":
					if(metricsName){
						// vehicle nameplate is not undefined
						returnValue = make.toLowerCase() + " " + metricsName.toLowerCase();
					}
					break;
				default:
					returnValue = make + " " + vehicleNameplate.toLowerCase();
				}
			}		
		return returnValue;
	};
	
	this.storeNameplateInfo = function(nameplate, modelCategory, modelYear){
		storedNameplate = nameplate;
		storedModelCategory = modelCategory;
		storedModelYear = modelYear;
	};	
	
	this.storeNameplateLinkoutInfo = function(brand, nameplate, page){
		storedBrand = brand;
		storedNameplate = nameplate;
		storedPageName = page;
	};	
	
	this.getCodeForModel = function(){
		return '';
	};

	this.siteLevel = function(){
		// hierarchy
		var siteLevel = "defaultsiteLevel";
		if(_widgets.context){
			var currentView = _widgets.context.SelectedContext.get("site.currentView");	
			switch(currentView){
				case "brand-home" :
				case "welcome-back": 
					siteLevel = "home";
					break;
				case "nameplate-overview" : 
					siteLevel = "vehicle:"+this.modelYear()+":"+this.modelCategory()+":"+ this.nameplate();
					break;
				case "photos":
				case "photos-interior"   :
				case "photos-exterior":
				case "photos-accessories":
				case "photopopup"   :
				case "videos":
				case "home360popup":
				case "html360":
					siteLevel = "vehicle:gallery:"+this.modelYear()+":"+this.modelCategory()+":"+this.nameplate();
					break;
				case "payment-estimator":
				case "pricing-and-payments-nameplate":
					siteLevel = "vehicle:pricing:"+this.modelYear()+":"+this.modelCategory()+":"+ this.nameplate();
					break;
				case "pricing-how-to"  : 
					siteLevel = "vehicle:pricing:"+this.modelYear()+":"+this.modelCategory()+":"+ this.nameplate();
					break;  
				case "features":
					siteLevel = "vehicle:features:"+this.modelYear()+":"+this.modelCategory()+":"+this.nameplate()+":"+this.featureCategoryName();
					break;
				case "warranty":
					siteLevel = "shopping tools:warranty:"+this.modelYear()+":"+this.modelCategory()+":"+this.nameplate();
					break;
				case "model-and-options-trim-selection":
					siteLevel = "vehicle:models:" + this.modelYear() + ":" + this.modelCategory() + ":" + this.nameplate();
					break;
				case "models-and-options-trim-details":
				case "model-and-options-detailed-compare" :
					siteLevel = "vehicle:models:" + this.modelYear() + ":" + this.modelCategory() + ":" + this.nameplate() +":"+this.compareTabName();
					break;
				case "search-results" :
					siteLevel = "search";
					break;
				case "fordcreditservices" :
					siteLevel = "fordcreditservices";
					break;
				case "owners" :
					siteLevel = "owners";
					break;
				case "contact-us" :
					siteLevel = "help:contact";
					break;  
				case "glossary" :
					siteLevel = 'help:glossary';
					break;
				case "privacy" :
					siteLevel = 'help:' + this.pageDetect('h1');
					break;
				case "california-privacy" :
					siteLevel = 'caprivacy';
					break;  
				case "competitivecompare":
				case "comparesummary":
				case "compareadvantage":
				case "comparephoto":
				case "compareequipped":
				case "comparechoose":
				case "comparechooseford":
					siteLevel = 'shopping tools:competitive compare:' + this.modelYear() + ':' + this.modelCategory() +':' + this.nameplate();
					break;
				case "newsevents" :
				case "news-all":
				case "events-all":
				case "news-detail":
				case "events-detail":
				case "news-search":
				case "events-search":
					siteLevel = 'media-events';
					break;  	
				case "innovation-sync-overview":
				case "innovation-sync-about"   :
				case "innovation-sync-features":
				case "innovation-sync-availability":
				case "innovation-sync-owner"   :
					siteLevel = 'awareness:features:sync';
					break;
				case "locateadealer":
					siteLevel = 'shopping tools:locate dealer';
					break;
				case "seo":
					siteLevel = 'lp:truck:truck type';
					break;
				case "brochures":
					siteLevel = 'shopping tools:brochures';
					break;
				case "interstitial":
					siteLevel = this.brandVar() + ':vehicle:interstitial';
					break;
				case "incentives":
					siteLevel = 'shopping tools:incentives';
					break;
				case "certifiedpreowned":
					siteLevel = 'shopping tools:cpo';
					break;
				case "vehicle-selection":
					siteLevel = 'vehicle select';
				break;
				case "reviews":
					siteLevel = 'vehicle:reviews:' + this.modelYear() + ':' + this.modelCategory() +':' + this.nameplate();
				break;
				default :
					siteLevel = "defaultsiteLevel";
			}
		}
		return siteLevel;
	};
	
	
	this.pageDetect = function(metric){
		var pageUrl = window.location.href;
		var pageNameDetected = "";
		if( pageUrl.indexOf("cap") > -1){
			if (metric == "h1") {
				pageNameDetected = "caprivacy";
			}
			else {
				pageNameDetected = "privacy: california";
			}
		}
		else{
			pageNameDetected = "privacy";	
		}
		return pageNameDetected;
	};
	
	this.trimName = function(){
	      var trimName = "";
              var key = "trim";
              
              var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
              var qs = regex.exec(window.location.href);
              if(qs){
                  trimName = qs[1];
              } 
              
              return trimName;
	};
	

	this.siteSection = function(){ 
		var siteSection = "" ;
		if(_widgets.context){
			var currentView = _widgets.context.SelectedContext.get("site.currentView");

			switch(currentView){
				case "brand-home":
				case "welcome-back": 
					siteSection = "home";
					break;
				case "nameplate-overview":
				case "pricing-and-payments-nameplate":
				case "features":
				case "model-and-options-trim-selection":
				case "models-and-options-trim-details":
				case "payment-estimator":
				case "model-and-options-detailed-compare":
				case "photos":
				case "photos-interior"   :
				case "photos-exterior":
				case "photos-accessories":
				case "photopopup"   :
				case "videos":
				case "reviews":
				case "home360popup":
				case "html360":
					siteSection = 'vehicle';
					break;
				case "warranty":
					siteSection = 'warranty';
					break;
				case "search-results":
					siteSection = 'search';
					break;
				case "fordcreditservices":
					siteSection = 'fordcreditservices';
					break;
				case "owners":
					siteSection = 'owners';
					break;
				case "privacy":
				case "contact-us":
				case "california-privacy" :
					siteSection = 'help';
					break;	
				case "glossary":
					siteSection = 'glossary';
					break;
				case "newsevents":
				case "news-all":
				case "events-all":
				case "news-detail":
				case "events-detail":
				case "news-search":
				case "events-search":
					siteSection = 'media-events';
					break;	
				case "competitivecompare":
				case "comparesummary":
				case "compareadvantage":
				case "comparephoto":
				case "compareequipped":
				case "comparechoose":
				case "comparechooseford":
					siteSection = 'competitive';
					break;   
				case "innovation-sync-overview":
				case "innovation-sync-about":
				case "innovation-sync-features":
				case "innovation-sync-availability":
				case "innovation-sync-owner":
					siteSection = 'awareness';
					break;
				case "locateadealer":
					siteSection = 'dealerships';
					break;
				case "seo":
					siteSection = 'lp';
					break;
				case "brochures":
					siteSection = 'brochures';
					break;	
				case "interstitial":
					siteSection = 'vehicle';
					break;	
				case "incentives":
					siteSection = 'incentives';
					break;	
				case "certifiedpreowned":
					siteSection = 'cpo';
					break;
				case "specifications":
					siteSection = 'vehicle';
					break;	
				case "vehicle-selection":
					siteSection = 'vehicle select';
				break;
				case "pricing-how-to":
					siteSection = 'vehicle';
				break;
				default:
					siteSection = 'defaultsiteSection';
			}
		}
		return siteSection;
	};
	
	this.site = function() {
		var make = this.getMake();
	    var site;
	    switch(make){
	        case "Ford": 
	        	site = "ford.com";
	        	break;
	        case "Lincoln": 
	        	site = "lincoln.com";
	        	break;
	        case "Mercury": 
	        	site = "mercuryvehicles.com";
	        	break;
	        default: 
	        	site = "ford.com";
	    }
	    return site;
	};
	
	this.client = function() {		
		var make = this.getMake();
        var client;
        switch(make){
            case "Ford": 
            	client = 'ford';
            	break;
            case "Lincoln": 
            	client = 'lincoln';
            	break;
            case "Mercury":
            	client = 'mercury';
            	break;
            default: 
            	client = 'ford';
        }
        return client;
	};

	this.brandVar = function(){
		var make = this.getMake();
		var brandVar;
		switch(make){
			case "Ford": 
				brandVar = "fv";
				break;
			case "Lincoln": 
				brandVar = "ln";
				break;
			case "Mercury": 
				brandVar = "mc";
				break;
			default: 
				brandVar = "fv";
		}
		
		return brandVar;
	};
	
	
	this.advertiseID = function(){
		var make = this.getMake();
		var advertiseID;
		switch(make){
			case "Ford": 
				advertiseID = "fvflup";
				break;
			case "Lincoln": 
				advertiseID = "lngen2";
				break;			
			default: 
				advertiseID = "lngen2";
		}
		
		return advertiseID;
	};

	this.getBrandType = function(){
		var currentView = _widgets.context.SelectedContext.get("site.currentView");
		var brandType;
		switch(currentView){
			case "innovation-sync-overview":
			case "innovation-sync-about":
			case "innovation-sync-features":
			case "innovation-sync-availability":
			case "innovation-sync-owner": 
				brandType = 'thsync';
				break;
			default:
				brandType = 'lngen2';
		}
		return brandType;
	};
	
	this.compareTabName = function(){ 

                if(!this.compareCategoryTabName){
                    this.compareCategoryTabName = "packages";
                }
                var categoryName = this.compareCategoryTabName.toLowerCase().replace(/_/g,' ');
                if(categoryName.indexOf('category')!=-1){
                    return categoryName.substring('category'.length);
                }else{
                    return categoryName;
                }
            
};
	
	// do not remove this function 
	this.compareOrDetails = function(sMetricsParam){
		var sReturn = "";

		if (this.nameplate()===""){
			switch(sMetricsParam){
				case "hier1":
					sReturn = 'shopping tools:competitive compare';
					break;
				case "pageName":
				case "eVar11":
				case "prop11":
					sReturn = this.brandVar()  + ":vehicle:compare";
					break;
				case "events":
					break;
				default:
					sReturn = "Implement Me this.compareOrDetails";
				}

		} else{

			switch(sMetricsParam){
				case "hier1":
					sReturn = this.siteLevel();
					break;
				case "pageName":
					sReturn = this.brandVar()  + ": vehicle: compare: details: " + this.nameplate();
					break;
				case "eVar11":
				case "prop11":
					sReturn = this.brandVar()  + ": vehicle : compare: details";
					break;
				case "events":
					sReturn= "event12";
					break;
				default:
					sReturn = "Implement Me this.compareOrDetails";
				}

		}
		return sReturn;
	};
	
	// photo popup handler
	this.photoPopupClickHandler = function(sMetricsParam) {
		var sReturn = this.brandVar() + ": vehicle: gallery: photos: ";
		
		var pageUrl = window.location.href;
		if( pageUrl.indexOf("exterior") > -1){
			sReturn += "exterior: full screen";
		}
		else if ( pageUrl.indexOf("interior") > -1){
			sReturn += "interior: full screen";	
		}
		else {
			sReturn += "full screen";	
		}
		
		if (sMetricsParam == 'pev2') {
			sReturn += ': ' + this.nameplate();	
		}
		
		return sReturn;
	};
	
	this.compareDart = function(){
		if (this.nameplate()!==null){
			dartTracker.trackEvent('cc', this.nameplate(), 1, this.getBrandType(), "");
		}
	};
	
	
	this.revealNameplate = function(){
		var revealNameplate = "";
		if(_widgets.context){
			var lifeCycleStage = _widgets.context.SelectedContext.get("nameplate.lifeCycleStage");
			if(typeof(lifeCycleStage) === 'string' && lifeCycleStage.toLowerCase() === "reveal") {
				var nameplate = __params.modelName;
				revealNameplate = nameplate + " Reveal";
			}
		}
		return revealNameplate;
	};

	this.fullVideoType = function(){ 
		var onClickValue = "" ;
		if(_widgets.context){
			var currentView = _widgets.context.SelectedContext.get("site.currentView");

			switch(currentView){
				case "innovation-sync-overview": 
				case "innovation-sync-about": 
				case "innovation-sync-features": 
				case "innovation-sync-availability": 
				case "innovation-sync-owner": 
					onClickValue = "fv: tech: sync: video: full";
					break;
				default:
					onClickValue = "fv: home: video: full: " + this.nameplate();
			}
		}
		return onClickValue;
	};

	this.locateDealerShowMetrics = function() {
		var ary = location.search.toLowerCase().split("?");
		var queryStr = ary.toString();
		var pageKey = "page";
		var pageFlag = queryStr.search(pageKey);
		if(pageFlag<0){
			return true;
		}
		return false;
	};
		
	this.locateDealerEvent = function(){
			var ary = location.search.toLowerCase().split("?");
			var queryStr = ary.toString();
			var zipKey = "zip";
			var pageKey = "page";
			var postalKey = "postalcode";
			var zipFlag = queryStr.search(zipKey); 
			var postalFlag = queryStr.search(postalKey);
			var pageFlag = queryStr.search(pageKey);
			if(zipFlag>0||(postalFlag>0&&pageFlag<0)  ){
				return "event1";
			}
			else{
				return "";
			}
	};

	this.locateDealerResults= function(){
		var zip = document.getElementById('resultsArea');
		if (zip === null) {
			return 'no results';
		}else{
			return 'results';		
		}
	};
		
	/*getter-setters NG News and Events pages*/
	this.setNewsDetailEvent = function(newsDetailTitle){
		this.newsTitle =  newsDetailTitle;
	};
	
	this.getNewsDetailEvent = function(){
		return this.newsTitle; 
	};
	
	this.setEventsDetailEvent = function(eventsDetailTitle){
		this.eventsTitle =  eventsDetailTitle;
	};
	
	this.getEventsDetailEvent = function(){
		return this.eventsTitle; 
	};
	
	this.getSearchCurrentResultNumber = function(){ 
		return this.searchCurrentResultNumber || 0;
	};

	this.searchTotalResults = function(){ 
		return _widgets.context.SearchContext.get('totalRecords');
	};
	
	this.bestBetsResults = function(){ 
		return _widgets.context.SearchContext.get('bestBetsRecords');
	};
	
	this.itemDetailName = function(){
		return this.itemName.toLowerCase() ;
	};
	
	this.getSEO_Segment = function(){
		return this.SEO_Segment;
	};
	
	this.getSEO_SubSegment = function(){
		return this.SEO_SubSegment;
	};
	
	this.getSEO_Category = function(){
		return this.SEO_Category;
	};
	
	this.getSEO_Link = function(){
		return this.SEO_Link;
	};
	
	this.getSEO_LinkType = function(){
		return this.SEO_LinkType;
	};
	
	this.getSEO_Campaign = function(){
		return this.SEO_Campaign;
	};
	
	this.getSEO_ClickType = function(){
		return this.SEO_ClickType;
	};
	
	this.searchResults = function(){
	this.clearVars();
	
	// Include Variable Set commons.
	this.commonsVariableSet();
	s.pageName = this.brandVar() + ':site search results:page' + this.searchCurrentPageNumber();
	//Variables for - Omniture
	
	s.eVar35=s.prop21=''+ this.getSearchCurrentResultNumber() + ':' + this.searchTotalResults()+'';
	s.eVar22=s.prop22='' + this.searchQueryTerm()+ '';
	s.prop34=''+ this.searchCurrentPageNumber()+'';
	s.eVar11=s.prop11=this.brandVar() +':site search results:page '+this.searchCurrentPageNumber()+'';

	void(s.t());
	};
	
	
	
	this.searchCurrentPageNumber = function(){
                return _widgets.context.SearchContext.get('page') + 1;            
        };
	this.getSearchCurrentResultNumber = function(){
                return this.searchCurrentResultNumber || 0;           
        };
	this.searchTotalResults = function(){ 
                return _widgets.context.SearchContext.get('totalRecords');            
        };
	this.searchQueryTerm = function(){ 
                return _widgets.context.SearchContext.get('correctedText') || _widgets.context.SearchContext.get('searchText');            
        };
	
	
	this.clearVars = function(){
		//Clearing Omniture Variables
		s.hier1='';
		s.eVar12='';
		s.prop12='';
		s.eVar22='';
		s.prop22='';
		s.prop34='';
		s.eVar9='';
		s.prop9='';
		s.eVar14='';
		s.prop14='';
		s.channel='';
		s.eVar35='';
		s.prop21='';
		s.eVar6='';
		s.prop6='';
		s.eVar15='';
		s.prop15='';
		s.eVar4='';
		s.prop4='';
		s.prop5='';
		s.eVar11='';
		s.prop35='';
		s.eVar16='';
		s.prop16='';		
		s.linkTrackVars='';
		s.events='';
		s.linkTrackEvents='';
		s.pageName='';
	};

	this.getMake = function() {
		var make = __params.make;
		var baseUrl = __params.baseURL;
		if(typeof(make) == "undefined"){
			if(baseUrl.indexOf("lincoln") >= 0){
				make = "Lincoln";
			}else if(baseUrl.indexOf("mercury") >= 0){
				make = "Mercury";
			}else{
				make = "Ford";
			}
		}
		return make;
		
	};

	this.inish = function(oSelf){
		this.self = oSelf;
	};

	this.trackMicroData = function(onClickName){
		eval('this.self.' + onClickName +'()');
	};
	
	
	this.trackMacroData = function(pageName){
		switch(pageName){	
		case 'nameplateMicrosite':
			this.nameplateMicrosite();
			break;
		case 'nameplateOverviewVideo':
			this.nameplateOverviewVideo();
		break;
		case 'nameplateOverviewImage':
			this.nameplateOverviewImage();	
		break;
		case 'featureCategoryViewed':
			this.featureCategoryViewed();
		break;
		case 'featureSubCategoryViewed':
			this.featureSubCategoryViewed();
		break;
		case 'lincoln-mkx-readmore':
			this.lincoln_mkx_readmore();
		break;
		case 'lincoln-mkx-explore':
			this.lincoln_mkx_explore();
		break;

		case 'lincoln-mkz-readmore':
			this.lincoln_mkz_readmore();
		break;
		case 'lincoln-mkz-explore':
			this.lincoln_mkz_explore();
		break;
		
		case '169-point-inspection':
			this.cpo('mc: sunset: cpo: benefits: 169 inspection');
		break;
		case 'warranty':
			this.cpo('mc: sunset: cpo: benefits: warranty');
		break;
		case '24-hour-roadside-assistance':
			this.cpo('mc: sunset: cpo: benefits: roadside assistance');
		break;
		case 'vehicle-history-report':
			this.cpo('mc: sunset: cpo: benefits: vehicle history');
		break;
		case 'benefits':
			this.cpo('mc: sunset: cpo: benefits: additional');
		break;
		case 'offers1':
			this.cpo('mc: sunset: cpo: offers: offers1');
		break;
		case 'offers2':
			this.cpo('mc: sunset: cpo: offers: offers2');
		break;
		case 'offers3':
			this.cpo('mc: sunset: cpo: offers: offers3');
		break;
		case 'cpoIncentives':
			this.cpo('mc: sunset: cpo: offers');
		break;
		case 'estimateFinance':
			this.estimateFinance();
		break;
		case 'estimateLease':
			this.estimateLease();
		break;
		case 'estimate_financePrint':
			this.estimateFinancePrint();
		break;
		case 'estimate_leasePrint':
			this.estimateLeasePrint();
		break;
		case 'incentivesresult':
			this.incentivesresult();
		break;
		case 'incentiveserror':
			this.incentiveserror();
		break;
		case 'searchResults':
			this.searchResults();
		break;
		case 'exterior':
		case 'interior':
		case 'capacities':
		case 'engine':
		case 'chassis':
		case 'towing':
		case 'payload':
		   this.compareCategoryTabName = pageName;
		   this.exterior();
		break;
		case 'viewall':
		   this.viewall();
		break;
		case 'viewallspecs':
		   this.compareCategoryTabName = 'view all';
		   this.viewall();
		break;
		
		// MKZ Hybrid Experience Pages
		case 'MKZ_exp':
			if(swfobject && swfobject.hasFlashPlayerVersion("9.0.0")) {
				this.mkz_hybrid_exp_page("ln:exp:home");
			} else {
				this.mkz_hybrid_exp_page("ln:exp:mkz:get flash");
			}
			break;
			
		case 'mkz_hybrid_petal_complete':
			this.mkz_hybrid_exp_petals("complete");
			break;
			
		case 'mkz_hybrid_petal_not_complete':
			this.mkz_hybrid_exp_petals("not complete");
			break;
			
		case 'mkz_hybrid_exp_overview':
			this.mkz_hybrid_exp_page("ln:exp:overview video");
			break;
			
		case 'mkz_hybrid_exp_fuel_eff':
			this.mkz_hybrid_exp_page("ln:exp:fuel efficiency");
			break;
			
		case 'mkz_hybrid_exp_luxury':
			this.mkz_hybrid_exp_page("ln:exp:luxury");
			break;
			
		case 'mkz_hybrid_exp_technology':
			this.mkz_hybrid_exp_page("ln:exp:technology");
			break;
			
		case 'mkz_hybrid_exp_technology_smart_guage_1':
			this.mkz_hybrid_exp_page("ln:exp:technology:smart guage:title 1");
			break;
			
		case 'mkz_hybrid_exp_technology_smart_guage_2':
			this.mkz_hybrid_exp_page("ln:exp:technology:smart guage:title 2");
			break;
			
		case 'mkz_hybrid_exp_technology_smart_guage_3':
			this.mkz_hybrid_exp_page("ln:exp:technology:smart guage:title 3");
			break;
			
		case 'mkz_hybrid_exp_technology_smart_guage_4':
			this.mkz_hybrid_exp_page("ln:exp:technology:smart guage:title 4");
			break;
			
		case 'mkz_hybrid_exp_technology_engine':
			this.mkz_hybrid_exp_page("ln:exp:technology:engine");
			break;
			
		case 'mkz_hybrid_exp_interior':
			this.mkz_hybrid_exp_page("ln:exp:interior space");
			break;
			
		// MKZ Hybrid Experience Clicks
		case 'mkz_hybrid_home_overview_cta':
			this.mkz_hybrid_exp_click("exp:home:cta", "exp:home:cta:smart guage");
			break;

		case 'mkz_hybrid_share':
			this.mkz_hybrid_exp_click("ln:exp:mkz:global:share this", "ln:exp:mkz:global:share this");
			break;
			
		case 'mkz_hybrid_petal_share':
			this.mkz_hybrid_exp_click("ln:exp:petal awards:share", "petal awards:share:complete");
			break;
			
		case 'mkz_hybrid_video_share':
			this.mkz_hybrid_exp_click("ln:exp:video", "exp:video:share");
			break;
	
		case 'mkz_hybrid_video_embed':
			this.mkz_hybrid_exp_click("ln:exp:video", "exp:video:embed");
			break;
			
		case 'mkz_hybrid_video_link':
			this.mkz_hybrid_exp_click("ln:exp:video", "exp:video:get link");
			break;
			
		case 'mkz_hybrid_luxury_pdf':
			this.mkz_hybrid_exp_click("ln:exp:luxury:pdf", "exp:luxury:pdf");
			break;
			
		case 'mkz_hybrid_luxury_learn_more':
			this.mkz_hybrid_exp_click("ln:exp:feature:next steps", "exp:feature:next steps:learn more");
			break;
			
		case 'mkz_hybrid_luxury_bp':
			this.mkz_hybrid_exp_click("ln:exp:feature:next steps", "exp:feature:next steps:build and price");
			break;
			
		case 'mkz_hybrid_luxury_search_inventory':
			this.mkz_hybrid_exp_click("ln:exp:feature:next steps", "exp:feature:next steps:search inventory");
			break;
			
		// MKX Hybrid Experience Pages
		case 'MKX_exp':
			if(swfobject && swfobject.hasFlashPlayerVersion("9.0.0")) {
				this.mkx_exp_page("home");
			} else {
				this.mkx_exp_page("get flash");
			}
			break;

		case 'mkx_exp_overview':
			this.mkx_exp_page("video:introduction");
			break;

		case 'mkx_exp_mylincoln_touch':
			this.mkx_exp_page("video:mylincoln touch");
			break;
			
		case 'mkx_exp_driving_experience':
			this.mkx_exp_page("video:driving experience");
			break;
			
		case 'mkx_exp_interior_comfort':
			this.mkx_exp_page("video:interior comfort");
			break;

		case 'mkx_exp_entertainment':
			this.mkx_exp_page("video:entertainment");
			break;
			
		// MKX Experience Clicks
		// Introduction video
		case 'mkx_overview_share':
			this.mkx_exp_click("introduction", "share this");
			break;
			
		case 'mkx_overview_embed':
			this.mkx_exp_click("introduction", "embed");
			break;
			
		case 'mkx_overview_link':
			this.mkx_exp_click("introduction", "get link");
			break;
		
		// MyLincoln Touch video	
		case 'mkx_mylincoln_touch_bp':
			this.mkx_exp_click("mylincoln touch", "bp");
			break;
			
		case 'mkx_mylincoln_touch_link_0':
			this.mkx_exp_click("mylincoln touch", "mylincoln touch");
			break;
			
		case 'mkx_mylincoln_touch_link_1':
			this.mkx_exp_click("mylincoln touch", "sync");
			break;
			
		case 'mkx_mylincoln_touch_share':
			this.mkx_exp_click("mylincoln touch", "share this");
			break;
			
		case 'mkx_mylincoln_touch_embed':
			this.mkx_exp_click("mylincoln touch", "embed");
			break;
			
		case 'mkx_mylincoln_touch_link':
			this.mkx_exp_click("mylincoln touch", "get link");
			break;
			
		// Driving Experience video	
		case 'mkx_driving_experience_bp':
			this.mkx_exp_click("driving experience", "bp");
			break;
			
		case 'mkx_driving_experience_link_0':
			this.mkx_exp_click("driving experience", "fuel economy");
			break;
			
		case 'mkx_driving_experience_link_1':
			this.mkx_exp_click("driving experience", "advancetrac with roll stability control");
			break;
			
		case 'mkx_driving_experience_link_2':
			this.mkx_exp_click("driving experience", "independent suspension");
			break;
			
		case 'mkx_driving_experience_share':
			this.mkx_exp_click("driving experience", "share this");
			break;
			
		case 'mkx_driving_experience_embed':
			this.mkx_exp_click("driving experience", "embed");
			break;
			
		case 'mkx_driving_experience_link':
			this.mkx_exp_click("driving experience", "get link");
			break;
			
		// Interior Comfort video	
		case 'mkx_interior_comfort_bp':
			this.mkx_exp_click("interior comfort", "bp");
			break;
			
		case 'mkx_interior_comfort_link_0':
			this.mkx_exp_click("interior comfort", "remote start");
			break;
			
		case 'mkx_interior_comfort_link_1':
			this.mkx_exp_click("interior comfort", "available rain-sensing wipers ");
			break;
			
		case 'mkx_interior_comfort_link_2':
			this.mkx_exp_click("interior comfort", "heated and cooled front seats");
			break;
			
		case 'mkx_interior_comfort_link_3':
			this.mkx_exp_click("interior comfort", "available heated second-row outboard seats");
			break;
			
		case 'mkx_interior_comfort_share':
			this.mkx_exp_click("interior comfort", "share this");
			break;
			
		case 'mkx_mylincoln_touch_embed':
			this.mkx_exp_click("interior comfort", "embed");
			break;
			
		case 'mkx_interior_comfort_link':
			this.mkx_exp_click("interior comfort", "get link");
			break;
			
		// Entertainment video	
		case 'mkx_entertainment_bp':
			this.mkx_exp_click("entertainment", "bp");
			break;
			
		case 'mkx_entertainment_link_0':
			this.mkx_exp_click("entertainment", "remote start");
			break;
			
		case 'mkx_entertainment_link_1':
			this.mkx_exp_click("entertainment", "available rain-sensing wipers");
			break;
			
		case 'mkx_entertainment_link_2':
			this.mkx_exp_click("entertainment", "heated and cooled front seats");
			break;
			
		case 'mkx_entertainment_share':
			this.mkx_exp_click("entertainment", "share this");
			break;
			
		case 'mkx_entertainment_embed':
			this.mkx_exp_click("entertainment", "embed");
			break;
			
		case 'mkx_entertainment_link':
			this.mkx_exp_click("entertainment", "get link");
			break;
		
	   	case 'cabBoxEngine':
	   		this.cabBoxEngine();
                break;
            	case 'categoryPackages':
                case 'categoryInterior_Features':
                case 'categoryExterior_Features':
                case 'categoryPower_and_Handling':
                case 'categorySafety':
                case 'categoryAccessories':
            		this.categoryPackages();
            	break;
		case 'currentModelYear':
                	this.currentModelYear();
                break;	
		case 'previousModelYear':
			this.previousModelYear();                	
			break;

		case 'mercuryOwnersClick':
			this.mercuryLinkout('flmo: home','referral: mc: owners');                	
			break;

		case 'mercuryFAQsClick':
			this.mercuryLinkout('flmo: faq','referral: flmo: faq');                	
			break;

		case 'serviceOwnersClick':
			this.mercuryLinkout('flmo: service coupons','referral: flmo: service coupons');                	
			break;

		case 'ownersManualClick':
			this.mercuryLinkout('flmo: owner manual','referral: flmo: owner manual');                	
			break;

		case 'scheduleServiceClick':
			this.mercuryLinkout('flmo: schedule service','referral: flmo: schedule service');                	
			break;

		case 'partsAccessoriesClick':
			this.mercuryLinkout('fv: accessories','referral: fv: accessories');                	
			break;

		case 'makePaymentClick':
			this.mercuryLinkout('flmc: payment','referral: flmc: payment');                	
			break;

		case 'servicePlansClick':
			this.mercuryLinkout('flmo: esp','referral: flmo: esp');                	
			break;

		case 'fordStoryClick':
			this.mercuryLinkout('fv: ford story','referral: fmc: ford story');                	
			break;

		case 'fordVehiclesClick':
			this.mercuryLinkout('fv: home','referral: fv: home');                	
			break;

		case 'lincolnVehiclesClick':
			this.mercuryLinkout('ln: home','referral: ln: home');                	
			break;

		case 'byoClick':
		case 'mercuryOwnersReferralClick':
			this.mercuryLinkout('flmo: service provider','referral: flmo: service provider');                	
			break;

		case 'modelClick':
			this.mercuryLinkout(storedBrand+': '+storedPageName,'referral: '+storedBrand+': '+storedNameplate+': '+storedPageName);                	
			break;

		default:
		}
	};

	this.mercuryLinkout = function(v6,c5) {
		this.clearVars();

		// Include Variable Set commons.
		this.commonsVariableSet();
		
		//Variables for - Omniture
		s.eVar6=s.prop6=v6;
		s.prop5=c5;
		s.pev2 = "referral: exit";
		s.events='event4';
		s.pe='lnk_e';
		
		void(s.t());
	};
	
	this.distViewAll = function(){
		var pageType = 'specs';
		if(_widgets.context){
			var currentView = _widgets.context.SelectedContext.get("site.currentView");
			if(currentView == 'specifications'){
				pageType = 'specs';
			}else{
				pageType = 'models';
			}
		}
		return pageType;
	};
		
	this.currentModelYear = function(){
		this.clearVars();
	
	// Include Variable Set commons.
	this.commonsVariableSet();
	s.pageName = this.brandVar() + ':vehicle:select:current my';
	//Variables for - Omniture
	
	s.eVar11=s.prop11=this.brandVar()+':vehicle:select';	
	void(s.t());
	};
	
	this.previousModelYear = function(){
		this.clearVars();
	
	// Include Variable Set commons.
	this.commonsVariableSet();
	s.pageName = this.brandVar() + ':vehicle:select:previous my';
	//Variables for - Omniture
	
	s.eVar11=s.prop11=this.brandVar()+':vehicle:select';	
	void(s.t());
	};
	
	
	
	
	this.modelsPage = function(){
		var modelsPageName = 'detail';
		if(_widgets.context){
			var currentView = _widgets.context.SelectedContext.get("site.currentView");
			if (currentView == 'model-and-options-detailed-compare'){
				modelsPageName = 'compare';
			}else{
				modelsPageName = 'detail';
			}
		}
		return modelsPageName;
	};
	
	this.featureCategoryViewed = function(){
		this.clearVars();
		
		// Include Variable Set commons.
		this.commonsVariableSet();		
		s.pageName = this.brandVar() + ':vehicle:feature:' +this.featureCategoryName() + ':' + this.nameplate();
		//Variables for - Omniture
		
		s.eVar11=s.prop11= this.brandVar() + ':vehicle:feature:'+this.featureCategoryName();
		
		void(s.t());
	};
	
	this.vehicleHomepageTag = function(){ 
                var homepageTag = "vhp";
				if(_widgets.context){
					var lifeCycleStage = _widgets.context.SelectedContext.get("nameplate.lifeCycleStage");
					if(typeof(lifeCycleStage) === 'string' && lifeCycleStage.toLowerCase() === "reveal") {
						homepageTag = "rhp";
					}
				}
                return homepageTag;            
        };
	
	
	this.featureSubCategoryViewed = function(){
		this.clearVars();
		
		// Include Variable Set commons.
		this.commonsVariableSet();		
		s.pageName = this.brandVar() + ':vehicle:feature:' +this.featureCategoryName() + ':' + this.featureName() + ':' + this.nameplate();
		//Variables for - Omniture
		
		s.hier1 = "vehicle:features:"+this.modelYear()+":"+this.modelCategory()+":"+this.nameplate()+":"+this.featureCategoryName() + ':' + this.featureName();
		s.eVar11=s.prop11= this.brandVar() + ':vehicle:feature:'+this.featureCategoryName() + ':' + this.featureName();
		
		void(s.t());
	};	
	
	this.cpo = function(pageName) {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 = s.prop11 = s.pageName = pageName;
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	}
	
	this.point_inspection = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 = "ln:cpo:benefits:169 point inspection";
		s.prop11 = "ln:cpo:benefits:169 point inspection";
		s.pageName =  "ln:cpo:benefits:169 point inspection";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.warranty = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 = "ln:cpo:benefits:comprehensive waranty";
		s.prop11 = "ln:cpo:benefits:comprehensive waranty";
		s.pageName =  "ln:cpo:benefits:comprehensive waranty";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.hour_roadside_assistance = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =  "ln:cpo:benefits:24 roadside";
		s.prop11 =  "ln:cpo:benefits:24 roadside";
		s.pageName =  "ln:cpo:benefits:24 roadside";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.vehicle_history_report = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =  "ln:cpo:benefits:vehicle history";
		s.prop11 =  "ln:cpo:benefits:vehicle history";
		s.pageName =  "ln:cpo:benefits:vehicle history";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.benefits = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =   "ln:cpo:benefits:additional";
		s.prop11 =  "ln:cpo:benefits:additional";
		s.pageName =  "ln:cpo:benefits:additional";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.cpoIncentives= function()  {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =   "ln:cpo:incentives";
		s.prop11 =  "ln:cpo:incentives";
		s.pageName =  "ln:cpo:incentives";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.offers1= function()  {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =   "ln:cpo:incentives:offers1";
		s.prop11 =   "ln:cpo:incentives:offers1";
		s.pageName =  "ln:cpo:incentives:offers1";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.offers2 = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =   "ln:cpo:incentives:offers2";
		s.prop11 =   "ln:cpo:incentives:offers2";
		s.pageName =  "ln:cpo:incentives:offers2";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.offers3 = function() {
		this.clearVars();
		this.commonsVariableSet();
		s.eVar11 =   "ln:cpo:incentives:offers3";
		s.prop11 =   "ln:cpo:incentives:offers3";
		s.pageName =  "ln:cpo:incentives:offers3";
		s.hier1="shopping tools:cpo";
		s.channel="cpo";
		void(s.t());
	};
	
	this.incentivesresult = function(){
		this.clearVars();
		this.commonsVariableSet();		
		s.pageName = this.brandVar() + ':vehicle:incentives:results:' + this.nameplate();
		//Variables for - Omniture
		s.hier1 = 'shopping tools:incentives:' + this.modelYear() + ':' + this.modelCategory() +':' + this.nameplate();
		s.eVar11=s.prop11= this.brandVar() + ':vehicle:incentives:results';
		s.events='event9';
		dartTracker.trackEvent('iv', this.nameplate(), 1, 'lngen2', '');
		void(s.t());
	};
	
	this.incentiveserror = function(){
		this.clearVars();	
		this.commonsVariableSet();
		s.pageName = this.brandVar() + ':incentives:error';
		//Variables for - Omniture
		
		s.eVar11=s.prop11= this.brandVar() + ':incentives:error';		
		void(s.t());
	};
	
	this.partFlipMediaTab = function(){
		this.clearVars();
	
		// Include Variable Set commons.
		this.commonsVariableSet();
		s.pageName = this.brandVar()+': vehicle: models: compare: '+this.compareTabName()+': item: photos: '+this.nameplate();
		//Variables for - Omniture
	
		s.eVar11=s.prop11=''+this.brandVar()+': vehicle: models: compare: '+this.compareTabName()+': item: photos';
	
		void(s.t());
	}
	
	this.compareText = function(){
		var make = this.getMake();
		var compareText = "lincolnadvantages";
		switch(make){
		case "Lincoln":
			var compareText = "lincolnadvantages";
			break;
		case "Ford":
			compareText = "fordadvantages";
			break;
		default:
			compareText = "lincolnadvantages";
			break;
		}
		return compareText;
	};
	
	this.trackMicroDataAndSEOContext = function(onClickName, sSEO_Segment, sSEO_SubSegment, sSEO_Category, sSEO_Link, sSEO_LinkType, sSEO_CampainID, sSEO_ClickType){
		
		this.SEO_Segment = sSEO_Segment;
		this.SEO_SubSegment = sSEO_SubSegment;
		this.SEO_Category = sSEO_Category;
		this.SEO_Link = sSEO_Link;		
		this.SEO_LinkType = sSEO_LinkType;
		this.SEO_Campaign = sSEO_CampainID;
		this.SEO_ClickType = sSEO_ClickType;
		
		eval('this.self.' + onClickName +'()');
	};	
};

var oMetricsTracker = new com.forddirect.brandsites.metrics.NewMetricsTracker();
oMetricsTracker.inish(oMetricsTracker);


