// 20111027J Events
var hpmmd=window.hpmmd||{type: 'Cleansheet Wash', page:{events:[]},product:{},user:{},legacy:{},promo:{}};
function setupCSMapping() {
	hpmmd.page['section']='ces';
	hpmmd.page['segment']=window.s_prop9||"consumer";
	hpmmd.page["conv73"]=window.s_eVar29;
	hpmmd.page["conv74"]=window.s_eVar30;
	hpmmd.page['cesPage']=window.s_prop27;

	hpmmd.page['traffic1']=window.s_prop1;
	hpmmd.page['traffic2']=window.s_prop2;
	hpmmd.page['traffic3']=window.s_prop3;
	hpmmd.page['traffic4']=window.s_prop4;
	hpmmd.page['traffic5']=window.s_prop5;
	if(window.s_eVar36) {
		hpmmd.search={sitesearch:{keyword:window.s_prop6||window.s_eVar36,type:window.s_eVar37||"unknown"}}; // Use prop36: need to re-map in CMA file
	}
	hpmmd.page.download_types="cab,drv,efi,frm,hqx,exe,zip,wav,mp3,mov,mpg,avi,doc,pdf,xls,dot,pot,ppt,wmv,tar";
}
	
cesBridgeFunction(hpmmd);

try{(function(){var base=('http:/'+'/ww'+'w.h'+'p.com/cma/ng/lib/hpanalytics_common.js').replace('.js',''),
		cspronames='www.hp.com|welcome.hp.com|www8.hp.com|h\\d+\\.www\\d\\.hp\\.com|atlanta.hp.com',
		csitgnames='g4t05...\\.houston\\.hp\\.com|itg\\.houston\\.hp\\.com';
(function(b,c,d,e){function doWrite(a){a=(_ssl&&a.indexOf('https')==-1?a.split('http').join('https'):a);document.write('<sc'+'ript language=\'JavaScript\' type=\'text/javascript\' src=\''+a+'\' xml:space=\'preserve\'></sc'+'ript>')}if(e!=null){doWrite(b+e);return}var f=window.location,a=f.hostname,href=f.href,_ssl=(f.protocol.toLowerCase().indexOf('https')!=-1),rpro=/[\?\&\#]hpanalyticspro=([^\&\?]*)/,respro=rpro.exec(href),rdev=/[\?\&\#]hpanalyticsdev=([^\&\?]*)/,resdev=rdev.exec(href),ritg=/[\?\&\#]hpanalyticsitg=([^\&\?]*)/,resitg=ritg.exec(href),target='_dev.js',t=c.split('|'),i,u=d.split('|'),pro=false,itg=false;for(i=t.length-1;i>=0;i=i-1){if(a.indexOf(t[i])!=-1||a.search(new RegExp(t[i]))!=-1){pro=true;break}}for(i=u.length-1;i>=0;i=i-1){if(a.indexOf(t[i])!=-1||a.search(new RegExp(u[i]))!=-1){itg=true;break}}if(pro){target='.js'}else if(itg){target='_itg.js'}if(resdev){arg=resdev[1].substring(0,4);target='_dev'+(arg.length>0?'_'+arg:'')+'.js'}if(resitg){arg=resitg[1].substring(0,4);target='_itg'+(arg.length>0?'_'+arg:'')+'.js'}if(respro){arg=respro[1].substring(0,4);target='.js'}window._hpenvref=e=target;doWrite(b+e)})(base,cspronames,csitgnames,window._hpenvref);
})()}catch(err){};
	
function trackcustomlinksOverride(utilityLabel, utilityValue, sourceData) {
	  
	  /* Define default values */
	  var linkType = 'o';
	  var linkTrackVarList = "";
	  var eventList = "";
	  var cl=(hpmmd.page.country||"us") + "/" + (hpmmd.page.language||"en");
	  var lprop1;
	  var eVar30Equivalent;
	  
	  if (!utilityLabel)
	    utilityLabel = "Diag";
	  
	    
	  if (utilityLabel.match("search:")) { 
	    // ISSUE: var searchEvents="event21";
	    // ISSUE: s.prop27 = utilityLabel;
	    s.prop4 = "7T";
	    // ISSUE: s.prop7 = "us";
	    // ISSUE: s.prop8 = "en";
	  }  
	    
	  if (utilityLabel.match("CountryOL:")) { 
	    utilityLabel = utilityLabel + " | "+cl+" | product";
	  }  
	
	  if (utilityLabel == "weResult:") {
	    utilityLabel = utilityLabel + " | " + utilityValue;
	  }  
	  // stripEvents(s);		
	  if (utilityLabel.match("L3survey:submit")) { 
	    s_linkTrackVars = "prop1";
	    lprop1 = utilityValue;
	    // s_sendCustomLinkEvent('',utilityLabel);
	    window.s_prop1=lprop1;
	    setupCSMapping();
	    trackMetrics("cesSupportLink",{name:utilityLabel,type:"link"});
	    return;    
	  }  
	    
	  if (utilityLabel == "Standard") {
	    // APPROVED: CYNDI: s.eVar29 = "dl:STD:" + utilityValue
	    // linkType = 'd';
	    setupCSMapping();
	  	trackMetrics("cesSupportLink",{name:utilityLabel,type:"download",utility_value:"dl:STD:" + utilityValue});
	  	return;
	
	    /* ISSUE: if (eventList == null || eventList == "") {
	      eventList = "event7";
	    }
	    else {
	      eventList = eventList + ",event7";
	    } */
	    
	    /* ISSUE: if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar29";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar29";
	    } */
	  }
	
	  if (utilityLabel == "alert") {
	    eVar30Equivalent = "alerts:" + utilityValue;
	    /* if (eventList == null || eventList == "") {
	      eventList = "scAdd";
	    }
	    else {
	      eventList = eventList + ",scAdd";
	    } */
	
	    /* if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar30";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar30";
	    } */
	  } 
	
	  if (utilityLabel == "topic") {
	    eVar30Equivalent = "topics:" + utilityValue;
	    /* if (eventList == null || eventList == "") {
	      eventList = "scAdd";
	    }
	    else {
	      eventList = eventList + ",scAdd";
	    }
	
	    if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar30";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar30";
	    } */
	  } 
	
	  if (utilityLabel == "faq") {
	    eVar30Equivalent ="faqs:" + utilityValue;
	    /* if (eventList == null || eventList == "") {
	      eventList = "scAdd";
	    }
	    else {
	      eventList = eventList + ",scAdd";
	    }
	
	    if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar30";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar30";
	    } */
	  } 
	
	  if (utilityLabel == "discuss") {
	    eVar30Equivalent = "forums:" + utilityValue;
	    /* if (eventList == null || eventList == "") {
	      eventList = "scAdd";
	    }
	    else {
	      eventList = eventList + ",scAdd";
	    }
	
	    if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar30";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar30";
	    } */
	  } 
	
	  if (utilityLabel == "tosn") {
	
	    if (utilityValue == "solve") {
	      eVar30Equivalent = "tosn::solve a problem";
	      /* if (eventList == null || eventList == "") {
	        eventList = "scAdd";
	      }
	      else {
	        eventList = eventList + ",scAdd";
	      } */
	    }
	      
	    if (utilityValue == "setup") {
	      eVar30Equivalent = "tosn::getting started";
	      /* if (eventList == null || eventList == "") {
	        eventList = "scAdd";
	      }
	      else {
	        eventList = eventList + ",scAdd";
	      } */
	    }
	    
	    if (utilityValue == "prodinfo") {
	      eVar30Equivalent = "tosn::product information";
	      /* if (eventList == null || eventList == "") {
	        eventList = "scAdd";
	      }
	      else {
	        eventList = eventList + ",scAdd";
	      } */
	    }
	    
	    if (utilityValue == "use") {
	      eVar30Equivalent = "tosn::how to";
	      /* if (eventList == null || eventList == "") {
	        eventList = "scAdd";
	      }
	      else {
	        eventList = eventList + ",scAdd";
	      } */
	    }
	  
	   /*  if (linkTrackVarList == null || linkTrackVarList == "") {
	      linkTrackVarList = "eVar30";
	    }
	    else {
	      linkTrackVarList = linkTrackVarList + ",eVar30";
	    } */
	    
	  } /* End of tosn */
	  
	  
	 if (utilityLabel == "solveCategory") {
	      eVar30Equivalent = "tosn::solve a problem:" +utilityValue;
	
	      /* if (linkTrackVarList == null || linkTrackVarList == "") {
	        linkTrackVarList = "eVar30";
	      }
	      else {
	        linkTrackVarList = linkTrackVarList + ",eVar30";
	      }  */
	  }
	  
	  if (utilityLabel == "setupCategory") {
	      eVar30Equivalent = "tosn::getting started:" +utilityValue;
	
	      /* if (linkTrackVarList == null || linkTrackVarList == "") {
	        linkTrackVarList = "eVar30";
	      }
	      else {
	        linkTrackVarList = linkTrackVarList + ",eVar30";
	      } */
	  }
	  
	  if (utilityLabel == "useCategory") {
	      eVar30Equivalent = "tosn::how to:" +utilityValue;
	
	      /* if (linkTrackVarList == null || linkTrackVarList == "") {
	        linkTrackVarList = "eVar30";
	      }
	      else {
	        linkTrackVarList = linkTrackVarList + ",eVar30";
	      } */
	  }
	  
	  if (utilityLabel == "prodinfoCategory") {
	      eVar30Equivalent = "tosn::product information:" +utilityValue;
	
	      /* if (linkTrackVarList == null || linkTrackVarList == "") {
	        linkTrackVarList = "eVar30";
	      }
	      else {
	        linkTrackVarList = linkTrackVarList + ",eVar30";
	      } */
	  }
	  
	  if (!utilityValue)
	    utilityValue = "checkindex"; 
	
	  /* s.events = eventList;
	
	  if ( searchEvents )
	    s.events = s.events  + ", " + searchEvents; */
	
	  /* ISSUE: s.products = "HP Deskjet 960c Printer"; */
	 
	  /* Define some variables needed by Omniture. */
	  setupCSMapping();
	  trackMetrics("cesSupportLink",{name:utilityLabel,type:"link", utility_value_2:eVar30Equivalent});
	  
	  /* s.linkTrackVars = linkTrackVarList + "events";
	  s.linkTrackEvents = eventList;
	  s.tl(this, linkType, utilityLabel);	 */
}

function cesBridgeFunction(md) {
	md.page["name"]=(function(p) {return (!p?"PATH|"+location.pathname.replace("/",":"):p.replace(/ces\:/i,"").replace(/\s*\|\s*/,":"));}) (window.s_pageName);
	function getQueryParam(k,u) {var re=new RegExp("\\?.*"+k+"\\=([^\\&]+)","i"),res=re.exec(u||location.href);
		return (!res?null:res[1]);
	}
	function stripEvents(s) {
		if(s.events) { s.events=s.events.replace(/[\,]?(event5|event7)/,"");}
	}
	var s_eVar4=""// Mapped to custom 74
	var tmp_softwareitem="";
	/* var s_linkTrackVars="s_prop1,s_prop25,s_events,s_products,s_prop3,s_prop4,s_prop5,s_prop7,s_prop8,s_prop9,s_eVar1,s_eVar2,s_prop13,eVar29,eVar30,prop27,prop4,prop7,prop8,products,events"; // added additional variables to the list eVar29,eVar30,prop27 - requested by Jason Downing, Laurie Nalani //
	var s_linkTrackEvents="event7,scAdd,event21"; //As per the request from Laurie and John// */

	// Common metrics plugin function - do not remove
	if(window.s_prop5 && (s_prop5.toLowerCase().indexOf('ces:document |') != -1 || s_prop5.toLowerCase().indexOf('softwaredownloadindex')!= -1)) {
		solutionid = getQueryParam("custom_solutionid");
		if(solutionid && solutionid.length>0) {
			if(s_prop5.toLowerCase().indexOf('ces:document |') != -1) {
					md.page["custom73"]=solutionid + "," + s_prop7 + "," + s_prop8 + "," + s_prop5; // Map eVar3 to Custom 73
			}
			else {
				temp_softwareitem = getQueryParam("softwareitem")
				md.page["custom73"] = solutionid + "," + s_prop7 + "," + s_prop8 + "," + s_prop3 + " | " + temp_softwareitem
			}
		}
		md.page.events.push("Article Or Content Consumption"); // Replaces event5
		/* if (window.s_events) {
			s_events+=",event5";
		}
		else {
			s_events="event5";
		}
		//s_events="event5" */
	}
	// once the query string is completely tagged with "tmp_track_link" then you can remove below code which uses jumpid track document//
	var h_jumpid=getQueryParam("jumpid");
	h_jumpid=h_jumpid==null?"":h_jumpid;
	if(h_jumpid && h_jumpid.length>0) {
		jumpid_array = h_jumpid.split("/");
		if (h_jumpid.indexOf("_recdoc") > -1) {	
			md.page["custom74"] = "refdoc:" + jumpid_array[1] + " | recdoc:"+jumpid_array[3]; // Replaces eVar4
			s_prop27= "recdoc:"+jumpid_array[3];			
			// s.eVar19 = "";
			// s.eVar20 = "";
		}
		if (h_jumpid.indexOf("_faqs") > -1) {	
			//s_eVar4 = "refdoc:" + jumpid_array[1] + " | recdoc:"+jumpid_array[3];
			s_prop27= "faqs:top_issues:"+jumpid_array[3];			
			// s.eVar19 = "";
			// s.eVar20 = "";
		}
		
	}
	
	// Recently intead of jumpid as Query string, its change to "tmp_track_link" for tracking documents //

	var h_tmp_track_link=getQueryParam("tmp_track_link");
	h_tmp_track_link=h_tmp_track_link==null?"":h_tmp_track_link;
	if(h_tmp_track_link && h_tmp_track_link.length>0) {
		h_tmp_track_link_array = h_tmp_track_link.split("/");
		if (h_tmp_track_link.indexOf("_recdoc") > -1) {	
			md.page["custom74"] = "refdoc:" + h_tmp_track_link_array[1] + " | recdoc:"+h_tmp_track_link_array[3]; // Replaces eVar4
			s_prop27= "recdoc:"+h_tmp_track_link_array[3];
		}
		if (h_tmp_track_link.indexOf("_faqs") > -1) {	
			//s_eVar4 = "refdoc:" + jumpid_array[1] + " | recdoc:"+jumpid_array[3];
			s_prop27= "faqs:top_issues:"+h_tmp_track_link_array[3];			
		}
		
	}
	if (window.s_pageName && s_pageName.indexOf("contacthp")>-1){
		window.s_prop27 = "ces:contacthp"
	}
	setupCSMapping();
	/* if(jQuery) {
		jQuery(document).ready(
			function() {window.trackcustomlinks=trackcustomlinksOverride;}
		);
	} else {
		window.trackcustomlinks=trackcustomlinksOverride;
	} */
};
function s_sendAnalyticsEvent(addlAccount,pageName) { 		trackMetrics("cesSupportPage",{name:pageName}); }
function s_sendCustomLinkEvent(addlAccount,linkName) { 		trackMetrics("cesSupportLink",{name:linkName,type:"link"}); }
function s_sendDownloadLinkEvent(addlAccount,linkName) { 	trackMetrics("cesSupportLink",{name:linkName,type:"download"}); }
function s_sendExitLinkEvent(addlAccount,linkName) { 		trackMetrics("cesSupportLink",{name:linkName,type:"exit"}); }

