/************************************************************************************/
/* $Revision: $
 * $Id: $
 *
 * Author: Coremetrics/PSD 
 * Coremetrics  v1.3, 10/14/2008
 * COPYRIGHT 1999-2008 COREMETRICS, INC. 
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 * Disclaimer: Coremetrics is not responsible for hosting or maintenance or this file
 *
 *
 * line 16 should be uncommented for production. dev.jockey.com should be replaced with www.jockey.com 
 * for production. Production version can be copied to stage
 */
/************************************************************************************/
//Production data warehouse flag
cmSetProduction();
/*===========================GLOBAL VARIABLES ===============================*/
// options for debug mode when sending tag:
// 1: only alert
// 2: only send tag
// 3: alert & send tag
var G_PS_DEBUG_MODE = 2;

// current page url
var G_PS_URL_PATH = "" + document.location;
var G_PS_PATHNAME = document.location.pathname.toLowerCase();
var G_PS_QUERYSTRING = document.location.search.toLowerCase();
var G_PS_URL_REFERRER = document.referrer.toLowerCase();
var G_PS_COOKIE_LIFETIME = 31536000; // 365*24*60*60 = 365 days
// cookie name
var G_PS_COOKIE_CATID = "PS_CATID";
var G_PS_COOKIE_PAGEID = "PS_PAGEID";
var G_PS_COOKIE_PROD_CATID = "PS_PROD_CATID";
var G_PS_COOKIE_PROD_NAME = "PS_PROD_NAME";
var G_PS_COOKIE_PROFILE = "PS_PROFILE";
var G_PS_FLAG = "PS_FLAG";		// used as a "session" variable to handle events between pages
var G_PS_FLAG_REG = "PS_FLAG_REG";
var G_PS_FLAG_BAG = "PS_FLAG_BAG";
// current category ID while browsing/searching/refining, etc
var G_PS_CUR_CATID = null;
/*========================= END GLOBAL VARIABLES =============================*/

/*=========================== BEGIN NAVIGATION ===============================*/
psHijackOnlickLeftMenu();
if (psIsSearchView()){
	psPostSearchView();
}
else if (psIsProductView()){
	psPostProductView();
}
else if (psIsPageView()){
	psPostPageView();
}
else if (psIsCartView()){
	psPostCartView();
}
else if (psIsOrderView()){
	psPostOrderView();
}
else 
{	
	psCreatePageviewTag(G_PS_PATHNAME, "Add Item to Cart"); // Other pages go to "ADD URL" category
}
function psIsPageView(){
	var pFlag=false;
	if (G_PS_PATHNAME == "/" || psReturnPathName().indexOf("main2.aspx")>=0 || psReturnPathName().indexOf("sitemapdetails.aspx")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "HOME");psSetCookie(G_PS_FLAG, "true");pFlag=true;
	}
	else if (psReturnPathName().indexOf("minis/main.aspx")>=0 || G_PS_PATHNAME == "/minis/"){
		psSetCookie(G_PS_COOKIE_CATID, "MINIS HOME");psSetCookie(G_PS_FLAG, "true");pFlag=true;
	}
	else if (psReturnPathName().indexOf("catalog/departmentmen.aspx")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "MENS");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("catalog/departmentwomen.aspx")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "WOMENS");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("catalog/departmentkids.aspx")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "KIDS");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("catalog/silhouette.aspx")>=0 && psGetValueFromUrl(G_PS_URL_PATH.toLowerCase(),"categoryname")=="clearance"){
		psSetCookie(G_PS_COOKIE_CATID, "SALE");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("shoppingbag/")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "CHECKOUT");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}		
	else if (psReturnPathName().indexOf("login.aspx")>=0 || psReturnPathName().indexOf("myaccount/")>=0){		
		psSetCookie(G_PS_COOKIE_CATID, "ACCOUNT");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}	
	else if (psReturnPathName().indexOf("customerservice/")>=0){		
		psSetCookie(G_PS_COOKIE_CATID, "CustomerService");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}	
	else if (psReturnPathName().indexOf("templates/contactus.aspx")>=0){		
		psSetCookie(G_PS_COOKIE_CATID, "CustomerService");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("corporateinfo/")>=0 || psReturnPathName().indexOf("legal/termsandconditions/")>=0 || 
		psReturnPathName().indexOf("privacypolicy/")>=0 || psReturnPathName().indexOf("pressroom/")>=0){		
		psSetCookie(G_PS_COOKIE_CATID, "CorporateInfo");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("aboutourproducts/")>=0){		
		psSetCookie(G_PS_COOKIE_CATID, "AboutOurProducts");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("jockeyclub/")>=0){		
		if (psReturnPathName().indexOf("jockeyclub/jockeyclubintro.aspx")>=0){
			psSetCookie(G_PS_COOKIE_CATID, "ACCOUNT");psSetCookie(G_PS_FLAG, "false");pFlag=true;
		}
		else{	
			psSetCookie(G_PS_COOKIE_CATID, "JockeyClub");psSetCookie(G_PS_FLAG, "false");pFlag=true;
		}
	}
	else if (psReturnPathName().indexOf("catalogquickorder.aspx")>=0 || psReturnPathName().indexOf("browsecatalogonline1.aspx")>=0 || psReturnPathName().indexOf("doubleoptin/")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "CATALOG");psSetCookie(G_PS_FLAG, "false");pFlag=true;
	}
	else if (psReturnPathName().indexOf("catalog/silhouette.aspx")>=0 || psReturnPathName().indexOf("minis/selection.aspx")>=0 || psReturnPathName().indexOf("microsite/selection.aspx")>=0){
	pFlag=true;		
	}
	return pFlag;
}
function psPostPageView(){
	var pPageID;var pCatID = psGetCookie(G_PS_COOKIE_CATID);
	if (pCatID==null){pCatID = "Bookmarks";}
	else if (psReturnPathName().indexOf("shoppingbag/")>=0){
		if (psReturnPathName().indexOf("shoppingbag/checkoutlogin.aspx")>=0){
			pPageID = "Checkout Login";
			psSubscribeProfilePages();
		}
		else if (psReturnPathName().indexOf("shoppingbag/paymentinfo.aspx")>=0){pPageID = "Payment Info";}
		else if (psReturnPathName().indexOf("shoppingbag/orderreview.aspx")>=0){pPageID = "Order Review";}
		else if (psReturnPathName().indexOf("shoppingbag/orderconfirmation.aspx")>=0){
			pPageID = "Order Confirmation";
			psPostOrderView();
		}		
	}
	else if (psReturnPathName()=="/login.aspx"){
		pPageID = "Login Page";
		psSubscribeProfilePages();
	}
	else if (psReturnPathName().indexOf("myaccount/")>=0){
		if (psReturnPathName().indexOf("myaccount/registrationcomplete.aspx")>=0){pPageID = "Registration Complete";}
		else if (psReturnPathName().indexOf("myaccount/myaccountdefault.aspx")>=0){pPageID = "My Account";}
		else if (psReturnPathName().indexOf("myaccount/myorders.aspx")>=0){
			var pRefererpage = psGetValueFromUrl(G_PS_URL_PATH.toLowerCase(),"refererpage");
			if (pRefererpage=="myorders"){pPageID = "My Orders";}
			else if (pRefererpage=="rapidrefill"){pPageID = "Rapid Refill";}
		}
		else if (psReturnPathName().indexOf("myaccount/creditcardlist.aspx")>=0){pPageID = "Credit Card List";}
		else if (psReturnPathName().indexOf("myaccount/personalinfo.aspx")>=0){
			pPageID = "Personal Info";
			psSubscribeProfilePages();
		}
		else if (psReturnPathName().indexOf("myaccount/passwordchange.aspx")>=0){pPageID = "Password Change";}
		else if (psReturnPathName().indexOf("myaccount/addresslist.aspx")>=0){pPageID = "Address List";	}
		else if (psReturnPathName().indexOf("myaccount/giftreminder.aspx")>=0){pPageID = "Gift Reminder";}
		else if (psReturnPathName().indexOf("myaccount/resetpassword.aspx")>=0){pPageID = "Reset Password";}
				
	}		
	else if (psReturnPathName().indexOf("customerservice/")>=0){
		pPageID = "CustomerService Home";
		if (psReturnPathName().indexOf("customerservice/contactus/")>=0){pPageID = "contactus";}
		else if (psReturnPathName().indexOf("customerservice/returnpolicy/")>=0){pPageID = "ReturnPolicy";}
		else if (psReturnPathName().indexOf("customerservice/faq/")>=0){pPageID = "FAQ";}
		else if (psReturnPathName().indexOf("customerservice/shippinginfo/")>=0){pPageID = "ShoppingInfo";}
		else if (psReturnPathName().indexOf("customerservice/giftcardinquiry.aspx")>=0){pPageID = "GiftCardInquiry";}
	}
	else if (psReturnPathName().indexOf("templates/contactus.aspx")>=0){pPageID = "contactus";}	
	else if (psReturnPathName().indexOf("corporateinfo/")>=0){
		pPageID = "CorporateInfo Home";
		if (psReturnPathName().indexOf("corporateinfo/history/")>=0){pPageID = "History";}
		else if (psReturnPathName().indexOf("corporateinfo/adarchive/")>=0){
			pPageID = "AdArchive Home";				
			if (psReturnPathName().indexOf("corporateinfo/adarchive/adarchive")>=0){
				var pTemp = psReturnPathName().substring(psReturnPathName().lastIndexOf("/")+1,psReturnPathName().lastIndexOf("."));
				pPageID = pTemp.substring(pTemp.length-4,pTemp.length)+" " + "Ad";
			}			
		}		
	}
	else if (psReturnPathName().indexOf("legal/termsandconditions/")>=0){pPageID = "TermsAndConditions";}		
	else if (psReturnPathName().indexOf("pressroom/")>=0){pPageID = "Pressroom";}
	else if (psReturnPathName().indexOf("privacypolicy/")>=0){			
		pPageID = "Privacy Policy";		
		if (psReturnPathName().indexOf("privacypolicy/codeofconduct/")>=0){pPageID = "CodeOfConduct" ;}			
	}
	else if (psReturnPathName().indexOf("aboutourproducts/")>=0){
		pPageID = "AboutOurProducts Home";		
		if(psReturnPathName().indexOf("aboutourproducts/collections/")>=0){pPageID = "Collections";}
		else if(psReturnPathName().indexOf("aboutourproducts/fabrics/")>=0){pPageID = "Fabrics";}
		else if(psReturnPathName().indexOf("aboutourproducts/productcare/")>=0){pPageID = "ProductCare";}
		else if(psReturnPathName().indexOf("aboutourproducts/sizing/")>=0){pPageID = "Sizing";}
	}
	else if (psReturnPathName().indexOf("jockeyclub/")>=0){	
		pPageID ="JockeyClub Home";
		if (psReturnPathName().indexOf("jockeyclub/jockeyclubintro.aspx")>=0){pPageID = "Jockey Club";}
		else if (psReturnPathName().indexOf("jockeyclub/mypoints/")>=0){pPageID = "MyPoints";}
		else if (psReturnPathName().indexOf("jockeyclub/storelocator/")>=0){pPageID = "Store Locator";}
		else if (psReturnPathName().indexOf("jockeyclub/faq/")>=0){pPageID = "Jockey Club FAQ";}
	}
	else if (psReturnPathName().indexOf("catalogquickorder.aspx")>=0){pPageID ="Catalog Jump";}
	else if (psReturnPathName().indexOf("browsecatalogonline1.aspx")>=0){pPageID ="Browse Catalog";}
	else if (psReturnPathName().indexOf("doubleoptin/")>=0){
		pPageID = "Catalog Request";
		if (psReturnPathName().indexOf("doubleoptin/doicatalogreq.aspx")>=0){pPageID = "Catalog Request";}
		else if (psReturnPathName().indexOf("doubleoptin/doiaddinfothanks.aspx")>=0){pPageID = "Catalog Request Complete";}
		else if (psReturnPathName().indexOf("doubleoptin/doisignup.aspx")>=0){pPageID = "Special Offers Signup";}
		else if (psReturnPathName().indexOf("doubleoptin/doithankyou.aspx")>=0){pPageID = "Special Offers Signup Complete";}
	}
	else if (psReturnPathName().indexOf("sitemapdetails.aspx")>=0){pPageID = "SiteMap Details";}
	else if (psReturnPathName().indexOf("catalog/silhouette.aspx")>=0 || psReturnPathName().indexOf("microsite/selection.aspx")>=0  || psReturnPathName().indexOf("minis/selection.aspx")>=0){
		var pCategoryName = psGetValueFromUrl(psReturnUrlPath(),"categoryname");
		var pDepartmentName = psGetValueFromUrl(psReturnUrlPath(),"departmentname");
		var pSilhouetteName = psGetValueFromUrl(psReturnUrlPath(),"silhouettename");
		var pClearance = psGetValueFromUrl(psReturnUrlPath(),"clearance");
		if (pCategoryName!=null && pClearance==null && pDepartmentName==null && pSilhouetteName==null){
			pPageID = document.title.substring(0,document.title.indexOf("|"));
			pCatID="SALE"
		}
		else{
			if (pCategoryName!=null && pDepartmentName!=null && pSilhouetteName!=null){
				pPageID = "Catalog: "+psTrim(pCategoryName)+"'s " + pSilhouetteName;
			}
			else if (pCategoryName!=null && pClearance!=null){
				pPageID = psTrim(pCategoryName)+"'s Clearance";
			}
//			if (psGetCookie(G_PS_FLAG)=="true"){
//				//pCatID="HOME";
//			}
//			else{				
				if (pCategoryName!=null && pDepartmentName!=null && pSilhouetteName!=null){
					pCatID = psTrim(pCategoryName)+psTrim(pDepartmentName)+psTrim(pSilhouetteName);
				}
				else if (pCategoryName!=null && pClearance!=null){
					pCatID = psTrim(pCategoryName)+"ClearanceList";
				}	
//			}
		}	
	}
	else{
		pPageID = document.title.substring(0,document.title.indexOf("|"));
	}	
	if (psGetCookie(G_PS_FLAG_REG)=="signin" || psGetCookie(G_PS_FLAG_REG)=="create" || psGetCookie(G_PS_FLAG_REG) == "update"){
		psPostRegistrationView();
	}
	psSetCookie(G_PS_COOKIE_CATID, pCatID);	
	psCreatePageviewTag(pPageID, pCatID, null, null)	
}

/*Start Tagging for search code*/
function psIsSearchView(){
	var pFlag=false;		
	if(psReturnUrlPath().indexOf("search.jockey.com")>=0){
		psSetCookie(G_PS_COOKIE_CATID, "SEARCH");psSetCookie(G_PS_FLAG, "FALSE");pFlag=true;
	}
	return pFlag;
}
function psPostSearchView(){	
	var pCatID = psGetCookie(G_PS_COOKIE_CATID);
	var pPageID = "SEARCH SUCCESSFUL";
	var pPageNo = psGetValueFromUrl(G_PS_URL_PATH.toLowerCase(),"page");	
	if (pCatID==null){pCatID = "Bookmarks";}	
	if (pPageNo==null || pPageNo==""){pPageNo=1;}
	var pSearchTerm = psGetSearchTerm();
	var pSearchResult = psGetSearchResult();
	if (pSearchResult=="0"){pPageID="SEARCH UNSUCCESSFUL";}
	else {pPageID="SEARCH SUCCESSFUL";}
	psCreatePageviewTag(pPageID, pCatID, pSearchTerm, pSearchResult);
	psSetCookie(G_PS_COOKIE_CATID, "SEARCH");		
}
function psGetSearchTerm(){
	var term = "";
	if (psCheckElementExist(ev1.keywords)==true){
		term=ev1.keywords;
	}	
	return term;
}
function psGetSearchResult(){
	var result = "0";
	var pResult=0;	
	var pTagSpan = document.getElementById("WSCS_facets");
	if (psCheckElementExist(pTagSpan)==true){		
		var pTagSubSpan = psGetElementsByClassName(pTagSpan,"SPAN","navtext");		
		var tagImage = pTagSpan.getElementsByTagName("img");
		if (psCheckArrayExist(tagImage)==true){			
			var pStr = psTrim(psGetInnerText(pTagSubSpan[0]));
			if (pStr!=""){					
				var pNo = pStr.substring(pStr.toLowerCase().indexOf("(")+1,pStr.toLowerCase().indexOf(")"));
				pResult += parseInt(pNo);
			}
		}
		else{
			if (psCheckArrayExist(pTagSubSpan)==true){			
				for(var i=0; i<pTagSubSpan.length; i++){								
					var pStr = psTrim(psGetInnerText(pTagSubSpan[i]));
					if (pStr!=""){					
						var pNo = pStr.substring(pStr.toLowerCase().indexOf("(")+1,pStr.toLowerCase().indexOf(")"));
						pResult += parseInt(pNo);
					}				
				}
			}
		}
	}
	if (pResult!=0)
		result= pResult;
	return result;
}
/*End Tagging for search code*/

function psPostRegistrationView(){	
	if (psGetCookie(G_PS_FLAG_REG) == "signin" || psGetCookie(G_PS_FLAG_REG) == "create" || psGetCookie(G_PS_FLAG_REG) == "update"){
		var uP = new psProfile();
		uP.readProfile(); // get user profile from cookie
		// post registration tag for login page
		psCreateRegistrationTag(uP.customerEmail,uP.customerEmail,null,null,null,null,null);
		psSetCookie(G_PS_FLAG_REG, "", "delete"); // turn off flag
	}	
}
function psSubscribeProfilePages(){
	if (psReturnPathName()=="/login.aspx" || psReturnPathName() =="/shoppingbag/checkoutlogin.aspx"){
		var btnLogin = document.getElementsByName("Login");
		if (psCheckArrayExist(btnLogin[0])==true){
			var oldCMFunc = btnLogin[0].onclick;
			btnLogin[0].onclick = function(){
				var uP = new psProfile();
				var txtEmail =  document.getElementById("GuestControl_UserName");				
				uP.customerID = txtEmail.value;	
				uP.customerEmail = txtEmail.value;					
				uP.customerCity = null;				
				uP.customerState = null;	
				uP.customerZIP=null;
				uP.newsletterName = null;
				uP.subscribe = null;
				uP.writeProfile();				
				psSetCookie(G_PS_FLAG_REG, "signin");		
				return oldCMFunc;
			}
		}
		var btnSave = document.getElementsByName("Save");
		if (psCheckArrayExist(btnSave[0])==true){
			var oldCMFunc = btnSave[0].onclick;
			btnSave[0].onclick = function(){
				var uP = new psProfile();
				var txtEmail =  document.getElementById("GuestControl_RegistrationFormNewUser_txtEmailAddress");
				if (psCheckElementExist(txtEmail)==true){
					uP.customerID = uP.customerEmail = txtEmail.value;	
				}				
				uP.customerCity = null;				
				uP.customerState = null;	
				uP.customerZIP=null;
				uP.newsletterName = null;
				uP.subscribe = null;
				uP.writeProfile();
				psSetCookie(G_PS_FLAG_REG, "create");		
				return oldCMFunc;
			}
		}
	}
	else if (psReturnPathName().indexOf("myaccount/personalinfo.aspx")>=0){
		var lnkSave = document.getElementById("ilnkSave");
		if (psCheckArrayExist(lnkSave)==true){
			var oldCMFunc = lnkSave.onclick;
			lnkSave.onclick = function(){
				var uP = new psProfile();
				var txtEmail =  document.getElementById("txtEmailAddress");				
				uP.customerID = txtEmail.value;	
				uP.customerEmail = txtEmail.value;					
				uP.customerCity = null;				
				uP.customerState = null;	
				uP.customerZIP=null;
				uP.newsletterName = null;
				uP.subscribe = null;
				uP.writeProfile();				
				psSetCookie(G_PS_FLAG_REG, "update");		
				return oldCMFunc;
			}
		}
	}
}
function psHijackOnlickLeftMenu(){
	var pTagDiv = psGetElementsByClassName(document,"DIV","leftnav");
	if (psCheckArrayExist(pTagDiv)==true){
		var pTagA = pTagDiv[0].getElementsByTagName("a");
		if (psCheckArrayExist(pTagA)==true){
			for(var i=0; i<pTagA.length;i++){
				var oldCMFunc = pTagA[i].onclick;
				 pTagA[i].onclick = function(){
					psSetCookie(G_PS_FLAG, "false");		
					return oldCMFunc;
				}
			}
		}
	}
}
function psHijackOnlickAddToBag(){
	var pAddToBag = document.getElementById("lnkButtonAddToBag");
	if (psCheckElementExist(pAddToBag)==true){
		var oldCMFunc = pAddToBag.onclick;
		 pAddToBag.onclick = function(){
			psSetCookie(G_PS_FLAG_BAG, "true");			
			return oldCMFunc;
		}
	}
}
function psIsProductView()
{
	var pFlag=false;
	var atbFlag = '';
	if (document.getElementById('atb') != null){atbFlag = document.getElementById('atb').value;}
	if (atbFlag != '1' && (psReturnPathName().indexOf("catalog/productdetails.aspx")>=0 || psReturnPathName().indexOf("microsite/productdetail.aspx")>=0 || psReturnPathName().indexOf("minis/productdetail.aspx")>=0 )){pFlag=true;}
	return pFlag;
}

/*
 * Determine if the page is the shopping cart page
 */
function psIsCartView()
{
	var pFlag = false;
	if (psReturnPathName().indexOf("shoppingbag.aspx")>=0 || psReturnPathName().indexOf("shoppingcart.aspx")>=0){pFlag=true;}	
	return pFlag;
}

/*
 * Determine if the page is the thank you page
 */
function psIsOrderView()
{
	//
	// TO-Do: Your logic to determine the receipt page goes here
	//
	return false;
}
function psPostProductView()
{
	var prd = new psProduct();
	if (prd.getProduct()) // Get product info successfully?
	{		
		psCreateProductviewTag(prd.id, prd.name, prd.catId);
		//alert("set cookie values" + prd.catId);
		psSetValueToCookie(G_PS_COOKIE_PROD_CATID, prd.id, prd.catId);		
		psSetCookie(G_PS_COOKIE_CATID,prd.catId);	
		psHijackOnlickAddToBag();
	}
}

/*
 * Process to post shop5tags for items in shopping cart
 */
function psPostCartView()
{
  if (validateElement('MicroShoppingBag')==false)
	psCreatePageviewTag("SHOPPING CART", "CART", null, null);
  else
 	psCreatePageviewTag("MINIS SHOPPING CART", "MINIS CART", null, null);
	if (psCheckElementExist(CMproductID)==false)
		return;
	var pProdID = CMproductID;
	var pArrProdID = pProdID.split(",");
	var prd = new psProduct();
	for(var i=0; i<pArrProdID.length; i++){
		var pProdID = pArrProdID[i];
		if (prd.getItem5(pProdID,i)) // Get shop5 item successfully?
		{
			psCreateShopAction5Tag(prd.id, prd.name, prd.quantity, prd.price, prd.catId);
		}
	}	
	// Make sure to have actual postings
	psDisplayShop5s();
}

/*
 * Process to post shop9tags for items purchased
 */
function psPostOrderView(){
	if(CMproductID != null)
	{
		//psCreatePageviewTag("Order Confirmation", "CHECKOUT", null,null);	
		var pOrderID=null;
		var isPPal=false;
		var pLabelNonCertificatePaymentHeading = document.getElementById("LabelNonCertificatePaymentHeading");
		if (psCheckElementExist(LabelNonCertificatePaymentHeading)==true){
		if (LabelNonCertificatePaymentHeading.innerHTML.substring(6,0).toLowerCase() == "paypal"){isPPal = true;}
		}
		if(isPPal)
		{
			var pLabelShipmentTo = document.getElementById("RepeaterShipments__ctl0_LabelShipmentTo");
			if (psCheckElementExist(pLabelShipmentTo)==true){
				var pArr1 = pLabelShipmentTo.innerHTML.split(",");
				var pArr3 = psTrim(pArr1[0]).split(">")
				var pCity = pArr3[2];
				var pArr2 =psTrim(pArr1[1]).split(" ")
				var pState = pArr2[0];
				var pZipCode = pArr2[1];
			}
		}
		else
		{
			var pLabelBillingCityStateZip = document.getElementById("LabelBillingCityStateZip");
			if (psCheckElementExist(pLabelBillingCityStateZip)==true){
				var pArr1 = pLabelBillingCityStateZip.innerHTML.split(",");
				var pCity = pArr1[0];
				var pArr2 =psTrim(pArr1[1]).split(" ")
				var pState = pArr2[0];
				var pZipCode = pArr2[1];
			}
		}
		var pLabelOrderNumber = document.getElementById("LabelOrderNumber");
		if (psCheckElementExist(pLabelOrderNumber)==true){
			var pOrderID = pLabelOrderNumber.innerHTML;
		}
		if (pOrderID==null)
			pOrderID="123456"; // Assign to Test
		var pLabelBillingEmail = document.getElementById("LabelBillingEmail");
		if (psCheckElementExist(pLabelBillingEmail)==true){
			var pEmail =pLabelBillingEmail.innerHTML;
		}
		var pLabelOrderTotal = document.getElementById("LabelOrderTotal");
		if (psCheckElementExist(pLabelOrderTotal)==true){
			var pOrderTotal =pLabelOrderTotal.innerHTML;
		}	
		var pShippingCharges = document.getElementById("RepeaterShipments__ctl0_LabelShippingCharges");
		if (psCheckElementExist(pShippingCharges)==true){
			var pShipping =pShippingCharges.innerHTML;
		}
		var pTagTable = psGetElementsByClassName(document,"table", "orderreview-table");
		if (psCheckArrayExist(pTagTable)==true){
			var pTagSpan = psGetElementsByClassName(pTagTable[0],"SPAN","label-text");				
		}
		var pProdID = CMproductID;	
		var pArrProdID = pProdID.split(",");	
		for(var i=0; i<pArrProdID.length; i++){
			var pProdID = pArrProdID[i];		
			var pProName = psGetInnerText(pTagSpan[i]) 
			var pCatID = psGetValueFromCookie(G_PS_COOKIE_PROD_CATID,pProdID);
			if (pCatID==null)
				pCatID = "UNKNOWN CATEGORY";
			var pKeyIdQty = "RepeaterShipments__ctl0_RepeaterShipmentItems__ctl"+i+"_LabelShipmentItemQuantity";		
			var pQtyObj =document.getElementById(pKeyIdQty);
			if (psCheckElementExist(pQtyObj)==true){
				var pQty = psTrim(pQtyObj.innerHTML.substring(0,pQtyObj.innerHTML.toLowerCase().indexOf("at")));
				var pPrice = psTrim(pQtyObj.innerHTML.substring(pQtyObj.innerHTML.toLowerCase().indexOf("at")+1,pQtyObj.innerHTML.length));
			}		
			psCreateShopAction9Tag(pProdID, pProName, pQty, pPrice, pEmail, pOrderID, pOrderTotal, pCatID);
		}	
		psDisplayShop9s();
		// Post order tag finally
		psCreateRegistrationTag(pEmail,pEmail, pCity, pState, pZipCode,null,null);	
		psCreateOrderTag(pOrderID, pOrderTotal, pShipping, pEmail, pCity, pState, pZipCode);
	}
}

/*====================== END TAGGING BUSSINESS LOGIC =========================*/


/*======================= GENERAL UTILITY FUNCTION ===========================*/
/* PURPOSE: constructor for product
 * Note: you can add more methods to psProduct in its prototype
 * RETURN: none
 */
function psProduct()
{
    this.id = null;
    this.name = null;
    this.catId = null;
    this.price = null;
    this.quantity = null;
	/*
	 * Extracting product info from source code for posting productview tag
	 */
	this.getProduct = function(){
		try{
			this.id = psGetValueFromUrl(psReturnUrlPath(),"cs_productid");			
			var pProName = psGetElementsByClassName(document,"SPAN","phprodname");	
			if (psCheckArrayExist(pProName)==true)
				this.name = psGetInnerText(pProName[0]);
			if (G_PS_URL_REFERRER!=""){
				if (psGetDomain(G_PS_URL_REFERRER).indexOf("www.jockey.com")>=0){
					if(psReturnUrlReferrer().indexOf("catalog/silhouette.aspx")>=0 || psReturnUrlReferrer().indexOf("microsite/selection.aspx")>=0 || psReturnUrlReferrer().indexOf("minis/selection.aspx")>=0){

					var pCategoryName = psGetValueFromUrl(psReturnUrlReferrer(),"categoryname");
					var pDepartmentName = psGetValueFromUrl(psReturnUrlReferrer(),"departmentname");
					var pSilhouetteName = psGetValueFromUrl(psReturnUrlReferrer(),"silhouettename");
					var pClearance = psGetValueFromUrl(psReturnUrlReferrer(),"clearance");
					if (pCategoryName!=null && pClearance==null && pDepartmentName==null && pSilhouetteName==null){pCatID="SALE"}
					else{				
						if (pCategoryName!=null && pDepartmentName!=null && pSilhouetteName!=null){
						pCatID = psTrim(pCategoryName)+psTrim(pDepartmentName)+psTrim(pSilhouetteName);
						}
						else if (pCategoryName!=null && pClearance!=null){
						pCatID = psTrim(pCategoryName)+"ClearanceList";
						}	
					}
						//this.catId = psGetCookie(G_PS_COOKIE_CATID);
						this.catId = pCatID;
						psSetCookie(G_PS_COOKIE_CATID, pCatID);	
						if (this.catId == null){
							this.catId="SEARCH";
						}
					}
					else if(psReturnUrlReferrer().indexOf("catalog/productdetails.aspx")>=0 || psReturnUrlReferrer().indexOf("microsite/productdetail.aspx")>=0 || psReturnUrlReferrer().indexOf("minis/productdetail.aspx")>=0){
						if (psGetCookie(G_PS_FLAG_BAG)=="true"){
							this.catId = psGetCookie(G_PS_COOKIE_CATID);
							if (this.catId == null){
								this.catId="SEARCH";
							}
							psSetCookie(G_PS_FLAG_BAG, "", "delete");
						}
						else{
							var pCs_catalog = psGetValueFromUrl(psReturnUrlPath(),"cs_catalog");
							if (pCs_catalog!=null){
								this.catId = "PrevNext_" + pCs_catalog;
							}
						}
					}
					else{
						this.catId = psGetCookie(G_PS_COOKIE_CATID);		
						if (this.catId == null){
							this.catId="SEARCH";
						}
					}					
				}
				else if (psGetDomain(G_PS_URL_REFERRER).indexOf("search.jockey.com")>=0){
					this.catId="SEARCH";
				}
				else{
					this.catId="BookMarks";
				}
			}
			else{
				this.catId = psGetCookie(G_PS_COOKIE_CATID);
				if (this.catId == null){
					this.catId="SEARCH";
				}
			}			
			return true;
		}
		catch (ex) { return false; }
	}
	/*
	 * Extracting product info from source code specified by the "current" row
	 * of items table in the shopping cart
	 */
	this.getItem5 = function(pProdID,lineCnt)
	{
		try
		{			
			this.id=pProdID;
			var pKeyIdPrice = "repShipments__ctl0_repLineItem__ctl"+lineCnt+"_ItemPrice";		
			var pPrice = document.getElementById(pKeyIdPrice);
			if (psCheckArrayExist(pPrice)==true){
				this.price = pPrice.innerHTML;
			}

			var pKeyIdQty = "repShipments__ctl0_repLineItem__ctl"+lineCnt+"_ItemQuantity";
			this.quantity = psGetElementValueById(pKeyIdQty,true);			
			this.catId = psGetValueFromCookie(G_PS_COOKIE_PROD_CATID,pProdID);
		
			if (validateElement('MicroShoppingBag')==true)
			{
				var pKeyIdName = "repShipments__ctl0_repLineItem__ctl"+lineCnt+"_itemName";
				var myObj = document.getElementById(pKeyIdName);
				this.name = psGetInnerText(myObj);
			}
			else if (validateElement('rwds') == true)
			{
				var pTagTable = psGetElementsByClassName(document,"div","des");		
				if (psCheckArrayExist(pTagTable)==true)
				{this.name = psGetInnerText(pTagTable[lineCnt]);}
			}
			else
			{
				var pTagTable = psGetElementsByClassName(document,"table","shoppingbag-details");		
				if (psCheckArrayExist(pTagTable)==true)
				{this.name = psGetInnerText(pTagTable[lineCnt].rows[0].cells[2]).replace('-','');}
			}
		 return true;
		}
		catch (ex) { return false; }
	}	
}

/* PURPOSE: constructor for profile
 * Note: you can add more methods to psProfile in its prototype
 * RETURN: none
 */
function psProfile(pCustomerID,pCustomerEmail, pCustomerCity, pCustomerState, pCustomerZIP, pNewsletterName,pSubscribe)
{
    this.customerID = pCustomerID;
	this.customerEmail = pCustomerEmail;
    this.customerCity = pCustomerCity;
    this.customerState = pCustomerState;
    this.customerZIP = pCustomerZIP;
	this.newsletterName = pNewsletterName;
	this.subscribe = pSubscribe;
	
	/*
	 * Get user profile from cookie
	 */
	this.readProfile = function()
	{
		this.customerEmail = psGetCookie(G_PS_COOKIE_PROFILE);		
		if (this.customerEmail != null)
		{
			var buf = this.customerEmail.split('|');
			for (var i=0; i<buf.length; i++)
			{
				var tempVal = buf[i];
                // when NULL is written to cookie, it becomes string, not literal constant
				buf[i] = (tempVal=="null" ? null : tempVal); 
			}
			this.customerID = this.customerEmail = buf[0];
			this.customerCity = buf[1];
			this.customerState = buf[2];
			this.customerZIP = buf[3];
			this.newsletterName = buf[4];
			this.subscribe = buf[5];			
		}
	}
	/*
	 * Set user profile to cookie
	 */
	this.writeProfile = function()
	{
		if (this.customerEmail == null)
			return;
		// make sure that the data contains 4 parts separated by 3 '|'
		var data = this.customerEmail + '|' + this.customerCity + '|' + this.customerState + '|' + this.customerZIP + '|' + this.newsletterName + '|' + this.subscribe;
		// store on cookie		
		psSetCookie(G_PS_COOKIE_PROFILE,data);	
	}
}
/* PURPOSE: Get inner text of an object or clean remove html tags of a particular string
 * RETURN: resultant string or null object
 */
function psGetInnerText(pTagOjb)
{
if (pTagOjb != null)
	{
		if (typeof(pTagOjb) == "object")
			return pTagOjb.innerHTML.replace(/\<+.+?\>+/g, "");
		else
			return pTagOjb.replace(/\<+.+?\>+/g, "");
	}
	return null;
}

/* PURPOSE: Remove all unaccepted characters in categoryid, including
 * [, ', ", :, comma,]
 * RETURN: string
 */
function psCleanCatId(pCatId)
{
    return (pCatId != null) ? pCatId.replace(/[\"]/g, "") : null;
}

function psCleanPageId(pPageId)
{
	return (pPageId != null) ? pPageId.replace(/[\n\t\v\r’\"]/gi, "") : null; 
}

function psCleanProductName(pProductName)
{
	if (pProductName!=null){
		pProductName = pProductName.replace(/&amp; /gi, "");
		pProductName = pProductName.replace(/&reg;/gi, "");
		pProductName = pProductName.replace(/&trade;/gi, "");	
		return (pProductName != null) ? pProductName.replace(/[\n\t\v\r’\"\`\®\™\:]/gi, "") : null; 
	}
	else
		return null;
}
function psRemoveSpecailsymbol(pString)
{
	var pPageId="";
	var arrWords=["Jockey","3D-Innovations","Midway","Elance","Nothing","Supima","Poco",
						"Promise","Tactel","tactel","3D-Contours","Ultimates","Jockey-Silks","Comfies","3D-Seamfree"];
	var pSpecialWords = psTrim(pString).split(" ");
	for(var i=0; i<pSpecialWords.length; i++){
		var pItem =psTrim(pSpecialWords[i]);		
		for(var index=0;index<arrWords.length; index++)
		{				
			if(pItem.indexOf(arrWords[index])==0)
			{				
				if (arrWords[index]=="3D-Innovations"){					
					if (pItem.lastIndexOf("Crew")>=0){
						pItem = "3D-InnovationsCrew";
						pSpecialWords[i]=pItem;
						break;
					}
					else{
						pItem=arrWords[index];				
						pSpecialWords[i]=pItem;
						break;
					}
				}
				else{
					pItem=arrWords[index];				
					pSpecialWords[i]=pItem;
					break;
				}
			}
		}
	}		
	for(var i=0;i<pSpecialWords.length;i++)
	{
		pItem=pSpecialWords[i];
		pPageId += pItem+" ";
	}
	return psTrim(pPageId);
}
function psReturnPathName(){
	return G_PS_PATHNAME.toLowerCase();
}
function psReturnUrlPath(){
	return G_PS_URL_PATH.toLowerCase();
}
function psReturnUrlReferrer(){
	return G_PS_URL_REFERRER.toLowerCase();
}
/* PURPOSE: Remove all leading & trailing spaces of a string
 * Note: [&nbsp;] is also considered as a space
 * RETURN: string
 */
function psTrim(pStr)
{
	if (pStr == null || typeof(pStr) == "undefined")
		return pStr;

	return pStr.replace(/&nbsp;/gi, ' ').replace(/^\s+|\s+$/g, '');
}

/* PURPOSE: extract value from the URL
 * in format of http://xxx.com/page.ext?key1=value1&key2=value2
 * RETURN: string value of the parameter
 */
function psGetValueFromUrl(pUrl, pKey)
{
    var re = new RegExp("[?&]" + pKey + "=([^&$]*)", "i");
    if (pUrl.search(re) == -1)
		return null;
    return unescape(RegExp.$1);
}

/* PURPOSE: returns the value of an element based on element_id
 * @pValueFlag: TRUE means VALUE  attribute of SELECT object returned, not innerHTML
 * RETURN: 
 *  Normal tag: decoded innerHTML
 *  INPUT tag: value attribute
 *  SELECT tag: decoded label of the selected option
 */
function psGetElementValueById(pTagId, pTagFlag)
{
    var tag = document.getElementById(pTagId);
    return psGetElementValue(tag, pTagFlag);
}

/* PURPOSE: returns the value of an element based on element object
 * Note: this function returns decoded text
 * to avoid "double" decode, don't invoke psHtmlDecode on returned value again
 * @pValueFlag: TRUE means VALUE  attribute of SELECT object returned, not innerHTML
 * RETURN: 
 *  Normal tag: decoded innerHTML
 *  INPUT tag: value attribute
 *  SELECT tag: decoded label of the selected option
 *  NULL: if element not exist
 */
function psGetElementValue(pTagObj, pTagFlag)
{
    var tagValue = null;
    if (pTagObj != null)
    {
        if (pTagObj.tagName.search(/^INPUT$/i) > -1)
           tagValue = pTagObj.value;
        else if (pTagObj.tagName.search(/^SELECT$/i) > -1)
        {
            if (pTagFlag == true)
                tagValue = pTagObj.options[pTagObj.selectedIndex].value;
            else
                tagValue = psHtmlDecode(pTagObj.options[pTagObj.selectedIndex].innerHTML);// return label instead of value
        }
        else
            tagValue = psHtmlDecode(pTagObj.innerHTML);
    }

    return tagValue;
}
function psGetElementsByClassName(psDocument, psElementTagName, psClassName){
    var arrResult = new Array();
    var index = 0;
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
    {
        return null;
    }
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        if(arrInputs[i].className.toLowerCase() == psClassName)
        {
            arrResult[index ++ ] = arrInputs[i];
        }
    }
    return arrResult;
}

// Check if array is exist or not
function psCheckArrayExist(pArrElement){
    if(typeof(pArrElement) == "undefined" || pArrElement == null || pArrElement.length <= 0)
    {
        return false;
    }

    return true;
}
function validateElement(elementname)
{
	try
	{
	var myObj = document.getElementById(elementname);
	if (myObj != null)
	{
	return true;
	}
	else
	{
	return false;
	}
	}
	catch (ex) {return false;}
}

// Check an element exist or not
function psCheckElementExist(pElement){
    if(typeof(pElement) == "undefined" || pElement == null)
		return false;
    return true;
}
/* PURPOSE: validate email format
 * RETURN: boolean
 */ 
function psCheckEmail(pEmail) 
{
    if (pEmail)
    {
        var i = pEmail.search(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
        return (i > -1);
    }

    return false;
}

/* PURPOSE: convert special HTML characters to normal character
 * Note: for each project, this function needs to be updated
 * RETURN: decoded string
 */
function psHtmlDecode(pValue)
{
    if (pValue)
    {
        pValue = pValue.replace(/&nbsp;/gi, " ");
        pValue = pValue.replace(/&quot;/gi, '"');
        pValue = pValue.replace(/&amp;/gi, "&");
        pValue = pValue.replace(/&lt;/gi, "<");
        pValue = pValue.replace(/&gt;/gi, ">");
    }

    return pValue;
}

/* PURPOSE: retrieve cookie value
 * RETURN: string
 */
function psGetCookie(pCookieName)
{
	var cookies = document.cookie;
	if (!pCookieName || !cookies)
		return null;

	cookies = "; " + cookies.toLowerCase();
	var key = "; " + pCookieName.toLowerCase() + "=";
	var start = cookies.lastIndexOf(key);
	if (start >= 0)
	{
		start = start + key.length;
		var end = cookies.indexOf(";", start);
		if (end == -1)
			end = cookies.length;

		return unescape(cookies.substring(start, end));
	}

    return null;
}

/* PURPOSE: set cookie value
 * Note: if the designated cookie is too big, the old items will be removed
 * because cookie size is limited to 4K
 * @pLifeTime in seconds
 * pDomain: don't specify if using current domain
 * RETURN: boolean
 */
function psSetCookie(pCookieName, pCookieValue, pLifeTime, pDomain)
{
    if (!pCookieName)
		return false;

	if(pLifeTime == "delete") 
    {         
        CC(pCookieName, pDomain);//delete cookie by calling coremetrics's cookie function
        return true;
    }
    // set cookie by calling coremetrics's cookie function
    var expire = (pLifeTime) ? (new Date((new Date()).getTime() + (1000 * pLifeTime))).toGMTString() : null;
    
    return CB(pCookieName, escape(pCookieValue), expire, pDomain);
}

/* PURPOSE: set value in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 * NOTE: Use null or '' for pValue to remove the pair specified by pKey
 */
function psSetValueToCookie(pCookieName, pKey, pValue)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// 
	var catCookie = psGetCookie(pCookieName);
	if (catCookie == null)
		catCookie = '';

	if (catCookie.indexOf(pKey) >=0) // Store before -> remove the old value
	{
        var reg = new RegExp("#" + pKey + "~([^#]*)", "gi");
        catCookie = catCookie.replace(reg, "");
	}
	// remove the last items (eldest items) until cookie size < 3500	
	if (pValue != null && pValue != '')
	{
		catCookie = "#" + pKey + "~" + pValue + catCookie;
		var cookieArray = null;
		while (catCookie.length > 3500)
		{
			cookieArray = catCookie.split("#");
			cookieArray.pop();
			catCookie = cookieArray.join("#");
		}
	}
	// Save to cookie
	psSetCookie(pCookieName, catCookie, G_PS_COOKIE_LIFETIME);
}

/* PURPOSE: get value stored in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 */
function psGetValueFromCookie(pCookieName, pKey)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// extract catId associated with the specified key (pKey)
    var catCookie = psGetCookie(pCookieName);
    if (catCookie != null)
    {
        var re = new RegExp("#" + pKey + "~([^#$]+)", "i");
		if (catCookie.search(re) == -1)
			return null;

        return RegExp.$1;
    }
    return null;
}
function psGetDomain(pUrl){
    var se = /^https*\:\/\/([^\/]+)/gi;
    return (pUrl.search(se) > -1) ? RegExp.$1 : null;
}
/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pId, pCatId, pSrchTerm, pSrchResult) 
{
	pId = psCleanPageId(pId);
	pCatId = psCleanCatId(pCatId);
    if (pSrchResult != null)
        pSrchResult += "";
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreatePageviewTag(" + pId + ", " + pCatId + ", " + pSrchTerm + ", " + pSrchResult + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreatePageviewTag(pId, pCatId, pSrchTerm, pSrchResult);
}

function psCreateProductviewTag(pId, pName, pCatId) 
{
	pName = psCleanProductName(psRemoveSpecailsymbol(pName));
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateProductviewTag(" + pId + ", " + pName + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateProductviewTag(pId, pName, pCatId);
}

function psCreateShopAction5Tag(pId, pName, pQuantity, pPrice, pCatId) 
{
	pName = psCleanProductName(psRemoveSpecailsymbol(pName));
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction5Tag(" + pId + ", " + pName + ", " + pQuantity + ", " + pPrice + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction5Tag(pId, pName, pQuantity, pPrice, pCatId);    
}

function psCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId) 
{
	pName = psCleanProductName(pName);
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction9Tag(" + pId + ", " + pName + ", " + pQuantity + ", " + pPrice + ", " + pCusID + ", " + pOrderID + ", " + pOrderTotal + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId);
}

function psCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateOrderTag(" + pId + ", " + pOrderTotal + ", " + pOrderShipping + ", " + pCusID + ", " + pCusCity + ", " + pCusState + ", " + pCusZip + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip);
}

function psCreateConversionEventTag(pId, pActionType, pCatID, pPoints) 
{
	pCatID = psCleanCatId(pCatID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateConversionEventTag(" + pId + ", " + pActionType + ", " + pCatID + ", " + pPoints + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateConversionEventTag(pId, pActionType, pCatID, pPoints);
}

function psCreateRegistrationTag(pCusID, pCustEmail, pCusCity, pCusState, pCusZip, pNewsletter, pSubscribe) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateRegistrationTag(" + pCusID + ", " + pCustEmail + ", " + pCusCity + ", " + pCusState + ", " + pCusZip + ", " + pNewsletter + ", " + pSubscribe + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateRegistrationTag(pCusID, pCustEmail, pCusCity, pCusState, pCusZip, pNewsletter, pSubscribe);
}

function psCreateErrorTag(pPageID, pCatId) 
{
	pPageID = psCleanPageId(pPageID);
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateErrorTag(" + pPageID + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateErrorTag(pPageID, pCatId);
}

function psDisplayShop5s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop5s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop5s();
}

function psDisplayShop9s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop9s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop9s();
}
/*===========================END GENERAL UTILITY FUNCTION ==================*/
