// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// Google Analytics code for www.lwcb.ca
//
// insert the following code into HTML files
// <script type="text/javascript" src="/GoogleAnalytics.js"></script> 
//
// by doing that, each page that includes that code will be tracked in Google Analytics
//
// In order to track PDF, etc. downloads (and avoid analyzing server logs) one of
// the helper routines below must be included in an "onclick" event of the link (Anchor) element
//
// The Download Categories and Actions, defined below, help organize your events in Google Analytics
// The Label, included as part of the link's "onclick" event code, helps identify that file
// (the label, in our case, will not include date info for daily PDFs because that is too specific
//  and the queries within GA already use dates, anyway).
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// INITIALIZATION
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21018229-2']);
  _gaq.push(['_trackPageview']); 

  (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);
  })();


//Each one of these has a helper function to make it easier to Log that type of event
var giGAValueToIgnore  = -999;
var gsGACatDownloads   = 'LWCBDownloads';
var gsGACatEmails      = 'LWCBContactInitiated';
var gsGACatMODownloads = 'LWCBMembOnlyDnlds';
var gsGACatMOContacts  = 'LWCBMOContactInitiated';
var gsGADnldAction_PermPDF     = 'PermPDF';
var gsGADnldAction_PercPDF     = 'PercPDF';
var gsGADnldAction_DataPDF     = 'DataPDF';
var gsGADnldAction_5YearPDF    = '5YearPDF';
var gsGADnldAction_RegActsPDF  = 'RegActsPDF';
var gsGADnldAction_BdDescPDF   = 'BdDescPDF';
var gsGADnldAction_MOC7PDF     = 'MOC7PDF';
var gsGADnldAction_BdDescEmail = 'BdDescEmail';

  
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// DOWNLOADS
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

	// This routine is called by the ones that follow it
	// There is an optional 4th parameter, "value", which is suggested to used for filesizes
	function recordGADownload(link, label, action) {
		var iValue=giGAValueToIgnore;
		if(arguments.length>3) {iValue = arguments[3];}
		if(iValue==giGAValueToIgnore) {
			_gaq.push(['_trackEvent', gsGACatDownloads, action, label]); //No Value Passed
		} else {
			_gaq.push(['_trackEvent', gsGACatDownloads, action, label, iValue]);
		}
		setTimeout('document.location = "' + link.href + '"', 100);
	}
  
  // example anchor HTML for the following function:
  // There is an optional 3rd parameter, "value", which is suggested to used for filesizes
  // <a href="http://www.example.com/some.pdf" onClick="recordGAPermPDF(this, 'The Docs');return false;">
  function recordGAPermPDF(link, label) {
    var sAction = gsGADnldAction_PermPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {     iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGAPercPDF(link, label) {
    var sAction = gsGADnldAction_PercPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGADataPDF(link, label) {
    var sAction = gsGADnldAction_DataPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGA5YearPDF(link, label) {
    var sAction = gsGADnldAction_5YearPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGARegActsPDF(link, label) {
    var sAction = gsGADnldAction_RegActsPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGABdDescPDF(link, label) {
    var sAction = gsGADnldAction_BdDescPDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }
  function recordGAMOC7PDF(link, label) {
    var sAction = gsGADnldAction_MOC7PDF,iValue=giGAValueToIgnore;
    if(arguments.length>2) {    	iValue = arguments[2];   }
    return recordGADownload(link,label,sAction,iValue);
  }

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Member-Only DOWNLOADS
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

	// This routine is called by the ones that follow it
	// There is an optional 4th parameter, "value", which is suggested to used for filesizes
	function recordGAMODownload(link, label, action) {
		var iValue=giGAValueToIgnore;
		if(arguments.length>3) {iValue = arguments[3];}
		if(iValue==giGAValueToIgnore) {
			_gaq.push(['_trackEvent', gsGACatMODownloads, action, label]); //No Value Passed
		} else {
			_gaq.push(['_trackEvent', gsGACatMODownloads, action, label, iValue]);
		}
		setTimeout('document.location = "' + link.href + '"', 100);
	}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// OUTBOUND LINKS
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// example anchor HTML for the following function:
// <a href="http://www.example.com" onClick="recordGAOutboundLink(this, 'Outbound Links', 'example.com');return false;">
  function recordGAOutboundLink(link, category, action) {
    _gat._getTrackerByName()._trackEvent(category, action);
    setTimeout('document.location = "' + link.href + '"', 100);
  }

  
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// EMAILS
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  
  function recordGAContactIntiated(link, label, action) {
    _gaq.push(['_trackEvent', gsGACatEmails, action, label]);
    setTimeout('document.location = "' + link.href + '"', 100);
  }

  function recordGAMOContactIntiated(link, label, action) {
    _gaq.push(['_trackEvent', gsGACatMOContacts, action, label]);
    setTimeout('document.location = "' + link.href + '"', 100);
  }

  function recordGABdDescEmail(link, label) {
    var sAction = gsGADnldAction_BdDescEmail;
    return recordGAContactIntiated(link,label,sAction);
  }

