/**
	A static class which encapsulates all of the functionality to track for avenue a
	
	@class AvenueA

	@example 
		AvenueA.addTag("nike_homepage");
		AvenueA.addTag("nike_footwear","nike_equipment_footwear");
	
		AvenueA.track("nike_homepage");
		AvenueA.track("nike_footwear");
		
		This will generate the following requests:
			http://switch.atdmt.com/action/nike_homepage
			http://switch.atdmt.com/action/nike_equipment_footwear
			
	@property trackAll boolean a property to determine if all tags passed 
		should be tracked by avenueA, or only ones from it's internal hash
	@property tagHash Object PRIVATE an internal storage object for translating 
		from coremetrics tags to avenueA tags
	
	@property imgMax int PRIVATE an internal number for detemining the maximum 
		avenueA tags that can be generated at a time
	@property imgIndex int PRIVATE an internal number used for counting which slot
		in the internal image array we are working with
	@property imgArray Object PRIVATE an internal storage object for storing the
		avenueA image requests
		 
		 
	@access static
	
	@author R/GA
	@author noel@rga.com
	
*/
var AvenueA = new Object();

AvenueA.trackAll = false;
AvenueA.tagHash = new Object();

AvenueA.imgMax = 10;
AvenueA.imgIndex = 0;
AvenueA.imgArray = new Array();


/**
	This will receive a generic action to track, determine if we need to track this action
	for avenueA, and if so, translate it to the proper avenueA tag if necessary
	
	@method generateAvenueATag

	@example AvenueA.track("nike_homepage");
		
	@param actionTag String The key will be the actionTag
*/
AvenueA.track = function(actionTag) {
	
	//var value;

	//if (this.trackAll) {
	//	value = actionTag;		
	//} else {
	//	value = this.tagHash[actionTag];		
	//}
	
	//if (value != null) {
		
	this.generateAvenueATag(actionTag);
				
	// Return tag information for debugging
	return AvenueA.prepAveADebugString(actionTag) ;
		
	//}

}


/**
	This information generation display information
      about the Avenue A tag for debugging
	
	@method prepAveADebugString
		
	@param actionTag String 
*/

AvenueA.prepAveADebugString = function( actionTag ) {

	var avea_debug_string = "" ;
	avea_debug_string = "<br /><br /><b>Avenue A Tag</b>" + "<br />" +
		"<i>Tag name</i> " + actionTag + "<br />" ;
	return avea_debug_string ;

}

/**
	This function is to generate the actual image request for an avenueA tag
	
	@method generateAvenueATag
		
	@param actionTag String The key will be the actionTag
*/
AvenueA.generateAvenueATag = function(actionTag) {

	var request = "http://switch.atdmt.com/action/"+actionTag;
	this.imgArray[this.imgIndex] = new Image();
	this.imgArray[this.imgIndex].src = request;
	this.imgIndex++;
	if (this.imgIndex > this.imgMax) this.imgIndex = 0;

}



/**
	This function is used to store a list of which action tags should be tracked for avenueA
	
	@method addTag
	
	@example 
		AvenueA.addTag("nike_homepage");
		AvenueA.addTag("nike_footwear","nike_equipment_footwear");
			
	@param actionTag String The key will be the actionTag
	@param translation String The value will be the tag which avenue a needs to use in place of the actionTag
*/
AvenueA.addTag = function(actionTag,translation) {
	
	if (translation != null) {
		this.tagHash[actionTag] = translation;
	} else {
		this.tagHash[actionTag] = actionTag;
	}
	
}