var CONVERSION_INITIATE = 1;
var CONVERSION_COMPLETE = 2;
		
function cmProduct(productId, name, quantity, price)
{
	this.productId=productId;
	this.name=name;
	this.quantity=quantity;
	this.price=price;
}

BLOOMIES.namespace("coremetrics");

		BLOOMIES.coremetrics.getMMCVendor = function () {
            return getQueryValue('PartnerID');
        }
		BLOOMIES.coremetrics.getMMCPlacement = function () {
            return "N/A";
        }
		BLOOMIES.coremetrics.getMMCCategory = function () {
            return "N/A";
        }
		BLOOMIES.coremetrics.getMMCItem = function () {
            return getQueryValue('BannerID')||this.getLinkshareID();
        }
		BLOOMIES.coremetrics.getLinkshareID = function () {
        	return getQueryValue('LinkshareID'); //Linkshare creates this ID - an encrypted string
        }
		BLOOMIES.coremetrics.getCustomerID = function () {
            return getCookie("bloomingdales_online_uid") || "0000000000";
        }
		BLOOMIES.coremetrics.getMachineID = function () {
			return getCookie("bloomingdales_online");
        }
	
        
        BLOOMIES.coremetrics.cmCreatePageviewTag = function(cmPageID, cmCategoryID, searchTerm, searchResults) {
			var customerID = this.getCustomerID;
        	cmCreatePageviewTag(	
        		cmPageID,
				cmCategoryID,
				searchTerm,
				searchResults,
				this.getMMCVendor(),
				this.getMMCCategory(),
				this.getMMCPlacement(),
				this.getMMCItem(),
				this.getMachineID(),
				this.getLinkshareID()
			);
        };
		
		
		BLOOMIES.coremetrics.addToBag = function(products, cmPageID, cmCategoryID){
			this.cmCreatePageviewTag(cmCategoryID + "_Add_To_Bag", cmCategoryID,"","");
			for (var product in products) {
				cmCreateShopAction5Tag(
					products[product].productId, 
					products[product].name.replace(/[,']/g,""), 
					products[product].quantity.toString(), 
					products[product].price.toString(), 
					cmCategoryID);
			}
			cmDisplayShop5s();
		}
		
		BLOOMIES.coremetrics.cmCreateConversionEventTag = function(eventID, actionType, cmCategoryID, points){
			cmCreateConversionEventTag(
				eventID, 
				actionType, 
				cmCategoryID, 
				points,
				""
				)
		}
		
		BLOOMIES.coremetrics.cmCreateConversionEventTag = function(eventID, actionType, cmCategoryID, points, attributes){
			cmCreateConversionEventTag(
				eventID, 
				actionType, 
				cmCategoryID, 
				points,
				attributes
				)
		}
		
		BLOOMIES.coremetrics.createRegistrationTag = function(emailAddress, city, state, zip, gender, isSubscribed) {
			cmCreateRegistrationTag(	
        		this.getCustomerID,
        		emailAddress,
        		city,
        		state,
        		zip,
        		gender,
        		"", //newsletter
        		isSubscribed,
        		"", //customerAge
        		"" //customerIncome
			);
        };