<!--
/* $Revision: 79775 $
 * $Id: cmdatatagutils-master.txt 79775 2008-02-22 11:15:57Z hwhite $
 * $Workfile: cmdatatagutils.js $ 
 * $Log:$ 
 * cmdatatagutils.js
 *
 * Coremetrics Tag v4.0, 4/18/2004
 * COPYRIGHT 1999-2002 COREMETRICS, INC. 
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 *
 * The following functions aid in the creation of Coremetrics data tags.
 * Date			Modifier		Description
 * 7-Apr-2006	Hutch White		Added User Agent Filtering
 * 10/02/06		Hutch White		Add Custom Coupon Tags
 * 11/21/06		Hutch White		1st Party Migration
 * 050807		MOCHOA			Added Conversion Event Tag function
 * 02/22/08		Hutch White		Added auto techprops, moved client variables from eluminate
 * 03/10/08		Hutch White		Added cm.ul=document.URL
 */

var cm_ClientID = "90044918";
var cm_TrackLink = "A";
var cm_TrackImpressions = "S";

var cmJv = "1.0";
if (typeof(isNaN) == "function") cmJv = "1.1";
if (typeof(isFinite) == "function") cmJv = "1.2";
if (typeof(NaN) == "number") cmJv = "1.3";
if (typeof(decodeURI) == "function") cmJv = "1.5";
if (typeof(Array.forEach) == "function") cmJv = "1.6";
if (typeof(Iterator) == "object") cmJv = "1.7";

// TAG GENERATING FUNCTIONS ---------------------------------------------------

var cmGomezKeynoteFlag = "0";

if (cGN.indexOf("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; KTXN)") >= 0)
{
	var cmGomezKeynoteFlag = "1";
}

/*
 * Calling this function points tags to the production database
 */
function cmSetProduction(){
	cm_HOST="data.coremetrics.com/eluminate?"; 
}

function cmCreatePageElementTag(elementID, elementCategory, pageID, pageCategoryID, elementLocation) {
	var cm=new _cm("tid", "15", "vn2", "e4.0");
	
	cm.eid=elementID;
	cm.ecat=elementCategory;
	cm.pflg=0;
	cm.pid=pageID;
	cm.pcat=pageCategoryID;
	cm.eloc=elementLocation;
	
	cm.writeImg();
}

function cmCreateProductElementTag(elementID, elementCategory, productID, productCategoryID, elementLocation) {
	var cm=new _cm("tid", "15", "vn2", "e4.0");

	cm.eid=elementID;
	cm.ecat=elementCategory;
	cm.pflg=1;
	cm.pid=productID;	
	cm.pcat=productCategoryID;
	cm.eloc=elementLocation;
	
	cm.writeImg();
}

function cmCreateConversionEventTag(eventID, actionType, categoryID, points) {
	var cm = new _cm("tid", "14", "vn2", "e4.0");
	cm.cid = eventID;
	cm.cat = actionType;
	cm.ccid = categoryID;
	cm.cpt = points;
	cm.writeImg();
 }
 
function cmCreateManualImpressionTag(pageID, trackSP, trackRE) {
		var cm = new _cm("tid","9","vn2","e4.0");
		cm.pi = pageID;
		cm.cm_sp = trackSP;
		cm.cm_re = trackRE;
		cm.st = cm_ClientTS;
		cm.writeImg();
}

function cmCreateManualLinkClickTag(href,name,pageID) {	
	if (cmCreateLinkTag == null && cM != null) {
		var cmCreateLinkTag = cM;
	}
	if (cmCreateLinkTag != null) {		
		var dt = new Date();
		cmLnkT3 = dt.getTime();
		cmCreateLinkTag(cm_ClientTS, cmLnkT3, name, href, false, pageID);
	}
}

/* manual PageviewTag for off site page tagging.  Allows client to supply URL and Referring URL
*/
function cmCreateManualPageviewTag(pageID, categoryID,destinationURL,ReferringURL,searchTerm) {
	var cm = new _cm("tid","1","vn2","e4.0");
	cm.pi = pageID;
	cm.cg = categoryID;
	cm.ul = document.URL;
	cm.rf = ReferringURL;
	if (searchTerm) {
		cm.se=searchTerm;
	}
	cm.writeImg();
}

/*
 * Creates a Tech Props tag.
 * pageID		: required. Page ID to set on this Pageview tag
 */
function cmCreateTechPropsTag(pageID, categoryID) {
	if (pageID) {
		var cm=new _cm("tid", "6", "vn2", "e4.0");
		cm.pc="Y";
		cm.pi = pageID;
		cm.cg = categoryID;
		cm.ul = document.URL;		
		// if available, override the referrer with the frameset referrer
		if (parent.cm_ref != null) {
			cm.rf = parent.cm_ref;
			parent.cm_ref = document.URL;
		}
		// if parent had mmc variables and this is the first pageview, add mmc to this url
		if(parent.cm_set_mmc) {
			cm.ul = document.location.href + 
					((document.location.href.indexOf("?") < 0) ? "?" : "&") + 
					parent.cm_mmc_params; 
			parent.cm_ref = cm.ul;
			parent.cm_set_mmc = false;
		}
		cm.addTP();
		cm.writeImg();
	}
}

/*
 * Creates a Pageview tag with the given Page ID
 *
 * pageID		: required. Page ID to set on this Pageview tag
 * searchString	: optional. Internal search string enterred by user to reach
 *				  this page.
 * categoryID	: optional. Category ID to set on this Pageview tag
 * numberOfSearchResults   : optional.  The number of search results returned.
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreatePageviewTag(pageID, searchString, categoryID, numberOfSearchResults) {
	if (pageID == null) {
		pageID = getDefaultPageID();
	}

	var cm = new _cm("tid", "1", "vn2", "e4.0");
	
	if (cm.tid == "1") {
		if (cI("cmTPSet") != 'Y') {
			cm.tid = "6";
			cm.pc = "Y";
			cm.addTP();
			document.cookie = "cmTPSet=Y; path=/";
		}
	}
		
	cm.pi = pageID;
	if (searchString) {
		cm.se = searchString;
	}
	if (categoryID) {
		cm.cg = categoryID;
	}
	if (numberOfSearchResults) {
		cm.sr = numberOfSearchResults;
	}

	// if available, override the referrer with the frameset referrer
	if (parent.cm_ref != null) {
		cm.rf = parent.cm_ref;
		parent.cm_ref = document.URL;
	}
	cm.ul = document.URL;		
	// if parent had mmc variables and this is the first pageview, add mmc to this url
	if(parent.cm_set_mmc) {
		cm.ul = document.location.href + 
		((document.location.href.indexOf("?") < 0) ? "?" : "&") + 
		parent.cm_mmc_params; 
		parent.cm_ref = cm.ul;
		parent.cm_set_mmc = false;
	}
	cm.writeImg();
}

/*
 * Creates a Pageview tag with the default value for Page ID. 
 * Format of Page ID is "x/y/z/MyPage.asp"
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateDefaultPageviewTag() {
	cmCreatePageviewTag(getDefaultPageID(), null, null);
}

/*
 * Creates a Productview Tag
 * Also creates a Pageview Tag by setting pc="Y"
 * Format of Page ID is "PRODUCT: <Product Name> (<Product ID>)"
 *
 * productID	: required. Product ID to set on this Productview tag
 * productName	: required. Product Name to set on this Productview tag
 * categoryID	: optional. Category ID to set on this Productview tag 
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateProductviewTag(productID, productName, categoryID) {
	var cm = new _cm("tid", "5", "vn2", "e4.0");

	if (productName == null) {
		productName = "";
	}
	cm.ul = document.URL;		
	// if available, override the referrer with the frameset referrer
	if (parent.cm_ref != null) {
		cm.rf = parent.cm_ref;
		parent.cm_ref = document.URL;
	}
	// if parent had mmc variables and this is the first pageview, add mmc to this url
	if(parent.cm_set_mmc) {
		cm.ul = document.location.href + 
		((document.location.href.indexOf("?") < 0) ? "?" : "&") + 
		parent.cm_mmc_params; 
		parent.cm_ref = cm.ul;
		parent.cm_set_mmc = false;
	}

	cm.pr = productID;
	cm.pm = productName;
	cm.cg = categoryID;

	cm.pc = "Y";
	cm.pi = "PRODUCT: " + productName + " (" + productID + ")";

	cm.writeImg();
}

/*
 * Variables and Arrays to support Lineitem Aggregation
 */

var cmShopProducts = new Array();
var cmShopIds = new Array();
var cmShopCats = new Array();
var cmShopQtys = new Array();
var cmShopPrices = new Array();
var cmShopSKUs = new Array();
var cmShopCounter = 0;
var cmShopOrderIds = new Array();
var cmShopCustomerIds = new Array();
var cmShopOrderPrices = new Array();

/* Internal, to support aggregation */
function cmGetProductIndex(id){
	var i =0;
	for (i=0; i<cmShopCounter; i++)
	{
		if (id==cmShopIds[i])
		{
			return i;
		}
	}
	return -1;
}

/*
 * 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
 * categoryID	: optional. Category to set on this Shop tag
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateShopAction5Tag(productID, productName, productQuantity, productPrice, categoryID) {
	var index = cmGetProductIndex(productID);
	if(index!=-1){
		var oldPrice = cmShopPrices[index];
		var oldQty = cmShopQtys[index];
		var newQty = oldQty + parseInt(productQuantity);
		var newPrice = (oldPrice*oldQty + parseInt(productQuantity)*parseFloat(productPrice))/(newQty);

		cmShopPrices[index] = newPrice;
		cmShopQtys[index] = newQty;

	} else {
		if (!categoryID) {
			categoryID = "";
		}

		cmShopProducts[cmShopCounter] = productName;
		cmShopIds[cmShopCounter] = productID;
		cmShopCats[cmShopCounter] = categoryID;
		cmShopQtys[cmShopCounter] = parseInt(productQuantity);
		cmShopPrices[cmShopCounter] = parseFloat(productPrice);
		cmShopCounter++;
	}
}

/* render the aggregated cart lineitems with Shop 5 tags*/
function cmDisplayShop5s(){
	var i;
	for(i=0; i<cmShopCounter;i++){
		var cm = new _cm("tid", "4", "vn2", "e4.0");
		cm.at = "5";
		cm.pr = cmShopIds[i]; 
		cm.pm = cmShopProducts[i];
		cm.cg = cmShopCats[i];
		cm.qt = cmShopQtys[i] ;
		cm.bp = cmShopPrices[i];
		cm.pc = "N";
		cm.ul = document.URL;				
		cm.writeImg();
	}
	cmShopCounter=0;
}

/*
 * 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
 * categoryID	: optional. Category to set on this Shop tag
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateShopAction9Tag(productID, productName, productQuantity,
				productPrice, customerID, orderID,
				orderTotal, categoryID) {
	var index = cmGetProductIndex(productID);
	if(index!=-1){
		var oldPrice = cmShopPrices[index];
		var oldQty = cmShopQtys[index];
		var newQty = oldQty + parseInt(productQuantity);
		var newPrice = (oldPrice*oldQty + parseInt(productQuantity)*parseFloat(productPrice))/(newQty);

		cmShopPrices[index] = newPrice;
		cmShopQtys[index] = newQty;
		cmShopSKUs[index] = "|" + productID + "|" + newPrice + "|" + newQty + "|";
	} else {
		if (!categoryID) {
			categoryID = "";
		}
		cmShopProducts[cmShopCounter] = productName;
		cmShopIds[cmShopCounter] = productID;			
		cmShopOrderIds[cmShopCounter] = orderID;
		cmShopOrderPrices[cmShopCounter] = orderTotal;
		cmShopCustomerIds[cmShopCounter] = customerID;
		cmShopCats[cmShopCounter] = categoryID;
		cmShopQtys[cmShopCounter] = parseInt(productQuantity);
		cmShopPrices[cmShopCounter] = parseFloat(productPrice);
		cmShopSKUs[cmShopCounter] = "|" + productID + "|" + productPrice + "|" + productQuantity + "|";
		cmShopCounter++;
	}
}


/* render the aggregated order lineitems with Shop 9 tags*/
function cmDisplayShop9s(){
	var i;
	for(i=0; i<cmShopCounter;i++){
		var cm = new _cm("tid", "4", "vn2", "e4.0");
		cm.at = "9";
		cm.pr = cmShopIds[i]; 
		cm.pm = cmShopProducts[i];
		cm.cg = cmShopCats[i];
		cm.qt = cmShopQtys[i] ;
		cm.bp = cmShopPrices[i];
		cm.cd = cmShopCustomerIds[i];
		cm.on = cmShopOrderIds[i];
		cm.tr = cmShopOrderPrices[i];
		cm.ul = document.URL;		
		cm.pc = "N";
		cm.writeImg();
	}
	cmShopCounter=0;
}

/*
 * 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
 * customerCity		: optional. City of Customer that placed this order
 * customerState	: optional. State of Customer that placed this order
 * customerZIP		: optional. Zipcode of Customer that placed this order
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateOrderTag(orderID, orderTotal, orderShipping, customerID, 
			  customerCity, customerState, customerZIP) {
	
		var cm = new _cm("tid", "3", "vn2", "e4.0");
		cm.on = orderID;
		cm.tr = orderTotal;
		cm.osk = getOSK();
		cm.sg = orderShipping;
		cm.cd = customerID;
		cm.sa = customerState;
		cm.ct = customerCity;
		cm.zp = customerZIP;
		cm.ul = document.URL;		
		cm.writeImg();
	
}

function getOSK() {
	var i =0;
	var result = "";
	for (i=0; i<cmShopCounter; i++)
	{
		result += cmShopSKUs[i];
	}
	return result;
}

/*
 * Creates a Registration tag and/or a Newsletter tag
 *
 * customerID		: required for Registration. ID of Customer to register.
 * customerEmail	: required for Newsletters. Optional for Registration.
 * customerCity		: optional. City of Customer that placed this order
 * customerState	: optional. State of Customer that placed this order
 * customerZIP		: optional. Zipcode of Customer that placed this order
 * newsletterName	: required for Newsletters. The name of the Newsletter.
 * subscribe		: required for Newsletters. Either "Y" or "N"
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateRegistrationTag(customerID, customerEmail, customerCity,
				customerState, customerZIP, newsletterName, 
				subscribe) {
	var cm = new _cm("tid", "2", "vn2", "e4.0");
	cm.cd = customerID;
	cm.em = customerEmail;
	cm.sa = customerState;
	cm.ct = customerCity;
	cm.zp = customerZIP;
	cm.ul = document.URL;		
	if (newsletterName && subscribe) {
		cm.nl = newsletterName;
		cm.sd = subscribe;
	}
	
	cm.writeImg();
}

/* Creates an Error Tag
 *
 * returns nothing, causes a document.write of an image request for this tag.
 */
function cmCreateErrorTag() {
	var cm=new _cm("tid", "404", "vn2", "e4.0");  //DO NOT CHANGE THESE PARAMETERS
	
	// get the referrer from the frameset
	if (parent.cm_ref != null) {
		cm.rf = parent.cm_ref;
		parent.cm_ref = document.URL;
	}
	cm.ul = document.URL;		
	// if parent had mmc variables and this is the first pageview, add mmc to this url
	if(parent.cm_set_mmc) {
		cm.ul = document.location.href + 
		((document.location.href.indexOf("?") < 0) ? "?" : "&") + 
		parent.cm_mmc_params; 
		parent.cm_ref = cm.ul;
		parent.cm_set_mmc = false;
	}

	cm.pc = "Y";
	cm.pi = getDefaultPageID();
	cm.writeImg();
}


// CUSTOM TAGS ---------------------------------------------------------------
/* The cmCreateXSellShopAction5Tag and cmCreateXSellShopAction9Tag work to populate
 * the data for the Toshiba Cross Sell Custom Report.  They will use the category ID 
 * that should be generatored for Cross Sell Heirarchy
 */

 /*
 * Creates a Cross Sell Shop 5 tag
 * primaryProductID:	Primary Product ID
 * primaryProductName:	Primary Product Name
 * originalCategoryID:	Original/standard category ID for the primary product within the 
 *			standard heirarchy.
 * crossProdID:		Cross Sold Item Product ID
 * crossProdName:	Cross Sold Item Product Name
 * crossProdQuantity:	Number of the cross sold item added to cart
 * crossProdPrice:	Price for the cross sold item
 * crossCategoryID:	Cross Sell category ID
 */


 // Variable Arrays to support line item aggregation for Cross Sold Tags

var cmPrimaryID				= new Array();
var cmPrimaryProductName	= new Array();
var cmPrimaryCatID			= new Array();
var cmCrossProductName		= new Array();
var cmCrossIDs				= new Array();
var cmCrossCats				= new Array();
var cmCrossQtys				= new Array();
var cmCrossPrices			= new Array();
var cmCrossCustomerID		= new Array();
var cmCrossOrderID			= new Array();
var cmCrossOrderTotal		= new Array();

var cmCrossCounter = 0;

var cmCrossSKUs = "";

/* Internal, to support aggregation */
function cmGetCrossIndex(id){
	var i =0;
	for (i=0; i<cmCrossCounter; i++)
	{
		if (id==cmCrossIDs[i])
		{
			return i;
		}
	}
	return -1;
}


function cmCreateXSellShopAction5Tag(     primaryProdID
					, primaryProdName
					, primaryCatID
					, crossProdID
					, crossProdName
					, crossProdQuantity
					, crossProdPrice
					, crossProdCatID
					) {

	crossProdID = crossProdID.toUpperCase();
	primaryProdID = primaryProdID.toUpperCase();

	var index = cmGetCrossIndex(crossProdID);
	if(index!=-1){
		var oldPrice = cmCrossPrices[index];
		var oldQty = cmCrossQtys[index];
		var newQty = oldQty + parseInt(crossProdQuantity);
		var newPrice = (oldPrice*oldQty + parseInt(crossProdQuantity)*parseFloat(crossProdPrice))/(newQty);

		cmCrossPrices[index] = newPrice;
		cmCrossQtys[index] = newQty;
	} else {
		if (!primaryCatID) {
			primaryCatID = "";
		}
		if (!crossProdCatID){
			crossProdCatID = "";
		}

		cmPrimaryID[cmCrossCounter] = primaryProdID;
		cmPrimaryProductName[cmCrossCounter] = primaryProdName;
		cmPrimaryCatID[cmCrossCounter] = primaryCatID;
		cmCrossProductName[cmCrossCounter] = crossProdName;
		cmCrossIDs[cmCrossCounter] = crossProdID;
		cmCrossCats[cmCrossCounter] = crossProdCatID;
		cmCrossQtys[cmCrossCounter] = parseInt(crossProdQuantity);
		cmCrossPrices[cmCrossCounter] = parseFloat(crossProdPrice);

		cmCrossCounter++;

	}

}
/* render the aggregated cart lineitems with Shop 5 tags*/
function cmDisplayCrossShop5s(){
	var i;
	for(i=0; i<cmCrossCounter; i++){
		var cm = new _cm("tid", "7", "vn2", "e4.0");
		cm.li = 1;
		cm.ps1 = cmPrimaryID[i]; 
		cm.ps2 = cmPrimaryProductName[i];
		cm.ps3 = cmPrimaryCatID[i] ;
		cm.ps4 = cmCrossIDs[i];
		cm.ps5 = cmCrossProductName[i];
		cm.ps6 = cmCrossCats[i];
		cm.ps7 = cmCrossQtys[i];
		cm.ps8 = cmCrossPrices[i];
		cm.ul = document.URL;		
		cm.writeImg();
	}
	cmCrossCounter=0;
}

/*
 * Creates a Cross Sell Shop 9 tag
 * primaryProductID:	Primary Product ID
 * primaryProductName:	Primary Product Name
 * originalCategoryID:	Original/standard category ID for the primary product within the 
 *			standard heirarchy.
 * crossProdID:		Cross Sold Item Product ID
 * crossProdName:	Cross Sold Item Product Name
 * crossProdQuantity:	Number of the cross sold item added to cart
 * crossProdPrice:	Price for the cross sold item
 * customerID:	Customer ID for order (should match standard shop 9 tag)
 * orderID:	Order ID given to order (should match standard shop 9 tag)
 * orderTotal:  Order Sub Total
 * crossCategoryID:	Cross Sell category ID
 */

function cmCreateXSellShopAction9Tag( primaryProductID
				, primaryProductName
				, primaryProdCatID
				, crossProdID
				, crossProdName
				, crossProdQty
				, crossProdPrice
				, crossCustomerID
				, crossOrderID
				, crossOrderTotal
				, crossProdCatID
				) {
	var index = cmGetCrossIndex(crossProdID);
	if(index!=-1){
		var oldPrice = cmCrossPrices[index];
		var oldQty = cmCrossQtys[index];
		var newQty = oldQty + parseInt(crossProdQty);
		var newPrice = (oldPrice*oldQty + parseInt(crossProdQty)*parseFloat(crossProdPrice))/(newQty);

		cmCrossPrices[index] = newPrice;
		cmCrossQtys[index] = newQty;
		//cmShopSKUs[index] = "|" + productID + "|" + newPrice + "|" + newQty + "|";
	} else {
		if (!primaryProdCatID) {
			primaryProdCatID = "";
		}
		if (!crossProdCatID) {
			crossProdCatID = "";
		}
		cmPrimaryID[cmCrossCounter] = primaryProductID;
		cmPrimaryProductName[cmCrossCounter] = primaryProductName;
		cmPrimaryCatID[cmCrossCounter] = primaryProdCatID;
		cmCrossProductName[cmCrossCounter] = crossProdName;
		cmCrossIDs[cmCrossCounter] = crossProdID;
		cmCrossCats[cmCrossCounter] = crossProdCatID;
		cmCrossQtys[cmCrossCounter] = parseInt(crossProdQty);
		cmCrossPrices[cmCrossCounter] = parseFloat(crossProdPrice);
		cmCrossCustomerID[cmCrossCounter] = crossCustomerID;
		cmCrossOrderID[cmCrossCounter] = crossOrderID;
		cmCrossOrderTotal[cmCrossCounter] = parseFloat(crossOrderTotal);

		cmCrossCounter++;
	}
}


/* render the aggregated order lineitems with Cross Sell 9 tags*/
function cmDisplayCrossShop9s(){
	var i;
	for(i=0; i<cmCrossCounter;i++){
		var cm = new _cm("tid", "7", "vn2", "e4.0");
		cm.li = "2";
		cm.ps1 = cmPrimaryID[i]; 
		cm.ps2 = cmPrimaryProductName[i];
		cm.ps3 = cmPrimaryCatID[i] ;
		cm.ps4 = cmCrossIDs[i];
		cm.ps5 = cmCrossProductName[i];
		cm.ps6 = cmCrossQtys[i];
		cm.ps7 = cmCrossPrices[i];
		cm.ps8 = cmCrossCustomerID[i];
		cm.ps9 = cmCrossOrderID[i];
		cm.ps10 = cmCrossOrderTotal[i];
		cm.ps11 = cmCrossCats[i];
		cm.ul = document.URL;				
		cm.writeImg();
	}
	cmCrossCounter=0;
}

/* Creates a Custom SourceCode Tag
 * sourceCode	: required for tracking source codes
 * returns nothing, causes a document.write of an image request for this tag.
 * 
 */
function cmCreateSourceCodeTag(sourceCode) {
	var cm=new _cm("tid", "7", "vn2", "e4.0");  //DO NOT CHANGE THESE PARAMETERS
	
	// get the referrer from the frameset
	if (parent.cm_ref != null) {
		cm.rf = parent.cm_ref;
		parent.cm_ref = document.URL;
	}
	cm.pc = "N";
	cm.li = "200002"
	if (sourceCode) {cm.ps1 = sourceCode;}
	cm.ul = document.URL;			
	cm.writeImg();
}

/* Creates a Custom Coupon Tag - This tag should be thrown when a coupon is registered
 * couponCode : Coupon code value.  One per tag.
 * sourceCode	: required for tracking coupons
 * returns nothing, causes a document.write of an image request for this tag.
 * 
 */
function cmCreateCouponTag(couponCode) {
	var cm=new _cm("tid", "7", "vn2", "e4.0");  //DO NOT CHANGE THESE PARAMETERS
	cm.li = "10";
	if (couponCode) {cm.ps1 = couponCode;}
	cm.ul = document.URL;			
	cm.writeImg();
}

/* Creates a Custom Coupon Order Tag - This tag should be thrown for every coupon used for an order tag.  Throw these tags on same page as order tag.
 * orderID : same value as used in the order tag
 * couponCode : Coupon code Value.  One value per tag
 * sourceCode	: required for tracking coupons
 * returns nothing, causes a document.write of an image request for this tag.
 * 
 */
function cmCreateCouponOrderTag(couponCode,orderID) {
	var cm=new _cm("tid", "7", "vn2", "e4.0");  //DO NOT CHANGE THESE PARAMETERS
	cm.li = "11";
	if (couponCode) {cm.ps1 = couponCode;}
	if (orderID) {cm.ps2 = orderID;}
	cm.ul = document.URL;			
	cm.writeImg();
}

// HELPER FUNCTIONS -----------------------------------------------------------
/* These functions are used by the tag-generating functions and/or may be used
 * in in general as convenience functions
 */

/*
 * Creates an acceptable default Page ID value to use for Pageview tags.
 * The default Page ID is based on the URL, and consists of the path and
 * filename (without the protocol, domain and query string).
 * 
 * example:
 * returns "x/y/MyPage.asp" for the URL http://www.mysite.com/x/y/MyPage.asp
 */
function getDefaultPageID() { 
	var pageName = window.location.pathname; 

	// eliminates everything after "?" (for Opera browswers)
	var tempIndex1 = pageName.indexOf("?");
	if (tempIndex1 != -1) {
		pageName = pageName.substr(0, tempIndex1);
	}
	// eliminates everything after "#" (for Opera browswers)
	var tempIndex2 = pageName.indexOf("#");
	if (tempIndex2 != -1) {
		pageName = pageName.substr(0, tempIndex2);
	}
	// eliminates everything after ";"
	var tempIndex3 = pageName.indexOf(";");
	if (tempIndex3 != -1) {
		pageName = pageName.substr(0, tempIndex3);
	}

	var slashPos = pageName.lastIndexOf("/");
	if (slashPos == pageName.length - 1) {
		pageName = pageName + "default.asp"; /****************** SET TO DEFAULT DOC NAME */
	}

	while (pageName.indexOf("/") == 0) {
		pageName = pageName.substr(1,pageName.length);
	}

	return(pageName); 
} 

var jvPrefix = "javascript:";
var mailPrefix = "mailto:";
var blackList = [	"false",
			"true",
			"%20false",
			"%20true"
			];
if (defaultNormalize == null) { var defaultNormalize = null; }



function myNormalizeURL(url, isHref) {
    var newURL = url;

    if (isHref) {

	    var paramString;
	    var paramIndex = newURL.indexOf("?");
	    var lastParamIndex = newURL.indexOf("#");
	    var anchor = "";
	    var params;
	    var keepParams = new Array();
	    var goodParam;    

	    if (newURL.indexOf(mailPrefix) == 0) {
		newURL = "mailto:";
	    } else if (newURL.toLowerCase().indexOf(jvPrefix) == 0) { 

		if(newURL.indexOf("javascript:validateForm") == 0) {
			paramIndex = newURL.indexOf("(");
			lastParamIndex = newURL.indexOf(")");
			paramString = newURL.substring(paramIndex+1, lastParamIndex);
			//paramString = myNormalizeURL(paramString, true);

			params = paramString.split(",");
			for(var i=0; i<params.length; i++) {
				goodParam = true;
				for(var j=0; j<blackList.length; j++) {
					if (params[i].indexOf(blackList[j]) == 0) {
						goodParam = false;
					}
				}
				if(goodParam == true) {
					keepParams[keepParams.length] = params[i];
				}
			}
			paramString = keepParams.join("&");


			newURL = "javascript:validateForm(" + paramString + ")";
		} 

	    } else {
	    	
		    if (paramIndex >= 0) {
			if(lastParamIndex >= 0) {
				paramString = newURL.substring(paramIndex+1, lastParamIndex);
				anchor = newURL.substring(lastParamIndex);
			} else {
				paramString = newURL.substring(paramIndex+1);
			}

			newURL = newURL.substring(0, paramIndex);
			params = paramString.split("&");
		
			for(var i=0; i<params.length; i++) {
				goodParam = true;
				for(var j=0; j<blackList.length; j++) {
					if (params[i].indexOf(blackList[j]) == 0) {
						goodParam = false;
					}
				}
				if(goodParam == true) {
					keepParams[keepParams.length] = params[i];
				}
			}
			
			newURL += "?" + keepParams.join("&");
			newURL += anchor;
		
		    }
	    }	  
	 
	    if (defaultNormalize != null) {
		newURL = defaultNormalize(newURL, isHref);
	    }
	}	
    return newURL;
}

// install normalization
if (document.cmTagCtl != null) {
    var func = "" + document.cmTagCtl.normalizeURL;
    if (func.indexOf('myNormalizeURL') == -1) {
        defaultNormalize = document.cmTagCtl.normalizeURL;
        document.cmTagCtl.normalizeURL = myNormalizeURL;
    }
}

//-->
