/* $Header: //depot/DocRoot/js/kr_hbx.js#29 $
 * This javascript sets hitbox variables needed to track 
 * site usage. 
 */

var _hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;}
var hbx=_hbEvent("pv");hbx.vpc="HBX0103u";hbx.gn="ehg-knightridder.hitbox.com";

//KRD: Page Name and Content Category
var _hbxArticleID = getHbxArticleID(document.location.pathname);
var _hbxPN = stripHbxSpChar(document.title); 

//KRD: Custom Metric
if (_hbxArticleID != "")
	_hbxPN = _hbxArticleID;

//BEGIN EDITABLE SECTION
//CONFIGURATION VARIABLES
initHbxAccounts();
hbx.acct=getHbxAccount(hbx_site)+';'+getHbxAccount('krd_global_rollup'); // hbx_site is set in JSP
hbx.pn= _hbxPN + "; ";//PAGE NAME(S)
hbx.mlc= getHbxMLC(document.location.pathname);
hbx.pndef="title";//DEFAULT PAGE NAME
hbx.ctdef="full";//DEFAULT CONTENT CATEGORY

//OPTIONAL PAGE VARIABLES
//ACTION SETTINGS
hbx.fv="";//FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
hbx.lt="auto";//LINK TRACKING
hbx.dlf="n";//DOWNLOAD FILTER
hbx.dft="n";//DOWNLOAD FILE NAMING
hbx.elf="n";//EXIT LINK FILTER

//SEGMENTS AND FUNNELS
hbx.seg="";//VISITOR SEGMENTATION
hbx.fnl="";//FUNNELS

//CAMPAIGNS
hbx.cmp="";//CAMPAIGN ID
hbx.cmpn="";//CAMPAIGN ID IN QUERY
hbx.dcmp="";//DYNAMIC CAMPAIGN ID
hbx.dcmpn="";//DYNAMIC CAMPAIGN ID IN QUERY
hbx.dcmpe="";//DYNAMIC CAMPAIGN EXPIRATION
hbx.dcmpre="";//DYNAMIC CAMPAIGN RESPONSE EXPIRATION
hbx.hra="";//RESPONSE ATTRIBUTE
hbx.hqsr="";//RESPONSE ATTRIBUTE IN REFERRAL QUERY
hbx.hqsp="";//RESPONSE ATTRIBUTE IN QUERY
hbx.hlt="";//LEAD TRACKING
hbx.hla="";//LEAD ATTRIBUTE
hbx.gp="";//CAMPAIGN GOAL
hbx.gpn="";//CAMPAIGN GOAL IN QUERY
hbx.hcn="";//CONVERSION ATTRIBUTE
hbx.hcv="";//CONVERSION VALUE
hbx.cp="null";//LEGACY CAMPAIGN
hbx.cpd="";//CAMPAIGN DOMAIN

//CUSTOM VARIABLES
hbx.ci="";//CUSTOMER ID

if (_hbxArticleID != "")
	hbx.hc1= 'Article|' + _hbxArticleID;//CUSTOM 1
else hbx.hc1 = '';

hbx.hc2="";//CUSTOM 2
hbx.hc3="";//CUSTOM 3
hbx.hc4="";//CUSTOM 4
hbx.hrf="";//CUSTOM REFERRER
hbx.pec="";//ERROR CODES

//INSERT CUSTOM EVENTS
if (isMoreNews()) {
 hbx.hc1= 'More+News|' + getParamValue("category_id");
} 
else if (isATE()) {
  hbx.hc1= 'Ask+The+Expert' + getForumParam(); 
} 
else if (isQAForum()) {
  hbx.hc1= 'QA+Forum' + getForumParam(); 
} 
else if ( isEntertainmentUrl(document.location) ) {
  mldPath = '/mld/' + kr_hbx_aeSite + '/entertainment/';
  if (kr_hbx_aePath != '') mldPath = mldPath + kr_hbx_aePath + '/';
  hbx.mlc = getHbxMLC(mldPath); 
  
  //if ae site, set a variable indicating so
  if (document.domain.indexOf('ae.') == 0) hbx.hc1 = hbx.hc1.replace('Article|', 'ae|');
}
else if (isSearch()) {

  hbx.hc1 = hbx.hc1.replace('Article|', 'Search|');
  var ev1 = new _hbEvent("search");
  
  //the string that the user searched for
  ev1.keywords=getParamValue("query"); // required

  //put in the nth result the user is viewing
  if (gotHits())
    ev1.results= getParamValue("pageStart");
  else
    ev1.results=0;
  
  //kind of search - article or web?
  ev1.attr1=getParamValue ("searchSelect"); 
  
  //for web search page size is always 10 and pageStart is page number, not nth result
  if (ev1.attr1.indexOf("article") > -1) {    
    ev1.attr2=getHitCount(); //set number of hits    
    ev1.attr3=getParamValue ("pageSize"); //set page size
  } else { 
    //else web based search
    ev1.attr2=0; //set number of hits
    ev1.attr3=10; //set page size
    //if pageStart is 2, we are on result number 11 {((2-1) * 10 ) + 1}
    ev1.results = ((ev1.results - 1) * 10) + 1; 
  }
  ev1.attr4=""; // optional
} 


