// The gaTracking() method reads the parameters as arguments, loops through the argument list and then triggers the analytics calls to the GA server. In this method first paramet is always the domain name.
// USAGE EXAMPLES: 
// MarsGAT.gaTracking('mywebsite.com','UA-24491019-1');
// MarsGAT.gaTracking('mywebsite.com','UA-24491019-1','UA-24491019-2');
// MarsGAT.gaTracking('','UA-24491019-1','UA-24491019-2','UA-24491019-3');


// The gaTrackingFlash() method reads the parameters as arguments, loops through the argument list and then triggers the analytics calls to the GA server.In this method first paramet is always the domain name and second parameter is always page name to be tagged.
// USAGE EXAMPLES: 
// MarsGAT.gaTrackingFlash('mywebsite.com','/trackingPageName','UA-24491019-1');
// MarsGAT.gaTrackingFlash('mywebsite.com',''/trackingPageName'','UA-24491019-1','UA-24491019-2');
// MarsGAT.gaTrackingFlash('','/trackingPageName','UA-24491019-1','','UA-24491019-2','UA-24491019-3');

var MarsGAT = {
	gaTracking : function (){
		var hostname = MarsGAT.getHostName(arguments);
		hostname = "."+hostname;
		for (var i = 1; i < arguments.length; i++) { //Counter starts from 1 since arguments[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
		}
	},
	gaTrackingFlash : function(){
		var hostname = MarsGAT.getHostName(arguments);
		hostname = "."+hostname;
		for (var i = 2; i < arguments.length; i++) { //Counter starts from 2 since arguments[0] is always domain name and arguments[1] is page 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', arguments[1]]); // calls the trackPageview() method and registers the pageview
		}
	},
	getHostName : function(arguments){
		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];
		}
		return hostname;
	}
};

(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);
})();
 
