/*** COPYRIGHT 2009  BY FDM4 INTERNATIONAL INC. - ALL RIGHTS RESERVED ********/
/*** googleAnalytics.js --                                                 ***/ 
/*****************************************************************************/
/* J010100 02/03/12 JKR P14649 Change to use asynchronous tracking.          */
/* J010000 01/18/12 JKR P14476 Add domain to Google tracking parameters.     */
/*****************************************************************************/
/* 020002 05/18/10 APY- Add missing tax param for pageTracker._addTrans.     */
/* 020001 03/17/10 APY- Change vGaID to siteContent.GaID.                    */
/* 020000 03/08/10 JB - Account for b2b results page as well.                */
/* 010001 05/07/09 JD2- Removed document.write. Timing issues. Added vGaID.  */
/* 010000 04/17/09 JD2- Created.                                             */
/*****************************************************************************/

/****** vvv J010100 vvv ******/
var _gaq = _gaq || [];

/* 010001 - removed document.write. */

/* Track page views */
if (typeof siteContent.GaID != "undefined")                                     /* 010001 */ /* 020001 */
{
    _gaq.push(['_setAccount', siteContent.GaID]);
    /****** vvv J010000 vvv ******/
    if (typeof GADomain != "undefined")
    {
        _gaq.push(['_setDomainName', GADomain]);
    }
    /****** ^^^ J010000 ^^^ ******/
    _gaq.push(['_trackPageview']);
}

/* getParam now in global.js  020000 */
/* Run E-commerce Analytics */
var gsLocation = getParam("location");                                          /* 020000 */

if (gsLocation == "b2c/retail-results.w" || gsLocation == "olc/results.w")
{
    if (vOrderHeader != null && vOrderLine.length > 0)
    {
        _gaq.push(['_addTrans',
            vOrderHeader.orderId,       // order ID - required
            vOrderHeader.affiliation,   // affiliation or store name
            vOrderHeader.total,         // total - required
            vOrderHeader.tax,           // tax
            vOrderHeader.shipping,      // shipping
            vOrderHeader.city,          // city
            vOrderHeader.state,         // state or province
            vOrderHeader.country        // country
        ]);

        $.each(vOrderLine,function(i)
        {
            _gaq.push(['_addItem',
                vOrderLine[i].orderId,      // order ID - required
                vOrderLine[i].sku,          // SKU/code
                vOrderLine[i].productName,  // product name
                vOrderLine[i].category,     // category or variation
                vOrderLine[i].price,        // unit price - required
                vOrderLine[i].quantity      // quantity - required
            ]);
        });

        _gaq.push(['_trackTrans']);
    }
}

(function() {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
})();
/****** ^^^ J010100 ^^^ ******/

