/*
Description :	Common js include file to call Google Analytics functions and send data to GA
Author		: 	David Eckman - deckman@vkistudios.com
Created	By	:	VKI Studios - www.vkistudios.com
Created		:	July 17, 2009
*/

// When the script loads, this entire script will run and call the sendGA function
// to report the pageview

// Virtual Pageviews (lightboxes, modal windows, etc)
// when needing to call a virtual page view, set the value of gatcPageName
// document.gatcPageName = '<Virtual Page name>' on the page and then initiate the rest
// of this script. This JS file and the sendGA function must already be loaded on the page
// ex:
// document.gatcPageName = '/register/step1';
// sendGA();

/* --------------------------------------------------------------------- */

// sendGA: sends the page tracking call to Google
function sendGA() { 
	if (typeof(pageTracker) == "object") {
		if (document.gatcPageName) {
			pageTracker._trackPageview(document.gatcPageName);
        } else {
			pageTracker._trackPageview();
        }
	}
}

// trackClick: track click events
// delay added to improve accuracy of external link tracking
function trackClick(fwdTo, pageName) {
	if (typeof(pageTracker) == "object") {
		pageTracker._trackPageview(pageName);
	}
	setTimeout("window.location.href = fwdTo;", 500);

}

// trackGAEvent: event tracking function
// reqired: category, action
function trackGAEvent(category,action,label,value) { 
 if (typeof pageTracker == 'object') {  
  if (typeof label == 'undefined') {
   label = null;
  }
  if (typeof value == 'undefined') {
   value = null;
  }
  pageTracker._trackEvent(category, action, label, value);
 }
}


// Call sendGA function
// try/catch should only be enabled on LIVE site so errors show up on dev/staging
try { 
	var pageTracker = _gat._getTracker('UA-9795634-1');
	// _setDomainName ensures cookies are not contaminated across subdomains
	// resulting in inflated visit numbers
	pageTracker._setDomainName('.bidfire.com');
	
	sendGA();

} catch(err) {}
