// This method reads the parameters as arguments, loops through the argument list and then triggers the analytics calls to the GA server.

// USAGE EXAMPLES: 
// gaTracking('dovechocolate.com','UA-24471926-1');
// gaTracking('dovechocolate.com','UA-24471926-1','UA-24471926-2');
// gaTracking('','UA-24471926-1','UA-24471926-2','UA-24471926-3');


function gaTracking() {
	var hostname = '';
	var _gaq = window._gaq || (window._gaq = []);
	if (arguments[0] == '') {
		hostname = document.location.hostname;
		if (hostname.indexOf('www.') != -1) {
			hostname = hostname.slice(4);
		}
	}
	else {
		hostname = arguments[0];
	}
	for (var i = 1; i < arguments.length; i++) { //Counter starts from 1 since argument[0] is always domain name
	  _gaq.push([i+'._setAccount', arguments[i]]); // sets the UA account numbers. 
	  _gaq.push([i+'._setDomainName', "."+hostname]); // sets domain to the one passed in the function
	  _gaq.push([i+'._trackPageview']); // calls the trackPageview() method and registers the pageview
	}
}

(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);
})();
 
