// This is a wrapper for WebSide Story.

// usage per page: 
//   * Include this wrapper
//   * Call WSS.Setup({<option> : <value>})
//   * Include hbx.js.

WSS = {};               // Global object for WebSideStory stuff

WSS.hbx_page = 'default_hbx';

WSS.default_hbx = {
    vpc:    "HBX0200u",                // Code version
    acct:   "DM570127OJRR93EN3",       // Account number(s)
    pn:     "PUT+PAGE+NAME+HERE",      // Page name(s)
    mlc:    "CONTENT+CATEGORY",        // Multi-level content category
    pndef:  "title",                   // Default page name
    ctdef:  "full",                    // Default content category
                                          
    // Optional Page variables
    // Action settings
    fv:     "",                        // Form validation minimum elements or submit function name
    lt:     "auto",                    // Link tracking
    dlf:    "n",                       // Download filter
    dft:    "n",                       // Download file naming
    elf:    "n",                       // Exit link filter
                                           
    // Segments and Funnels
    seg:    "",                        // Visitor segmentation
    fnl:    "",                        // Funnels
                                          
    // Campaigns
    cmp:    "",                        // Campaign id
    cmpn:   "",                        // Campaign id in query
    dcmp:   "",                        // Dynamic campaign id
    dcmpn:  "",                        // Dynamic campaign id in query
    dcmpe:  "",                        // Dynamic campaign expiration
    dcmpre: "",                        // Dynamic campaign response expiration
    hra:    "",                        // Response attribute
    hqsr:   "",                        // Response attribute in referral query
    hqsp:   "",                        // Response attribute in query
    hlt:    "",                        // Lead tracking
    hla:    "",                        // Lead attribute
    gp:     "",                        // Campaign goal
    gpn:    "",                        // Campaign goal in query
    hcn:    "",                        // Conversion attribute
    hcv:    "",                        // Conversion value
    cp:     "null",                    // Legacy campaign  
    cpd:    "",                        // Campaign domain
                                          
    // Custom Variables
    ci:     "",                        // Customer id
    hc1:    "",                        // Custom 1
    hc2:    "",                        // Custom 2
    hc3:    "",                        // Custom 3
    hc4:    "",                        // Custom 4
    hrf:    "",                        // Custom referrer
    pec:    ""                         // Error codes
};

WSS['item-view-tracking'] = {
    vpc   : "HBX0140.01a",          // Code Version
    acct  : "DM570127OJRR93EN3",    //ACCOUNT NUMBER(S)
    pn    : "PUT+PAGE+NAME+HERE",   //PAGE NAME(S)
    mlc   : "CONTENT+CATEGORY",     //MULTI-LEVEL CONTENT CATEGORY
    pndef : "title",                //DEFAULT PAGE NAME
    ctdef : "full",                 //DEFAULT CONTENT CATEGORY
    
    //OPTIONAL PAGE VARIABLES
    //ACTION SETTINGS
    fv  : "",           //FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
    lt  : "none",       //LINK TRACKING
    dlf : "n",          //DOWNLOAD FILTER
    dft : "n",          //DOWNLOAD FILE NAMING
    elf : "n",          //EXIT LINK FILTER
    
    //SEGMENTS AND FUNNELS
    seg : "",           //VISITOR SEGMENTATION
    fnl : "",           //FUNNELS
    
    //CAMPAIGNS
    cmp   : "", //CAMPAIGN ID
    cmpn  : "", //CAMPAIGN ID IN QUERY
    dcmp  : "", //DYNAMIC CAMPAIGN ID
    dcmpn : "", //DYNAMIC CAMPAIGN ID IN QUERY
    hra   : "", //RESPONSE ATTRIBUTE
    hqsr  : "", //RESPONSE ATTRIBUTE IN REFERRAL QUERY
    hqsp  : "", //RESPONSE ATTRIBUTE IN QUERY
    hlt   : "", //LEAD TRACKING
    hla   : "", //LEAD ATTRIBUTE
    gp    : "", //CAMPAIGN GOAL
    gpn   : "", //CAMPAIGN GOAL IN QUERY
    hcn   : "", //CONVERSION ATTRIBUTE
    hcv   : "", //CONVERSION VALUE
    
    //CUSTOM VARIABLES
    hc1 : "", //CUSTOM 1
    hc2 : "", //CUSTOM 2
    hc3 : "", //CUSTOM 3
    hc4 : "", //CUSTOM 4
    hrf : "", //CUSTOM REFERRER
    pec : "", //ERROR CODES
    
    //COMMERCE VARIABLES
    cacct : "975701318733", 
    pr  : "PRODUCT",   //comma delimited products
    bd  : "BRAND", 
    ca  : "CATEGORIES", 
    pc  : "PRICE",     //comma delimited prices
    qn  : "QUANTITY",  //comma delimited quantities
    sr  : "STORE",     //store
    cp  : "null",      //campaign
    cam : "0",         //cart add methodology, 0  :  highwatermark, 1  :  incremental
    pv  : 1            //product view flag, 0  :  cart add, 1  :  product view
}

WSS['order-confirmation'] = {
    vpc   : "HBX0200.01oG",     // Code Version
    eacct : "DM570127OJRR93EN3", //ACCOUNT NUMBER(S)
    pn    : "PUT+PAGE+NAME+HERE", //PAGE NAME(S)
    mlc   : "CONTENT+CATEGORY", //MULTI-LEVEL CONTENT CATEGORY
    pndef : "title", //DEFAULT PAGE NAME
    ctdef : "full", //DEFAULT CONTENT CATEGORY
    
    //SEGMENTS AND FUNNELS
    seg : "", //VISITOR SEGMENTATION
    fnl : "", //FUNNELS
    
    //CAMPAIGNS
    cmp   : "", //CAMPAIGN ID
    cmpn  : "", //CAMPAIGN ID IN QUERY
    dcmp  : "", //DYNAMIC CAMPAIGN ID
    dcmpn : "", //DYNAMIC CAMPAIGN ID IN QUERY
    hra   : "", //RESPONSE ATTRIBUTE
    hqsr  : "", //RESPONSE ATTRIBUTE IN REFERRAL QUERY
    hqsp  : "", //RESPONSE ATTRIBUTE IN QUERY
    hlt   : "", //LEAD TRACKING
    hla   : "", //LEAD ATTRIBUTE
    gp    : "", //CAMPAIGN GOAL
    gpn   : "", //CAMPAIGN GOAL IN QUERY
    hcn   : "", //CONVERSION ATTRIBUTE
    hcv   : "", //CONVERSION VALUE
    cp    : "null", //LEGACY CAMPAIGN
    
    //CUSTOM VARIABLES
    ci  : "", //CUSTOMER ID
    hc1 : "", //CUSTOM 1
    hc2 : "", //CUSTOM 2
    hc3 : "", //CUSTOM 3
    hc4 : "", //CUSTOM 4
    pec : "", //ERROR CODES
    
    //COMMERCE VARIABLES
    cacct : "975701318733", 
    pr : "PRODUCT",   //comma delimited products
    bd : "BRAND", 
    ca : "CATEGORIES", 
    pc : "PRICE",     //comma delimited prices
    qn : "QUANTITY",  //comma delimited quantities
    st : "SHIP+TYPE",  //shipping type
    sp : "SHIP+COST",  //shipping cost (total)
    sr : "STORE",     //store
    oi : "ORDER+ID",   //order id
    sy : "CITY",       //shipping city
    sa : "STATE",      //shipping state
    sz : "ZIP",    	   //shipping zip code
    so : "COUNTRY",    //shipping country
    pt : "PAYMENT+TYPE", 	//payment type
    sk : "SKU",        //comma-delimited sku
    cu : "CUSTOMER+TYPE",  //customer type
    ds : "DISCOUNT",   //discount
    po : "PROMOTION",  //promotion
    c1 : "CUSTOM+ONE", //custom one
    c2 : "CUSTOM+TWO"  //custom two
    
}

WSS['add-to-cart'] = {
    vpc   : "HBX0140.01a",  // Code version
    acct  : "DM570127OJRR93EN3", //ACCOUNT NUMBER(S)
    pn    : "PUT+PAGE+NAME+HERE", //PAGE NAME(S)
    mlc   : "CONTENT+CATEGORY", //MULTI-LEVEL CONTENT CATEGORY
    pndef : "title", //DEFAULT PAGE NAME
    ctdef : "full", //DEFAULT CONTENT CATEGORY
    
    //OPTIONAL PAGE VARIABLES
    //ACTION SETTINGS
    fv  : "", //FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
    lt  : "none", //LINK TRACKING
    dlf : "n", //DOWNLOAD FILTER
    dft : "n", //DOWNLOAD FILE NAMING
    elf : "n", //EXIT LINK FILTER
    
    //SEGMENTS AND FUNNELS
    seg : "", //VISITOR SEGMENTATION
    fnl : "", //FUNNELS
    
    //CAMPAIGNS
    cmp   : "", //CAMPAIGN ID
    cmpn  : "", //CAMPAIGN ID IN QUERY
    dcmp  : "", //DYNAMIC CAMPAIGN ID
    dcmpn : "", //DYNAMIC CAMPAIGN ID IN QUERY
    hra   : "", //RESPONSE ATTRIBUTE
    hqsr  : "", //RESPONSE ATTRIBUTE IN REFERRAL QUERY
    hqsp  : "", //RESPONSE ATTRIBUTE IN QUERY
    hlt   : "", //LEAD TRACKING
    hla   : "", //LEAD ATTRIBUTE
    gp    : "", //CAMPAIGN GOAL
    gpn   : "", //CAMPAIGN GOAL IN QUERY
    hcn   : "", //CONVERSION ATTRIBUTE
    hcv   : "", //CONVERSION VALUE
    
    //CUSTOM VARIABLES
    hc1 : "", //CUSTOM 1
    hc2 : "", //CUSTOM 2
    hc3 : "", //CUSTOM 3
    hc4 : "", //CUSTOM 4
    hrf : "", //CUSTOM REFERRER
    pec : "", //ERROR CODES
    
    //COMMERCE VARIABLES
    cacct : "975701318733", 
    pr  : "PRODUCT",   //comma delimited products
    bd  : "BRAND", 
    ca  : "CATEGORIES", 
    pc  : "PRICE",     //comma delimited prices
    qn  : "QUANTITY",  //comma delimited quantities
    sr  : "STORE",     //store
    cp  : "null",   //campaign
    cam : "0",   //cart add methodology, 0  :  highwatermark, 1  :  incremental
    pv  : 0    //product view flag, 0  :  cart add, 1  :  product view
}

WSS['checkout'] = {
    vpc   : "HBX0140.01c",  // Code Version
    acct  : "DM570127OJRR93EN3", //ACCOUNT NUMBER(S)
    pn    : "PUT+PAGE+NAME+HERE", //PAGE NAME(S)
    mlc   : "CONTENT+CATEGORY", //MULTI-LEVEL CONTENT CATEGORY
    pndef : "title", //DEFAULT PAGE NAME
    ctdef : "full", //DEFAULT CONTENT CATEGORY
    
    //OPTIONAL PAGE VARIABLES
    //ACTION SETTINGS
    fv  : "", //FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
    lt  : "none", //LINK TRACKING
    dlf : "n", //DOWNLOAD FILTER
    dft : "n", //DOWNLOAD FILE NAMING
    elf : "n", //EXIT LINK FILTER
    
    //SEGMENTS AND FUNNELS
    seg : "", //VISITOR SEGMENTATION
    fnl : "", //FUNNELS
    
    //CAMPAIGNS
    cmp   : "", //CAMPAIGN ID
    cmpn  : "", //CAMPAIGN ID IN QUERY
    dcmp  : "", //DYNAMIC CAMPAIGN ID
    dcmpn : "", //DYNAMIC CAMPAIGN ID IN QUERY
    hra   : "", //RESPONSE ATTRIBUTE
    hqsr  : "", //RESPONSE ATTRIBUTE IN REFERRAL QUERY
    hqsp  : "", //RESPONSE ATTRIBUTE IN QUERY
    hlt   : "", //LEAD TRACKING
    hla   : "", //LEAD ATTRIBUTE
    gp    : "", //CAMPAIGN GOAL
    gpn   : "", //CAMPAIGN GOAL IN QUERY
    hcn   : "", //CONVERSION ATTRIBUTE
    hcv   : "", //CONVERSION VALUE
    
    //CUSTOM VARIABLES
    hc1 : "", //CUSTOM 1
    hc2 : "", //CUSTOM 2
    hc3 : "", //CUSTOM 3
    hc4 : "", //CUSTOM 4
    pec : "", //ERROR CODES
    
    //COMMERCE VARIABLES
    cacct : "975701318733", 
    pr : "PRODUCT",   //comma delimited products
    pc : "PRICE",     //comma delimited prices
    qn : "QUANTITY",  //comma delimited quantities
    st : "SHIP+TYPE",  //shipping type
    sp : "SHIP+COST",  //shipping cost (total)
    sr : "STORE",     //store
    cp : "null"   //campaign
}

    WSS.postInit={};

WSS.postInit['item-view-tracking'] = 'function $ii( a, b,c){ return a.indexOf(b, c?c:0)};function $is(a,b, c){return b>a.length?"":a.substring(b,c!=null?c:a.length)};function $a(v){ return escape(v) }; var _sv=10, _bn=navigator.appName,_mn="we74",_bv=parseInt(navigator.appVersion),__r=".referrer",_rf=$a(eval("document"+__r)),_epg="n&cam="+hbx.cam+"&pv="+(hbx.pv>0?"1":"0&abd_type=cart_add")+"&product="+$a(hbx.pr)+"&quantity="+$a(hbx.qn)+"&brand="+$a(hbx.bd)+"&category="+$a(hbx.ca)+"&price="+$a(hbx.pc)+"&store="+$a((hbx.sr=="S"+"TORE")?1:hbx.sr)+"&tz=PST&aid="+hbx.cacct;if(!$ii(_bn,"Micro"+"soft"))_bn="MSIE";if(_bn=="MSIE"&&_bv==2)_bv=3;function $l(m,l){return m=="/"?m:(($ii(m,"/")?"/":"")+(m.lastIndexOf("/")==l?m.substring(0,l):m))};function $n(a,b){return(a==""||a=="/")?"/":$is(a,hbx.ctdef!="full"?a.lastIndexOf("/",b-2): $ii(a,"/"),b)};function $o(a,b,c){var d=location.pathname,e=$is(d,d.lastIndexOf("/")+1,d.length);if(a&&b==c){return(hbx.pndef=="title"&&document.title!=""&&document.title!=location)?document.title:e?e:hbx.pndef}else{return(b==c)?$n(d,d.lastIndexOf("/")):$l(b,b.length-1)}};function $p(a,b,c,d){return ""+(c>-1?$o(b,$is(a,0,c),d)+";"+$p($is(a,c+1),b,$ii($is(a,c+1),";")):$o(b,a,d))};hbx.mlc=$p( hbx.mlc,0,$ii(hbx.mlc,";"),"CONTENT+CAT"+"EGORY");hbx.pn=$p(hbx.pn,1,$ii(hbx.pn,";"),"PUT+"+"PAGE+NAME+HERE" );';

WSS.postInit['order-confirmation'] = 'function $gp(a){a=$d("protocol");return (a.length>0)?hbx.protocol+"://":(location.protocol=="https:"?"https://":"http://")} function $ii(a,b,c){ return a.indexOf(b,c?c:0)};function $is(a,b,c){return b>a.length? "":a.substring(b,c!=null?c:a.length)};var __r=".referrer",_hS=""+ location.search, _sv=10,_ss=_sc="u", _bn=navigator.appName,_bv=parseInt(navigator.appVersion),_bnN=_bn=="Netscape",_N6=(_bnN&&_bv>4) ,_E5P=(($ii(navigator.userAgent,\'MSIE 5\')>-1)||($ii(navigator.userAgent,\'MSIE\'+ \' 6\')>-1)),__f,_$r="document"+__r+"+\'\'}",_$c="catch(_e)",_tls=""+top.location. search;if(!$ii(_bn,"Microsoft"))_bn="M";if(_bn=="M"&&_bv==2)_bv=3; function $a(v,c){return escape(($d("lc")=="y"&&typeof c!=\'undefined\')?v.toLowerCase():v)} function _vc(m,l){return(m=="/")? m:(( $ii(m,"/")?"/":"")+(m. lastIndexOf("/")==l?$is(m,0,l):m))};function _gf( x){return $is(x,x.lastIndexOf( "/")+1,x.length)};function _wn(n){return(n=="PUT"+"+PAGE+NAME+HERE"||n=="CONTE"+ "NT+C"+"ATEGORY")};function _gd(x,i){return(x==""||x=="/")?"/" :$is(x,( hbx.ctdef!= "full")?x.lastIndexOf("/",i-2):$ii(x,"/"),i)};function _ps(b, p){var l=location. pathname;if(b&&_wn(p)){return( hbx.pndef=="title" && document.title !=""&&document. title!=location)?document.title:_gf(l)?_gf(l):hbx.pndef}else{return(_wn(p)?_gd(l,l.lastIndexOf("/")):_vc(p,p.length-1 ))}};function _pm(m,h,i){return ""+(i>-1?_ps(h,$is(m,0,i))+";"+_pm($is(m,i+1,m.length),h,$ii($is(m,i+1,m.length),";")):_ps(h,m))};hbx.mlc=_pm(hbx.mlc,0,$ii(hbx.mlc,";")); hbx.pn=_pm(hbx.pn,1,$ii(hbx.pn,";"));function $d(v){return(typeof eval("self.hbx."+v)!="undefined")?eval("self.hbx."+v):""};function $f(a,b){return(!$ii(a,"?"+b+"="))?0: $ii(a,"&"+b+"=")};function $g(a,b,c,d){var e=$f(a,b);if(d&&e<0&&top&&self!=top){e=$f(_tls,b);if(e>-1)a=_tls};return(e>-1)?$is(a,e+2+b.length,($ii(a,"&",e+1)>-1)?$ii(a,"&",e+1):a.length):c};function $h(a,b,c){if(!a)a=c;if(_E5P||_N6){eval("try{__f=$g(_hS,\'"+a+"\',\'"+b+"\',1)}"+_$c+"{}")}else{__f=$g(_hS,a,b,1)}return __f};function $i(a,b,c,d){__f=$is(a,$ii(a,"?"));if(b){if(_E5P||_N6){eval( "try{hbx.hra=$g(__f,hbx.hqsr,hbx.hra,0)}"+_$c+"{}")}else{hbx.hra=$g(__f,hbx.hqsr,hbx.hra,0)}};if(c&&!hbx.hra){if(_E5P||_N6){eval("try{hbx.hra=$g(_hS,hbx.hqsp,hbx.hra,1)"+"}"+_$c+"{}")}else{ hbx.hra=$g(_hS,hbx.hqsp,hbx.hra,1)}};if(d&&!hbx.hra)hbx.hra=d;return hbx.hra};hbx.cmp=$h($d("cmpn"),$d("cmp"),"CMP");hbx.gp=$h($d("gpn"),$d("gp"),"GP");hbx.dcmp=$h($d("dcmpn" ), $d( "dcmp"), "DCMP");var _rf=""+eval("document"+__r);if(_E5P||_N6){eval("try{_rf=top."+_$r+_$c+"{_rf="+_$r)}else{if(top.document&&parent.frames.length>1){ _rf=eval("document"+__r)+""}else if(top.document){_rf=eval("top.document"+__r)+""}}if(( _rf=="undefined")||(_rf==""))_rf="bookmark";_hrat=hbx.hra;hbx.hra="";hbx.hra=$i($is(_rf,$ii( _rf,"?")),$d("hqsr"), $d("hqsp"), _hrat); if(document.images)_sv=11;if(window.screen ){ _sv=12; _ss = screen.width+ "*"+screen.height;_sc=document.all?screen.colorDepth:screen.pixelDepth};var _ra=new Array();if(_ra.toSource)_sv=13;if(_bn=="M"&&_ra.shift)_sv=13;_rf=$a(_rf);function _ecr(x,w){_ed=(w=="*")?$ii(x,"*"):x.length; if($ii(x,"CP=")>-1){_be=$ii(x,"CP=")+3}else{return "null"}return($is(x,_be,_ed ))};hbx.cp=_ecr(document.cookie,"*");_dt=(new Date()).getHours();_e2=$gp()+hbx.gn+"/HG?hc="+"none&hb="+hbx.eacct+"&event=true&eid=1&aid="+hbx.cacct+"&tz=PST&customerid="+$a(hbx.ci)+"&orderid="+ $a(hbx.oi)+"&shipcity="+$a(hbx.sy)+"&shipstate="+$a(hbx.sa)+"&shipzipcode="+$a(hbx.sz )+ "&shipcountry="+ $a(hbx.so)+ "&paymenttype="+$a(hbx.pt)+"&product="+$a(hbx.pr)+"&price="+ $a(hbx.pc)+"&quantity="+ $a(hbx.qn)+"&brand="+$a(hbx.bd)+"&category="+$a(hbx.ca)+"&shippingtype="+$a(hbx.st)+"&shipping="+$a((hbx.sp=="S"+"HIP+COST")?0:hbx.sp)+"&store="+$a((hbx.sr=="S"+"TORE")?1:hbx.sr)+"&sku="+$a(hbx.sk)+"&customer_type="+$a(hbx.cu)+"&discou"+"nt="+$a(( hbx.ds=="D"+"ISCOUNT")?0:hbx.ds)+"&promotion="+$a((hbx.po=="P"+"ROMOTION")?\'\':hbx.po)+ "&li_custom1="+$a(hbx.c1 )+"&li_custom2="+$a(hbx.c2)+(_bnN?("&bn="+$a(_bn)):"")+"&sv="+_sv+"&ss="+_ss+ "&sc="+_sc+"&dt="+_dt+"&cp="+hbx.cp+"&cmp="+hbx.cmp+"&gp="+hbx.gp+"&abd_type=order&n=" +$a(hbx.pn,1)+"&vcon="+$a(hbx.mlc,1)+"&seg="+hbx.seg+"&dcmp="+$a(hbx.dcmp)+"&fnl="+$a(hbx.fnl)+"&pec="+$a(hbx.pec)+"&cv="+$a(hbx.hcv)+"&gn="+$a(hbx.hcn)+"&ld="+$a(hbx.hlt)+"&la="+$a(hbx.hla)+"&c1="+$a(hbx.hc1)+"&c2="+$a(hbx.hc2)+"&c3="+$a(hbx.hc3)+"&c4="+$a(hbx.hc4)+"&vpc="+hbx.vpc;var _hbthreshold=2048;var _hbi=new Image();function $oe(a){return $gp()+"//"+hbx.gn+"/HG?hc=none&hb="+hbx.eacct+"&hec=1&ec=1&err="+$a(a);}_hbi.src=(_e2.length<_hbthreshold)?(_e2):($oe("Commerce Order "+$a(hbx.oi)+" request over 2k limit."))';

WSS.postInit['add-to-cart'] = 'function $ii( a, b,c){ return a.indexOf(b, c?c:0)};function $is(a,b, c){return b>a.length? "":a.substring(b,c!=null?c:a.length)};function $a(v){ return escape(v) }; var _sv=10, _bn=navigator. appName,_mn="we74",_bv=parseInt(navigator.appVersion),__r=".referrer",_rf=$a(eval("document"+__r)), _epg="n&cam="+hbx.cam+"&pv="+(hbx.pv>0?"1":"0&abd_type=cart_add")+"&product="+$a(hbx.pr)+ "&quantity="+$a(hbx.qn)+"&brand="+$a(hbx.bd)+"&category="+$a(hbx.ca)+"&price="+$a(hbx.pc)+ "&store="+$a((hbx.sr=="S"+"TORE")?1:hbx.sr)+"&tz=PST&aid="+hbx.cacct;if(!$ii(_bn,"Micro"+ "soft"))_bn="MSIE";if(_bn=="MSIE"&&_bv==2)_bv=3;function $l(m,l){return m=="/"? m:(($ii(m,"/")?"/":"")+(m.lastIndexOf("/")==l?m.substring(0,l):m))};function $n( a,b){return(a==""||a=="/")?"/":$is(a,hbx.ctdef!="full"?a.lastIndexOf("/",b-2): $ii( a,"/"),b)};function $o(a,b,c){var d=location.pathname,e=$is(d,d.lastIndexOf("/")+ 1,d.length);if(a&&b==c){return(hbx.pndef=="title"&&document.title!=""&&document. title!=location)?document.title:e?e:hbx.pndef}else{return(b==c)?$n(d,d.lastIndexOf( "/")):$l(b,b.length-1)}};function $p(a,b,c,d){return ""+(c>-1?$o(b,$is(a,0,c),d )+";"+$p($is(a,c+1),b,$ii($is(a,c+1),";")):$o(b,a,d))};hbx.mlc=$p( hbx.mlc,0,$ii(hbx.mlc, ";"),"CONTENT+CAT"+"EGORY");hbx.pn=$p(hbx.pn,1,$ii(hbx.pn,";"),"PUT+"+"PAGE+NAME+HERE" );';

WSS.postInit['checkout'] = 'function $a(v){return escape(v)}; var _sv=10,_bn=navigator.appName,_bv=parseInt( navigator.appVersion),__r=".referrer",_rf=$a(eval("document"+__r)),_epg="n&abd_type=checkout&prod"+ "uct="+$a(hbx.pr)+"&quantity="+ $a(hbx.qn)+"&price="+$a(hbx.pc)+"&shippingtype="+$a(hbx.st)+ "&shipping="+$a((hbx.sp=="S"+ "HIP+COST" )?0:hbx.sp)+"&store="+$a((hbx.sr=="S"+"TORE")?1: hbx.sr)+"&tz=PST&aid="+hbx.cacct; if(_bn.indexOf("Microsoft")==0)_bn="MSIE";if(_bn== "MsIE"&&_bv==2)_bv=3;function $c(m,l){return(m=="/")?m:((m.indexOf("/")?"/":"")+ (m.lastIndexOf("/")==l?m.substring(0,l):m))};function _gf(x){return x.substring( x.lastIndexOf("/")+1)};function $b(n){return(n=="PUT+P"+"AGE+NAME+HERE"||n=="C"+ "ONTENT+C"+"ATEGORY")};function _gd(x,i){return(x==""||x=="/")?"/":x.substring(( hbx.ctdef!= "full" ) ? x.lastIndexOf("/",i-2):x.indexOf("/"),i)};function _ps(b,p){ var l=location.pathname; if( b &&$b(p)){return(hbx.pndef=="title"&&document.title!= ""&& document.title !=location)?document.title:_gf(l)?_gf(l):hbx.pndef}else{return( $b(p) )? _gd( l, l.lastIndexOf("/")): $c( p,p.length-1)}};function _pm(m,h,i){ return ""+ (i>-1?_ps(h,m.substring(0,i))+";"+_pm(m.substring(i+1),h,m.substring( i+1).indexOf(";" )):_ps(h,m))};hbx.mlc=_pm(hbx.mlc,0,hbx.mlc.indexOf(";"));hbx.pn=_pm(hbx.pn,1, hbx.pn.indexOf(";"));_sv=11';

WSS.logErr = function(msg) {
    if (typeof console != 'undefined' && typeof console.log != 'undefined')
        console.log(msg);
    else
        alert(msg);
};

WSS.Ecommerce = function(hbx_action) {
    WSS.hbx_page = hbx_action;
    return WSS;
};

WSS.CharFilter = function(value) {
  var illegal=/[\\\"\&\|\#\$\%\^\*\:\!\<\>\~\;\']/g
  return value.replace(/ /g,'+').replace(illegal,'');
};

WSS.DefaultFilter = function(value) {
  var illegal=/["\&\<\>\']/g
  return value.replace(illegal,'');
};

WSS.SearchResults = function(keywords,app) {
    var kwords = keywords.replace(/['"\\]/g,'').replace(/&/g,' ').replace(/\s+/g,' '); //'
    if (kwords.length > 25) kwords = kwords.slice(0,25);
        
    var str = "var ev1 = _hbEvent('search'); " + 
              "ev1.keywords = '" + kwords + "';" + 
              "ev1.results = 1;" + 
              "ev1.attr1 = '" + app + "';";
    setTimeout(str,0);
}

WSS.Setup = function(args) {
    // Only call it once
    if (typeof WSS.Setup.count != 'undefined') {
        WSS.logErr("Multiple calls to WSS.Setup");
        return false;
    }
    WSS.Setup.count = 1;

    var valid = true,
        map = {
            name              : 'pn'
           ,contentc          : 'mlc'
           ,member_id         : 'ci'
           ,link_tracking     : 'lt'
           ,auto_set_name     : 'pndef'
           ,auto_set_contentc : 'ctdef'
           ,account           : 'acct'
           ,eaccount          : 'eacct'

           // Ecommerce Variables (do not have defaults)
           ,add_method        : 'cam'
           ,brand             : 'bd'
           ,category          : 'ca'
           ,commerce_account  : 'cacct'
           ,discount          : 'ds'
           ,email             : 'ci'
           ,order_id          : 'oi'
           ,pay_type          : 'pt'
           ,price             : 'pc'
           ,product           : 'pr'
           ,product_view      : 'pv'
           ,quantity          : 'qn'
           ,ship_city         : 'sy'
           ,ship_cost         : 'sp'
           ,ship_country      : 'so'
           ,ship_state        : 'sa'
           ,ship_type         : 'st'
           ,ship_zip          : 'sz'
           ,sku               : 'sk'
           ,type              : 'c1' 
           ,total_amount      : 'hc1'
        },
        filter = {
            name : WSS.CharFilter
        },
        default_fn = {
            uri : function(value) {
                return WSS.CharFilter(window.location.href);
            }
        };

    function initHbx() {
        var initialObj;
        window._hbEC = 0;
        window._hbE = new Array;
        window._hbEvent = function(a,b){
            b=_hbE[_hbEC++]=new Object();
            b._N=a;
            b._C=0;
            return b;
        }
        window.hbx = _hbEvent("pv");
        window.hbx.gn = "ehg-cardomain.hitbox.com";
        if (typeof WSS[WSS.hbx_page] == 'undefined')
            WSS.hbx_page = 'default_hbx';
        initialObj = WSS[WSS.hbx_page];
        for (var p in initialObj) {
            window.hbx[p] = initialObj[p];
        }
    }

    if (typeof window.hbx != 'object') 
        initHbx();                      // initialize global hbx;

    for (var name in args) {
        if(!(name in map)) {
            WSS.logErr("Unknown property passed to WSS.Setup: '" +
                       name + "'; value='" + args[name] + "'");
            valid = false;
        }
    }

    for(var key in map) {
        if(typeof(window.hbx[map[key]]) == "undefined") { continue; }
        if(args && typeof(args[key]) != "undefined") {
            if (key in filter) {
                window.hbx[map[key]] = filter[key](args[key]);
            } else {
                window.hbx[map[key]] = WSS.DefaultFilter(args[key]);
            }
        } else if(key in default_fn) {
            window.hbx[map[key]] = default_fn[key]();
        }
    }

    return valid;
}

