/**
 * ------------------------------------------------------------------------------------------------------------
 *  THIS CODE IS NOT APPROVED FOR USE IN/ON ANY OTHER WEB SITE OR PRODUCT COMPONENT.
 *  Copyright (c) 2009 Backcountry.com.  All rights reserved.
 * ------------------------------------------------------------------------------------------------------------
 */
 
/**
 * ------------------------------------------------------------------------------------------------------------
 * Constructor of the SiteTracker object
 * @constructor:
 *
 * @param {String} account The site account number used for the tracking system.
 * @param {String} profile The profile number.
 * @param {Object} serverTracker SiteTracker object used to create pageTracker object.
 * ------------------------------------------------------------------------------------------------------------
 */

BCNTRY.odat.marketing.SiteTracker = function(account, profile, serverTracker) {
	this._trackNumber = "UA-" + account + "-" + profile;
	try {
		this._pageTracker = serverTracker._getTracker(this._trackNumber);
	} catch(err) {
	}	
	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Sets the linker functionality flag as part of enabling cross-domain user tracking. By default, this method 
 * is set to false and linking is disabled.
 * @param Boolean enable If this parameter is set to true, then linker is enabled. Else, linker is disabled. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.setAllowLinker = function(enable) {
	this._pageTracker._setAllowLinker(enable);
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Sets the domain name for cookies. There are three modes to this method: ("auto" | "none" | [domain]). 
 * By default, the method is set to auto, which attempts to resolve the domain name based on the location object
 * in the DOM. 
 * @param String   newDomainName New default domain name to set. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.setDomainName = function(newDomainName) {
	this._pageTracker._setDomainName(newDomainName);
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to set the allow domain hash flag. By default, this value is set to true. 
 * @param Boolean enable If this parameter is set to true, then domain hashing is enabled. Else, domain hashing
 * 							is disabled. True by default. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.setAllowHash = function(value) {
	this._pageTracker._setAllowHash(value);
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to track a page view.
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.trackPage = function() {
	this._pageTracker._trackPageview();
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to track an event on a page.
 * 
 * @param {String} category The name of the category that the event is associated to.
 * @param {String} action The name of the action that the event is executing.
 * @param {String} label Optional descriptor used to set more information about the event.
 * @param {String} value Optional value to set more information about the event.
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.trackEvent = function(category, action, label, value) {
	this._pageTracker._trackEvent(category, action, label, value);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to create a tracking link, to track information between different domains.
 *
 * @param {String} url The url to link to.
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.getTrackLink = function(url) {
	this._pageTracker._link(url);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to create a tracking link, to track information between different domains. This link is to be used
 * in forms.
 *
 * @param {String} url The url to link to.
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.getTrackLinkByPost = function(url) {
	this._pageTracker._linkByPost(url);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to create a variable for a visitor segment.
 *
 * @param {String} value The name of the segment.
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.createSegment = function(value) {
	this._pageTracker._setVar(value);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to track a transaction.Arguments for this method are matched by position, so be sure to supply all 
 * parameters, even if some of them have an empty value.
 *
 * @param {String} orderId Required. Internal unique order id number for this transaction. 
 * @param {String} affiliation Partner or store affiliation (undefined if absent).
 * @param {String} total Required. Total dollar amount of the transaction. 
 * @param {String} tax Tax amount of the transaction. 
 * @param {String} shipping Shipping charge for the transaction. 
 * @param {String} city City to associate with transaction. 
 * @param {String} state State to associate with transaction. 
 * @param {String} country Country to associate with transaction. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.addTransaction = function(orderId, affiliation, total, tax, shipping, city, state, country) {
	this._pageTracker._addTrans(orderId, affiliation, total, tax, shipping, city, state, country);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to an item to a transaction.Arguments for this method are matched by position, so be sure to supply all 
 * parameters, even if some of them have an empty value.
 *
 * @param {String} orderId Required. Internal unique order id number for this transaction. 
 * @param {String} sku Required. Item's SKU code. 
 * @param {String} name Product name. 
 * @param {String} category Product category. 
 * @param {String} price Required. Product price. 
 * @param {String} quantity Required. Purchase quantity. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.addItemToTransaction = function(orderId, sku, name, category, price, quantity) {
	this._pageTracker._addItem(orderId, sku, name, category, price, quantity);	
};

/**
 * ------------------------------------------------------------------------------------------------------------
 * Function to track a transaction, tracking both the transaction and the item associated with it. It should be
 * called after trackPage and it should be used along with addTransaction and addItemToTransaction.
 *
 * @param {String} orderId Required. Internal unique order id number for this transaction. 
 * @param {String} sku Required. Item's SKU code. 
 * @param {String} name Product name. 
 * @param {String} category Product category. 
 * @param {String} price Required. Product price. 
 * @param {String} quantity Required. Purchase quantity. 
 * ------------------------------------------------------------------------------------------------------------
 */
BCNTRY.odat.marketing.SiteTracker.prototype.trackTransaction = function() {
	this._pageTracker._trackTrans();
};