<!--
/*
 * $Id: cmcustom-10119225-90211790-102611.txt 181478 2011-10-26 19:16:38Z abrink $
 * $Rev: 181478 $
 *
 * Date		Eng			Descr
 * 030508	KAndrews	Configure Registration Tag
 * 050208	KAndrews	Configure Endeca Custom Tag
 * 111008	JBowser		Added code for Explore
 * 052510	ETowb		Changed default client ID and default host for new test system
 * 072810	HWhite		Modified library to pass Explore Attributes 0-5 as Extra Fields 10-15 for pageviews
 * 082610	YHunt		Deactivate cm_SkipHandlerReg; restore standard handler functionality
 * 102611	ABrink		Update to latest lib release
 */

/*
 * Creates a Tech Props tag.
 * pageID		: required. Page ID to set on this Pageview tag
 */
function cmCreateTechPropsTag(pageID, categoryID,attributes,extraFields) {
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}	
	cmMakeTag(["tid","6","pi",pageID,"cg",categoryID,"pc","Y","pv10",cm_exAttr[0],"pv11",cm_exAttr[1],"pv12",cm_exAttr[2],"pv13",cm_exAttr[3],"pv14",cm_exAttr[4],"pv15",cm_exAttr[5],"cmAttributes",attributes,"cmExtraFields",extraFields]);
}

/*
 * Creates a Pageview tag with the given Page ID
 * pageID	: required. Page ID to set on this Pageview tag
 */
function cmCreatePageviewTag(pageID, categoryID, searchString, searchResults,primaryRole,documentType,publishedDate,primaryAuthor,userType, attributes,extraFields) {
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
	cmMakeTag(["tid","1","pi",pageID,"cg",categoryID,"se",searchString,"sr",searchResults,"pv1",primaryRole,"pv2",documentType,"pv3",publishedDate,"pv4",primaryAuthor,"pv5",userType,"pv10",cm_exAttr[0],"pv11",cm_exAttr[1],"pv12",cm_exAttr[2],"pv13",cm_exAttr[3],"pv14",cm_exAttr[4],"pv15",cm_exAttr[5],"cmAttributes",attributes,"cmExtraFields",extraFields]);
}

/*
 * Creates a Productview Tag
 * Also creates a Pageview Tag by setting pc="Y"
 * productID	: required. Product ID to set on this Productview tag
 * productName	: required. Product Name to set on this Productview tag
 */
function cmCreateProductviewTag(productID, productName, categoryID, attributes, cm_vc) {
	cmMakeTag(["tid","5","pi",c1(cm_ClientID) ? c1(cm_ClientID) : "Product: " + productName + " (" + productID + ")","pr",productID,"pm",productName,"cg",categoryID,"pc","Y","cm_vc",cm_vc?cm_vc:cmExtractParameter("cm_vc",document.location.href),"cmAttributes",attributes]);
}

/*
 * Creates a Shop tag with Action 5 (Shopping Cart)
 * productID	: required. Product ID to set on this Shop tag
 * quantity		: required. Quantity to set on this Shop tag
 * productPrice	: required. Price of one unit of this product
 */
function cmCreateShopAction5Tag(productID,productName,productQuantity,productPrice,categoryID,primaryRole,documentType,publishedDate,primaryAuthor,attributes,extraFields) {
	if ((typeof(cm_currencyCode) == "undefined") || (!cm_currencyCode)) {
		cm_currencyCode = "";
	}
    productPrice = productPrice.toString().replace(cmPricePattern, "");
	productID = productID.toString().replace(cmSpacePattern, "");
	var hashValue = "" + (attributes ? attributes + "|||" : "") + (extraFields ? "extra" + extraFields : "");
	cmAddShop(["pr",productID,"pm",productName,"qt",productQuantity,"bp",productPrice,"cg",categoryID,"sx1",primaryRole,"sx2",documentType,"sx3",publishedDate,"sx4",primaryAuthor,"cmAttributes",attributes,"cmExtraFields",extraFields,"ha1",cm_hex_sha1(hashValue),"cc",cm_currencyCode,"at","5","tid","4","pc","N"]);
}

/*
 * Creates a Shop tag with Action 9 (Order Receipt / Confirmed)
 * productID	: required. Product ID to set on this Shop tag
 * productName	: required. Product Name to set on this Shop tag
 * quantity		: required. Quantity to set on this Shop tag
 * productPrice	: required. Price of one unit of this product
 * customerID	: required. ID of customer making the purchase
 * orderID		: required. ID of order this lineitem belongs to
 * orderTotal	: required. Total price of order this lineitem belongs to
 */
function cmCreateShopAction9Tag(productID,productName,productQuantity,productPrice,customerID,orderID,orderTotal,categoryID,primaryRole,documentType,publishedDate,primaryAuthor,attributes,extraFields) {
	if ((typeof(cm_currencyCode) == "undefined") || (!cm_currencyCode)) {
		cm_currencyCode = "";
	}
    productPrice = productPrice.toString().replace(cmPricePattern, "");
	orderTotal = orderTotal.toString().replace(cmPricePattern, "");
	productID = productID.toString().replace(cmSpacePattern, "");
	var hashValue = "" + (attributes ? attributes + "|||" : "") + (extraFields ? "extra" + extraFields : "");
	cmAddShop(["pr",productID,"pm",productName,"qt",productQuantity,"bp",productPrice,"cg",categoryID,"sx1",primaryRole,"sx2",documentType,"sx3",publishedDate,"sx4",primaryAuthor,"cmAttributes",attributes,"cmExtraFields",extraFields,"ha1",cm_hex_sha1(hashValue),"cd",customerID,"on",orderID,"tr",orderTotal,"cc",cm_currencyCode,"at","9","tid","4","pc","N"]);
}

/*
 * Creates an Order tag
 * orderID			: required. Order ID of this order
 * orderTotal		: required. Total of this order (minus tax and shipping)
 * orderShipping	: required. Shipping charge for this order
 * customerID		: required. Customer ID that placed this order
 */
function cmCreateOrderTag(orderID,orderTotal,orderShipping,customerID,customerCity,customerState,customerZIP,customerCountry,attributes,extraFields) {
	if ((typeof(cm_currencyCode) == "undefined") || (!cm_currencyCode)) {
		cm_currencyCode = "";
	}
    orderShipping = orderShipping.toString().replace(cmPricePattern, "");
	orderTotal = orderTotal.toString().replace(cmPricePattern, "");	
	cmMakeTag(["tid","3","osk",cmCalcSKUString(),"on",orderID,"tr",orderTotal,"sg",orderShipping,"cd",customerID,"ct",customerCity,"sa",customerState,"zp",customerZIP,"or1",customerCountry,"cc",cm_currencyCode,"cmAttributes",attributes,"cmExtraFields",extraFields]);
}

/*
 * Creates a Registration tag and/or a Newsletter tag
 * customerID		: required for Registration. ID of Customer to register.
 * newsletterName	: required for Newsletters. The name of the Newsletter.
 * subscribe		: required for Newsletters. Either "Y" or "N"
 */
function cmCreateRegistrationTag(customerID, customerEmail, customerCity,
				customerState, customerZIP, Country, Role, newsletterName, 
				subscribe, attributes) {
	cmMakeTag(["tid","2","cd",customerID,"em",customerEmail,"ct",customerCity,"sa",customerState,"zp",customerZIP,"cy",Country,"rg11",Role,"nl",newsletterName,"sd",subscribe,"cmAttributes",attributes]);
}

var cmEndecaSearchTerm = new Array();
var cmEndecaDimension = new Array();
var cmEndecaDimensionValue = new Array();
var cmEndecaCounter = 0;
 
function cmCreateEndecaSearch(searchTerm, dimension, dimensionValue) {
	cmEndecaSearchTerm[cmEndecaCounter] = searchTerm;
	cmEndecaDimension[cmEndecaCounter] = dimension;
	cmEndecaDimensionValue[cmEndecaCounter] = dimensionValue;
	cmEndecaCounter++;
}
 
function cmDisplayEndecaSearch() {
	var i;
 
	var datestamp = new Date();
	var stamp = (Math.floor(Math.random() * 11111111)) + datestamp.valueOf();
 
	for(i=0; i<cmEndecaCounter;i++){
		cmMakeTag(["tid","7","li",10100,"ps1",cmEndecaSearchTerm[i],"ps2",cmEndecaDimensionValue[i],"ps3",cmEndecaDimension[i],"ps4",stamp]);
	}
	cmEndecaCounter = 0;
}
 
function cmCreateEndecaClick(searchTerm, dimension, dimensionValue) {
	cmEndecaSearchTerm[cmEndecaCounter] = searchTerm;
	cmEndecaDimension[cmEndecaCounter] = dimension;
	cmEndecaDimensionValue[cmEndecaCounter] = dimensionValue;
	cmEndecaCounter++;
}
 
function cmDisplayEndecaClick() {
	var i;
	var datestamp = new Date();
	var stamp = (Math.floor(Math.random() * 11111111)) + datestamp.valueOf();
	
	for(i=0; i<cmEndecaCounter;i++){
		cmMakeTag(["tid","7","li",10101,"ps1",cmEndecaSearchTerm[i],"ps2",cmEndecaDimensionValue[i],"ps3",cmEndecaDimension[i],"ps4",stamp]);
	}
	cmEndecaCounter = 0;
}

//-->
