/*
 * cmdatatagutils.js for IBM Websphere Commerce
 * $Id: cmdatatagutils -MASTER.txt 151890 2010-07-14 15:28:15Z etowb $
 * $Revision: 151890 $
 *
 * Version 4.2.0
 *
 * Coremetrics Tag v4.0, 8/7/2006
 * COPYRIGHT 1999-2002 COREMETRICS, INC. 
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 *
 * The following functions aid in the creation of Coremetrics data tags.
 *
 * 05/14/09	LHIBBARD		Setup catIDoverride to be used as cm_vc
 * 06/05/09	LHIBBARD		Moved catIDoverride to 8th parameter by adding dummyParm
 * 09/05/09	MESTES			Enable io_v4.js
 * 05/03/10 YHUNT			Added "review" parameter to registration tag per ticket 10015491
 * 07/02/10	CROBERTS		Turned off track impressions as they were not tracking them before
 * 07/12/10	ABRINK			CUSTOM: Do not collect Shop5 and Shop9 when Base Price <= 0.01
 * 07/14/10	ETOWB			Updated for new test system
 */

var cm_exAttr=new Array;  
var cm_ClientID = "60203636";
var cm_HOST="testdata.coremetrics.com/cm?"
var cm_TrackLink = "A";
var cm_TrackImpressions = "";
var cm_JSFEnabled = false;

//
// IO V4 NewPig Configuration
// 
// The following variables are global to io_v4.js
// 
if (typeof(IORequest) == "function")
{
   IORequest.client_id           = cm_ClientID;  // client id
   IORequest.encrypt_cats        = true;         // stores categories as 8 digit hex numbers (use if site has long category names)
   IORequest.encrypt_prds        = true;         // stores products as 8 digit hex numbers (use if site has long product names) 
   IORequest.conflict_resolution = true;         // for pages with multiple zones - a recommendation appearing in zone 1 will be filtered out from zone 2
   IORequest.max_prd_length      = 25;           // products with lengths longer than this number will be ignored
   IORequest.max_cat_length      = 25;           // categories with lengths longer than this number will be ignored
   IORequest.timeout             = [8000, 4000]; // timeout for download of product file [first, subsequent] (ms)
   IORequest.use_site_category   = false;        // a site category is the one passed on cmCreate[Page|Product]Tag
                                                 // a non site category is passed in the product files
   // 
   // IORequest.a_max_elements - the sizes of the arrays stored in the IO cookie.  The sizes should 
   // be kept to a minimum to reduce the length of the IO cookie.  
   // 
   // The arrays we are keeping are:
   //
   //  0 pv: order in which products are viewed 
   //  1 pc: order in which products are carted
   //  2 pp: order in which products are purchased
   //  3 cv: order in which categories are viewed
   //  4 cn: the number of views of each corresponding category in the cv array
   //  5 bv: order in which brands are viewed
   //  6 bn: the number of views of each corresponding brand in the cv array
   //
   // IORequest.a_max_elements 
   //
   // Note that the size of the cn array (element 4) and the size of the cv (element 3) are the same 
   // (in the default case 10).  This means we are keeping an array of the last 10 categories
   // viewed and a separate array of the number of times each of the categories was viewed.
   //
   if ((IORequest.ie_version() !== null) && (IORequest.ie_version() < 7.0))
   {
      IORequest.a_max_elements = [3,3,5,3,3,3,3];
   }
   else
   {
      IORequest.a_max_elements = [3,3,5,3,3,7,7];
   }

   //
   // In product files, 5 customer specified attributes are supported.  By default, those are:
   //
   // 1 - product description
   // 2 - url to product page (for anchor tag)
   // 3 - price
   // 4 - rating (1 to 5 stars)
   // 5 - url to image
   //
   // The array below specifies which of these attributes are required.  If an attribute
   // is required but is not passed in the product file, the corresponding recommendation
   // will not be passed to the zone population function.
   //
   IORequest.required_attributes  = [1,0,0,0,0];

   //
   // Access method 
   //
   // 'json remote' or 'ajax remote'
   //
   // 'ajax remote' is the recommended access method if the clients server can be configured
   // to allow remote servers to be mapped into the space of the local server (such as the Proxypass
   // directive in Apache).
   //
   // The directive to use in Apache is:
   //
   // ProxyPass /limelight/ http://coremetric.vo.llnwd.net/o33/
   // 
   // this will allow cross domain ajax requests to our Content Delivery Network.
   //
   // see: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass for details
   //
   // Both 'json remote' and 'ajax remote' return identical files.  'ajax remote' is recommended
   // due to its ability to handle 404's.  To be specific, in the case of a "file not found" error, 
   // 'json remote' waits for a timeout to occur before proceeding which may be up to 2 seconds
   // (configurable above), while 'ajax remote' will respond with a 404 which may return in milliseconds.
   // For content which is available, response times are similar.
   //
   IORequest.access_method             = 'json remote';

   //
   // Default product file JSON object that defines the recommendations to be used if communications fail
   //
   // Example:
   //
   // IORequest.default_product_file = {"hd":["20090603162001","90110130","P","82","V4",12],"pd":[["FUCO-02",0,"MC-10007","MODERN OCCASIONAL TABLE","10027","245.79","4","FUCO_02.jpg"],["FUCO-03",81610.37,"MC--1","TWO-DRAWER COFFEE TABLE","10029","247.89","4","FUCO_03.jpg"],["FUCO-01",70950.58,"MC-10007","SLEEK OCCASIONAL TABLE","10025","380.10","3","FUCO_01.jpg"],["FUDE-03",67009.54,"MC-10006","STUDENTS DESK","10023","349.99","3","FUDE_03.jpg"],["FUDE-01",51750.44,"MC--1","EXECUTIVE SIX-DRAWER DESK","10019","849.99","2","FUDE_01.jpg"],["FUDEL-04",41030.65,"MC-10009","ADJUSTABLE DESK LAMP","10043","62.59","4.5","FUDEL_04.jpg"],["FUOF-04",37794.1,"MC--1","SPINDLE BACK CHAIR","10015","99.99","2","FUOF_04.jpg"],["FUDE-02",32265.93,"MC-10006","CRAFT TABLE","10021","259.99","4","FUDE_02.jpg"],["FUTA-01",22503.76,"MC-10008","MOCHA LINEN TABLE LAMP","10031","39.99","3","FUTA_01.jpg"],["FUDEL-03",14126.68,"MC-10009","LAMPE DE BUREAU ? COL DE CYGNE","10041","60.49","4.5","FUDEL_03.jpg"],["FUOF-05",12756.14,"MC-10005","Silver Metallic Straight Back Chair","10017","67.99","4.5","FUOF_05.jpg"],["FUTA-02",11456.86,"MC-10008","BEIGE LINEN TABLE LAMP","10033","28.99","4","FUTA_02.jpg"]],"ap":["","//websphere.lab.dfw.coremetrics.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10001&storeId=10001&productId=","$","","//websphere.lab.dfw.coremetrics.com/wcsstore/ConsumerDirect/images/catalog/"]};
   //
   // note: this should be assigned by a Coremetrics implementation engineer.  
   //
   // It entails downloading a product file and inserting the JSON object that makes up that product file.  The example
   // above shows the expected format.  (the URL of the file can be obtained using a firebug enabled version of FireFox and and 
   // checking the debug output as displayed in the console tab of FireFox).
   //
   IORequest.default_product_file = undefined;
}

// code to determine javascript version
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";

var cmCheckCMEMFlag = true;
var cmSendOSLinkClickTag = true;

function cmSetProduction(){
	cm_HOST="www9.newpig.com/cm?";
	cm_ClientID = "90203636";
//	cm_JSFPCookieDomain = "somedomain.com";
}

 function cmCreateConversionEventTag(eventID, actionType, categoryID, points,attributes) {
 	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
	cmMakeTag(["tid","14","cid",eventID,"cat",actionType,"ccid",categoryID,"cpt",points,"cm_exAttr",cm_exAttr]);
}

function cmCreatePageviewTag(__pi,__cg,__se,__sr, store_id, attributes) {
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}	
	cmMakeTag(["tid","1","pi",__pi,"cg",__cg,"se",__se,"sr",__sr,"pc","Y","pv11",store_id,"cm_exAttr",cm_exAttr]);
}

function cmCreateDefaultPageviewTag(__cg) {
	cmCreatePageviewTag(cmGetDefaultPageID(),__cg);
}

function cmCreateProductviewTag(__pi,__pr,__pm,__cg,store_id,pageCount,dummyParm,catIDoverride,attributes) {
	if (catIDoverride)	{
		if (catIDoverride != "0") {				// allows client to override WSC auto-catID value if catIDoverride is not null or "0"
		__cg = catIDoverride;
		}
	}
	if ((pageCount == null) || pageCount == "") {
		pageCount = 'Y';
	}
	if ((__pi == null) || (__pi == "") || (pageCount == "N")) {
		__pi = cG7.cM0[cm_ClientID];
	}	
	if (attributes){	// send attributes as 2nd JSP extraparms= value
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
	cmMakeTag(["tid","5","pi",__pi,"pr",__pr,"pm",__pm,"cg",__cg,"pc",pageCount,"pv11",store_id,"li","1010","ps1",store_id,"ps2",__pr,"ps3",__cg,"cm_vc",catIDoverride,"cm_exAttr",cm_exAttr]);
	cmMakeTag(["tid","7","li","11000","ps1",__pr]);
}

var __sArray = new Array();
var __skuString = "";
var __ex=new Array();
function __cmGetPI(__id){
	var __pI;
	for (__pI = 0; __pI < __sArray.length; ++__pI) {
		if (__id == __sArray[__pI][1]) return __pI;
	}
	return -1;
}

function __cmGetPIPC(__pr,__cg) {
	var __pI, i;
	var cmAttr1=new Array();
	var cmAttr2=new Array();
	for (i=0;i<__ex.length;++i){
		cmAttr1=cmAttr1+__ex[i];
	}		
	for (__pI = 0; __pI < __sArray.length; ++__pI) {
		if (__ex.length>0){
			cmAttr2=new Array();		
			for (i=__sArray[__pI].length-__ex.length*2+1;i<__sArray[__pI].length;i=i+2){
				cmAttr2=cmAttr2+__sArray[__pI][i];
			}
	
			if (__pr == __sArray[__pI][1] && __cg == __sArray[__pI][9] && cmAttr1==cmAttr2){
				return __pI;
			}
		} else {
		if (__pr == __sArray[__pI][1] && __cg == __sArray[__pI][9]) return __pI;
	}
	}	
	return -1;
}

function cmAddShop(__v) {

	var __i = __cmGetPIPC(__v[1],__v[9]);
	if (__i == -1) {
		if (__ex.length>0){
			for (var i=0; i<__ex.length; ++i){
				__v[__v.length]="s_a"+(i+1);
				__v[__v.length]=__ex[i];
			}
		}
		__sArray[__sArray.length] = __v;
	}
	else {
		var __oQ = __sArray[__i][5];
		var __oP = __sArray[__i][7];
		__sArray[__i][5] = parseInt(__sArray[__i][5]) + parseInt(__v[5]);
		__sArray[__i][7] = (((__v[7]*__v[5])+(__oP*__oQ))/__sArray[__i][5]);
	}
}

function cmCreateShopAction5Tag(__pr,__pm,__qt,__bp,__cg, store_id, currency, catIDoverride,attributes) {
	if (__bp > 0.01)  {
		if (catIDoverride)	{
			if (catIDoverride != "0") {				// allows client to override WSC auto-catID value if catIDoverride is not null or "0"
			__cg = catIDoverride;
		}
		} 
		var cm_slotNum;
		if (attributes){
			__ex=attributes.split("-_-");
		} else {
		__ex=new Array();
		}	
		cmAddShop(["pr",__pr,"pm",__pm,"qt",__qt,"bp",__bp,"cg",__cg,"at","5","tid","4","pc","N","sx11",store_id,"cc",currency,"li","11000","ps1",__pr]);
	}
}

function cmCreateShopAction9Tag(__pr,__pm,__qt,__bp,__cd,__on,__tr,__cg, store_id, currency, account_name, contract_name, catIDoverride,attributes) {
	if (__bp > 0.01)  {
		if (catIDoverride)	{
			if (catIDoverride != "0") {				// allows client to override WSC auto-catID value if catIDoverride is not null or "0"
			__cg = catIDoverride;
		}		
		}	  
		var cm_slotNum;	  
		if (attributes){
			__ex=attributes.split("-_-");
		} else {
		__ex=new Array();
		}
		cmAddShop(["pr",__pr,"pm",__pm,"qt",__qt,"bp",__bp,"cg",__cg,"cd",__cd,"on",__on,"tr",__tr,"at","9","tid","4","pc","N","sx11",store_id,"cc",currency,"sx13",account_name,"sx14",contract_name,"li","11000","ps1",__pr]);
		cmCalcSKUString();
	}
}

function cmDisplayShop5s() {
	cmDisplayShops();
}

function cmDisplayShop9s() {
	cmCalcSKUString();
	cmDisplayShops();
}

function cmCalcSKUString() {
	__skuString = "";
	for (i = 0; i < __sArray.length; ++i) {
		__skuString += "|"+__sArray[i][1]+"|"+__sArray[i][7]+"|"+__sArray[i][5]+"|";
	}
}

function cmDisplayShops() {
	var i;
	for (i = 0; i < __sArray.length; ++i) {
		for (var l=0;l<__sArray[i].length;++l){
			if (__sArray[i][l]=="sn"){
				__sArray[i][l+1]=i.toString();
			}
		}
		cmMakeTag(__sArray[i]);
	}
	__sArray = new Array();
}

function cmCreateOrderTag(__on,__tr,__sg,__cd,__ct,__sa,__zp, store_id, currency, promotion_name, promotion_discount, promotion_code, attributes) {
	if (((promotion_code == null) || (promotion_code == "")) && promotion_name) { promotion_code = "No Code"; } 
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
    cmMakeTag(["tid","3","osk",__skuString,"on",__on,"tr",__tr,"sg",__sg,"cd",__cd,"ct",__ct,"sa",__sa,"zp",__zp,"or11",store_id,"cc",currency,"or13",promotion_name,"or14",promotion_discount,"or15",promotion_code,"cm_exAttr",cm_exAttr]);
}

function cmCreateRegistrationTag(__cd,__em,__ct,__sa,__zp,__nl,__sd, store_id, customer_country, age, gender, marital_status, num_children, num_in_household, company_name, hobbies, income, review) {

	if (review) {                     

            marital_status = review;

      } else {

            marital_status = null; }

	cmMakeTag(["tid","2","cd",__cd,"em",__em,"ct",__ct,"sa",__sa,"zp",__zp,"nl",__nl,"sd",__sd,"rg1",store_id,"cy",customer_country,"ag",age,"gd",gender,"rg11",marital_status,"rg12",num_children,"rg13",num_in_household,"rg14",company_name,"rg15",hobbies,"ml",income]);
}

function cmCreateErrorTag(__pi,__cg, store_id,attributes) {	
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
	cmMakeTag(["tid","404","pi",__pi,"cg",__cg,"pc","Y","pv1",store_id,"cm_exAttr",cm_exAttr]);
}

function cmGetDefaultPageID () {
	var __p = window.location.pathname;
	var __t1 = __p.indexOf("?");
	if (__t1 != -1) __p = __p.substr(0, __t1);
	var __t2 = __p.indexOf("#");
	if (__t2 != -1) __p = __p.substr(0, __t2);
	var __t3 = __p.indexOf(";");
	if (__t3 != -1) __p = __p.substr(0, __t3);
	var __sp = __p.lastIndexOf("/");
	if (__sp == __p.length - 1) {
		__p = __p + "default.asp"; /* SET TO DEFAULT DOC NAME */
	}
	while (__p.indexOf("/") == 0) {
		__p = __p.substr(1,__p.length);
	}
	return(__p);
}

function cmMakeTag(__v) {
	var cm = new _cm("vn2", "e4.0");
	var i;
	for (i = 0; i < __v.length; i += 2) {
		var _n = __v[i];
		var _v = __v[i + 1];
		cm[_n] = _v;
	}

	var datestamp = new Date();	
	var stamp = (Math.floor(Math.random() * 11111111)) + datestamp.valueOf();	
	cm.rnd = stamp;
	
	if (cm.tid == "6") {
		cm.addTP();
		document.cookie = "cmTPSet=Y; path=/";
	}

	if (cm.tid == "1") {
		if (cI("cmTPSet") != 'Y') {
			cm.tid = "6";
			cm.pc = 'Y';
			cm.addTP();
			document.cookie = "cmTPSet=Y; path=/";
		}
	}

	if (cm.tid != "4" && typeof(cm.cm_exAttr)!="undefined"){
		switch(cm.tid){
			case "6":
				prefix="pv";
				break;
			case "1":
				prefix="pv";
				break;
			case "2":
				prefix="rg";
				break;
			case "5":
				prefix="pr";
				break;
			case "3":
				prefix="o";
				break;
			case "14":
				prefix="c";
				break;
			case "15":
				prefix="e";
				break;
			default:
				break;
		}		
		var attrNum=cm.cm_exAttr.length;
		if (attrNum>15){
			attrNum=15;
		}
		for (i=0;i<attrNum;i++){
			if (cm.tid == "2"){
				Attval=prefix+(i+1);
			} else {
				Attval=prefix+"_a"+(i+1);
			}
			cm[Attval]=cm.cm_exAttr[i];
		}
		cm.cm_exAttr=null;
	}	
	if ((cm.pi == null) && (cm.pc == "Y")) {
		cm.pi = cmGetDefaultPageID();
	}

	try{
	if (parent.cm_ref != null) {
		cm.rf = parent.cm_ref;
		if (cm.pc == "Y") {
			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; 
		if (cm.pc == "Y") {
			parent.cm_ref = cm.ul;
			parent.cm_set_mmc = false;
		}
	}
	}
	catch(err){}

	if (!(cm.ul)) {
		cm.ul = document.location.href;
	}
	if (!(cm.rf)) {
		cm.rf = document.referrer;
	}

	cm.ul = cmRemoveParameter("krypto",cm.ul);
	cm.rf = cmRemoveParameter("krypto",cm.rf);

	if (cmCheckCMEMFlag){cmStartTagSet();}
    cm.writeImg();
	if (cmCheckCMEMFlag) {
		cmCheckCMEM();
		cmCheckCMEMFlag = false;
		cmSendTagSet();	
	}

	//check to see if we fire link click for email campaign (cm_cr)
	if (cmSendOSLinkClickTag) {
		if ((window.location.href.indexOf("cm_cr=OS:") > -1) || (window.location.href.indexOf("cm_cr=OS%3A") > -1) || (window.location.href.indexOf("cm_cr=OS%3a") > -1)) {
			var tempHref = window.location.href;
			tempHref = tempHref.split("cm_cr=OS:").join("cm_cr=");
			tempHref = tempHref.split("cm_cr=OS%3A").join("cm_cr=");
			tempHref = tempHref.split("cm_cr=OS%3a").join("cm_cr=");
			tempHref = tempHref.split("-_-E-mail%20Activity-_-").join("-_-1-_-");
			tempHref = tempHref.split("-_-E-mail%2BActivity-_-").join("-_-1-_-");
			tempHref = tempHref.split("-_-E-mail%2bActivity-_-").join("-_-1-_-");
			cmCreateManualLinkClickTag(tempHref,null,"Email");
			cmSendOSLinkClickTag = false;
		}
	}

	// Intelligent Offer call
	if (typeof cm_ted_io == 'function') {
		cm_ted_io(cm);
	}

}

if (defaultNormalize == null) { var defaultNormalize = null; }

function myNormalizeURL(url, isHref) {
	if (cmIndexOfParameter("#",url) != -1) {
		newURL = (cmRemoveParameter ("cm_cr",url));
	} else {
		var newURL = url;
	}
    
    if (isHref) {
	    var blackList = ["krypto="];
	    var paramString;
	    var paramIndex = newURL.indexOf("?");
	    var params;
	    var keepParams = new Array();
	    var goodParam;
	
	    if (paramIndex > 0) {
		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++) {
			//This match is case insensitive.  Remove .toLowerCase() to add case sensitivity
				if (params[i].toLowerCase().indexOf(blackList[j].toLowerCase()) == 0) {
					goodParam = false;
				}
			}
			if(goodParam == true) {
				keepParams[keepParams.length] = params[i];
			}
		}
		
		newURL += "?" + keepParams.join("&");
	
	    }
	 
	    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;
    }
}

function cmIndexOfParameter (parameter, inString) {
	return inString.indexOf(parameter);
}

function cmExtractParameter (parameter, inString) {
    if (cmIndexOfParameter(parameter, inString) == -1) {
        return null;
    }
	var s = inString;
	var begin = s.indexOf(parameter);
	var end = s.indexOf("&", begin);
	if (end == -1) {
		end = s.length;
	}
	var middle = s.indexOf("=", begin);
	return s.substring(middle + 1, end);
}

function cmRemoveParameter (parameter, inString) {
    if (cmIndexOfParameter(parameter, inString) == -1) {
        return inString;
    }
	var s = inString;
	var begin = s.indexOf(parameter);
	var start = (begin - 1);
	var end = s.indexOf("&", begin);
	if (end == -1) {
		end = s.length;
	}
	if (s.substring(start, begin) == "?") {    // retain leading "?"
		start = (start + 1);
		end = (end + 1);
	}
	return s.substring(0, start) + s.substring(end, s.length);
}

function cmCheckCMEM() {
	if (cmIndexOfParameter("cm_em",document.location.href) != -1){
		var emailAddress = cmExtractParameter("cm_em",document.location.href);
		if (emailAddress.indexOf(":")>-1){
			emailAddress=emailAddress.substring(emailAddress.indexOf(":")+1);
		}	
		cmCreateRegistrationTag(emailAddress,emailAddress);
	}
	if (cmIndexOfParameter("cm_lm",document.location.href) != -1){
		var emailAddress = cmExtractParameter("cm_lm",document.location.href);
		if (emailAddress.indexOf(":")>-1){
			emailAddress=emailAddress.substring(emailAddress.indexOf(":")+1);
		}	
		cmCreateRegistrationTag(emailAddress,emailAddress);
	}
}

/* manual PageviewTag for off site page tagging.  Allows client to supply URL and Referring URL
*/
function cmCreateManualPageviewTag(pageID, categoryID,DestinationURL,ReferringURL) {
	cmMakeTag(["tid","1","pi",pageID,"cg",categoryID,"ul",DestinationURL,"rf",ReferringURL]);
}

function cmCreateManualImpressionTag(pageID, trackSP, trackRE) {
		// insert code to get pageID from cmTagControl if pageID is null
		cmMakeTag(["tid","9","pi",pageID,"cm_sp",trackSP,"cm_re",trackRE,"st",cm_ClientTS]);
}

function cmCreateManualLinkClickTag(href,name,pageID) {	
	if (cmCreateLinkTag == null && cM != null) {
		var cmCreateLinkTag = cM;
	}
	if (cmCreateLinkTag != null) {		
		var dt = new Date();
		cmLnkT3 = dt.getTime();
		href = cG7.normalizeURL(href, true);
		cmCreateLinkTag(cm_ClientTS, cmLnkT3, name, href, false, pageID);
	}
}

function cmCreatePageElementTag(elementID, elementCategory, pageID, pageCategoryID, elementLocation, attributes) {
	if (attributes){
		var cm_exAttr=new Array;
		cm_exAttr=attributes.split("-_-");
	}
	cmMakeTag(["tid","15","eid",elementID,"ecat",elementCategory,"pflg","0","pid",pageID,"pcat",pageCategoryID,"eloc",elementLocation,"cm_exAttr",cm_exAttr]);
}

function cmCreateProductElementTag(elementID, elementCategory, productID, productCategoryID, elementLocation) {
	cmMakeTag(["tid","15","eid",elementID,"ecat",elementCategory,"pflg","1","pid",productID,"pcat",productCategoryID,"eloc",elementLocation]);
}
