// HP Common Metrics Architecture 20051223a
// BEGIN Clickstream:
var s_hp_optOut = false // WARNING: IF SET TO TRUE, PAGE WILL NOT BE TRACKED

/* These variables are used to capture email ID code  - captures e-mail identy in eVar10 and prop24 */
var s_hp_emid="dimid";
var s_hp_autoemcid="dicid";

// Common Dynamic Account structure - please do not use unless authorized by CKM&A Ops
var s_dynamicAccountSelection=true;
var s_dynamicAccountList="hphqtestaquarius=localhost,aquariusitg,aquarius-netdev,ckwww,devaa,ejwww,h25460,h25461,h25459,h25458,qcaaa,qcbaa,srdev,vaadev01,ztxaacs,ztxaaws,cpqcorp.net,pro-aq-sama"
var s_dynamicAccountMatch=window.location.hostname

var s_trackDownloadLinks=true
var s_trackExternalLinks=true
var s_trackInlineStats=true
var s_linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,doc,pdf,xls,cgi,dot,pot,ppt,wmv,asx"
var s_linkInternalFilters="hp,compaq,cpqcorp,javascript:"
var s_linkLeaveQueryString=true
if (!(window.s_account)){
	var s_account="hphqglobal";
	if (window.document.getElementsByName('hpo')[0]){
		s_account=s_account+","+document.getElementsByName('hpo')[0].value;
	}
}
else { /* NonStop computing report suite fix: MJW 20051012a*/
	if(s_account.indexOf("hphqwwnonstop") != -1 || s_account.indexOf("hphqenterprisesolutions") != -1) {
		if(s_account.indexOf("hphqwwesg") == -1) {s_account=s_account + ",hphqwwesg";}
		s_account=s_hp_sr(s_account,",hphqbcs","");
	}
}

var h_url = window.location.href.toLowerCase();
var h_urlPath = window.location.pathname.substring(1);
//var h_enableFlag = true;

// Folder lists to exclude certain action when these folder are listed in URL //
var h_excludeCookieFolderList = "/hpsub,/PublicSector,/hho,/smb-ap"; 
var h_excludeSurveyFolderList = "/hpsub,/PublicSector,/hho,/smb-ap,/campaigns,/contact-hp"
var h_excludeFolderList = "/hpsub,/PublicSector,/hho,/smb-ap,/cache"; // exclude auto population of pageName, prop18 & prop19 for these folder lists//

/*
var h_excludeFolderList = h_excludeFolderList.split(',');
for (i=0; i<h_excludeFolderList.length; i++) {
	exfolName = h_excludeFolderList[i].toLowerCase();
	if (h_url.indexOf(exfolName) > -1) { h_enableFlag = false; break;}
}
*/
//var messagingStr = /\/enterprise\/\D{2}\/\D{2}\/messaging/i;
//var eventStr = /\/enterprise\/\D{2}\/\D{2}\/events/i;
//if ((messagingStr.test(h_url)) || (eventStr.test(h_url)) ){ h_enableFlag = false;}

// end of flag setting code//

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1].replace("%20", " ");
    }
  } 
}

// Changes requested by Richard //
	if ((window.s_pageName && s_pageName.indexOf("HPS|") == 0) && (s_pageName.indexOf("Vista") > 0)) 
	{
			if (window.s_pageName){ s_pageName = s_pageName.replace("HPS|", "Vista|"); }
			if (window.s_prop18){ s_prop18 = s_prop18.replace("hp services", "Vista");}
			if (window.s_prop19){ s_prop19 = s_prop19.replace("hp services", "Vista");}
			s_account="hphqglobal"
	}

s_hp_fixMercury();
function s_hp_fixMercury() {  
	if (getQueryVariable("rd")=="mercury") {
		s_pageName=s_pageName+"|rd=mercury"
	}
	if (window.s_prop19 && s_prop19.indexOf("ENT|MS|")== 0) { 
		s_pageName = s_pageName.replace("ENT|", "MS|");
		s_prop18 = "ENT: MS|";
		s_prop19 = s_prop19.replace("ENT|MS|", "ENT: MS|");
	}
}

/* Flash functions */

function s_sendAnalyticsEventFlashScreen(addlAccount,analyticsEventName) {
	if(window.s_prop7 && window.s_prop8){ var c_l = s_prop7+"|"+s_prop8+"|";}
	else { var c_l="null|null|";}
	analyticsEventName=c_l+analyticsEventName;
	s_sendAnalyticsEvent(addlAccount,analyticsEventName);
}

function s_sendCustomLinkEventFlashScreen(addlAccount,analyticsLinkName) {
	if(window.s_prop7 && window.s_prop8) { var c_l = s_prop7 + "|" + s_prop8+"|";}
	else {var c_l="null|null|";}
	analyticsLinkName=c_l+analyticsLinkName;
	s_sendCustomLinkEvent(addlAccount,analyticsLinkName);
}

/* End of Flash functions */

function s_hp_doPostMetaTagFunction() {
	/* to Automate s_pageName,prop18,prop19,s_account value population for the new URL Structure excluding h_excludeFolderList, Requested by Spellman, David A. */	
	if (!s_hp_checkIfFolderExists(h_excludeFolderList)) {
		if (window.s_prop7) {s_hp_setRegionVariables (window.s_prop7)}
		
		// excludeFlag should be defined as true or false depending on exclude folder list.
		// wirte a wrapper function to identify as exlcude folder list.
		// chedck with rich to get the inclusion file.

		h_url_Array = h_url.split('/');
		h_urlPath_Array = h_urlPath.split('.');
		var folder1 = h_url_Array[3];
		var folder4 = h_url_Array[6];
		var folder5 = h_url_Array[7];
		if (folder4==null) {folder4="";}
		if (folder5==null) {folder5="";}
		var folder5_array = folder5.split("-");
		window.s_pageName = h_urlPath_Array[0];
		window.s_prop18= "ENT: "+folder1 + "|"+ folder4;
		window.s_prop19= window.s_prop18 + "|"+ folder5_array[0];
	}
	/* end of auto population code*/
	// include survey files if exclude folder list does not have in the URL and region is defined//
	if (window.s_hp_region) {
		if (!s_hp_checkIfFolderExists(h_excludeSurveyFolderList)){	
			s_hp_includeSurveyFiles (window.s_hp_region);
		}
	}

	//This part of code adds region level cma files//
	if(window.s_account && s_account.indexOf("hphqap") != -1) {
	s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/region/ap/apcma.js");
	} 
	if(window.s_account && s_account.indexOf("hphqemea") != -1) {
		s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/region/emea/emeacma.js");
	}
	if(window.s_account && s_account.indexOf("hphqna") != -1) {
		s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/region/na/nacma.js");
	}
	if(window.s_account && s_account.indexOf("hphqla") != -1) {
		s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/region/la/lacma.js");
	}
	// end of region level cma files addition code //
} // end of s_hp_doPostMetaTagFunction

// Common metrics plugin function - do not remove
function s_hp_doMetricsPlugins() { 
	// This part of code segments site sections depending on the page name varialbe if the s_account varialbe has hphqhhomktg//
	if (window.s_account && s_account.indexOf("hphqhhomktg")>-1)
	{
		var url = window.location.toString();
		// Do define the Site Section categories depending on pageName and URL strings //
		if (window.s_pageName && s_pageName.indexOf("CES:ac")>-1 || url.indexOf("activitycenter")>-1) {
			s_channel = "Activity Center" ;
		}
		if (window.s_pageName && s_pageName.indexOf("hho|DE")>-1) {
			s_channel = "Digital Entertainment" ;	
		}
		if ((window.s_pageName && s_pageName.toLowerCase().indexOf("hho|dpc") > -1) || url.indexOf("consumer/digital_photography")>-1) {
			s_channel = "Digital Photography" ;	
		}
		if (window.s_pageName && s_pageName.indexOf("hho|EC")>-1) {
			s_channel = "Everyday Computing" ;
		}
		if (window.s_pageName && s_pageName.indexOf("hho|EP")>-1) {
			s_channel = "Everyday Printing" ;	
		}
		if (window.s_pageName && s_pageName.indexOf("HP Online classes")>-1) {
			s_channel = "Online classes" ;	
		}
		if (window.s_pageName && s_pageName.indexOf("hho|DC")>-1 || url.indexOf("/cpc/hp/")>-1) {
			s_channel = "PC Discovery Center" ;	
		}
		if (window.s_pageName && s_pageName.indexOf("hho|RPS")>-1) {
			s_channel = "Retail Photo Solutions" ;	
		}
		if (url.indexOf("consumer/digital_photography/free/software")>-1 || url.indexOf("states/pse")>-1 || url.indexOf("states/ize")>-1 ) {
			s_channel = "Photosmart essentials" ;	
		}
	}
	// end of site section segmentation code//
} // end function ()

if(window.s_prop18 && s_prop18.length>0) { s_prop18=s_hp_sr(s_hp_sr(s_prop18,"| ","|")," |","|");}
if(window.s_prop19 && s_prop19.length>0) { s_prop19=s_hp_sr(s_hp_sr(s_prop19,"| ","|")," |","|");}
if(window.s_prop20 && s_prop20.length>0) { s_prop20=s_hp_sr(s_hp_sr(s_prop20,"| ","|")," |","|");}
if(window.s_prop21 && s_prop21.length>0) { s_prop21=s_hp_sr(s_hp_sr(s_prop21,"| ","|")," |","|");}
function s_hp_sr(inval,a,b) {
	if(inval && inval.length>0) { inval=inval.split(a).join(b); }
	return inval;
}

/*** DO NOT MODIFY THIS SECTION ***/
/* Under no circumstances should you modify this code */

// Added to facilitate region-level survey service
var s_hp_region;
if(window.s_prop7 && s_prop7.toLowerCase().indexOf("us") != -1) {
	s_hp_region = "na";
}
if (!s_hp_checkIfFolderExists(h_excludeCookieFolderList)){
	s_hp_includeJavaScriptFile("h71028.www7.hp.com","/enterprise/js/hp_segment_cookie.js"); // File which sets the LEB cookie to segment //
}

s_hp_includeJavaScriptFile("h71028.www7.hp.com","/enterprise/js/getdocument_cc_lc.js"); // Inclusion requested by Rich //
s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/metrics/sc/s_code_remote.js");

function s_hp_includeJavaScriptFile(hp_hostname,hp_path) {
	if(!(window.s_hp_optOut && window.s_hp_optOut == true)) {
		var hp_ssl=(window.location.protocol.toLowerCase().indexOf('https')!=-1)
		if(hp_hostname && hp_hostname.length>0) {
			if(hp_ssl == true && hp_hostname.toLowerCase().indexOf("welcome.") != -1) { hp_hostname = "secure.hp-ww.com"; }
			var fullURL = "http" + (hp_ssl?"s":"") + "://" + hp_hostname + hp_path
		}
		else
			var fullURL=hp_path;
		document.write("<sc" + "ript language=\"JavaScript\" src=\""+fullURL+"\"></sc" + "ript>");
	}
}
// END Clickstream:
if(window.s_account && s_account.indexOf("hphqemea") != -1) {
	s_hp_includeJavaScriptFile("welcome.hp-ww.com","/cma/region/emea/aquariuspub/script_publish.js");
}

function s_hp_setRegionVariables(countryCode) {
	switch(countryCode.toLowerCase()) {
		case "ca":
			s_hp_region = "na";
			if (s_account.toLowerCase().indexOf("hphqna")== -1) s_account += ",hphqna";
			if (s_account.toLowerCase().indexOf("hphqnaca")== -1) s_account += ",hphqnaca";
			if (s_account.toLowerCase().indexOf("hphqnaentmktg")== -1 && s_account.toLowerCase().indexOf("hphqwwfinserv")== -1) s_account += ",hphqnaentmktg";
			break;
		case "us":
			s_hp_region = "na";
			if (s_account.toLowerCase().indexOf("hphqna")== -1) s_account += ",hphqna";
			if (s_account.toLowerCase().indexOf("hphqnaentmktg")== -1 && s_account.toLowerCase().indexOf("hphqwwfinserv")== -1) s_account += ",hphqnaentmktg";
			break;
		case "kr":
		case "cn":
		case "jp":
		case "tw":
		case "au":
		case "hk":
		case "sg":
		case "in":
		case "th":
		case "nz":
		case "my":
		case "ph":
		case "vn":
		case "id":
			s_hp_region = "ap";
			s_hp_countryRS = "hphqap"+countryCode;
			if (s_account.toLowerCase().indexOf("hphqap")== -1) s_account += ",hphqap";
			if (s_account.toLowerCase().indexOf("hphqapenterprise")== -1 && s_account.toLowerCase().indexOf("hphqwwfinserv")== -1) s_account += ",hphqapenterprise";
			if (s_account.toLowerCase().indexOf(s_hp_countryRS)== -1) s_account += ","+s_hp_countryRS;
			break;
		case "de": 
		case "fr": 
		case "es": 
		case "uk": 
		case "nl": 
		case "it": 
		case "pl": 
		case "se": 
		case "be": 
		case "dk": 
		case "ch": 
		case "pt": 
		case "ru": 
		case "no": 
		case "at": 
		case "fi": 
		case "cz": 
		case "tr": 
		case "hu": 
		case "il": 
		case "gr": 
		case "za": 
		case "ie": 
		case "sk": 
		case "ro": 
		case "ua": 
		case "gb": 
		case "sa":
		case "by":
		case "emea_africa":
		case "emea_middle_east":
			s_hp_region = "emea";
			s_hp_countryRS = "hphqemea"+countryCode;
			if (s_account.toLowerCase().indexOf("hphqemea")== -1) s_account += ",hphqemea";
			if (s_account.toLowerCase().indexOf(s_hp_countryRS)== -1) s_account += ","+s_hp_countryRS;
			break;
		case "lamerica_nsc_carib":
		case "lamerica_nsc_cnt_amer":
		case "br":  
		case "mx": 
		case "ar": 
		case "co": 
		case "cl": 
		case "ve": 
		case "pe": 
		case "pr": 
		case "ec": 
		case "ns": 
		case "bo": 
		case "uy": 
		case "sv": 
		case "py": 
		case "hn":
			s_hp_region = "la";
			s_hp_countryRS = "hphqla"+countryCode;
			if (s_account.toLowerCase().indexOf("hphqla")== -1) s_account += ",hphqla";
			if (s_account.toLowerCase().indexOf(s_hp_countryRS)== -1) s_account += ","+s_hp_countryRS;
			break;
		default:
	}
	window.s_account = s_account;
}

function s_hp_includeSurveyFiles(region) {
	switch(region.toLowerCase()) {
		case "na":
		case "w1":
			s_hp_includeJavaScriptFile("h18030.www1.hp.com","/survey/source/na_enterprise.js");	
			break;
		case "emea":
			s_hp_includeJavaScriptFile("h18030.www1.hp.com","/survey/source/emea_enterprise.js");	
			break;
		case "ap":
			s_hp_includeJavaScriptFile("h18030.www1.hp.com","/survey/source/ap_enterprise.js");	
			break;
		case "la":
			s_hp_includeJavaScriptFile("h18030.www1.hp.com","/survey/source/la_enterprise.js");	
			break;
		default:
	}
}

// This functino check if the commma seperated folder list sent exists in the URL or Not, true if its exists and false if its not //
function s_hp_checkIfFolderExists(folderList) {
	var h_folderListArray = folderList.split(',');
	for (var i=0; i<h_folderListArray.length; i++) {
		var exfolName = h_folderListArray[i].toLowerCase();
		if (h_url.indexOf(exfolName) > -1) { return true;}
	}
	return false;
}