// version 1.08.01 2011-02-28 14:00


WebTracker.prototype.TrackVehicleHub = function()
{
	this._cookieName="_wtvsp"; // interactivity tracking cookie
	var nonPVExt = ".action";
	var myT = this;
	
	this._eventParams["externalclick"] = new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac: evObj.AC,
	  				dl:24
	  			},
	  			DCSext: {},
	  			DCS:{dcsuri:document.location.pathname + "/external-click",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - External Click",
  					evObj.URL
  				]
  			}
  		};
  		if(typeof(evObj.ToolboxPath) != "undefined")
  			myT._trackParams.webtrends.DCSext["Toolbox"] = evObj.ToolboxPath;
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
	
	this._eventParams["toolboxopen"]= new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "VSHToolBoxExpand",
	  				dl:22
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/open-toolbox",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Toolbox",
  					"Open"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
	
	this._eventParams["toolboxclose"]= new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "VSHToolBoxCollapse",
	  				dl:22
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/close-toolbox",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Toolbox",
  					"Close"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
  
  // Special Offers
	this._eventParams["postcodeenterpostcode"] = new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"Postcode_" + evObj.Postcode,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/enter-postcode",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Special Offers",
  					"Entered Postcode",
  					evObj.Postcode
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
			try
			{
				wt.AddToBucket("V","PostcodeInput");
			} catch(err) {}
		}
	);
  
  
  // Special Offers
	this._eventParams["specialoffersbuttonclick"] = new EventObj(
		"always",
		function() { 
			var evObj = arguments[0];
			var ac="SpecialoffersHP";
			var rt=myT._getSectTypeFromURL();;
			
			switch(evObj.State)
			{
				case "SeeAllOffers":
					rt+="SeeAllOffers";
					break;
				case "HideAllOffers":
					rt+="HideAllOffers";
					break;
				default:
					if(typeof(evObj.Vehicle)!="undefined")
						rt+=evObj.Vehicle + "SeeOffers";
					break;
			}
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:rt,
	  				dl:21
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/click",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Special Offers",
  					"Button Click",
  					rt
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
  
  
  
	this._eventParams["specialofferview"] =  new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
			var srcID = myT._getSourceID(evObj.Source);
			
			evObj.OfferName = evObj.OfferName.replace(/\s+/g," ");
			evObj.OfferName = evObj.OfferName.replace(/[^a-zA-Z0-9]/g,"");
			
			var vehicleType = myT._getVehicleFromString(evObj.Vehicle);
			var sGroup1="", sGroup2="", cGroup2 = "";
			
			var dl = document.location.pathname.toLowerCase();
			var dq = document.location.search.toLowerCase();
			var isTFODirect = (dl.indexOf('toyota-finance-offer')>0) ? 1 : 0;
			var isSO = (dl.indexOf('/special-offers')==0) ? 1 : 0;
			var isTFOHome = (dl=="/special-offers/toyota-finance-offer") ? 1 : 0;
			var isSOHome = (dl=="/special-offers") ? 1 : 0;
			var isAnon = (dl=="/special-offers/entry") ? 1 : 0;
			var isDirectOffer = (dq.indexOf("offerid=")>0) ? 1 : 0;
			var uri = document.location.pathname;
			var TFOState = "Special Offer";
			var state=myT._getSectTypeFromURL();

			// fix any missing srcID based on the URL
			if(isTFODirect && srcID=="OTH")
				srcID="TFO";
			else if(isSO && srcID=="OTH")
				srcID="SO";
				
			if(evObj.IsTFO)
				TFOState = "TFO 2.9";

			if(typeof(evObj.Region) == "undefined" && typeof(window["userDetailsDealerPostcode"]) != "undefined")
				evObj.Region = window["userDetailsDealerPostcode"];
			else if(typeof(evObj.Region) == "undefined")
				evObj.Region += "Unspecified Region";
				
			if(evObj.IsTFO == 2)
			{
				if(isSOHome) {
					sGroup1 = "Offer Detail";
					TFOState = "Special Offer";
				} else {
					sGroup1 = "Offer Detail";
					cGroup2 = "TFA Landing Page";
					sGroup2 = evObj.OfferName;
					TFOState = "TFA";
					srcID="TFA";
				}
			}
			else if(evObj.IsTFO && isTFODirect && ! isTFOHome)
			{
				sGroup1 = "Toyota-finance-offer 2.9 - " + vehicleType;
				cGroup2 = "Retail: Finance Offer 2.9";
				sGroup2 = "Finance " + vehicleType;
			}
			else if(evObj.IsTFO && isTFODirect )
			{
				sGroup1 = "Toyota-finance-offer 2.9 - Homepage";
				cGroup2 = "Retail: Finance Offer 2.9";
				sGroup2 = "Homepage";
			}
			else if(evObj.IsTFO && (isDirectOffer || evObj.OfferID != "") )
			{
				sGroup1 = "Offer Detail";
				cGroup2 = "Toyota-finance-offer 2.9 - Homepage";
				sGroup2 = vehicleType + " Offer Detail";
				if(isDirectOffer)
					uri = "/special-offers/offer-offerid:" + evObj.OfferID + ":2.9-direct";
				else
					uri = "/special-offers/offer-offerid:" + evObj.OfferID + ":2.9-pop-up";
			}
			else if(isDirectOffer || evObj.OfferID != "" )
			{
				sGroup1 = "Offer Detail";
				
				if(isDirectOffer)
					uri = "/special-offers/offer-offerid:" + evObj.OfferID + ":-direct";
				else
					uri = "/special-offers/offer-offerid:" + evObj.OfferID + ":-pop-up";
			}
			else if(isAnon && isTFODirect )
			{
				sGroup1 = "Entry Page";
			}
			else if(isSOHome )
			{
				sGroup1 = "Homepage";
			}
			
			if(typeof(evObj.ClickType)!="undefined")
				uri+=evObj.ClickType;
			
			var eType="";
			if(typeof(evObj.EntryType) != "")
				eType=evObj.EntryType;
			
			var wtac = state + vehicleType.replace(/\s+/g,"") + "SpecialOfferVSO" + srcID;
			
			if(typeof(evObj.ClickType) !="undefined")
				wtac += evObj.ClickType;
			
			

  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:wtac,
	  				cg_n: "Retail: Redesign Site",
	  				cg_s: sGroup1,
	  				dl:0
	  			},
	  			DCS:{dcsuri:uri,dcsqry:""},
	  			DCSext:{
	  				VehicleID: vehicleType,
	  				OfferID:evObj.OfferID,
	  				OfferName:evObj.OfferName,
	  				Postcode:evObj.PostCode,
	  				OfferSource:srcID,
	  				OfferRegion:evObj.Region,
	  				EntryType:eType,
	  				SpecOfferType:TFOState
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Special Offers",
  					"View Special Offer " + "-" + TFOState,
  					vehicleType + "-" + evObj.OfferID + "-" + evObj.PostCode
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
			
			if(cGroup2!="")
			{
				myT._trackParams = {
					webtrends:{
						WT:{
							cg_n: cGroup2,
							cg_s: sGroup2,
							dl:0
						},
						DCS:{dcsuri:uri,dcsqry:""},
						DCSext:{}
					}
				};
				if(typeof(evObj) != "undefined") { myT._sendData(); }
			}
		}
	);
  	
	this._eventParams["specialofferprint"] =  new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
			var srcID = myT._getSourceID(evObj.Source);
			var state=myT._getSectTypeFromURL();
			
			var vdd = evObj.Vehicle + "|" + evObj.OfferID + "|";
			if(typeof(evObj.Region) != "undefined")
				vdd += evObj.Region;
			else
				vdd += "Unspecified Region";
			
			var eType="";
			if(typeof(evObj.EntryType) != "")
				eType=evObj.EntryType;
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:state + evObj.Vehicle + "SpecialOfferPSO" + srcID,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/print-offer-" + evObj.OfferID,dcsqry:""},
	  			DCSext:{
	  				OfferID:evObj.OfferID,
	  				Postcode:evObj.PostCode,
	  				PrintOffer:1,
	  				OfferSource:srcID,
	  				SpecOfferVRID:vdd,
	  				EntryType:eType
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Special Offers",
  					"Print Special Offer",
  					evObj.OfferID + "-" + evObj.PostCode
  				]
  			}
  		};
  		
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
  	
	this._eventParams["specialofferseealloffers"] =  new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
			var srcID = myT._getSourceID(evObj.Source);
			var state=myT._getSectTypeFromURL();
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:state + evObj.Vehicle + "SpecialOfferSAO" + srcID,
	  				dl:22
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/see-all-offers",dcsqry:""},
	  			DCSext:{Postcode:evObj.PostCode,SeeAllOffers:1}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Special Offers",
  					"See All Offers",
  					evObj.PostCode
  				]
  			}
  		};
  		
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);

	// Specifications
	this._eventParams["specificationsexpandall"]= new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"Specifications_" + evObj.Vehicle + "_ExpandAll",
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/expand-all",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/expand-all"],
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Specifications",
  					"Expand All"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		}
	);
  	
	this._eventParams["specificationscollapseall"]= new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"Specifications_" + evObj.Vehicle + "_CollapseAll",
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/collapse-all",dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/collapse-all"],
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Specifications",
  					"Collapse All"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	this._eventParams["specificationsexpand"]=new EventObj(
		"always",
		function() { 
			var evObj = arguments[0]; 
			var h="heading";
			if(typeof(evObj.Heading) != "undefined")
				h=evObj.Heading;
				
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"Specifications_" + evObj.Vehicle + "_Expand_" + h,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/expand-" + h,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				SpecHeading: h
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/expand-" + h],
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Specifications",
  					"Expand - " + h
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	this._eventParams["specificationscollapse"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var h="heading";
			if(typeof(evObj.Heading) != "undefined")
				h=evObj.Heading;

  		myT._trackParams = {
  			googleanalytics:{
  				_trackEvent:[
  					"Click Tracking",
  					evObj.Vehicle + " - Specifications",
  					"Collapse - " + h
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	// Accessories
	
	this._eventParams["accessoriesexpand"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var h="Unknown";
			if(typeof(evObj.Heading) != "undefined")
				h=evObj.Heading;
			h = myT._getSourceID(h);
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "AccessoriesEXP" + h,
	  				dl:21
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/ExpandCTA-" + h,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/expandcta-" + h],
  				_trackEvent:[
  					"Accessories",
  					evObj.Vehicle + " - Accessories",
  					"Expand CTA Click - " + h
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	
	this._eventParams["accessoriescategory"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var h="Unknown";
			if(typeof(evObj.Heading) != "undefined")
				h=evObj.Category;
			h = myT._getSourceID(h);
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "AccessoriesCAT" + h,// add in second group accessories and vehicle-accessories
	  				cg_n: evObj.Vehicle + ' Accessories',
	  				cg_s: evObj.Category,
	  				dl:0
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/Category-" + h,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/category-" + h],
  				_trackEvent:[
  					"Accessories",
  					evObj.Vehicle + " - Accessories",
  					"Category - " + h
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	this._eventParams["accessoriesapplicability"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0];
			var i="item";
			if(typeof(evObj.Item) != "undefined")
				i=evObj.Item;
			
			i = i.replace(/\W/g,"");
				
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "AccessoriesAPPL" + i,
	  				dl:21	
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/applicability-" + i,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/applicability-" + i],
  				_trackEvent:[
  					"Accessories",
  					evObj.Vehicle + " - Accessories",
  					"Expand - " + i
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);


  var accessoriesFunc = 		function(evObj) {  
			var h="",cgn="",cgs="";
			if(typeof(evObj.Item) != "undefined")
				h=evObj.Item.replace(/[\W]/g,"");
			else if(typeof(evObj.Image) != "undefined")
			{
				var t = evObj.Image.split("-");
				if(t.length>0)
					h= t[t.length-1];
				else
					h=evObj.Image.replace(/[\W]/g,"");
			}
			
			cgn = myT._capitaliseFirst(evObj.Vehicle) + " Accessories";
			cgs = "All";
			var sect="";
			if(typeof(evObj.Section) != "undefined")
				cgs=sect=evObj.Section;
			
			var dl = document.location.pathname.toLowerCase();
			var uri=dl + "/";
			if(sect!="")
				uri += sect + "/";
			uri+=h;
				
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:"VH" + evObj.Vehicle + "AccessoriesITM" + h, // add second groups
	  				cg_n: myT.cGroup + ";" + cgn,
	  				cg_s: myT.sGroup + ";" + cgs,
	  				dl:0
	  			},
	  			DCS:{dcsuri:uri,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackPageview:[uri],
  				_trackEvent:[
  					"Accessories",
  					evObj.Vehicle + " - Accessories",
  					"View Item - " + h
  				]
  			}
  		};

  			
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		};
		
	this._eventParams["accessoriesitem"]=new EventObj(
		"always", 
		function() { accessoriesFunc(arguments[0]); }
	);
		
	this._eventParams["accessoriesviewimage"]=new EventObj(
		"always", 
		function() { accessoriesFunc(arguments[0]); }
	);
	
	// Modules
	
	this._eventParams["moduleimpression"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var h="";
			if(typeof(evObj.Module) != "undefined")
				h=evObj.Module.replace(/[\W]/g,"");

  		myT._trackParams = {
  			/*webtrends:{
	  			WT:{
	  				cg_n: myT.cGroup,
	  				cg_s: myT.sGroup
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/module-impression-" + h,dcsqry:""},
	  			DCSext:{
	  				ModuleSect:evObj.Section,
	  				ModuleImpr:1
	  			}
	  		},*/
  			googleanalytics:{
  				//_trackPageview:[document.location.pathname + "/module-impression-" + h],
  				_trackEvent:[
  					"Modules",
  					"Impressions",
  					evObj.Section + " - " + h
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	this._eventParams["moduleinteract"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var h="";
			if(typeof(evObj.Module) != "undefined")
				h=evObj.Module.replace(/[\W]/g,"");
			var mcta="";
			if(typeof(evObj.CTA) != "undefined")
				mcta = evObj.CTA;
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				dl:22
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/module-interaction-" + h,dcsqry:""},
	  			DCSext:{
	  				ModuleName:evObj.Module,
	  				ModuleSect:evObj.Section,
	  				ModuleInteract:1,
	  				ModuleCTAName: mcta
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/module-interaction-" + h],
  				_trackEvent:[
  					"Modules",
  					evObj.Module,
  					"Interactions - " + evObj.Section
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	// Compare Grades
	this._eventParams["comparegradesstart"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/compare-grades-start",dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID:evObj.Vehicle,
	  				CompareGradeSection:evObj.Source,
	  				CompareGradeStart:1
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/compare-grades-start"],
  				_trackEvent:[
  					"Compare Grades",
  					evObj.Vehicle + "-" + evObj.Source,
  					"Start"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	this._eventParams["comparegradescomplete"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			
			if(evObj.Source.toLowerCase()=="unspecified source")
			{
				var dl = document.location.pathname;
				if(dl.indexOf('range')>0)
					evObj.Source = "Range";
				else if(dl.indexOf('specifications')>0)
					evObj.Source = "Specification";
			}

  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + "/compare-grades-complete",dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID:evObj.Vehicle,
	  				CompareGradeSection:evObj.Source,
	  				CompareGradeComplete:1
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + "/compare-grades-complete"],
  				_trackEvent:[
  					"Compare Grades",
  					evObj.Vehicle + "-" + evObj.Source,
  					"Complete"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	// video
	this._eventParams["videovideoplay"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			
			var flvStatus="Playing the video";
			var uext = "/playing-video-" + evObj.VideoName.replace(/\W/g,"_")
			
			var vName = myT._capitaliseFirst(evObj.Vehicle) + "|HSD|" + document.title + "|" + evObj.VideoName;
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Videos",
	  				cg_s: myT._capitaliseFirst(evObj.Vehicle),
	  				Model:evObj.Vehicle,
	  				ti:evObj.VideoName,
	  				flv_name: vName,
	  				flv_status: flvStatus,
	  				flv_percentplay:"0%",
	  				flv_viewduration:evObj.VideoDuration,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + uext],
  				_trackEvent:[
  					"Videos",
  					evObj.Section + ":" + evObj.VideoName,
  					"Play"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	this._eventParams["videovideopause"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			
			var flvStatus="Pausing the video";
			var uext = "/pausing-video-" + evObj.VideoName.replace(/\W/g,"_");
			
			var vName = myT._capitaliseFirst(evObj.Vehicle) + "|HSD|" + document.title + "|" + evObj.VideoName;
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Videos",
	  				cg_s: myT._capitaliseFirst(evObj.Vehicle),
	  				Model:evObj.Vehicle,
	  				ti:evObj.VideoName,
	  				flv_name: vName,
	  				flv_status: flvStatus,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + uext],
  				_trackEvent:[
  					"Videos",
  					evObj.Section + ":" + evObj.VideoName,
  					"Pause"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	this._eventParams["videovideoresume"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			
			var flvStatus="Resuming the video";
			var uext = "/resuming-video-" + evObj.VideoName.replace(/\W/g,"_");
			
			var vName = myT._capitaliseFirst(evObj.Vehicle) + "|HSD|" + document.title + "|" + evObj.VideoName;
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Videos",
	  				cg_s: myT._capitaliseFirst(evObj.Vehicle),
	  				ti:evObj.VideoName,
	  				Model:evObj.Vehicle,
	  				flv_name: vName,
	  				flv_status: flvStatus,
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + uext],
  				_trackEvent:[
  					"Videos",
  					evObj.Section + ":" + evObj.VideoName,
  					"Resume"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	this._eventParams["videovideoprogress"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var vn = evObj.VideoName.replace(/\W/g,"_");
			var isOK = 0;
			
			var pc;
			if(evObj.PercentPlayed>=0.25 && evObj.PercentPlayed<0.5)
				pc=25;
			else if(evObj.PercentPlayed>=0.5 && evObj.PercentPlayed<0.75)
				pc=50;
			else if(evObj.PercentPlayed>=0.75 && evObj.PercentPlayed<1)
				pc=75;
			
			if(pc==undefined) return;
			if(typeof(this._videoProgressTracker)=="undefined")
				this._videoProgressTracker = {};
				
			if(typeof(this._videoProgressTracker[vn])=="undefined")
			{
				this._videoProgressTracker[vn] = pc;
				isOK=1;
			}
			else if(pc>this._videoProgressTracker[vn])
				isOK=1;
				
			this._videoProgressTracker[vn] = pc;
			
			if(isOK==0) return;
			
			var uext = "/video-progress-" + vn;
			
			var vName = myT._capitaliseFirst(evObj.Vehicle) + "|HSD|" + document.title + "|" + evObj.VideoName;
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ti:evObj.VideoName,
	  				flv_percentplay:pc+"%",
	  				flv_name: vName,
	  				dl:22
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + uext],
  				_trackEvent:[
  					"Videos",
  					evObj.Section + ":" + evObj.VideoName,
  					"Percent Played",
  					pc
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	this._eventParams["videovideocomplete"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			
			var flvStatus="Completing the video";
			var uext = "/completing-video-" + evObj.VideoName.replace(/\W/g,"_");
			
			var vName = myT._capitaliseFirst(evObj.Vehicle) + "|HSD|" + document.title + "|" + evObj.VideoName;
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Videos",
	  				cg_s: myT._capitaliseFirst(evObj.Vehicle),
	  				Model:evObj.Vehicle,
	  				flv_name: vName,
	  				flv_status: flvStatus,
	  				flv_percentplay:"100%",
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle
	  			}
	  		},
  			googleanalytics:{
  				_trackPageview:[document.location.pathname + uext],
  				_trackEvent:[
  					"Videos",
  					evObj.Section + ":" + evObj.VideoName,
  					"Complete"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	



	// Colour Picker

	this._eventParams["coloursdemosclick"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var cgn= myT._capitaliseFirst(evObj.Vehicle) + " Colour and Demo";
			var cgs=evObj.Section;
			var uext = "/colour-picker-" + evObj.Section.replace(/\W+/g,"_");
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n:cgn,
	  				cg_s:cgs,
	  				dl:21
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				CPLocation: evObj.Section
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Colour Picker",
  					evObj.Vehicle,
  					evObj.Section
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	var intextfunc = function(t,evObj) { 
			
			var dl = document.location.pathname.toLowerCase();
			
			var cfg="",st="",cgn="",cgs="",intext="";
			var wtac="VH" + evObj.Vehicle + "ColourPicker" + t;
			if(typeof(evObj.Range) != "undefined")
				wtac+= evObj.Range;
				
			wtac+= evObj.BodyType + evObj.ActionType;
			if(evObj.ActionType=="PriceVehicle")
			{
				cfg="PriceVehicle";
			}
			else if(evObj.ActionType=="ColourSelection" || evObj.ActionType=="BodySelection" || evObj.ActionType=="GradeSelection")
			{
				st="Colour and Demo";
				cfg = "Action:" + evObj.ActionType + ";Section:" + evObj.Section.replace(/\W+/g,"_") + ";BodyType:" + evObj.BodyType + ";Colour:" + evObj.Colour.replace(/\W+/g,"_") + ";Range:" + evObj.Range;
				cgn=evObj.Vehicle + " " + st;
				cgs=t+" View";
			}
			else if(evObj.ActionType=="FullScreen")
			{
				cfg = "FullScreen";
			}
			
			var uri = dl + "/" + t.toLowerCase() + "/" + cfg; 
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac:wtac,
	  				dl:21
	  			},
	  			DCS:{dcsuri:uri,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				CPLocation: evObj.Section
	  			}
	  		},
  			googleanalytics:{
  				
  				_trackEvent:[
  					"Colour Picker",
  					evObj.Vehicle,
  					cfg
  				]
  			}
  		};
  		if(cgn!="")
  			myT._trackParams.webtrends.WT["cg_n"] = cgn;
  		if(cgs!="")
  			myT._trackParams.webtrends.WT["cg_s"] = cgs;
  			
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 

	this._eventParams["vehicleexteriorcolourtoolclick"]=new EventObj(
		"always", 
		function(){intextfunc('Exterior',arguments[0]);}
	);
	this._eventParams["coloursdemoclick"]=new EventObj(
		"always", 
		function(){
			var evObj=arguments[0];
			intextfunc(evObj.Section,evObj);
		}
	);

	this._eventParams["coloursdemosdownload"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 

			var uext = "/download-share-" + evObj.Section.replace(/\W+/g,"_")
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Vehicles: " + evObj.Vehicle,
	  				cg_s: "Download & Share",
	  				dl:20
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				CPDownloadCTA: evObj.CTA
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Colour Picker",
  					evObj.Vehicle + " - " + evObj.Section,
  					evObj.CTA
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	// Gallery

	// button click
	this._eventParams["gallerybuttonclick"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var uext = "/image-button";
			var wtac = evObj.Vehicle.replace(/\s+/g,"")+"_"+evObj.Type.replace(/\s+/g,"")+"_Gallery";
			var gType = evObj.Type;

			if(evObj.Type=="Video")
			{
				uext = "/video-button";
				wtac = evObj.Vehicle.replace(/\s+/g,"")+"_"+evObj.Type.replace(/\s+/g,"")+"_Gallery";
			}
				
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				cg_n: "Hybrid Synergy Drive Gallery Section",
	  				cg_s: gType,
	  				ac:wtac,
	  				dl:0
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Gallery",
  					evObj.Vehicle,
  					evObj.Type + " Button Click"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	// view image
	this._eventParams["galleryviewimage"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var imgSrc = evObj.Image.split("-");
			var img = imgSrc[imgSrc.length-1];
			var uext = "/" + img.replace(/\W+/g,"_")
			var sect;
			var dl = document.location.pathname.toLowerCase();
			var uri=dl + "/images/" + img;

  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				ac: "HSD_HP_Banner_"+evObj.Image,
	  				dl:0
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				GalleryImage: evObj.Image
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Gallery",
  					'HSD',
  					evObj.Image
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	// pricing
	this._eventParams["pricingstart"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var uext="/pricing-start";
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				PricingStart:1
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Pricing",
  					evObj.Vehicle,
  					"Start"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	this._eventParams["pricingcomplete"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var uext="/pricing-complete";
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				dl:29
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				VehicleConversionID: evObj.Vehicle,
	  				PricingComplete:1,
	  				PriceConfig: evObj.Grade.replace(/\W+/g,"-") + "_" + evObj.Body.replace(/\W+/g,"-") + "_" + evObj.Transmission.replace(/\W+/g,"-") + "_" + evObj.Colour.replace(/\W+/g,"-") , 
	  				PriceLastCTA:"BPYT Click"
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Pricing",
  					evObj.Vehicle,
  					"Complete"
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

	// finance calculator
	this._eventParams["calculatorsubmit"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			if(typeof(this.fcalcsub) == "undefined")
				this.fcalcsub=0;
				
			if(this.fcalcsub==1)
			{
				myT._log("Fired already - returning no action");
				return;
			}
			var uext="/calculator-" + evObj.Type.replace(/\W+/g,"-");
			
			var cType="calc_submit";
			var t = (evObj.Type.replace(/\W+/g,"")).toLowerCase();
			if(t=="loanrepayments")
				cType="FCalc_Submit";
			
  		myT._trackParams = {
  			webtrends:{
	  			WT:{
	  				calc_name:evObj.Type
	  			},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				OfferSource: evObj.Source
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Calculators",
  					evObj.Type,
  					"Submit"
  				]
  			}
  		};
  		
  		myT._trackParams.webtrends.DCSext[cType] = 1;
			if(typeof(evObj) != "undefined") { myT._sendData(); }
			this.fcalcsub=1;
		} 
	);
	
	// TFA vs. TFO tracking
	this._eventParams["sotfotfaset"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var vals = evObj.Values.SOTFO + "-" + evObj.Values.TFATFO;
			
			var uext="/so-tfo-tfa-set-" + vals + nonPVExt;

  		myT._trackParams = {
  			webtrends:{
  				WT:{
  					dl:21
  				},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"SO-TFA-TFO",
  					vals
  				]
  			}
  		};
  		
  		if(typeof(evObj.Values.SOTFO) != "undefined")
  			myT._trackParams.webtrends.DCSext["SOTFO"] = evObj.Values.SOTFO;
  		if(typeof(evObj.Values.TFATFO) != "undefined")
  			myT._trackParams.webtrends.DCSext["TFATFO"] = evObj.Values.TFATFO;
  			
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	var cgsda = function(evObj)
	{
			var uext="/compare-grades-";
			var gaact="";
			var wtac="Specifications_" + myT._capitaliseFirst(evObj.Vehicle) + "_" + evObj.Action;
			if(evObj.Action == "ShowDifferences")
			{
				uext += "show-differences";
				gaact="Show Differences";
			}
			else if(evObj.Action == "ShowAll")
			{
				uext += "show-all";
				gaact="Show All";
			}
			else
				return;
				
  		myT._trackParams = {
  			webtrends:{
  				WT:{
  					ac:wtac,
  					dl:22
  				},
	  			DCS:{dcsuri:document.location.pathname + uext,dcsqry:""},
	  			DCSext:{
	  				
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Compare Grades",
  					evObj.Vehicle,
  					gaact
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
	}
	
	// Compare Grades - Show Differences
	this._eventParams["comparegradesshowdifferences"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			cgsda(evObj);
		} 
	);	
	// Compare Grades - Show All
	this._eventParams["comparegradesshowall"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			cgsda(evObj);
		} 
	);
		
	
	// Share via Social Media
	this._eventParams["shareclick"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var dl=evObj.Source +  "/share-Service-" + evObj.Dest + "/Source-" + evObj.Source;
			
			var state=myT._getSectTypeFromURL();
  		myT._trackParams = {
  			webtrends:{
  				WT:{
  					ac:state + "ShareSocialClick",
  					dl:0
  				},
	  			DCS:{dcsuri:dl,dcsqry:""},
	  			DCSext:{
	  				ShareClick:1
	  			}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Share Link",
  					evObj.Dest,
  					dl
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
		
	
	// mini colour picker
	this._eventParams["minicolourpickerclick"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var dl=document.location.pathname + "/minicolourpicker-click-Colour:" + evObj.Colour.replace(/\s+/g,"-") ;
			
			var wtac="VH" + evObj.Vehicle + "MiniColourPicker";
			//TODO check for vehicle type/grade
  		myT._trackParams = {
  			webtrends:{
  				WT:{
  					ac:wtac,
  					dl:21
  				},
	  			DCS:{dcsuri:dl,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Mini Colour Click",
  					evObj.Vehicle,
  					evObj.Colour
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);
	
	

		
	
	// range banner
	this._eventParams["rangebannerclick"]=new EventObj(
		"always", 
		function() { 
			var evObj = arguments[0]; 
			var dl=document.location.pathname + "/rangebanner-" + evObj.Range + "-" + evObj.ActionType;
			
			var wtac="VH" + evObj.Vehicle + "RangeBanner" + evObj.ActionType + evObj.Range;
			
  		myT._trackParams = {
  			webtrends:{
  				WT:{
  					ac:wtac,
  					dl:21
  				},
	  			DCS:{dcsuri:dl,dcsqry:""}
	  		},
  			googleanalytics:{
  				_trackEvent:[
  					"Range Banner",
  					evObj.Vehicle + "-" + evObj.Range,
  					evObj.ActionType
  				]
  			}
  		};
			if(typeof(evObj) != "undefined") { myT._sendData(); }
		} 
	);

}


// initialise the module
$(document).ready(function() 
	{
		if(typeof(wt) != "undefined")
			wt.TrackVehicleHub();
			
			
			// check whether the user is in the Toyota Finance Advantage or Special Offers section
			var dp = document.location.pathname.toLowerCase();
			if(document.location.search.indexOf('test=')>0)
				dp = document.location.search.replace(/\?test=/,"");
			
			var sotfoState="", tfotfaState="";
			if(dp.indexOf("/finance/toyota-finance-advantage") ==0)
			{
				tfotfaState = "TFA";
			}
			else if(dp.indexOf("/special-offers")==0)
			{
				if(dp.indexOf('/special-offers/toyota-finance-offer')==0)
				{
					sotfoState = "TFO";
					tfotfaState = "TFO";
				}
				else
					sotfoState = "SO";
			};
			
			// CHECK THAT VEHICLE HUB IS TRACKED WHEN A SPECIAL OFFER IS SHOWN
			if(sotfoState != "" || tfotfaState != "")
				wt.ReceiveEvent({EventClass:"SOTFOTFA",Action:"Set",Values:{SOTFO:sotfoState,TFATFO:tfotfaState}});
	}
);
