/*
* Coremetrics object will contain all the functions which in turn will call the  
* coremetrics functions of Reebok
*
* @author Cwad
*/
 
var cm = {
	
	productSearchFlag: false,
	/*
	* Creates page view for the customer service landing page
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category for customer landing
	*/
	createPageViewTagForCustomerServiceLandingPage : function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	}, 
	
	/*
	* Creates page view for the Opt Out page
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category for customer landing
	*/
	createPageViewTagForOptOutPage : function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	}, 
	
	/*
	* Creates page view for the homepage
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category for homepage
	*/
	createPageViewTagForHomePage : function(pageId, categoryId) {
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates page view for a category landing page
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category for the page
	*/
	createPageViewTagForCategoryLandingPage : function(pageId, categoryId) {
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates page view for the contact us page
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category for contact us
	*/
	createPageViewTagForContactUs : function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Completes the conversion tag
	*/
	createConversionEventCompletionTag: function(eventId, actionType, eventCategoryId){
		cmCreateConversionEventTag(eventId, actionType, eventCategoryId, null);
	},
	
	/*
	* Starts the event for contact us page
	*/
	createConversionEventTagForContactUs : function(){
		cmCreateConversionEventTag("Contact Us", "1", "Customer Service", "30");
	},
	
	/*
	* Completes the event for contact us page
	*/
	createConversionEventTagForConfirmation: function(){
		cmCreateConversionEventTag("Contact Us", "2", "Customer Service", "50");
	},
	
	/*
	* Completes the event for creating an Element tag
	*/
	createElementTag: function(elementId, elementCategory){
		cmCreatePageElementTag(elementId, elementCategory);
	},
	
	/* Creates page view for the FAQ page
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of FAQ
	*/
	createPageViewTagForFaq: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);	
	},
	
	/*
	* Creates page view for the FAQ sections pages
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of FAQ
	*/
	createPageViewtagForFaqSection: function(pageId, categoryId){
		//use the pageId and categoryId sent to us
		cmCreatePageviewTag(pageId, categoryId, null);		
	},
	
	/*
	* Creates page view for the Retail Locator
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of retail locator
	*/
	createPageViewtagForRetailLocator: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Starts the event for retail locator page
	*/
	createEventConversionForRetailLocator: function(){
		cmCreateConversionEventTag("Store Locator","1","Off-Line","100");
	},
	
	/*
	* Completes the event for retail locator page
	*/
	createEventCompletionForRetailLocator: function(){
		cmCreateConversionEventTag("Store Locator","2","Off-Line","400");
	},
	
	/*
	* Creates page view for the Retail Locator Serach
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of retail locator search 
	* if the search is succesul or unsuccessful
	*/
	
	createPageViewForRetailLocatorSearch: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates product view for the Product Detail
	* @param country is the country code
	* @param productId is the productId of the product
	* @param productName is the name of the product
	* @param categoryId is the country code followed by the category
	* the categoryId should be the categoryId of the referring page, so we get 
	* document.referrer and split it it obtain the categoryId
	*/
	createProductViewForProductDetail: function(country, productId, productName, ref){
		var categoryId ;
		if(ref){
			categoryId=  ref;
		}else{
			categoryId = "/"+country+"/home";
		}
		cmCreateHtmlProductviewTag("SH", productId, productName, categoryId);
	},
	
	/*
	* Creates page view for the Corporate links
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of the page
	*/
	createPageViewTagForCorporate: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates page view for the category pages
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of the page
	*/
	createPageViewTagForCategoryPages: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates page view for product serach results
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of the page
	* @param option is whether the page was successful or not
	* @param searchTerm is the search term used by the user
	* @param numOfResults is the number of results returned (0 for unsuccessful search)
	*/
	createPageViewTagForProductSeach: function(pageId, categoryId, option, searchTerm, numOfResults){
		cmCreatePageviewTag(pageId, categoryId, searchTerm, numOfResults);
	}, 
	
	/*
	* Creates page view for product serach results
	* @param pageId is the country code and the name of the page
	* @param categoryId is the country code followed by the category of the page
	* @param option is whether the page was successful or not
	* @param searchTerm is the search term used by the user
	* @param numOfResults is the number of results returned (0 for unsuccessful search)
	*/
	createPageViewTagForProductGrid: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	}, 

	/*
	* Creates page view for the Error page
	* @param pageId is the name of the page
	* @param categoryId is the country code followed by the category of the page
	*/
	createPageViewForError: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* used to call set the production enviroment for Coremetrics
	*/
	setProductionFlag: function(){
		cmSetProduction();
	},
	
	createPageViewForRondoPage: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	/*
	* Creates page view for a micro site page
	* @param pageId is the name of the page
	* @param categoryId is the country code followed by the category of the page
	*/
	createPageViewForMicrosite: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	
	sendMarketingPageView: function(queryString){
		if(queryString.search("cm_mmc=")>=0){
			/*var marketingParameter = queryString.substring((queryString.indexOf("=")+1));
			cmCreatePageviewTag( "Marketing event:" +marketingParameter, "OFF-SITE MARKETING PROGRAMS", null);*/ 
			
		}
	},
	
	createShopAction5Tag: function(productID,productName,productQuantity,productPrice,currencyCode){
		cmCreateShopAction5Tag(productID,productName,productQuantity,productPrice,"Shop|Checkout",null,currencyCode);
	},
	
	createShopAction5TagConfigurator: function(productID,productName,productQuantity,productPrice,currencyCode,widget){
		cmCreateShopAction5Tag(productID,productName,productQuantity,productPrice,widget,null,currencyCode);
	},
	
	displayShop5s: function(){
		cmDisplayShop5s();
	},
	
	createShopAction9Tag: function(productId, productName, quantity, unitPrice, customerId, orderId, orderSubtotal, currencyCode){
		cmCreateShopAction9Tag(productId, productName, quantity, unitPrice, customerId, orderId, orderSubtotal, null, null, currencyCode);
	},

	createShopAction9TagConfigurator: function(productId, productName, quantity, unitPrice, customerId, orderId, orderSubtotal, currencyCode, widget){
		cmCreateShopAction9Tag(productId, productName, quantity, unitPrice, customerId, orderId, orderSubtotal, widget, null, currencyCode);
	},
	
	displayShop9s: function(){
		cmDisplayShop9s();
	},
	
	createOrderTag : function(orderId, orderSubtotal, orderShipping, customerId, customerCity, customerState, customerZip, currencyCode){
		cmCreateOrderTag(orderId, orderSubtotal, orderShipping, customerId, customerCity, customerState, customerZip, currencyCode);
	},
	
	createRegistrationTag: function(customerId, customerEmail, customerCity, customerState, customerZip){
		cmCreateRegistrationTag(customerId, customerEmail, customerCity, customerState, customerZip, null, null);
	},
	
	createPageViewForCheckoutLogin: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForOrderConfirmation: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForCheckoutPayment: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForCheckoutReview: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForCheckoutShipping: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForCheckoutBilling: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createRegistrationtagForCheckout: function(customerEmail){
		cmCreateRegistrationTag(customerEmail, customerEmail, null, null, null, null, null);
	},
	createPageViewForYRPages: function(pageId, categoryId){
		cmCreatePageviewTag(pageId, categoryId, null);
	},
	createPageViewForPDP: function(country, recipeId, recipeName){
		top.cmCreateProductviewTag(country, recipeId, recipeName, "Overlay PDP");
	},
	createPageViewForMainPDP: function(country, productId, productName, categoryId){
		cmCreateHtmlProductviewTag(country, productId, productName, categoryId);
	}
};

