/************************************************************************************/
/* $Revision: $
 * $Id: $
 *
 * Author: Coremetrics/PSD
 * Coremetrics  v3.1, 2010/11/08
 * COPYRIGHT 1999-2010 COREMETRICS, INC.
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 * Disclaimer: Coremetrics is not responsible for hosting or maintenance or this file
 *
 */
/************************************************************************************/
//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;
var G_OutPut = [];
var G_SitePrefix = null;

var G_PS_ARR_DOMAIN = ["venus.com"];
// current page url
var G_PS_URL_PATH = "" + document.location.href.toLowerCase();
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 = 1209600; // 14*24*60*60 = 14 days
// cookie name
var G_PS_COOKIE_CATID = "PS_CATID";
var G_PS_COOKIE_PROD_NAME = "PS_PROD_NAME";
var G_PS_COOKIE_PROFILE = "PS_PROFILE";
var G_PS_COOKIE_FLAG = "PS_FLAG";
// new kinds of cookies
var G_PS_COOKIE_SHOP = "PS_SHOP";

// current category ID while browsing/searching/refining, etc
var G_PS_CUR_CATID = null;

/*========================= END GLOBAL VARIABLES =============================*/
/*=========================== BEGIN NAVIGATION ===============================*/
try 
{
	psDoNavigation();
} 
catch (aEx) {}
/*================ Navigation Function ================*/
function psDoNavigation()
{
	psPreCheck();
	
	if (psIsTopPageView()) 
	{
		psPostTopPage();
	}
	else if (psIsProdsListPageView()) 
	{
		psPostProdsListPage();
	}
	else if (psIsProductView()) 
	{
		psPostProductView();
	}
	else if (psIsSearchView()) 
	{
		psPostSearchView();
	}
	else if (psIsCartView()) 
	{
		psPostCartView();
	}
	else if (psIsAccountManagePageView()) 
	{
		psPostAccountManagePage();
	}
	else if (psIsCheckOutPageView()) 
	{
		psPostCheckOutPage();
	}
	else if (psIsOrderView()) 
	{
		psPostOrderView();
	}
	else if (psIsWishListPageView()) 
	{
		psPostWishListPage();
	}
	else if (psIsCatalogOrderPageView())
	{
		psPostCatalogOrderPage();
	}
	else if (psIsSCFCPageView()) 
	{
		psPostSCFCPage();
	}
	else 
	{
		psCreatePageviewTag(G_PS_PATHNAME, "ADD URL");
	}
	psDoComboTasks();
}

/*================ End Of Navigation Function ================*/
/*================ Navi Confirmation Functions ================*/

/*
* New format of 'PS_SHOP' cookie: #prodID~catID
* Old format of 'PS_SHOP' cookie: #prodID-size-style~catID
* used to get value of CatId from cookie with new format.
* RETURN: string
*/
function psAdjustGetValueFrom_PS_SHOP_Cookie( pKey)
{		
	var catCookie = psGetCookie(G_PS_COOKIE_SHOP);
	
	if (catCookie != null) 
	{			
		catCookie = catCookie + "#";
		var myRegEx = new RegExp('\\#'+pKey+'(\\-([^\\-~#]*))*(\\-([^\\-~#]*))*~([^#]*)#');        
		return (catCookie.search(myRegEx) > -1) ? RegExp.$5 : null;
	}
	return null;
}

function psPreCheck()
{
	if (psIsLoggedIn()) 
	{
		var lCookieValue = psGetValueFromCookie(G_PS_COOKIE_FLAG, 'UpFlag');
		if (psIsExisted(lCookieValue)) 
		{
			if (lCookieValue == 'login' || lCookieValue == 'new cus') 
			{
				var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
				if (lString.match(/^\/secure\/checkout_shipping\.aspx/) === null) 
				{
					psPostRegistration();
				}
				else
				{
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'sendReg', 'ok');
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'delete');
				}
				if (lCookieValue == 'login')
				{
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'sendReg', 'ok');
				}
			}
		}
	}
	psSetSitePrefix();	
}

function psSetSitePrefix ()
{
	var lElement = ele ('siteVersion');
	if (psIsElement (lElement))
	{
		G_SitePrefix = psGetElementValue (lElement, false);
		psSetValueToCookie (G_PS_COOKIE_FLAG, 'siteVersion' , G_SitePrefix);
		return;
	}
	G_SitePrefix = (G_SitePrefix === null) ? psGetValueFromCookie(G_PS_COOKIE_FLAG, 'siteVersion').toUpperCase() : G_SitePrefix;
	
	if (G_SitePrefix !== null)
	{
		return;
	}
	else
	{
		G_SitePrefix = (Math.floor(Math.random()*9+1)<5)? 'A' : 'B';
		psSetValueToCookie (G_PS_COOKIE_FLAG, 'siteVersion' , G_SitePrefix);
	}
}

function psDoComboTasks()
{
	psDoHijackLinksClick('ctl00_sidebarNav_lblrecentlyviewed',{caseId:1, cValue:'RECENTLYVIEW'});
}

function psIsLoggedIn()
{
	var lUserEle = ele('ctl00_lblLogin');
	if (psCheckEleContent(lUserEle, /you\sare\ssigned\sin/,{toLWC:true, clHTMLtag:true,	HTMLdecode:true}) !== null) 
	{
		return true;
	}
	return false;
}

function psIsCatalogOrderPageView ()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	G_OutPut = [];
	
	if (lString.match(/^\/secure\/(catalogrequest)\.aspx/) !== null) 
	{
		G_OutPut[0] = 1;
		G_OutPut[1] = RegExp.$1;
		return true;
	}
	if (lString.match(/^\/secure\/(catalogrequest_confirm)\.aspx/) !== null) 
	{
		G_OutPut[0] = 2;
		G_OutPut[1] = RegExp.$1;
		return true;
	}
	return false;
}

function psIsCheckOutPageView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	G_OutPut = [];
	
	if (lString.match(/^\/secure\/(checkout_(billing|account|shipping|payment))\.aspx/) !== null) 
	{
		if (RegExp.$1) 
		{
			if (RegExp.$2 == 'billing') 
			{
				G_OutPut[0] = 1;
			}
			if (RegExp.$2 == 'account') 
			{
				G_OutPut[0] = 2;
			}
			if (RegExp.$2 == 'shipping') 
			{
				G_OutPut[0] = 3;
			}
			if (RegExp.$2 == 'payment') 
			{
				G_OutPut[0] = 4;
			}
			G_OutPut[1] = RegExp.$1;
			G_OutPut[2] = 'checkout';
		}
		return true;
	}
	return false;
}

function psIsAccountManagePageView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	G_OutPut = [];

	if (lString.match(/^\/secure\/((?:checkout_)?login|newaccount|accountinformation|myaccount)\.aspx/) !== null) 
	{
		G_OutPut[0] = G_OutPut[1] = G_OutPut[2] = G_OutPut[3] = null;
		if (RegExp.$1) 
		{
			var lPhrase = RegExp.$1;
			if (lPhrase === 'login' || lPhrase === 'checkout_login' || lPhrase === 'newaccount') 
			{
				G_OutPut[0] = 1;
				G_OutPut[3] = (lPhrase === 'newaccount') ? {param1:'ctl00_Body1_registerbutton', param2:'ctl00_Body1_regemail', param3:'new cus'} : {param1:'ctl00_Body1_loginbutton', param2: 'ctl00_Body1_loginemail', param3: 'login'};
			}
			if (lPhrase === 'accountinformation') 
			{
				G_OutPut[0] = 3;
			}
			if (lPhrase === 'myaccount') 
			{
				G_OutPut[0] = 4;
			}
			
			G_OutPut[1] = lPhrase;
			G_OutPut[2] = (lPhrase === 'checkout_login') ? 'checkout' : 'account';
		}
		return true;
	}
	return false;
}

function psIsTopPageView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	var lSpecialPagesArray = ['viewcart'];
	G_OutPut = [];
	
	if (lString == '/default.aspx' || lString.match(/^(\/)+$/) !== null) 
	{
		G_OutPut[0] = 1;
		return true;
	}
	if (lString.match(/^\/([a-z\-]+)\.aspx(?:\?(?:(start\=[^\W]+)|(storeid\=1)))?$/) !== null) 
	{
		var lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '' && getArrayIndexOf(lPhrase, lSpecialPagesArray) == -1) 
		{
			G_OutPut[0] = 2;
			G_OutPut[1] = lPhrase;
			G_OutPut[2] = lPhrase;
			return true;
		}
	}
	if (lString.match(/\/products\.aspx\?branch\=[0-9]+\~[0-9]+\~$/) !== null) 
	{
		G_OutPut[0] = 3;
		G_OutPut[1] = psGenerateCatIdArray(lString);
		return true;
	}
	return false;
}

function psIsSCFCPageView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	var lCatPagesArray = ['swim', 'collections', 'newarrivals'];
	var lNotSSPagesArray = ['search'];
	// reset the OutPut global array
	G_OutPut = [];
	var lPhrase = '';
	if (lString.match(/^\/([a-zA-Z0-9]+)(\/default\.aspx)/) !== null) 
	{
		lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '' && getArrayIndexOf(lPhrase, lCatPagesArray) > -1) 
		{
			G_OutPut[0] = 1;
			G_OutPut[1] = RegExp.$1;
			return true;
		}
	}
	if (lString.match(/\/(sale|clearance)_([a-z]+)_(shopbystyle|shopbyfabric)\.aspx$/) !== null) 
	{
		G_OutPut[0] = 2;
		G_OutPut[1] = RegExp.$1;
		G_OutPut[2] = RegExp.$2;
		G_OutPut[3] = RegExp.$3;
		return true;
	}
	if (lString.match(/\/(shopbyfabric)(_sale)?\.aspx\?branch\=([0-9]+\~)+/) !== null) 
	{
		G_OutPut[0] = 3;
		G_OutPut[1] = RegExp.$1 ? RegExp.$1 : '';
		G_OutPut[2] = RegExp.$2 ? psDoExtremeTrim(RegExp.$2) + ':' : '';
		G_OutPut[3] = psGenerateCatIdArray(lString);
		return true;
	}
	// for special search return reult
	if (lString.match(/^\/([a-zA-Z_]+)\.aspx\?(?:branch\=(?:([0-9]+)~)+)?\&?searchterm\=/) !== null) 
	{
		lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '' && getArrayIndexOf(lPhrase, lNotSSPagesArray) == -1) 
		{
			G_OutPut[0] = 4;
			G_OutPut[1] = RegExp.$1 ? RegExp.$1 : '';
			G_OutPut[2] = RegExp.$2 ? RegExp.$2 : '';
			return true;
		}
	}
	// for some paticular cases of SSL
	if (lString.match(/^\/secure\/([\w\W]+)\.aspx/) !== null) 
	{
		lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '' && !psIsCheckOutPageView() && !psIsAccountManagePageView()) 
		{
			G_OutPut[0] = 5;
			G_OutPut[1] = lPhrase;
			return true;
		}
	}
	if (lString.match(/^\/(shopbycatalog)\/([a-z0-9]+)\/index\.aspx/) !== null) 
	{
		G_OutPut[0] = 4;
		G_OutPut[1] = RegExp.$1 ? RegExp.$1 : '';
		G_OutPut[2] = RegExp.$2 ? RegExp.$2 : '';
		return true;
	}
	if (lString.match(/^\/([a-z1-9_]+)\/([\w\W]+)\.aspx/) !== null) 
	{
		lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '') 
		{
			if (lPhrase === 'customerservice') 
			{
				G_OutPut[0] = 4;
				G_OutPut[2] = lPhrase;
				G_OutPut[1] = RegExp.$2 ? RegExp.$2 : '';
			}
			else 
			{
				G_OutPut[0] = 5;
				G_OutPut[1] = lPhrase;
			}
		}
		return true;
	}
	if (lString.match(/\/([a-z]+)\.aspx\?branch\=([0-9]+\~)+/) !== null)
	{
		G_OutPut[0] = 6;
        G_OutPut[1] = RegExp.$1;
		G_OutPut[2] = psGenerateCatIdArray(lString);
		return true;
	}
	if (lString.match(/^\/([a-z\_]+)\.aspx/) !== null)
	{
		G_OutPut[0] = 5;
        G_OutPut[1] = RegExp.$1;
		return true;
	}
	return false;
}

function psIsProdsListPageView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	G_OutPut = [];
	
	// local function to factory the tasks
	function lRegularTask(aCaseID)
	{
		G_OutPut[0] = aCaseID;
		G_OutPut[1] = psGenerateCatIdArray(lString);
	}
	
	if (lString.match(/\/products\.aspx\?(?:storeid\=0\&)?branch\=([0-9]+\~)+/) !== null) 
	{
		lRegularTask(1);
		return true;
	}
	if (lString.match(/\/sale\.aspx\?(?:storeid\=0\&)?branch\=([0-9]+\~)+/) !== null) 
	{
		lRegularTask(2);
		return true;
	}
	if (lString.match(/\/onsale\.aspx\?(?:storeid\=0\&)?branch\=([0-9]+\~)+/) !== null) 
	{
		lRegularTask(3);
		return true;
	}
	if (lString.match(/\/([a-z]+)_([a-z]+)_browsebysize_department\.aspx\?(?:storeid\=0\&)?branch\=([0-9]+\~)+/) !== null) 
	{
		var lPhrase = (RegExp.$1) ? RegExp.$1 : '';
		if (lPhrase !== '') 
		{
			if (lPhrase == 'sale') 
			{
				lRegularTask(3);
			}
			else if (lPhrase == 'clearance') 
			{
				lRegularTask(2);
			}
			else 
			{
				return false;
			}
			return true;
		}
	}
	return false;
}

function psIsSearchView()
{
	return (G_PS_PATHNAME.indexOf('/search.aspx') > -1) ? true : false;
}

function psIsProductView()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	return (lString.match(/^\/(catqorder_)?viewproduct\.aspx/) !== null) ? true : false;
}

function psIsCartView()
{
	return (G_PS_PATHNAME.indexOf('/viewcart.aspx') > -1) ? true : false;
}

function psIsOrderView()
{
	return (G_PS_PATHNAME.indexOf('/secure/checkout_receipt.aspx') > -1) ? true : false;
}

function psIsWishListPageView()
{
	return (G_PS_PATHNAME.indexOf('/wishlist.aspx') > -1) ? true : false;
}

/*================ End Of Navi Confirmation Functions ================*/
/*============================ END NAVIGATION ================================*/
/*===================== BEGIN TAGGING BUSSINESS LOGIC ========================*/
function psGetSearchTerm()
{
	var term = "";
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	term = psGetValueFromUrl(lString, 'searchterm');
	
	var lFilterTerm = psGetValueFromUrl(lString, 'parentproductcolorid');
	if (lFilterTerm !== null) 
	{
		term = term + '(filter:' + lFilterTerm + ')';
	}
	return unescape(psHtmlDecode(term));
}

function psCheckEleContent(aElement, aRegPattern, aOptionObj)
{
	if (!psIsElement(aElement)) 
	{
		return null;
	}
	else 
	{
		var lHTMLtext = aElement.innerHTML;
		if (aOptionObj.toLWC === true) 
		{
			lHTMLtext = lHTMLtext.toLowerCase();
		}
		if (aOptionObj.clHTMLtag === true) 
		{
			lHTMLtext = psCleanHtmlTag(lHTMLtext);
		}
		if (aOptionObj.HTMLdecode === true) 
		{
			lHTMLtext = psHtmlDecode(lHTMLtext);
		}
		return lHTMLtext.match(aRegPattern);
	}
}

function psGetSearchResult()
{
	var result = "0";
	
	var lEles = elsByTname(document, 'strong');
	if (psIsArray(lEles)) 
	{
		for (var i = 0; i<lEles.length;i++)
		{
			var lHTMLtext = lEles[i].innerHTML;
			lHTMLtext = psHtmlDecode(psCleanHtmlTag(lHTMLtext.toLowerCase()));
			if (lHTMLtext.match(/your search did not produce any results\./) !== null) 
			{
				break;
			}
			else if (lHTMLtext.match(/viewing results [0-9]+ to [0-9]+ of ([0-9]+)\:/) !== null) 
			{
				result = RegExp.$1;
				break;
			}
		}
	}
	return result;
}

function psGetOuterNode(aEl, pTagName , aRe)
{
	var lReturnEle = null;
	var lRe = aRe;
	
	if (!psIsElement(aEl)) 
	{
		return null;
	}
	else 
	{
		lReturnEle = aEl;
		do 
		{
			lReturnEle = lReturnEle.parentNode;
		}
		while (lReturnEle.nodeName.toLowerCase() != pTagName);
	}
	lRe--;
	if (lRe !== 0) 
	{
		return psGetOuterNode(lReturnEle, pTagName, lRe);
	}
	else 
	{
		return lReturnEle;
	}
}

function psGetCurCatIDfromURI()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	var lCatIDsArray = psGenerateCatIdArray(lString);
	return (psIsArray(lCatIDsArray)) ? lCatIDsArray[lCatIDsArray.length - 1] : '';
}

function psGenerateCatIdArray(aInput)
{
	try 
	{
		var lStr = aInput;
		lStr = lStr.match(/branch\=((?:[0-9]+\~?)+)/)[1];
		if (lStr.length <= 0) 
		{
			return null;
		}
		else 
		{
			var lReturnValue = [];
			var lTempArray = lStr.split('~');
			var lLength = lTempArray.length;
			
			if (lLength <= 0) 
			{
				return null;
			}
			else 
			{
				for (var i = 0; i<lLength; i++)
				{
					if (!(lTempArray[i] === "" || lTempArray[i] === null)) 
					{
						lReturnValue.push(lTempArray[i]);
					}
				}
			}
			return lReturnValue;
		}
		return null;
	} 
	catch (aExcep) 
	{
		return null;
	}
}

function psDoExtremeTrim(aString)
{
	return aString.replace(/[^a-zA-Z0-9\&\-\s\(\)]/ig, '');
}

function psGetCurrentPageNo()
{
	var lPageNo = psGetValueFromUrl(G_PS_URL_PATH, 'page');
	lPageNo = ((lPageNo === null) || (lPageNo === '99999')) ? '1' : lPageNo;
	return lPageNo;
}

function psGetCurrentPageName(aPrefix)
{
	var lPrefix = psIsExisted(aPrefix) ? aPrefix : '';
	var lPageStr = '';
	var lPageNo = psGetCurrentPageNo();
	
	var lNameAtBreadcum = psGetNameFromLastBreadcum();
	
	var lMainName = (lNameAtBreadcum === null) || (lNameAtBreadcum.match(/^(\s)*$/) !== null) ? psGetPNameFromURL() : lNameAtBreadcum;
	lMainName = (lMainName === null) ? psGetPageTitle() : lMainName;
	
	lMainName = (lMainName === null) ? '' : lMainName;
	lMainName = (lMainName.indexOf(lPrefix) === 0) ? lMainName.replace(lPrefix, '') : lMainName;
	lPageStr = lPrefix + lMainName + '[Page: ' + lPageNo + ']';
	
	return lPageStr;
}

function psGetPageTitle()
{
	var lTitleTag = document.getElementsByTagName("title");
	return (lTitleTag.length > 0) ? psGetElementValue(lTitleTag[0]) : "";
}

function psGetNameFromLastBreadcum()
{
	var lEl = ele('breadcrumblastelement');
	return (psIsElement(lEl)) ? psDoExtremeTrim(psHtmlDecode(psCleanHtmlTag(lEl.innerHTML))) : null;
}

function psGetPNameFromURL()
{
	var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
	var lResult = psGetValueFromUrl(lString, 'dept');
	if (lResult === null) 
	{
		return null;
	}
	else 
	{
		return lResult.replace(/[\+]/ig, ' ');
	}
}

function psDoHijackLinksClick(aInput, aOptions)
{
	var lRecEle = ele(aInput);
	if (psIsElement(lRecEle)) 
	{
		var lLinksList = elsByTname(lRecEle, 'a');
		if (psIsArray(lLinksList)) 
		{
			var lBreak = false;
			for (var i = 0; i<lLinksList.length; i++)
			{
				switch (aOptions.caseId)
				{
					case 1:
					{
						psSetEventHandler(lLinksList[i], 'click', function()
						{
							psSetCookie(G_PS_COOKIE_CATID, aOptions.cValue);
						});
						break;
					}
					case 2:
					{
						if (i < aOptions.limiter) 
						{
							psSetEventHandler(lLinksList[i], 'click', function()
							{
								psSetCookie(G_PS_COOKIE_CATID, aOptions.cValue);
							});
						}
						else 
						{
							lBreak = true;
						}
						break;
					}
				}
				if (lBreak === true)
				{
					break;
				}
			}
		}
	}
	else 
	{
		return;
	}
}

function psDoHijackAddToCart(aBtnId, aProdsArray)
{
	var lProds = aProdsArray;
	var lCatId = null;
	
	try 
	{
		var lDoHijackBtn = psSetEventHandler(aBtnId, 'click', function()
		{
			var lItemID = [];
			if (psIsArray(lProds)) 
			{
				lCatId = lProds[0].mCatID;
				var lItemID = [];
				for (var i1 = 0; i1 < lProds.length; i1++) 
				{
					for (var i2 = 1; i2 <= 5; i2++) 
					{
						var lTempEle = ele('ddl' + (i1 + 1) + '_' + i2);
						if (psCheckEleContent(lTempEle, /(^\d*$)|(select\smultiple)/,{toLWC:true, clHTMLtag:true, HTMLdecode:true}) === null) 
						{
							var lInsideSpanEle = elsByTname(lTempEle, 'span')[0];
							if (psCheckEleContent(lInsideSpanEle, /(^\d*$)|(out\sof\sstock)/,{toLWC:true, clHTMLtag:true, HTMLdecode:true}) === null) 
							{
								var lInputEle = elsByTname(lTempEle, 'input');
								if (psIsArray(lInputEle)) 
								{
									lInputEle = lInputEle[0];
									var lInputValue = psGetElementValue(lInputEle, false);
									lInputValue = psTrim(lInputValue.toLowerCase());
									lInputValue = lInputValue.match (/([^-]*)/)[0].toLowerCase();
									var t = getArrayIndexOf(lInputValue, lItemID);
									if (t == -1) 
									{
										lItemID.push(lInputValue);
									}
								}
							}
						}
					}
				}
			}
				
			if (lItemID.length > 0) 
			{
				for (var i4=0; i4<lItemID.length; i4++)
				{
					psSetValueToCookie(G_PS_COOKIE_SHOP, lItemID[i4], lCatId);
				}
			}
		});
	} 
	catch (aExcep) 
	{
		return;
	}
}

function psSetTempUserProfile(aPrefix, isAnon)
{
	var lUp = new psProfile();
	
	if (isAnon === true) 
	{
		lUp._cusId = psGenerateRandomValue();
		
	}
	else 
	{
		lUp._cusId = psGetElementValueById('ctl00_Body1_email', false);
	}
	lUp._email = lUp._cusId;
	lUp._city = psGetElementValueById('ctl00_Body1_' + aPrefix + 'city', false);
	lUp._zipcode = psGetElementValueById('ctl00_Body1_' + aPrefix + 'zip', false);
	lUp._state = psGetElementValueById('ctl00_Body1_ddl' + aPrefix + 'state', true);
	lUp._state = (lUp._state === null) ? psGetElementValueById('ctl00_Body1_' + aPrefix + 'state', false) : lUp._state;
	lUp.writeProfile();
}

function psSetAjaxW84CLogOrder ()
{
	w84me (this,function (o)
	{
		var lBtnEle = document.getElementById('ctl00_Body1_submitorderbutton');
		if (lBtnEle.wasHijacked === undefined)
		{
			psSetEventHandler(lBtnEle, 'click', function()
			{
				var lIsValidate = Page_ClientValidate();
				if (lIsValidate) 
				{
					psSetTempUserProfile('billing', false);
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'OrderCatalog', 'yes');
				}
			});
			lBtnEle.wasHijacked = true;
		}
	},{isBreak:false});
}

function psSetAjaxW84WishList ()
{
	w84me (this,function (o)
	{
		var lBtnEle = document.getElementById('ctl00_Body1_LinkButton1');
		if (lBtnEle.wasHijacked === undefined)
		{
			var lAddToBagBtn = document.getElementById('ctl00_Body1_rwishlist_ctl01_lb_movetocart');
			var lTblEle = psGetOuterNode(lAddToBagBtn, 'table', 2);
			var lTblRows = null;
			if (psIsElement(lAddToBagBtn))
			{
				lTblRows = lTblEle.rows;
				lTblRows = convertToArray(lTblRows);
				var lItemRows = lTblRows.slice(2);
				if (lItemRows.length > 0) 
				{
					for (var i=0; i<lItemRows.length;i++)
					{
						var lListStrongEles = elsByTname(lItemRows[i], 'strong');
						var lProdIDEle = null;
						if (psIsArray(lListStrongEles)) 
						{
							lProdIDEle = lListStrongEles[0];
						}
						var lProdIDEleText = psHtmlDecode(psCleanHtmlTag(psGetElementValue(lProdIDEle, false).toLowerCase()));
						var lProdID = lProdIDEleText.match(/^([^\s]+)/)[1];
						
						var lMoveToBagEle = null;
						var lLinkEles = elsByTname(lItemRows[i], 'a');
						if (psIsArray(lLinkEles))
						{
							for (var j=0;j<lLinkEles.length;j++)
							{
								if (psCheckEleContent(lLinkEles[j], /move\sto\sbag/,{toLWC:true, clHTMLtag:false, HTMLdecode:true}) !== null) 
								{
									lMoveToBagEle = lLinkEles[j];
									lMoveToBagEle.prodID = lProdID;
								}
							}
						}
						if (psIsElement(lMoveToBagEle))
						{
							psSetEventHandler(lMoveToBagEle, 'click', function()
							{
								psSetValueToCookie(G_PS_COOKIE_SHOP, this.prodID, 'wishlist');
							});
						}
					}
				}
			}		
			lBtnEle.wasHijacked = true;
		}
	},{isBreak:false});
}


/*================ Posting Logic Functions ================*/
function psPostRegistration()
{
	var lUp = new psProfile();
	lUp.readProfile();
	if (lUp.email !== null) 
	{
		psCreateRegistrationTag(lUp.email, lUp.email, lUp.city, lUp.state, lUp.zipcode);
	}
	psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'delete');
}

function psCheckValidationRule_01 (pEClassName, pETagName, pCondition, pFunc )
{
	function isTrue (pObj)
	{
		var lReturnValue = false;
		if (pObj.innerHTML !== '')
		{
			if (pObj.style.display !== 'none')
			{
				if (pObj.style.visibility !== 'hidden')
				{
					lReturnValue = true;
				}
			}
		}
		return lReturnValue;
	}
	
	var lErrorEls = elsByCname(pEClassName, document, pETagName);
	if (psIsArray(lErrorEls))
	{
		for (var i1 = 0; i1<lErrorEls.length; i1 ++)
		{
			var lEleHTML = lErrorEls[i1].innerHTML;
			if (isTrue(lErrorEls[i1]) && pCondition)
			{
				pFunc();
				break;
			}
		}
	}
}

function psPostCheckOutPage()
{
	var lPageID = '';
	var lCatID = '';
	
	switch (G_OutPut[0])
	{
		case 1:
		{
			// checkout_billing.aspx
			if (!psIsLoggedIn()) 
			{
				var lDoHijackSubmitBtn = psSetEventHandler('ctl00_Body1_submitbutton', 'click', function()
				{
					var lIsValidate = Page_ClientValidate();
					if (lIsValidate) 
					{
						psSetTempUserProfile('billing', true);
					}
				});
			}
			else
			{
				psCheckValidationRule_01 ('ErrorControl' ,'span', (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'sendReg') == 'ok'), psDoBind(this,psSetValueToCookie, [G_PS_COOKIE_FLAG, 'sendReg', 'no']));
				psSetEventHandler('ctl00_Body1_submitbutton', 'click', function()
				{
					var lIsValidate = Page_ClientValidate();
					if (lIsValidate) 
					{
						psSetValueToCookie(G_PS_COOKIE_FLAG, 'sendReg', 'ok');
					}
				});
			}
			break;
		}
		case 2:
		{
			psCheckValidationRule_01 ('ErrorControl' ,'span', (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'UpFlag') == 'anonymous checkout'), psDoBind(this,psSetValueToCookie, [G_PS_COOKIE_FLAG, 'UpFlag', 'delete']));
			var lDoHijackSubmitBtn = psSetEventHandler('ctl00_Body1_loginbutton', 'click', function()
			{
				var lUp = new psProfile();
				if (lUp.readProfile()) 
				{
					lUp._cusId = lUp._email = psGetElementValueById('ctl00_Body1_regemail', false);
					lUp.writeProfile();
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'anonymous checkout');
				}
			});
			break;
		}
		case 3:
		{
			var lUp = new psProfile();
			
			var lIsAnonymousCheckOut = (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'UpFlag') == 'anonymous checkout') ? true : false;
			if (lIsAnonymousCheckOut) 
			{
				lUp.saveTemp();
				psCreateRegistrationTag(lUp.email, lUp.email, lUp.city, lUp.state, lUp.zipcode);
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'delete');
			}
			else 
			{
				if (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'sendReg') == 'ok') 
				{
					var lBillingInfoEle = document.getElementById('ctl00_Body1_lblbillinginformation');
					if (psIsElement(lBillingInfoEle)) 
					{
						var lBillTblEle = elsByTname(lBillingInfoEle, 'table');
						lBillTblEle = lBillTblEle[0];
						var lBillInfoCell = lBillTblEle.rows[0].cells[0];
						var lRawText = lBillInfoCell.innerHTML;
						
						lRawText = lRawText.replace(/\n|<\/?strong>/gi, '');
						lRawText = lRawText.replace(/<br>$/i, '');
						var lPersonInfo = lRawText.split(/<br>/i);
						
						if (lUp.readProfile()) 
						{
							lUp.city = lPersonInfo[2].match(/([\w\W]+),\s([^,]+)$/)[1];
							lUp.state = lPersonInfo[2].match(/([\w\W]+),\s([^,]+)$/)[2];
							lUp.zipcode = lPersonInfo[3].match(/([\w\W]+)\s([\w]+)$/)[1];
							lUp.writeProfile();
							psCreateRegistrationTag(lUp.email, lUp.email, lUp.city, lUp.state, lUp.zipcode);
							psSetValueToCookie(G_PS_COOKIE_FLAG, 'sendReg', 'no');
						}
					}	
				}
			}
			break;
		}
		case 4:
		{
			psPostShop5();
			break;
		}
	}
	
	lPageID = G_OutPut[1];
	lCatID = G_OutPut[2];
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostAccountManagePage()
{
	var lPageID = '';
	var lCatID = '';
	
	switch (G_OutPut[0])
	{
		case 1:
		{
			psSetEventHandler(G_OutPut[3].param1, 'click', function()
			{
				var lEmail = psGetElementValueById(G_OutPut[3].param2, false);
				if (psIsString(lEmail)) 
				{
					var lUp = new psProfile();
					lUp.cusId = lUp.email = psTrim(lEmail);
					lUp.writeProfile();
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', G_OutPut[3].param3);
				}
			});
			break;
		}
		case 3:
		{
			if (psGetValueFromCookie(G_PS_COOKIE_FLAG,'UpFlag') == 'update account')
			{
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'delete');
			}
			psSetEventHandler('ctl00_Body1_submitbutton', 'click', function()
			{
				var lIsValidate = Page_ClientValidate();
				if (lIsValidate) 
				{
					psSetTempUserProfile('', false);
					psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'update account');
				}
			});
			break;
		}
		case 4:
		{
			var lIsUpdateSucessFull = (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'UpFlag') === 'update account') ? true : false;
			
			if (lIsUpdateSucessFull) 
			{
				var lUp = new psProfile();
				lUp.saveTemp();
				psCreateRegistrationTag(lUp.email, lUp.email, lUp.city, lUp.state, lUp.zipcode);
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'UpFlag', 'delete');
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'sendReg', 'no');
			}
			break;
		}
	}
	
	lPageID = G_OutPut[1];
	lCatID = G_OutPut[2];
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostTopPage()
{
	var lPageID = '';
	var lCatID = '';
	
	switch (G_OutPut[0])
	{
		case 1:
		{
			lPageID = lCatID = 'home';
			break;
		}
		case 2:
		{
			lPageID = G_OutPut[1];
			lCatID = G_OutPut[2];
			break;
		}
		case 3:
		{
			lPageID = psGetPageTitle();
			lCatID = G_OutPut[1][G_OutPut[1].length - 2];
			break;
		}
	}
	
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostProdsListPage()
{
	var lPageID = '';
	var lCatID = '';
	
	var lCenterEles = elsByTname(document, 'center');
	if (psIsArray(lCenterEles)) 
	{
		if (lCenterEles.length === 1) 
		{
			var lMsgEle = lCenterEles[0];
			if (psCheckEleContent(lMsgEle, /your search did not produce any results\./,{toLWC:true, clHTMLtag:true, HTMLdecode:true}) !== null) 
			{
				lPageID = 'NoProductFound';
				lCatID = 'NoProduct';
				psCreatePageviewTag(lPageID, lCatID, null, null);
				psSetCookie(G_PS_COOKIE_CATID, lCatID);
				return;
			}
		}
	}
	
	var lCat = psIsArray(G_OutPut[1]) ? G_OutPut[1][G_OutPut[1].length - 2] : '';
	switch (G_OutPut[0])
	{
		case 1:
		{
			lPageID = psGetCurrentPageName();
			lCatID = lCat;
			break;
		}
		case 2:
		{
			lPageID = psGetCurrentPageName('Clearance -');
			lCatID = 'sale:' + lCat;
			break;
		}
		case 3:
		{
			lPageID = psGetCurrentPageName('onsale:');
			lCatID = 'onsale:' + lCat;
			break;
		}
	}

	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostSCFCPage()
{
	var lPageID = '';
	var lCatID = '';
	
	switch (G_OutPut[0])
	{
		case 1:
		{
			lPageID = G_OutPut[1];
			lCatID = (G_OutPut[1] == 'swim') ? 'swim:ShopByStyle' : G_OutPut[1];
			break;
		}
		case 2:
		{
			lPageID = G_OutPut[1] + '_' + G_OutPut[2] + '_' + G_OutPut[3];
			lCatID = G_OutPut[1] + ':' + G_OutPut[3];
			break;
		}
		case 3:
		{
			lPageID = G_OutPut[2] + G_OutPut[1];
			lCatID = G_OutPut[3][G_OutPut[3].length - 1];
			break;
		}
		case 4:
		{
			lPageID = G_OutPut[1];
			if (G_OutPut[2] === '') 
			{
				lCatID = G_OutPut[1];
			}
			else 
			{
				lCatID = G_OutPut[2];
			}
			break;
		}
		case 5:
		{
			lPageID = lCatID = G_OutPut[1];
			break;
		}
		case 6:
		{
			lPageID = G_OutPut[1];
			lCatID = G_OutPut[2][G_OutPut[2].length - 2];
			break;
		}
	}
	
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostSearchView()
{
	G_PS_CUR_CATID = 'SEARCH';
	var pageId = null;
	var sTerm = psGetSearchTerm();
	var sResult = psGetSearchResult();
	
	if (sResult == 0 || sResult == "0") 
	{
		pageId = "SEARCH UNSUCCESSFUL";
	}
	else 
	{
		pageId = "SEARCH SUCCESSFUL PAGE " + '[' + psGetCurrentPageNo() + ']';
	}
	
	if (pageId !== null) 
	{
		psCreatePageviewTag(pageId, G_PS_CUR_CATID, sTerm, sResult);
	}
	psSetCookie(G_PS_COOKIE_CATID, G_PS_CUR_CATID);
}

function psPostWishListPage()
{
	var lPageID = 'wishlist';
	var lCatID = 'wishlist';
	
	psSetAjaxW84WishList();
	
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostProductView()
{
	// First create a page view tag for the product view page
	var lPageID = 'Product:' + psGetNameFromLastBreadcum();
	var lCatID = '';
	var lSwitch = false;
	var lProducts = [];
	
	var lCatIDfrCookie = psGetCookie(G_PS_COOKIE_CATID);
	if (lCatIDfrCookie == 'recommended' ||
	lCatIDfrCookie == 'recentlyview' ||
	lCatIDfrCookie == 'search' ||
	lCatIDfrCookie == 'catqorder' ||
	lCatIDfrCookie == 'wishlist') 
	{
		lCatID = lCatIDfrCookie;
		lSwitch = true;
	}
	else 
	{
		lCatID = psGetCurCatIDfromURI();
	}
	
	var lProductEles = elsByCname('producttitle', document, 'td');
	if (psIsArray(lProductEles)) 
	{
		for (var i=0; i<lProductEles.length; i++)
		{
			var lElement = psGetOuterNode(lProductEles[i], 'table', 2);
			var prd = new psProduct(lElement);
			if (prd.getProduct())
			{
				var lPcatID = (lSwitch) ? lCatID : prd.catId;
				prd.mCatID = lPcatID;
				psCreateProductviewTag(prd.id, prd.name, lPcatID);
				lProducts.push(prd);
			}
		}
	}
	else 
	{
		var lProdMsgEle = ele('ctl00_Body1_viewProduct1_lblmessage');
		if (psCheckEleContent(lProdMsgEle, /we\'re sorry but this item is currently unavailable\./,{toLWC:true, clHTMLtag:true, HTMLdecode:true}) !== null) 
		{
			lPageID = 'Product:NoProduct';
			lCatID = 'NoProduct';
		}
	}
	
	psDoHijackAddToCart('addtocartbutton', lProducts);
	psDoHijackLinksClick('ctl00_Body1_viewProduct1_accessory1_panelaccessory',{caseId:1, cValue:'RECOMMENDED'});
	psDoHijackLinksClick('ctl00_Body1_viewProduct1_lblbrowsebuttons',{caseId:1, cValue:'products browse'});
	
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, lCatID);
}

function psPostShop5()
{
	var cartTbl = null;
	
	var lTempTdElemens = elsByCname('carthighlightbg', document, 'td');
	if (psIsArray(lTempTdElemens)) 
	{
		cartTbl = psGetOuterNode(lTempTdElemens[0], 'table', 1);
	}

	if (cartTbl === null) 
	{
		return;
	}
	
	var rows = cartTbl.rows;
	var prd = new psProduct();
	for (var r = 0; r < rows.length; r++) 
	{
		if (rows[r].innerHTML.search(/Item\#\/Description/gi) !== -1) 
		{
			continue;
		}
		if (prd.getItem5(rows[r]))
		{
			psCreateShopAction5Tag(prd.id, prd.name, prd.quantity, prd.price, prd.catId, prd.pAttributes);
			psDoHijackLinksClick(rows[r],{caseId:2, limiter:2, cValue:prd.catId});
		}
	}
	psDisplayShop5s();
}

function psPostCartView()
{
	G_PS_CUR_CATID = "CART";
	psCreatePageviewTag("SHOPPING CART", G_PS_CUR_CATID, null, null);
	psPostShop5();
	psSetCookie(G_PS_COOKIE_CATID, G_PS_CUR_CATID);
}

function psPostOrderView()
{
	G_PS_CUR_CATID = "CHECKOUT";
	psCreatePageviewTag("THANK YOU", G_PS_CUR_CATID, null);
	
	var cartTbl = null;
	var lTblWrapper = ele('ctl00_Body1_lbllineitems');
	cartTbl = elsByTname(lTblWrapper, 'table');
	if (psIsArray(cartTbl)) 
	{
		cartTbl = cartTbl[0];
	}
	
	if (cartTbl === null) 
	{
		return;
	}
	
	var rows = cartTbl.rows;
	var ord = new psOrder();
	ord.getOrder();
	var uP = new psProfile();
	uP.readProfile();

	var prd = new psProduct();
	for (var r = 0; r < rows.length; r++)
	{
		if (rows[r].innerHTML.search(/Ext\.\sPrice/gi) !== -1) 
		{
			continue;
		}
		if (prd.getItem9(rows[r])) 
		{
			psCreateShopAction9Tag(prd.id, prd.name, prd.quantity, prd.price, uP.cusId, ord.id, ord.subtotal, prd.catId, prd.pAttributes);
		}
	}
	psDisplayShop9s();
	var pAtts = psGetAttributes("sc1") + "-_-" + psGetAttributes("sc2");
	psCreateOrderTag(ord.id, ord.subtotal, ord.shipping, uP.cusId, uP.city, uP.state, uP.zipcode, pAtts);
	psCreateRegistrationTag(uP.cusId, uP.email, uP.city, uP.state, uP.zipcode, null, null);
	
	psSetCookie(G_PS_COOKIE_FLAG, "", "delete");
	psSetCookie(G_PS_COOKIE_SHOP, "", "delete");
}
/* Added for feedback 2010/06/15 */
function psGetAttributes(pAtb){
	var pAttribute = psGetValueFromUrl(G_PS_QUERYSTRING, pAtb);
	if(pAttribute != null && pAttribute != ""){
		return G_SitePrefix + "=" + pAttribute;
	}
	else{
		return "";
	}
}

function psPostCatalogOrderPage ()
{
	var lPageID = '';
	var lCatID = '';
	
	lPageID = lCatID = G_OutPut[1];
	
	switch (G_OutPut[0])
	{
		case 1:
		{
			
			if (psGetValueFromCookie(G_PS_COOKIE_FLAG,'OrderCatalog') == 'yes')
			{
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'OrderCatalog', 'no');
			}
			psSetAjaxW84CLogOrder();
			break;
		}
		case 2:
		{
			if (psGetValueFromCookie(G_PS_COOKIE_FLAG, 'OrderCatalog') == 'yes') 
			{
				var lUp = new psProfile();
				lUp.saveTemp();
				psCreateRegistrationTag(lUp.email, lUp.email, lUp.city, lUp.state, lUp.zipcode);
				var pAtts = psGetAttributes("sc1") + "-_-" + psGetAttributes("sc2");
				psCreateOrderTag('catalogrequest-' + psGenerateRandomValue() , '5.00', '0.00', lUp.cusId, lUp.city, lUp.state, lUp.zipcode, pAtts);
				psSetValueToCookie(G_PS_COOKIE_FLAG, 'OrderCatalog', 'no');
			}
			break;
		}
	}
	
	psCreatePageviewTag(lPageID, lCatID, null, null);
	psSetCookie(G_PS_COOKIE_CATID, G_PS_CUR_CATID);
}

/*================ End Of Posting Logic Functions ================/
 /*====================== END TAGGING BUSSINESS LOGIC =========================*/
/*======================= GENERAL UTILITY FUNCTION ===========================*/
function psCleanHtmlTag(pValue)
{
	return (pValue != null) ? pValue.replace(/\<+.+?\>+/g, "") : null;
}

function psProduct()
{
	this.e = (arguments[0]) ? arguments[0] : null;
	this.mID = null;
	this.mCatID = null;
	this.id = null;
	this.name = null;
	this.catId = null;
	this.price = null;
	this.quantity = null;
	this.pAttributes = '';
	
	// internal functions
	function lRegularTask()
	{
		var lArgs = arguments;
		var lReturnText = '';
		var lEle = null;
		if (lArgs.length > 1) 
		{
			var lEles = elsByCname(lArgs[0], lArgs[1], lArgs[2]);
			if (psIsArray(lEles)) 
			{
				if (lEles.length != 1) 
				{
					return '';
				}
				else 
				{
					lEle = lEles[0];
				}
			}
			else 
			{
				return '';
			}
			lReturnText = psHtmlDecode(psCleanHtmlTag(psGetElementValue(lEle, lArgs[3]).toLowerCase()));
		}
		else if (lArgs.length == 1) 
		{
			lEle = lArgs[0];
			lReturnText = psHtmlDecode(psCleanHtmlTag(psGetElementValue(lEle, false).toLowerCase()));
		}
		else 
		{
			return '';
		}
		return lReturnText;
	}
	
	function lSetIdAndAttributes()
	{
		var lArgs = arguments;
		var lHTMLtext = (lArgs.length > 1) ? lRegularTask(lArgs[0], lArgs[1], lArgs[2], false) : lRegularTask(lArgs[0]);

		this.mID = lHTMLtext;
		
		if (lHTMLtext.match(/([^\-]+)\-?([^\-]+)?\-?([^\-]+)?/) !== null)
		{
			this.id = RegExp.$1.toLowerCase();
			var lTempSize = '';
			var lTempColor = '';
			if (RegExp.$3 === undefined)
			{
				lTempColor = (RegExp.$2 === undefined)? RegExp.$2 : '';
			}
			else
			{
				lTempSize = RegExp.$2;
				lTempColor = RegExp.$3;
			}
			
			this.pAttributes =lTempSize+'-_-'+lTempColor;
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function lIsSpecialCases(aElement)
	{
		var lNameHTMLtext = lRegularTask(aElement);
		if (lNameHTMLtext !== '') 
		{
			if (lNameHTMLtext.match(/gift\scard/) !== null) 
			{
				this.name = 'GIFT CARD';
				this.pAttributes = '';
			}
			if (lNameHTMLtext.match(/gift\sbox/) !== null) 
			{
				this.name = 'GIFT BOX';
				this.pAttributes = '';
			}
			if (lNameHTMLtext.match(/send\sinvoice/) !== null) 
			{
				this.name = 'INVOICE';
				this.pAttributes = '';
			}
			psSetValueToCookie(G_PS_COOKIE_SHOP, this.mID, this.name.replace(/\s/ig,''));
		}
	}
	
	this.reset = function()
	{
		this.id = null;
		this.mID = null;
		this.mCatID = null;
		this.name = null;
		this.catId = null;
		this.price = null;
		this.quantity = null;
		this.pAttributes = '';
	};
	
	this.getProduct = function()
	{
		try 
		{
			if (!psIsExisted(this.e)) 
			{
				return false;
			}
			this.reset();
			
			var lEles = elsByTname(this.e, 'strong');
			if (psIsArray(lEles)) 
			{
				for (var i=0; i<lEles.length;i++)
				{
					if (psCheckEleContent(lEles[i], /style\s\#([a-z0-9]+)/,{toLWC:true, clHTMLtag: true, HTMLdecode: true}) !== null) 
					{
						this.id = RegExp.$1;
						break;
					}
				}
			}
			
			lEles = elsByCname('producttitle', this.e, 'td');
			if (!psIsArray(lEles) && lEles.length != 1) 
			{
				return false;
			}
			else 
			{
				if (psCheckEleContent(lEles[0], /^([^\$]+)/,{toLWC:true, clHTMLtag:true, HTMLdecode:true}) !== null) 
				{
					this.name = psTrim(RegExp.$1);
				}
			}
			
			this.catId = psGetCurCatIDfromURI();
			return true;
		} 
		catch (ex) 
		{
			return false;
		}
	};

	this.getItem5 = function(itemRow)
	{
		try 
		{
			this.reset();
			var lCheck = lSetIdAndAttributes.call(this, 'bluetext', itemRow, 'font');
			if (!lCheck) 
			{
				return false;
			}
			
			this.name = lRegularTask('small', itemRow, 'font', false);
			if (this.name === '') 
			{
				lIsSpecialCases.call(this, itemRow.cells[2]);
			}
			else
			{
				this.mID = this.id;
			}
			
			this.price = psCleanPrice(lRegularTask(itemRow.cells[5]));
			this.price = (this.price === '') ? psCleanPrice(lRegularTask(itemRow.cells[4])) : this.price;
			
			this.quantity = lRegularTask('', itemRow, 'select', true);
			
			this.price = (this.price !== '')? (parseFloat(this.price)/this.quantity).toFixed(2) + '' : '0.00';
			
			this.catId = psGetValueFromCookie(G_PS_COOKIE_SHOP, this.mID);
			if(this.catId == null)
			{
				this.catId = psAdjustGetValueFrom_PS_SHOP_Cookie(this.mID);
				if(this.catId == null) this.catId = "unknown";
			}
			
			return true;
		} 
		catch (ex) 
		{
			return false;
		}
	};

	this.getItem9 = function(itemRow)
	{
		try 
		{
			this.reset();
			// set id and attributes for this product
			var lCheck = lSetIdAndAttributes.call(this, itemRow.cells[0]);
			if (!lCheck) 
			{
				return false;
			}
			
			this.name = lRegularTask(itemRow.cells[1]);
			this.price = psCleanPrice(lRegularTask(itemRow.cells[4]));
			this.quantity = lRegularTask(itemRow.cells[3]);
			this.catId = psGetValueFromCookie(G_PS_COOKIE_SHOP, this.id);
			if(this.catId == null)
			{
				this.catId = psAdjustGetValueFrom_PS_SHOP_Cookie(this.id);
				if(this.catId == null) this.catId = "unknown";
			}
			
			return true;
		} 
		catch (ex) 
		{
			return false;
		}
	};
}

function psProfile()
{
	this.cusId = null;
	this.email = null;
	this.city = null;
	this.state = null;
	this.zipcode = null;
	this.newsletter = null;
	this.subscribe = null;
	
	this._cusId = null;
	this._email = null;
	this._city = null;
	this._state = null;
	this._zipcode = null;
	this._newsletter = null;
	this._subscribe = null;
	
	this.saveTemp = function()
	{
		try 
		{
			if (!this.readProfile()) 
			{
				return false;
			}
			else 
			{
				this.cusId = this._cusId;
				this.email = this._email;
				this.city = this._city;
				this.state = this._state;
				this.zipcode = this._zipcode;
				this.newsletter = this._newsletter;
				this.subscribe = this._subscribe;
				if (this.writeProfile()) 
				{
					return true;
				}
				else 
				{
					return false;
				}
			}
		} 
		catch (aExcep) 
		{
			return false;
		}
	}
	
	this.readProfile = function()
	{
		try 
		{
			this.cusId = psGetCookie(G_PS_COOKIE_PROFILE);
			if (this.cusId != null) 
			{
				var buf = this.cusId.split('|');
				for (var i = 0; i < buf.length; i++) 
				{
					var tempVal = buf[i];
					buf[i] = (tempVal == "null" ? null : tempVal);
				}
				this.cusId = buf[0];
				this.email = buf[1];
				this.city = buf[2];
				this.state = buf[3];
				this.zipcode = buf[4];
				this.newsletter = buf[5];
				this.subscribe = buf[6];
				
				this._cusId = buf[7];
				this._email = buf[8];
				this._city = buf[9];
				this._state = buf[10];
				this._zipcode = buf[11];
				this._newsletter = buf[12];
				this._subscribe = buf[13];
			}
			if (!this.cusId) 
			{
				this.cusId = psGenerateRandomValue();
			}
			return true;
		} 
		catch (ex) 
		{
			return false;
		}
	};
	
	this.writeProfile = function()
	{
		try 
		{
			if (this.cusId == null && this._cusId == null) 
			{
				return false;
			}
			var data = this.cusId + '|' +
			this.email +
			'|' +
			this.city +
			'|' +
			this.state +
			'|' +
			this.zipcode +
			'|' +
			this.newsletter +
			'|' +
			this.subscribe +
			'|' +
			this._cusId +
			'|' +
			this._email +
			'|' +
			this._city +
			'|' +
			this._state +
			'|' +
			this._zipcode +
			'|' +
			this._newsletter +
			'|' +
			this._subscribe;
			
			psSetCookie(G_PS_COOKIE_PROFILE, data);
			return true;
		} 
		catch (ex) 
		{
			return false;
		}
	};
}

function psOrder()
{
	this.id = null;
	this.subtotal = null;
	this.shipping = null;
	
	this.getOrder = function()
	{
		try 
		{
		
			var lString = doURLdecode((G_PS_PATHNAME.concat(G_PS_QUERYSTRING)).toLowerCase());
			this.id = psGetValueFromUrl(lString, 'weborderid');
			
			var spanItem = document.getElementById("ctl00_Body1_lbltotals");
			if(psIsExisted(spanItem))
			{
				spanItem = psHtmlDecode(spanItem.innerHTML);
				var se = /Sub\-Total([^\$]*)\$([\d\.\,]*)\s*\<\/td\>/gi;
				this.subtotal = (spanItem.search(se)>-1)? RegExp.$2:0;
				se = /Promotional([^\(\$]*)\(\$([\d\.\,]*)\s*\)/gi;
				this.subtotal = (spanItem.search(se)>-1)? (this.subtotal - RegExp.$2):this.subtotal;
				se = /Shipping([^\$]*)\$([\d\.\,]*)\s*\<\/td\>/gi;
				this.shipping = (spanItem.search(se)>-1)? RegExp.$2:0;
			}
			
			if (!this.id) 
			{
				this.id = psGenerateRandomValue();
			}
			
			var lUp = new psProfile();
			lUp.readProfile();
			
			var lEmaiEle = document.getElementById('ctl00_Body1_lblreceiptheader');
			if (psIsElement(lEmaiEle)) 
			{
				lEmaiEle = elsByTname(lEmaiEle, 'strong')[0];
			}
			var lEmail = lEmaiEle.innerHTML;
			
			lUp.cusId = lEmail;
			lUp.email = lEmail;
			
			var lBillingInfoEle = document.getElementById('ctl00_Body1_lblbillingaddress');
			if (psIsElement(lBillingInfoEle)) 
			{
				var lBillFontEle = elsByTname(lBillingInfoEle, 'font');
				lBillFontEle = lBillFontEle[0];
				
				var lRawText = lBillFontEle.innerHTML;
				lRawText = lRawText.replace(/\n/gi, '');
				lRawText = lRawText.replace(/<br>$/i, '');
				var lPersonInfo = lRawText.split(/<br>/i);
				
				var lMyLength = lPersonInfo.length;
				
				lUp.city = lPersonInfo[lMyLength-3].match(/([\w\W]+),\s([^,]+)$/)[1];
				lUp.state = lPersonInfo[lMyLength-3].match(/([\w\W]+),\s([^,]+)$/)[2];
				lUp.zipcode = lPersonInfo[lMyLength-2];
			}
			
			if (!lUp.cusId) 
			{
				lUp.cusId = psGenerateRandomValue();
			}
			
			return lUp.writeProfile();
		} 
		catch (ex) 
		{
			return false;
		}
	};
}

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)
{
	return (pProductName != null) ? pProductName.replace(/[\n\t\v\r’\'\"\™\®]/gi, "") : null; 
}

function psTrim(pStr)
{
	if (pStr == null || typeof(pStr) != "string") 
	{
		return pStr;
	}
	return (pStr != null) ? pStr.replace(/&nbsp;|\u00A0/gi, ' ').replace(/^\s+|\s+$/g, '') : null;
}

function psGetValueFromUrl(pUrl, pKey)
{
	pUrl = (pUrl != null) ? "?" + psTrim(pUrl.toLowerCase()) : null;
	pKey = (pKey != null) ? psTrim(pKey.toLowerCase()) : null;
	
	if (pUrl == null || pKey == null || pUrl.indexOf(pKey) == -1) 
	{
		return null;
	}
	
	var start = pUrl.indexOf('&' + pKey + '=');
	start = (start == -1) ? pUrl.indexOf('?' + pKey + '=') : start;
	if (start >= 0) 
	{
		start = start + pKey.length;
		var end = pUrl.indexOf("&", start);
		if (end == -1)
		{
			end = pUrl.length;
		}
		var middle = pUrl.indexOf("=", start);
		return pUrl.substring(middle + 1, end);
	}
	return null;
}

function psGetElementValueById(pTagId, pValueFlag)
{
	var tag = document.getElementById(pTagId);
	return psGetElementValue(tag, pValueFlag);
}

function psGetElementValue(pTagObj, pValueFlag)
{
	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 (pValueFlag == true) 
			{
				tagValue = pTagObj.options[pTagObj.selectedIndex].value;
			}
			else 
			{
				tagValue = psHtmlDecode(pTagObj.options[pTagObj.selectedIndex].innerHTML);
			}
		}
		else 
		{
			tagValue = psHtmlDecode(pTagObj.innerHTML);
		}
	}
	return tagValue;
}

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, ">");
		pValue = pValue.replace(/&gt;/gi, ">");
	}
	return pValue;
}

function psGetMainDomain(pUrl)
{
	var se = /^https*\:\/\/([^\/\:]+)/gi;
	var domain = (pUrl.search(se) > -1) ? RegExp.$1 : null;
	if (domain != null) 
	{
		if (domain.indexOf("www") == 0) 
		{
			domain = domain.substring(4, domain.length);
		}
		if (G_PS_ARR_DOMAIN != null) 
		{
			for (var i = 0; i < G_PS_ARR_DOMAIN.length; i++) 
			{
				se = new RegExp("[\.]" + G_PS_ARR_DOMAIN[i] + "$", "gi");
				if (("." + domain).search(se) > -1) 
				{
					domain = G_PS_ARR_DOMAIN[i];
					break;
				}
			}
		}
		domain = "." + domain;
	}
	return domain;
}

function psCleanPrice(pPrice)
{
	var pattern = /[^0-9\.]/gi;
	return (pPrice != null ? pPrice.toString().replace(pattern, "") : null);
}

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;
}

function psCookieBase(pCookieName, pCookieValue, pLifeTime)
{
	var pDomain = psGetMainDomain(G_PS_URL_PATH);
	CC(pCookieName, pDomain);
	if (pLifeTime == "delete") 
	{
		return true;
	}
	var expire = (pLifeTime) ? (new Date((new Date()).getTime() + (1000 * pLifeTime))).toGMTString() : null;
	
	return CB(pCookieName, escape(pCookieValue), expire, pDomain);
}

function encodeHtml(strValue)
{
	if (strValue != null) 
	{
		strValue = escape(strValue);
		strValue = strValue.replace(/\//g, "%2F");
		strValue = strValue.replace(/\?/g, "%3F");
		strValue = strValue.replace(/\=/g, "%3D");
		strValue = strValue.replace(/&/g, "%26");
		strValue = strValue.replace(/@/g, "%40");
	}
	return strValue;
}

function psSetCookie(pCookieName, pCookieValue, pLifeTime)
{
	if (!pCookieName) 
	{
		return false;
	}
	
	pCookieValue = (pCookieValue == null) ? "null" : pCookieValue;
	
	if (pLifeTime != "delete") 
	{
		pCookieName = psTrim(pCookieName);
		var oldCookieValue = psGetCookie(pCookieName);
		oldCookieValue = (oldCookieValue == null) ? "null" : oldCookieValue;
		var totalSize;
		if (document.cookie.indexOf(pCookieName) > -1) 
		{
			totalSize = document.cookie.length + encodeHtml(pCookieValue).length - encodeHtml(oldCookieValue).length;
		}
		else 
		{
			totalSize = document.cookie.length + encodeHtml(pCookieValue).length + encodeHtml(pCookieName).length;
		}
		if (totalSize > 3500) 
		{
			return false;
		}
	}
	psCookieBase(pCookieName, pCookieValue, pLifeTime);
	return true;
}

function psSetValueToCookie(pCookieName, pKey, pValue)
{
	if (!pCookieName || !pKey) 
	{
		return false;
	}
	
	pCookieName = psTrim(pCookieName);
	pKey = (pKey != null) ? "#" + psTrim(pKey).toLowerCase() + "~" : pKey;
	var catCookie = psGetCookie(pCookieName);
	catCookie = (catCookie == null) ? "" : catCookie;
	pValue = (pValue == null) ? "null" : pValue;
	var oldCatCookie = catCookie;
	
	var start = catCookie.indexOf(pKey);
	
	var totalsize;
	if (start >= 0)
	{
		var oldValue = psGetValueFromCookie(pCookieName, pKey.replace(/[\~\#]/gi, ""));
		oldValue = (oldValue == null) ? "null" : oldValue;
		var end = catCookie.indexOf("#", start + pKey.length);
		if (end == -1) 
		{
			end = catCookie.length;
		}
		catCookie = catCookie.replace(catCookie.substring(start, end), "");
		totalsize = document.cookie.length + encodeHtml(pKey).length + encodeHtml(pValue).length - encodeHtml(oldValue).length;
	}
	else 
	{
		totalsize = document.cookie.length + encodeHtml(pKey).length + encodeHtml(pValue).length;
		if (document.cookie.indexOf(pCookieName) < 0) 
		{
			totalsize += encodeHtml(pCookieName).length;
		}
	}
	catCookie = pKey + pValue + catCookie;
	var cookieArray = null;
	var count = 0;
	while (totalsize > 3500 && count<1000) 
	{
		var l1 = encodeHtml(catCookie).length;
		cookieArray = catCookie.split("#");
		cookieArray.pop();
		catCookie = cookieArray.join("#");
		var l2 = encodeHtml(catCookie).length;
		totalsize -= (l1 - l2);
		count++;
	}
	if (catCookie == null || catCookie == "") 
	{
		catCookie = oldCatCookie;
	}
	psCookieBase(pCookieName, catCookie, G_PS_COOKIE_LIFETIME);
	return true;
}

function psGetValueFromCookie(pCookieName, pKey)
{
	pCookieName = psTrim(pCookieName);
	pKey = (pKey != null) ? "#" + psTrim(pKey).toLowerCase() + "~" : pKey;
	var catCookie = psGetCookie(pCookieName);
	if (catCookie != null) 
	{
		var start = catCookie.indexOf(pKey);
		if (start >= 0) 
		{
			start = start + pKey.length;
			var end = catCookie.indexOf("#", start);
			if (end == -1) 
			{
				end = catCookie.length;
			}
			return catCookie.substring(start, end);
		}
		return null;
	}
	return null;
}

function psGenerateRandomValue()
{
	var dtDate = new Date();
	var cusRandom = (dtDate.getTime() % 10000000) + (Math.floor(Math.random() * 10000));
	return cusRandom;
}

function psShorttenPageID(pLink)
{
	var temp1 = pLink;
	if (temp1 != null) 
	{
		temp1 = (temp1.length > 255) ? temp1.substr(0, 255) : temp1;
	}
	return temp1;
}

/*================== Vu libs ==================*/
function getArrayIndexOf(aElement, aArray)
{
	var lReturnValue = -1;
	for (var i=0; i<aArray.length; i++)
	{
		if (aElement === aArray[i])
		{
			lReturnValue = i;
			break;
		} 
	}
	return lReturnValue;
}

function doURLdecode(aURL)
{
	var lReturn = aURL;
	if (lReturn) 
	{
		lReturn = lReturn.replace(/\%7e/gi, "~");
		lReturn = lReturn.replace(/\%20/gi, " ");
		lReturn = lReturn.replace(/\+/gi, " ");
	}
	return lReturn;
}

function elsByCname(aSearchClass, aNode, aTag)
{
	var classElements = [];
	var lNode = (aNode === null || aNode === undefined || aNode === '') ? document : aNode;
	var lTag = (aTag === null || aTag === undefined || aTag === '') ? '*' : aTag;
	var els = lNode.getElementsByTagName(lTag);
	if (els.length <= 0) 
	{
		return null;
	}
	var pattern = new RegExp('(^|\\\\s)' + aSearchClass + '(\\\\s|$)');
	for (var i = 0; i<els.length; i++)
	{
		if (pattern.test (els[i].className))
		{
			classElements.push (els[i]);
		}
	}
	return (classElements.length <= 0) ? null : classElements;
}

function convertToArray(aInput)
{
	var lReturnValue = [];
	
	if (aInput.length === 0) 
	{
		return lReturnValue;
	}
	else 
	{
		for (var i=0; i<aInput.length; i++)
		{
			lReturnValue.push (aInput[i]);
		}
		return lReturnValue;
	}
}

function elsByTname(aObj, aTagName)
{
	var lTag = (aTagName === null || aTagName === undefined || aTagName === '') ? '*' : aTagName;
	var lNode = (aObj === null || aObj === undefined || aObj === '') ? document : aObj;
	var els = lNode.getElementsByTagName(lTag);
	if (els.length <= 0) 
	{
		return null;
	}
	return convertToArray(els);
}

function psIsExisted(aInput)
{
	return (typeof(aInput) === "undefined" || aInput === null) ? false : true;
}

function psIsElement(o)
{
	if (!psIsExisted(o)) 
	{
		return false;
	}
	return (typeof HTMLElement === "object" ? o instanceof HTMLElement : typeof o === "object" && o.nodeType === 1 && typeof o.nodeName === "string");
}

function psIsArray(aInput)
{
	if (!psIsExisted(aInput) || typeof aInput != 'object') 
	{
		return false;
	}
	else 
	{
		var criterion = aInput.constructor.toString().match(/array/i);
		return (criterion !== null);
	}
}

function psIsString(aStr)
{
	if (aStr === undefined || aStr === null) 
	{
		return false;
	}
	if (typeof aStr == 'string') 
	{
		return true;
	}
	if (typeof aStr == 'object') 
	{
		var lObjConstructor = aStr.constructor;
		if (typeof(lObjConstructor) === "undefined" || lObjConstructor === null) 
		{
			return false;
		}
		
		var criterion = aStr.constructor.toString().match(/string/i);
		return (criterion !== null);
	}
	return false;
}

function w84me ()
{
    if (arguments.length < 3)
    {
        return;
    }
    var lArgs = Array.prototype.slice.call(arguments);
    var lThisObj = lArgs.shift();
    var lFunc = lArgs.shift();
    var lFlag = lArgs[0];

    lFunc.apply (lThisObj, lArgs);

    if (lFlag.isBreak === false)
    {
        setTimeout(psDoBind(this,w84me,arguments), 100);
    }
}

function psDoBind(aObj, aFunc, args)
{
	return function()
	{
		var lObj = (aObj === true) ? this : aObj;
		return (aFunc === undefined || aFunc === null || typeof aFunc != 'function') ? null : aFunc.apply(lObj, Array.prototype.slice.call(args || []).concat(Array.prototype.slice.call(arguments)));
	};
}

function ele()
{
	var elements = [];
	for (var i = (arguments.length - 1); i >= 0; i--) 
	{
		var element = arguments[i];
		if (typeof element == 'string') 
		{
			element = document.getElementById(element);
		}
		if (arguments.length == 1) 
		{
			return element;
		}
		elements.push(element);
	}
	return elements;
}

function psSetEventHandler(aInput, aEvent, aFunc)
{
	function tuneStr(aStr)
	{
		var output = aStr.toLowerCase();
		return (output.indexOf('on') === 0) ? output.slice(2) : output;
	}
	
	function addEvent(aObj, aEvt, aFn)
	{
		if (document.addEventListener) 
		{
			addEvent = function(aObj, aEvt, aFn)
			{
				aObj.addEventListener(aEvt, aFn, false);
			};
		}
		else if (document.attachEvent) 
		{
			addEvent = function(aObj, aEvt, aFn)
			{
				aObj.attachEvent('on' + aEvt, aFn);
			};
		}
		else 
		{
			addEvent = function(aObj, aEvt, aFn)
			{
				aObj['on' + aEvt] = aFn;
			};
		}
		addEvent(aObj, aEvt, aFn);
	}
	
	function doBind(aObj, aFunc, args)
	{
		return function()
		{
			var lObj = (aObj === true) ? this : aObj;
			return (aFunc === undefined || aFunc === null || typeof aFunc != 'function') ? null : aFunc.apply(lObj, Array.prototype.slice.call(args || []).concat(Array.prototype.slice.call(arguments)));
		};
	}
	
	// get out of the function if the parameters is not valide, for faster compile
	if (aInput === undefined || aEvent === "" || aInput === null ||
	!psIsString(aEvent) ||
	aEvent === "" ||
	aFunc === undefined ||
	aFunc === null ||
	typeof aFunc != 'function') 
	{
		return false;
	}
	
	var lDomElement = psIsString(aInput) ? document.getElementById(aInput) : aInput;
	
	if (lDomElement === null || lDomElement === undefined || !psIsElement(lDomElement)) 
	{
		return false;
	}
	
	var lEventStr = tuneStr(aEvent);
	
	try 
	{
		if (typeof lDomElement['on' + lEventStr] == 'function') 
		{
			lDomElement.oldEventHandler = lDomElement['on' + lEventStr];
			lDomElement['on' + lEventStr] = doBind(lDomElement, function()
			{
				aFunc.apply(this);
				return this.oldEventHandler();
			});
			return true;
		}
		else 
		{
			addEvent(lDomElement, lEventStr, doBind(lDomElement, aFunc));
			return true;
		}
	} 
	catch (aExcep) 
	{
		return false;
	}
}

/*================== End of Vu libs ==================*/
/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pId, pCatId, pSrchTerm, pSrchResult) 
{
	pId = psCleanPageId(pId);
	pId = psShorttenPageID(pId);
	pCatId =  G_SitePrefix + ':' + 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(pName);
	pCatId =  G_SitePrefix + ':' + 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, pAttributes) 
{
	pName = psCleanProductName(pName);
	pCatId =  G_SitePrefix + ':' + psCleanCatId(pCatId);
	pQuantity = psCleanPrice(pQuantity);
	pPrice = psCleanPrice(pPrice);
	if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
		alert("cmCreateShopAction5Tag(" + pId + ", " + pName + ", " + pQuantity + ", " + pPrice + ", " + pCatId + ", " + pAttributes + ")");
	if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
		cmCreateShopAction5Tag(pId, pName, pQuantity, pPrice, pCatId, pAttributes);
}

function psCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId, pAttributes) 
{
	pName = psCleanProductName(pName);
	pCatId =  G_SitePrefix + ':' + psCleanCatId(pCatId);
	pQuantity = psCleanPrice(pQuantity);
	pPrice = psCleanPrice(pPrice);
	pOrderTotal = psCleanPrice(pOrderTotal);
	if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
		alert("cmCreateShopAction9Tag(" + pId + ", " + pName + ", " + pQuantity + ", " + pPrice + ", " + pCusID + ", " + pOrderID + ", " + pOrderTotal + ", " + pCatId + ", " + pAttributes + ")");
	if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
		cmCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId, pAttributes);
}

function psCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip, pAttributes) 
{
	pOrderTotal = psCleanPrice(pOrderTotal);
	pOrderShipping = psCleanPrice(pOrderShipping);
	if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
		alert("cmCreateOrderTag(" + pId + ", " + pOrderTotal + ", " + pOrderShipping + ", " + pCusID + ", " + pCusCity + ", " + pCusState + ", " + pCusZip + ", " + pAttributes + ")");
	if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
		cmCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip, pAttributes);
}

function psCreateConversionEventTag(pId, pActionType, pCatID, pPoints) 
{
	pCatId =  G_SitePrefix + ':' + 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 =  G_SitePrefix + ':' + 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 ==================*/
