
	var ga_account = 'UA-21036077-2';
	
	// *****************************************************************************************************************
	// link and form settings
	
		/*  a special note about delay settings - if an event causes some action in the browser, like changing pages or 
				opening an email client, a delay is needed. It appears that a 0.1 second delay is sufficient to allow
				the track event code to trigger the ping to GA. Without this delay the event will not be recorded
		*/
	
	var ga_settings = {};
	ga_settings.anchorClick = true;
	ga_settings.extensions = ['pdf', 'doc', 'xls', 'csv', 'jpg', 'gif', 'mp3', 'swf', 'txt', 'ppt', 'zip', 'gz', 'dmg', 'xml'];
	
	ga_settings.external = {};
	ga_settings.external.category = 'link';							// event category for external link
	ga_settings.external.action = 'outbound';						// 2nd parameter
																											// 3rd parameter will be url of link
																											// 4th parameter is always be 0 (zero)
	ga_settings.external.non_interact = true;						// 5th parameter == non_interact == true means don't count this as a page interaction
	ga_settings.external.target = '_blank';
	ga_settings.external.delay = 0.0;
	
	ga_settings.mailto = {};
	ga_settings.mailto.category = 'link';								// event category for mailto link
	ga_settings.mailto.action = 'mailto';
	ga_settings.mailto.non_interact = false;
	ga_settings.mailto.target = 'na';
	ga_settings.mailto.delay = 0.1;
	
	ga_settings.download = {};
	ga_settings.download.category = 'link';							// event category for download link
	ga_settings.download.action = 'download';
	ga_settings.download.non_interact = false;
	ga_settings.download.target = '_blank';
	ga_settings.download.delay = 0.0;
	
	ga_settings.formSubmit = true;											// track form submissions events
																											// this is not the same as conversions with is completed form submissions
																											// this only counts how many times forms are submitted withou
																											// regard to if they succceed or not
	
	ga_settings.forms = {};
	ga_settings.forms.category = 'form';
	ga_settings.forms.action = 'submit';
	ga_settings.forms.non_interact = false;
	ga_settings.forms.target = 'na';
	ga_settings.forms.delay = 0.1;
	
	ga_settings.formConversions = true;
	ga_settings.conversions = {};
	ga_settings.conversions.category = 'form';
	ga_settings.conversions.action = 'conversion';
	ga_settings.conversions.non_interact = false;
	
	ga_settings.conversionPages = ['/contact-us/thank-you/'];		// list of form tank you pages, paths must be absolute form web root
																										// i.e. start with a /
	
	ga_settings.siteSpeedSampleRate = 1;			// page sample rate %, default is 1, max is 10, must be an integer
	
	// end link and form settings
	// *****************************************************************************************************************
	
	
	// *********************************************************************
	// Social Media Setting 
	
	ga_sharethis = {};
	ga_sharethis.setup = true;
	ga_sharethis.switchTo5x = true;
	ga_sharethis.publisher_id = '04cb0857-4bca-4463-9241-2871ba2b8657';
	
	// End Social Media Settings
	// *********************************************************************
	
	// install GA and link tracking
	
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', ga_account]);
	_gaq.push(['_trackPageview']);
	
	
	// make sure it is an int from 2 to 10
	theRate = Math.round(ga_settings.siteSpeedSampleRate);
	if (theRate > 10) {
		theRate = 10;
	}
	if (theRate > 1) {
		_gaq.push(['_setSiteSpeedSampleRate', theRate]);
	}

	(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);
	})();
	
	if (window.addEventListener) {
		window.addEventListener('load', bluntAddEvents, false);
	} else if (window.attachEvent) {
		window.attachEvent('onload', bluntAddEvents);
	}
	
	// install social tracking
	if (ga_sharethis.setup && ga_sharethis.publisher_id != '') {
		var switchTo5x  = ga_sharethis.switchTo5x;
		var sharethis = document.createElement('script');
		sharethis.type = 'text/javascript';
		sharethis.async = true;
		sharethis.src = 'http://w.sharethis.com/button/buttons.js';
		
		// stlight.options cannot be set until the the sharethis script is loaded
		// adding an onload function to the script ensures it is loaded before trying to access its properties
		if (window.addEventListener) {
			sharethis.addEventListener('load', sharethisOptions, false);
		} else if (window.attachEvent) {
			sharethis.attachEvent('onload', sharethisOptions);
		}
		
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(sharethis, s);
		
	}
	
	function sharethisOptions() {
		stLight.options({publisher:ga_sharethis.publisher_id});
	} // end function sharethisPublisher
	
	function bluntAddEvents() {
		
		var theLoc = 'http://'+location.host;
		var theLocLen = theLoc.length;
		var theSecLoc = 'https://'+location.host;
		var theSecLocLen = theLoc.length;
		
		if (ga_settings.anchorClick) {
			addAnchorClickEvents();
		}
		
		if (ga_settings.formSubmit) {
			addFromSubmitEvents();
		}
		
		if (ga_settings.formConversions) {
			trackConversion();
		}
		
		function addFromSubmitEvents() {
			var formCount = document.forms.length;
			if (formCount > 0) {
				var theCategory = ga_settings.forms.category;
				var theAction = ga_settings.forms.action;
				var theValue = 0;
				var theNonInteract = ga_settings.forms.non_interact;
				var theDelay = ga_settings.forms.delay;
				var theTarget = '';
				for (var i=0; i<formCount; i++) {
					if (ga_settings.forms.target != 'na' && document.forms[i].target == '') {
						document.forms[i].target = ga_settings.forms.target;
					}
					// to track we need the form name and the place it is submitted to
					// label will be the form name, page it is on and page submitted to
					var theName = document.forms[i].name;
					if (theName == '') {
						theName = ''+i;
					}
					var theFrom = stripThisDomain(location.href);
					var theTo = document.forms[i].action;
					if (theTo != '') {
						theTo = stripThisDomain(theTo);
						if (isExteranlLink(theTo)) {
							theNonInteract = true;
						}
						if (theFrom == theTo) {
							theTo = 'same';
						}
					} else {
						theTo = 'same';
					}
					var theLabel = 'Form='+theName+'&From='+theFrom+'&To='+theTo;
					document.forms[i].ga_category = theCategory;
					document.forms[i].ga_action = theAction;
					document.forms[i].ga_label = theLabel;
					document.forms[i].ga_value = theValue;
					document.forms[i].ga_nonInteract = theNonInteract;
					document.forms[i].ga_delay = theDelay;
					if (window.addEventListener) {
						// most browsers
						document.forms[i].addEventListener('submit', function(){
							//_gat._getTrackerByName()._trackEvent(this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract);
							_gaq.push(['_trackEvent', this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract]);
							ga_eventPause(this.ga_delay);
						}, false); // end addEventListener
					} else if (window.attachEvent) {
						// windows/IE
						document.forms[i].attachEvent('onsubmit', function(){
							//_gat._getTrackerByName()._trackEvent(this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract);
							_gaq.push(['_trackEvent', this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract]);
							ga_eventPause(this.ga_delay);
						}); // end attachEvent
					}
				} // end for each form
			} // end if count forms > 0
		} // end function addFormSubmitEvents
		
		function addAnchorClickEvents() {
			var theAnchors = document.getElementsByTagName('a');
			var aLength = theAnchors.length;
			for (var i=0; i<aLength; i++) {
				var theCategory = '';
				var theAction = '';
				var theLabel = '';
				var theValue = 0;
				var theNonInteract = true;
				var theTarget = '';
				var theDelay = 0.0;
				if (typeof(theAnchors[i].href) != 'undefined') {
					var theHref = stripThisDomain(theAnchors[i].href);
					// now we have the location without being a fully qualified url to this site
					// check for external/email/document links
					var trackEvent = false;
					
					// check for special links here, for example an link to twitter
					// this would change the categories/actions/labels/etc to those of the special links
					// **********************************************************************************************************************
					
					// check for protocol in link
					// means external link
					if (!trackEvent && isExteranlLink(theHref)) {
						//alert(theHref+' External');
						// this is an external link
						trackEvent = true;
						// set values for event tracking
						theCategory = ga_settings.external.category;
						theAction = ga_settings.external.action;
						theLabel = theHref;
						theNonInteract = ga_settings.external.non_interact;
						// added feature, add a target="_blank" to all outbound links
						theDelay = ga_settings.external.delay;
						theTarget = '';
						if (ga_settings.external.target != 'na') {
							theTarget = ga_settings.external.target;
						}
					} 
					
					// mailto link
					if (!trackEvent && isMailtoLink(theHref)) {
						// mailto link
						trackEvent = true;
						// set values for event tracking
						theCategory = ga_settings.mailto.category;
						theAction = ga_settings.mailto.action;
						theLabel = theHref.substring(7);
						theNonInteract = ga_settings.mailto.non_interact;
						theDelay = ga_settings.mailto.delay;
						theTarget = '';
						if (ga_settings.mailto.target != 'na') {
							theTarget = ga_settings.mailto.target;
						}
					}
					
					if (!trackEvent && isDownloadLink(theHref)) {
						// this is a trackable extension for download
						trackEvent = true;
						// download link
						// set values for tracking
						theCategory = ga_settings.download.category;
						theAction = ga_settings.download.action;
						theLabel = theHref;
						theNonInteract = ga_settings.download.non_interact;
						theTarget = '';
						if (ga_settings.download.target != 'na') {
							theTarget = ga_settings.download.target;
						}
					} // end if else mailto
					
					if (trackEvent) {
						// add event tracking function to anchor
						//alert(theCategory+', '+theAction+', '+theLabel+', '+theValue+', '+theNonInteract);
						theAnchors[i].ga_category = theCategory;
						theAnchors[i].ga_action = theAction;
						theAnchors[i].ga_label = theLabel;
						theAnchors[i].ga_value = theValue;
						theAnchors[i].ga_nonInteract = theNonInteract;
						theAnchors[i].ga_delay = theDelay;
						if (theTarget != '' && theAnchors[i].target == '') {
							theAnchors[i].target = theTarget;
						}
						if (window.addEventListener) {
							// most browsers
							theAnchors[i].addEventListener('click', function(){
								//_gat._getTrackerByName()._trackEvent(this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract);
								_gaq.push(['_trackEvent', this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract]);
								ga_eventPause(this.ga_delay);
							}, false); // end addEventListener
						} else if (window.attachEvent) {
							// windows/IE
							theAnchors[i].attachEvent('onclick', function(){
								//_gat._getTrackerByName()._trackEvent(this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract);
								_gaq.push(['_trackEvent', this.ga_category, this.ga_action, this.ga_label, this.ga_value, this.ga_nonInteract]);
								ga_eventPause(this.ga_delay);
							}); // end attachEvent
						}
					} // end if trackEvent
					
				} // end check for href is defined
			} // end for i = length of anchors
			
		} // end function addAnchorClickEvents
			
		function stripThisDomain(theUrl) {
			// see if the link is a fully qualified URL back to this domain
			// need to check both secure and non-secure versions
			// if it is, strip off the location host from the link
			//alert(theHref.substring(theLocLen));
			theUrl = String(theUrl);
			//alert('Start: '+theUrl);
			//alert(theUrl.indexOf(theLoc));
			if (theUrl.indexOf(theLoc) == 0) {
				// strip it off
				theUrl = theUrl.substring(theLocLen);
			}
			if (theUrl.indexOf(theSecLoc) == 0) {
				// strip it off
				theUrl = theUrl.substring(theSecLocLen);
			}
			//alert('Finish: '+theUrl);
			return theUrl;
		} // end function stripThisDomain
		
		function isDownloadLink(theUrl) {
			var theReturn = false;
			theExtension = theUrl.split('.').pop();
			var theExtensionList = ga_settings.extensions;
			var theMax = theExtensionList.length;
			for (var i=0; i<theMax; i++) {
				if (theExtension == theExtensionList[i]) {
					theReturn = true;
					break;
				} // end if is a trackable extension
			} // end foreach extension
			return theReturn;
		} // end function isDownload
		
		function isMailtoLink(theUrl) {
			var theReturn = false;
			if (theUrl.indexOf('mailto:') == 0) {
				theReturn = true;
			}
			return theReturn;
		} // end function isMailtoLink
		
		function isExteranlLink(theUrl) {
			var theReturn = false;
			if (theUrl.indexOf('://') != -1) {
				theReturn = true;
			}
			return theReturn;
		} // end function isExteranlLink
		
		function addDate(theLabel) {
			var date = new Date();
			var d  = date.getDate();
			var day = (d < 10) ? '0' + d : d;
			var m = date.getMonth() + 1;
			var month = (m < 10) ? '0' + m : m;
			var yy = date.getYear();
			var year = (yy < 1000) ? yy + 1900 : yy;
			var hours = date.getHours()
			var minutes = date.getMinutes()
			theLabel += ' '+year+'-'+month+'/'+day+' '+hours+':'+minutes;
			return theLabel;
		} // end function addDate
		
		function trackConversion() {
			// if the current page is in the list of conversion page
			// track the conversion event
			var theLocation = stripThisDomain(document.location);
			theLocation = theLocation.replace(/\?.*$/, '');
			if (ga_settings.conversionPages.indexOf(theLocation) != -1) {
				var theReferer = document.referrer;
				if (theReferer != '') {
					theReferer = stripThisDomain(theReferer);
					theReferer = theReferer.replace(/\?.*$/, '');
				}
				var theCategory = ga_settings.conversions.category;
				var theAction = ga_settings.conversions.action;
				var theLabel = 'Page='+theLocation+'&From='+theReferer;
				var theValue = 0;
				var theNonInteract = ga_settings.conversions.non_interact;
				
				_gaq.push(['_trackEvent', theCategory, theAction, theLabel, theValue, theNonInteract]);
			}
			
		} // end function trackConversion
		
	} // end function (class) bluntAddEvents
	
	function ga_eventPause(delay) {
		// ga event tracking will not complete unless there is a slight pause
		// between the event being sent to google and the location changing
		var ms = delay*1000; // pause for seconds
		ms += new Date().getTime();
		while (new Date() < ms){}
	} // end function longPause
	
