/************************************************************************************/
/* $Revision: 104896 $
 * $Id: cmtaggingservices.js 104896 2008-12-01 15:11:00Z croberts $
 *
 * Author: Coremetrics/PSD 
 * Coremetrics  v4.8, 01/20/2009
 * COPYRIGHT 1999-2008 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 MUST stay commented out.  The client has a wrapper function in their
//  source code to handle the call. 20080904 -Carl Roberts
//cmSetProduction();
/*===========================GLOBAL VARIABLES ===============================*/
// current page url
var G_PS_URL_PATH 				= "" + document.location;
var G_PS_URL_REFERRER 			= document.referrer.toLowerCase();
var G_PS_PATHNAME 				= document.location.pathname.toLowerCase();
var G_PS_QUERYSTRING 			= document.location.search.toLowerCase();
var G_PS_COOKIE_LIFETIME 		= 5184000; // 60*24*60*60 = 60 days (updated from 5, dpl 20100824)
// cookie name
var G_PS_COOKIE_CATID 			= "PS_CATID";
var G_PS_COOKIE_PROD_CATID 		= "PS_PROD_CATID";
var G_PS_COOKIE_REGISTRATION	= "PS_REGISTRATION"
var G_PS_FLAG 					= "PS_FLAG";
var G_PS_DOMAIN_TOMMYBAHAMA		= "http://www.tommybahama.com"

// options for debug mode when sending tag:
// 1: only alert
// 2: only send tag
// 3: alert & send tag
var G_PS_DEBUG_MODE = 2;
/*========================= END GLOBAL VARIABLES =============================*/
/*=========================== BEGIN NAVIGATION ===============================*/
if (document.body != null && document.body.innerHTML.search(/\/images\/error\/text2_v1_m56577569830471711.gif/gi)>=0){
	psCreateErrorTag("Page Unavailable", "HOME PAGE");
}
// -- dpl 07/15/2010 - updated to accomodate two URLs representing "Home Page":
//else if(G_PS_PATHNAME.indexOf("store/index.jsp")>=0){
//	psCreatePageviewTag("HOME PAGE", "HOME PAGE", null, null);
//}
else if (G_PS_PATHNAME.indexOf("store/index.jsp")>=0 || G_PS_URL_PATH==G_PS_DOMAIN_TOMMYBAHAMA || G_PS_URL_PATH=="http://www.tommybahama.com/" || G_PS_URL_PATH.indexOf("www.tommybahama.com/?")>=0){
	psCreatePageviewTag("HOME PAGE", "HOME PAGE", null, null);
}

else if(G_PS_PATHNAME.indexOf("prd_")>=0){ 	
	var pPageId;var pCatId;var pProName;var pProId;
	var pProIdArr = G_PS_PATHNAME.split("/");					
	for(var i=0;i<pProIdArr.length;i++){
		if (pProIdArr[i].indexOf("prd_")>=0){
			pProId = pProIdArr[i].substring(pProIdArr[i].indexOf("prd_")+4,pProIdArr[i].length);
			if (pProIdArr[i-1] == "giftcards_m"){
				pProName = psRemovePlus(pProIdArr[pProIdArr.length-1].substring(0,pProIdArr[pProIdArr.length-1].indexOf("."))) ;	
			}
			else{
				var divTag_proName = psGetElementsByClassName(document,"div","detail_title");
				if (psCheckArrayExist(divTag_proName)==true){			
					pProName = psTrim(psGetInnerText(psHtmlDecode(divTag_proName[0].innerHTML)));
				}
			}				
		}
		if (pProId!=null && pProName!=null){
			break;
		}
	}				
	if (G_PS_URL_REFERRER!=""){
		pCatId = psGetCookie(G_PS_COOKIE_CATID);
		if (psGetDomain(G_PS_URL_REFERRER).indexOf("tommybahama.com")>=0){					
			if (pCatId == null){pCatId="SEARCH";}
		}
		else{pCatId="BookMarks";}
	}
	else{
		pCatId = psGetCookie(G_PS_COOKIE_CATID);
		if (pCatId == null){pCatId="SEARCH";}
	}	
	psCreateProductviewTag(pProId, pProName, pCatId);
	psCreateEventsForAddToBag(pProId);
}
/*--------- old search page commented out---------
else if (G_PS_PATHNAME.indexOf("store/catalog/search_results.jsp")>=0){	
	var h1Tag =  psGetElementsByClassName(document,"h1","floatleft");
	if (psCheckArrayExist(h1Tag)==true)
	{
		var spanTag =h1Tag[0].getElementsByTagName("span");
		if (psCheckArrayExist(spanTag)==true)
		{
			var pPageId = "SEARCH SUCCESSFUL";
			var pKeyWords =psTrim(spanTag[0].innerHTML);			
			pKeyWords = pKeyWords.substring(1,pKeyWords.length-1);
			var pArrSearchString = psCleanHtmlTag(psTrim(h1Tag[0].innerHTML)).split(" ");
			var pSearchResults = psTrim(pArrSearchString[pArrSearchString.length-2]);
			if (pSearchResults=="0")
				pPageId = "SEARCH UNSUCCESSFUL";
			psCreatePageviewTag(pPageId, "SEARCH",pKeyWords, pSearchResults);
			psSetCookie(G_PS_COOKIE_CATID,"SEARCH");			
		}		
	}
}
----------- END old search page ------------
*/

//---------------- NEW Search Page ---------------
else if (G_PS_PATHNAME.indexOf("store/catalog/search_results.jsp")>=0){	
	
	var pPageId = "SEARCH UNSUCCESSFUL";
	var pKeyWords = "";
	var pSearchResults = "0";
	
	/*
	 * get the search term
	 * find the div tag with class=title:
	 * <div class="title" id="title_search">
	 *	<h1>SEARCH RESULTS:&nbsp;&quot;shirts&quot;</h1>	
	 */
	var divTitleClassTag = psGetElementsByClassName(document,"div","title");
	if (psCheckArrayExist(divTitleClassTag)==true)
	{
		var h1Tag = divTitleClassTag[0].getElementsByTagName("h1");
		if (psCheckArrayExist(h1Tag)==true)
		{		
			var pKeyWordsTag = psTrim(h1Tag[0].innerHTML);
			var pArrpKeyWords = psCleanHtmlTag(psTrim(pKeyWordsTag)).split(":");
			pKeyWords = psTrim(pArrpKeyWords[pArrpKeyWords.length-1]);			
			pKeyWords = pKeyWords.substring(1,pKeyWords.length-1);
		}
	}
	
	/* now check if we have any search results
	 * look for the spanResultsHeaderSelected:
	 * <td class="tdHeaderRight">
	 *	<span class="spanResultsHeaderLabel">VIEWING:</span>&nbsp;&nbsp;<span class="spanResultsHeaderSelected">1 - 3 of 3</span>
	 * </td>	 
	 */
	var spanResultsTag = psGetElementsByClassName(document,"span","spanresultsheaderselected");	
	if (psCheckArrayExist(spanResultsTag)==true)
	{
		// we have some search results
		pPageId = "SEARCH SUCCESSFUL";
		var pArrSearchTotal = psCleanHtmlTag(psTrim(spanResultsTag[1].innerHTML)).split(" ");
		pSearchResults = psTrim(pArrSearchTotal[pArrSearchTotal.length-1]);						
		
	} else {
		// no search results
		// use default values defined above
	}
	
	psCreatePageviewTag(pPageId, "SEARCH",pKeyWords, pSearchResults);
	psSetCookie(G_PS_COOKIE_CATID,"SEARCH");				
}

//---------------- END NEW Search Page ---------------





else if (G_PS_PATHNAME.indexOf("store/catalog/product_detail_modal.jsp")>=0){
	var pProId ; var pCatId;var pProName;
	var divTag = psGetElementsByClassName(document,"div","modal_detail_title");
	if (psCheckArrayExist(divTag)==true)
	{
		pProName = psTrim(psGetInnerText(psHtmlDecode(divTag[0].innerHTML)));			
		var divTagProId = psGetElementsByClassName(document,"div","modal_detail_text");
		if (psCheckArrayExist(divTagProId)==true)
		{
			var liTag = divTagProId[0].getElementsByTagName("li");
			if (psCheckElementExist(liTag)==true){
				pProId = psTrim(psGetInnerText(psHtmlDecode(liTag[liTag.length-1].innerHTML)));	
			}						
			pCatId = "May we also suggest";
			psSetCookie(G_PS_COOKIE_CATID,pCatId);
			psCreateProductviewTag(pProId, pProName, pCatId);
			psCreateEventsForAddToBag(pProId);
		}
	}	
}
else if (G_PS_PATHNAME.indexOf("store/checkout/cart.jsp")>=0){
	psCreatePageviewTag("Shoppingcart", "store:checkout:Shoppingcart", null, null);
	var divTag = psGetElementsByClassName(document,"div","title");
	if (psCheckArrayExist(divTag)==true){
		var ImageTag = divTag[0].getElementsByTagName("img");
		if (psCheckArrayExist(ImageTag)==true){
			if (ImageTag[0].alt=="Your Shopping Bag"){
				psPostCartView();
			}
		}
	}	
}
else if (G_PS_PATHNAME.indexOf("store/checkout/payment.jsp")>=0){
	psCreatePageviewTag("PAYMENT", "store:checkout:payment", null, null);		
}
else if (G_PS_PATHNAME.indexOf("store/checkout/order_confirm.jsp")>=0){
	var pRegStr = psGetCookie(G_PS_COOKIE_REGISTRATION);
	if (psCheckElementExist(pRegStr)==true){
		// Get City, State, and Zipcode
		var buf = document.body.innerHTML.toLowerCase().split("title_shortline_230")[1];
		if (buf != null && buf != "undefined"){
			buf = buf.split("</td>")[0];
			buf = buf.split("<br");
			buf = buf[buf.length-2]; // the last one
			buf = psHtmlDecode(buf.replace("/>", ""));
			var zip = buf.substr(buf.lastIndexOf(" ") + 1);
			buf = buf.substring(0, buf.lastIndexOf(" "));
			var state = buf.substr(buf.lastIndexOf(" ") + 1);
			var city = buf.substring(0, buf.lastIndexOf(", ")).replace(">", "");
			var email = pRegStr.split("|")[0];
			psCreateRegistrationTag(email, email, city, state, zip);
		}
	}
	// Throw shop9 & order tags
	psPostOrderView();
}
///////////////////////////////////////////////////////////////
//
// dpl - added 06/03/2010 - do not update tag on view larger page:
else if (G_PS_PATHNAME.indexOf("store/catalog/product_view_larger_modal.jsp")>=0){
	//do nothing		
}
// do not update tag on size chart view:
else if (G_PS_PATHNAME.indexOf("generalcontent/modal/size_charts.jsp")>=0) {
	//do nothing
}
// do not update tag on size chart view:
else if (G_PS_PATHNAME.indexOf("store/catalog/product_detail.jsp")>=0) {
	//do nothing
}
// do not update tag on modal view:
else if (G_PS_PATHNAME.indexOf("/tbg/generalcontent/modal/")>=0) {
	//do nothing
}
// do not update tag on SEO landing page view:
else if (G_PS_PATHNAME.indexOf("/tbg/s/")>=0) {
	//do nothing
}
//
//
////////////////////////////////////////////////////////////////
else{
	var pPageID=null; var pCatID=null;
	var liTag = document.getElementById("leftnav_on");
	if (psCheckArrayExist(liTag)==true)
	{		
		pPageID = psTrim(psGetInnerText(psHtmlDecode(liTag.getElementsByTagName("a")[0].innerHTML)));		
		var liSubTag=document.getElementById("left_nav_sub_on");
		if (psCheckElementExist(liSubTag)==true){
			pPageID = psTrim(psGetInnerText(psHtmlDecode(liSubTag.getElementsByTagName("a")[0].innerHTML)));	
		}
	}
	// dpl - added on 7/29/2010 - remove commas and apostrophes from tag:
	if (pPageID!=null) {
		pPageID = pPageID.replace(",","");
		pPageID = pPageID.replace("'","");
	}
	var strValue = G_PS_PATHNAME.substring(G_PS_PATHNAME.lastIndexOf("/")+1,G_PS_PATHNAME.length);
	var arrFlash = G_PS_PATHNAME.split("/");	
	if (arrFlash!=null){	
		if (arrFlash.length==3){
			if (arrFlash[1]=="tbg"){				
				pCatID =  strValue.substring(0,strValue.indexOf("."));	
				pPageID =psRemove_dash(pCatID); 	
			}
			else{
				pCatID = arrFlash[1] + ":" + strValue.substring(0,strValue.indexOf("."));				
				pPageID =psRemove_dash(strValue.substring(0,strValue.indexOf("."))); 
			}
		}
		else if (arrFlash.length==4){
			if (arrFlash[1]=="tbg"){
				pCatID = arrFlash[2] + ":" + strValue.substring(0,strValue.indexOf("."));			
			}
			else{
				pCatID = arrFlash[1] + ":" + arrFlash[2] + ":" + strValue.substring(0,strValue.indexOf("."));			
			}
		}
		else if (arrFlash.length==5){
			if (arrFlash[1]=="tbg")
				pCatID = arrFlash[2] + ":" + arrFlash[3] + ":" + strValue.substring(0,strValue.indexOf("."));
			else
				pCatID = arrFlash[1] + ":" + arrFlash[2] + ":" + arrFlash[3] + ":" + strValue.substring(0,strValue.indexOf("."));
		}
	}
	if (pPageID==null)
		pPageID = psRemove_dash(strValue.substring(0,strValue.indexOf(".")));	
	psCreatePageviewTag(pPageID,pCatID,null, null);		
	psSetCookie(G_PS_COOKIE_CATID,pCatID);
}
psSubscribeProfilePages();
psPostRegistrationView();

/*
 * Check to throw page view tag during checkout process
 * RETURN: checkout step index
 */
function postCheckoutPageView()
{
	var result = -1;
	var ulTag = psGetElementsByClassName(document,"ul","checkout_nav");
	if (psCheckArrayExist(ulTag)==true)
	{
		var imgTag = ulTag[0].getElementsByTagName("img");
		if (psCheckArrayExist(imgTag)==true)
		{		
			for (var i =0; i<imgTag.length; i++)
			{				
				if (imgTag[i].src.indexOf("/media/TB001/images/checkout/nav_chk_billing_on")>=0)
				{
					psCreatePageviewTag("Billing & Shipping", "store:checkout:Billing & Shipping", null, null);
					result = 0;
				}
				else if (imgTag[i].src.indexOf("/media/TB001/images/checkout/nav_chk_payment_on")>=0)
				{
					psCreatePageviewTag("PAYMENT", "store:checkout:PAYMENT", null, null);	
					result = 1;
				}
				else if (imgTag[i].src.indexOf("/media/TB001/images/checkout/nav_chk_review_on")>=0)	
				{
					psCreatePageviewTag("Review", "store:checkout:Review", null, null);			
					result = 2;
				}
				else if (imgTag[i].src.indexOf("/media/TB001/images/checkout/nav_chk_confirmation_on")>=0)	
				{
					psCreatePageviewTag("Confirmation", "store:checkout:Confirmation", null, null);	
					result = 3;
				}
			}
		}
	}
	return result;
}
/*============================ END NAVIGATION ================================*/
/*===================== BEGIN TAGGING BUSSINESS LOGIC ========================*/
function psCreateEventsForAddToBag(pProId){
	var pAddToBag = document.getElementById("normalDetailAdd");			
	if (psCheckElementExist(pAddToBag)==true){
		pAddToBag.OldFunc = pAddToBag.onclick; // backup pointer
		pAddToBag.onclick = function(){			
			var pCatId = psGetCookie(G_PS_COOKIE_CATID);			
			psSetValueToCookie(G_PS_COOKIE_PROD_CATID,psTrim(pProId).toLowerCase(),pCatId);								
			if (this.OldFunc!=null)
				return this.OldFunc();
		}			
	}
}
function psSubscribeProfilePages(){
	if (G_PS_PATHNAME.indexOf("store/checkout/cart.jsp")>=0 || G_PS_PATHNAME.indexOf("store/checkout/address_details.jsp")>=0){
		var btn_create_account = document.getElementById("btn_create_account");
		if (psCheckElementExist(btn_create_account)==true){			
			btn_create_account.OldFunc = btn_create_account.onclick; // backup pointer
			btn_create_account.onclick = function(){
				var pEmail = document.getElementById("emailAddress");
				pEmail = (pEmail != null ? pEmail.value : psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION)));
				var pZipCode = document.getElementById("bill_zip");
				pZipCode = (pZipCode != null ? pZipCode.value : "");
				var pCity = document.getElementById("bill_city");
				pCity = (pCity != null ? pCity.value : "");
				var pState = psGetElementValue(document.getElementById("bill_state"),true); 			
				psSetCookie(G_PS_COOKIE_REGISTRATION,pEmail+"|"+pCity+"|"+pState+"|"+pZipCode);
				psSetCookie(G_PS_FLAG,"regcheckout");			
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}		
		var btn_continue = document.getElementById("btn_set_address"); 
		if (psCheckElementExist(btn_continue)==true){
			btn_continue.OldFunc = btn_continue.onclick; // backup pointer
			btn_continue.onclick = function(){
				var pEmail = document.getElementById("emailAddress");
				pEmail = (pEmail != null ? pEmail.value : psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION)));
				var pZipCode = document.getElementById("bill_zip");
				pZipCode = (pZipCode != null ? pZipCode.value : "");
				var pCity = document.getElementById("bill_city");
				pCity = (pCity != null ? pCity.value : "");
				var pState = psGetElementValue(document.getElementById("bill_state"),true); 			
				psSetCookie(G_PS_COOKIE_REGISTRATION,pEmail+"|"+pCity+"|"+pState+"|"+pZipCode);
				psSetCookie(G_PS_FLAG,"regcheckout");			
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/myaccount/edit_bill_address.jsp")>=0 || G_PS_PATHNAME.indexOf("store/myaccount/add_bill_address.jsp")>=0){	
		var btnAddrSubmit =document.getElementById("addrSubmit");
		if (psCheckElementExist(btnAddrSubmit)==true){
			btnAddrSubmit.OldFunc = btnAddrSubmit.onclick; 
			btnAddrSubmit.onclick = function()
			{
				var pCity = document.getElementsByName("BILL_TO_ADDRESS<>city")[0].value;
				var pZipCode = document.getElementsByName("BILL_TO_ADDRESS<>postal")[0].value; 	 			
				var pState_obj = document.getElementsByName("BILL_TO_ADDRESS<>state_cd"); 
				var pState = psGetElementValue(pState_obj[0],true);
				var pEmail = psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION));
				psSetCookie(G_PS_COOKIE_REGISTRATION,pEmail+"|"+pCity+"|"+pState+"|"+pZipCode);
				psSetCookie(G_PS_FLAG,"billaddress");
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/account/login_or_register.jsp")>=0){		
		var btnCreate = document.getElementById("button_account_create");	
		if (psCheckElementExist(btnCreate)==true){
			btnCreate.OldFunc = btnCreate.onclick; // backup pointer
			btnCreate.onclick = function(){
				var pEmailCreate = document.getElementsByName("USER_ACCOUNT<>email");			
				if (psCheckArrayExist(pEmailCreate)==true)
				{				
					psSetCookie(G_PS_COOKIE_REGISTRATION,pEmailCreate[0].value);
					psSetCookie(G_PS_FLAG,"create");
				}
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
		var btnLogin =document.getElementById("login");
		if (psCheckElementExist(btnLogin)==true){
			btnLogin.OldFunc = btnLogin.onclick; // Backup pointer
			btnLogin.onclick = function(){
				var pEmail_Login=document.getElementsByName("LOGIN<>userid");			
				if (psCheckArrayExist(pEmail_Login)==true){					
					psSetCookie(G_PS_COOKIE_REGISTRATION,pEmail_Login[0].value);
					psSetCookie(G_PS_FLAG,"login");
					
				}
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
		var btnForgotPass =document.getElementById("button_forgot_password");
		if (psCheckElementExist(btnForgotPass)==true){
			btnForgotPass.OldFunc = btnForgotPass.onclick; // backup pointer
			btnForgotPass.onclick = function(){
				var pEmail_forgotPass=document.getElementsByName("FORGOT_PASSWORD<>email");			
				if (psCheckArrayExist(pEmail_forgotPass)==true){				
					psSetCookie(G_PS_FLAG,"forgotpassword");
					
				}
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/myaccount/edit_personal_information.jsp")>=0 || G_PS_PATHNAME.indexOf("store/account/edit_account.jsp")>=0){			
		var btnEditInfoSubmit =document.getElementById("editInfoSubmit");
		if (psCheckElementExist(btnEditInfoSubmit)==true){
			btnEditInfoSubmit.OldFunc = btnEditInfoSubmit.onclick; // backup pointer
			btnEditInfoSubmit.onclick = function(){
				var pEmail_Info=document.getElementsByName("USER_ACCOUNT<>email");			
				if (psCheckArrayExist(pEmail_Info)==true){				
					psSetCookie(G_PS_COOKIE_REGISTRATION,pEmail_Info[0].value);
					psSetCookie(G_PS_FLAG,"info");				
				}
				// Invoke original function
				if (this.OldFunc!=null)
					return this.OldFunc();
			}
		}
	}
}
function psPostRegistrationView(){		
	if (G_PS_PATHNAME.indexOf("store/account/login_or_register.jsp")>=0){
		if (psGetCookie(G_PS_FLAG) == "login" || psGetCookie(G_PS_FLAG) == "create"){			
			var divError_login = psGetElementsByClassName(document,"div","site_error");			
			if (psCheckArrayExist(divError_login)==false){				
				var pEmail = psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION));
				if (psCheckElementExist(pEmail)==true){
					psCreateRegistrationTag(pEmail,pEmail);			
					psSetCookie(G_PS_FLAG," ", "delete")
				}
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/myaccount/edit_personal_information.jsp")>=0){
		if (psGetCookie(G_PS_FLAG) == "info"){
			var divError_Info = psGetElementsByClassName(document,"div","site_error");
			if (psCheckArrayExist(divError_Info)==false){
				var pEmail = psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION));
				if (psCheckElementExist(pEmail)==true){
					psCreateRegistrationTag(pEmail,pEmail);			
					psSetCookie(G_PS_FLAG," ", "delete")
				}
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/checkout/address_details.jsp")>=0){	
		var tagH1 = document.getElementsByTagName("H1");
		if (psCheckArrayExist(tagH1)==true){
			if (psGetInnerText(tagH1[0]).toUpperCase()=="2. PAYMENT"){
				if (psGetCookie(G_PS_FLAG) == "regcheckout"){
					psPostReg();
					psSetCookie(G_PS_FLAG," ", "delete");
				}			
			}
		}
	}
	else if (G_PS_PATHNAME.indexOf("store/myaccount/add_bill_address.jsp")>=0 || G_PS_PATHNAME.indexOf("store/myaccount/edit_bill_address.jsp")>=0){
		if (psGetCookie(G_PS_FLAG) == "billaddress"){
			var divError_bill = psGetElementsByClassName(document,"div","site_error");
			if (psCheckArrayExist(divError_bill)==false){
				psPostReg();
				psSetCookie(G_PS_FLAG," ", "delete");
			}
		}
	}	
}
function psPostReg(){
	var pRegStr = psGetCookie(G_PS_COOKIE_REGISTRATION);
	if (pRegStr!=null){
		psCreateRegistrationTag(pRegStr.split("|")[0],pRegStr.split("|")[0],pRegStr.split("|")[1],pRegStr.split("|")[2],pRegStr.split("|")[3]);			
		psSetCookie(G_PS_FLAG," ", "delete")
	}
}
function psSplitEmail(tempEmail)
{
	if (tempEmail!=null){
		if (tempEmail.indexOf("|")>0){			
			return tempEmail.split("|")[0];
		}
		else{
			return tempEmail;
		}
	}
	return "";	
}
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;
}

// Check an element exist or not
function psCheckElementExist(pElement){
    if(typeof(pElement) == "undefined" || pElement == null)
		return false;
    return true;
}
// Find element by name
function psGetElementByName(psDocument, psElementTagName, psElementName, psElementType){
    // Find all elements that tag name is specified
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)    
        return null;    
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        // Find one that has specified name
        if(arrInputs[i].name.toLowerCase() == psElementName)
        {
            // If element type is provided
            if(typeof(psElementType) != "undefined" && psElementType != "")
            {
                // Find it
                if(arrInputs[i].type.toLowerCase() == psElementType)
					return arrInputs[i];                
            }
            else
				return arrInputs[i];
        }
    }
    return null;
}

// Get elements which name is known
function psGetElementsByName(psDocument, psElementTagName, psElementName, psElementType){
    var arrResult = new Array();
    var index = 0;
    // Find all elements that tag name is specified
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
        return null;    
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        // Find one that has specified name
        if(arrInputs[i].name.toLowerCase() == psElementName)
        {
            // If element type is provided
            if(typeof(psElementType) != "undefined" && psElementType != "")
            {
                // Find it
                if(arrInputs[i].type.toLowerCase() == psElementType)
                {
                    arrResult[index] = arrInputs[i];
                    index ++ ;
                }
            }
            else
            {
                arrResult[index] = arrInputs[i];
                index ++ ;
            }
        }
    }

    return arrResult;
}
/*
 * Process to post shop5tags for items in shopping cart
 */
function psPostCartView(){			
	var selectTag=document.getElementsByName("CART_ITEM_ARRAY<>quantity");
	var tdTag=psGetElementsByClassName(document,"td","bag_link line_btm_light line_right");	
	if (psCheckArrayExist(tdTag)==true)
	{		
		for(var i=0;i<tdTag.length;i++)
		{		
			var pParentNote = tdTag[i].parentNode;			
			if (pParentNote.tagName.toUpperCase()=="TR")
			{					
				var pPrice = psGetInnerText(pParentNote.getElementsByTagName("td")[2]);	
				pPrice = psCleanPrice(pPrice);				
				var pQty=psGetElementValue(selectTag[i],true);					
			}
			var pStr= psTrim(psGetInnerText(psHtmlDecode(tdTag[i].innerHTML))).replace("-add note--","");			
			var pProId = psTrim(pStr.substring(pStr.lastIndexOf(" "),pStr.length));
			var pProName = psTrim(pStr.substring(0,pStr.lastIndexOf(" ")));
			var pCatId_temp = psGetValueFromCookie(G_PS_COOKIE_PROD_CATID,pProId.toLowerCase());
			if (psCheckElementExist(pCatId_temp)==false){
				pCatId_temp = "UNKHOWN";	
			}
			psCreateShopAction5Tag(pProId, pProName, pQty,psCleanPrice(pPrice),pCatId_temp);
		}
	}	
	// Make sure to have actual postings
	psDisplayShop5s();
}

/*
 * Process to post shop9tags for items purchased
 */
function psPostOrderView(){	
	var ord = new psOrder();	    
	var arrQty = new Array();
	var arrUnitPrice = new Array();
	ord.getOrder(); // Get order info from source code	
	var tdTag = psGetElementsByClassName(document,"td","bag_link line_btm_light line_right");
	if (psCheckElementExist(tdTag)==true){
		for(var r = 0; r<tdTag.length; r++){		
			var pParentNote = tdTag[r].parentNode;			
			if (pParentNote.tagName.toUpperCase()=="TR")
			{					
				var pPrice = psGetInnerText(pParentNote.getElementsByTagName("td")[2]);	
				pPrice = psCleanPrice(pPrice);
				var pQty = psGetInnerText(pParentNote.getElementsByTagName("td")[5]);	
			}
			var pStrProduct = psTrim(tdTag[r].innerHTML);			
			var pProId  = psTrim(psGetInnerText(pStrProduct.toLowerCase().split("<br>")[1]));
			var pProdName = psTrim(psGetInnerText(pStrProduct.toLowerCase().split("<br>")[0]));
			var pCatId = psGetValueFromCookie(G_PS_COOKIE_PROD_CATID,pProId.toLowerCase());	
			if (pCatId==null)	
				pCatId ="UNKHOWN";
			psCreateShopAction9Tag(pProId,pProdName, pQty, pPrice, ord.cusId, ord.id, ord.subtotal, pCatId);
		}		
	}	
	// Make sure to have actual postings
	psDisplayShop9s();
	// Post order tag finally
	psCreateOrderTag(ord.id, ord.subtotal, ord.shipping, ord.cusId, ord.cusCity, ord.cusState, ord.cusZIP);	
}

/*====================== END TAGGING BUSSINESS LOGIC =========================*/


/*======================= GENERAL UTILITY FUNCTION ===========================*/
/*
 * Order object encapsulates order Id, subtotal, shipping and customer Id
 * This design is aimed at code resuse and easy readability
 */
function psOrder(pOrderId, pSubtotal, pShipping, pCusId, pcusCity, pcusState, pcusZIP){
	this.id = pOrderId;
	this.subtotal = pSubtotal;
	this.shipping = pShipping;
	this.cusId = pCusId;
	this.cusCity = pcusCity;
	this.cusState = pcusState;
	this.cusZIP = pcusZIP;
	/*
	 * get order info from source code
	 */	
	this.getOrder = function()
	{
		var h2Tag = document.getElementsByTagName("h2");		
		if (psCheckArrayExist(h2Tag)==true){
			this.id = h2Tag[0].innerHTML.split(":")[1];
			if (this.id != null)
				this.id = psTrim(psGetInnerText(this.id));
			else
				this.id =psGenerateRandomValue();
		}		
		//==============================================
		// Get City, State, and Zipcode
		this.cusId = psSplitEmail(psGetCookie(G_PS_COOKIE_REGISTRATION));
		if (this.cusId==null){this.cusId = psGenerateRandomValue();}
		var buf = document.body.innerHTML.toLowerCase().split("title_shortline_230")[1];
		if (buf != null && buf != "undefined")
		{
			buf = buf.split("</td>")[0];
			buf = buf.split("<br");
			buf = buf[buf.length-2]; // the last one
			buf = psHtmlDecode(buf.replace("/>", ""));
			this.cusZIP = buf.substr(buf.lastIndexOf(" ") + 1);
			buf = buf.substring(0, buf.lastIndexOf(" "));
			this.cusState = buf.substr(buf.lastIndexOf(" ") + 1);
			this.cusCity = buf.substring(0, buf.lastIndexOf(", ")).replace(">", "");
		}
		//==============================================
		var bFlag_Item=false;
		var bFlag_GiftService=false;
		var bFlag_shipping=false;
		var strTotalItem="";
		var strTotalGiftService="";
		
		var tdTag = document.getElementsByTagName("td");
		if (psCheckElementExist(tdTag)==true){
			for (var i=0;i<tdTag.length;i++){
				if (psTrim(psGetInnerText(tdTag[i].innerHTML))=="ITEM(S)"){
					strTotalItem =  psTrim(psGetInnerText(tdTag[i+1].innerHTML));					
					bFlag_Item=true;
				}
				else if  (psTrim(psGetInnerText(tdTag[i].innerHTML))=="GIFT SERVICE"){
					strTotalGiftService =  psTrim(psGetInnerText(tdTag[i+1].innerHTML));					
					bFlag_GiftService=true;
				}
				else if  (psTrim(psGetInnerText(tdTag[i].innerHTML))=="SHIPPING"){
					this.shipping =  psTrim(psGetInnerText(tdTag[i+1].innerHTML)).replace("$","");					
					bFlag_shipping=true;
				}
				if (bFlag_Item==true && bFlag_GiftService==true && bFlag_shipping==true){
					break;
				}	
			}				
		}			
		var totalItem = psCleanPrice(strTotalItem);
		var totalGiftService = psCleanPrice(strTotalGiftService);
		this.subtotal = parseFloat(totalItem) + parseFloat(totalGiftService);		
	}
}
/*
 * Generate a random number
 */
function psGenerateRandomValue()
{
	var dtDate = new Date();
	var cusRandom = (dtDate.getTime()%10000000) + (Math.floor(Math.random()*10000));
	return cusRandom;
}
/* PURPOSE: Get inner text of an object or clean remove html tags of a particular string
 * RETURN: resultant string or null object
 */
 function psGetDomain(pUrl){
    var se = /^https*\:\/\/([^\/]+)/gi;
    return (pUrl.search(se) > -1) ? RegExp.$1 : null;
}

/* PURPOSE: Get inner text of an object or remove html tags of a particular string
 *          work properly even when the designated tag/text has script tag inside
 * RETURN: resultant string or null object
 */
function psGetInnerText(pTagOjb){
	var pattern = /<script[\s\S]*?<\/script>/gi; // question mark means non-greedy
	if (pTagOjb != null)
	{
		var sT = (typeof(pTagOjb) == "object") ? pTagOjb.innerHTML : pTagOjb;
		// remove all script tags and its content
		while (sT.search(pattern) > -1)
		{
			sT = sT.replace(pattern, "");
		}
		return sT.replace(/\<+.+?\>+/g, "");
	}
	return null;
}
/* PURPOSE: Remove all unaccepted characters in categoryid, including
 * [', ", :, ©, ®, comma]
 * RETURN: string
 */
function psCleanHtmlTag(pTextWithTags){
    return (pTextWithTags != null) ? pTextWithTags.replace(/\<+.+?\>+/g, "") : 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)
{
	return (pProductName != null) ? pProductName.replace(/[\n\t\v\r’\'\"]/gi, "") : null; 
}
function psRemovePlus(pString)
{
	if (pString != null){
		pString = pString.replace(/[\&\'\(\)]/gi, "");
		pString = pString.replace(/[\+]/gi, " ");
	}
	return pString; 
}
function psRemove_dash(pString)
{
	if (pString != null){
		pString = pString.replace(/[\&\'\(\)]/gi, "");
		pString = pString.replace(/[\_]/gi, " ");
	}
	return pString; 
}
/* 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) != "string")
		return pStr;
	return (pStr) ? pStr.replace(/&nbsp;|\u00A0/gi, ' ').replace(/^\s+|\s+$/g, '') : null;
}
/* PURPOSE: extract value from the URL
 * in format of http://xxx.com/page.ext?key1=value1&key2=value2
 * or key1=value1&key2=value2
 * RETURN: string value of the parameter
 */
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 psGetValueFromUrlFriendly(pUrl, pKey)
{
    var st = pKey + "/";
    if (typeof(pUrl.split(st)[1]) != "undefined")
		return  pUrl.split(st)[1].split("/")[0];
	else 
		return null;
}
/* 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, pValueFlag){
    var tag = document.getElementById(pTagId);
    return psGetElementValue(tag, pValueFlag);
}

/* 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, 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);// return label instead of value
        }
        else
            tagValue = psHtmlDecode(pTagObj.innerHTML);
    }

    return tagValue;
}

/* 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 = (pKey != null) ? "#" + psTrim(pKey).toLowerCase() + "~" : pKey;
	// 
	var catCookie = psGetCookie(pCookieName);
	catCookie = (catCookie == null) ? "" : catCookie;

	var start = catCookie.indexOf(pKey);
	if (start >= 0) // Store before -> remove the old value
	{
		var end = catCookie.indexOf("#", start + pKey.length);
		if (end == -1)
			end = catCookie.length;
		catCookie = catCookie.replace(catCookie.substring(start, end), "");
	}
	
	// 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 = (pKey != null) ? "#" + psTrim(pKey).toLowerCase() + "~" : pKey;
	// extract catId associated with the specified key (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 psGetDomain(pUrl){
    var se = /^https*\:\/\/([^\/]+)/gi;
    return (pUrl.search(se) > -1) ? RegExp.$1 : null;
}
function psCleanPrice(pPrice)
{
	var pattern = /[^0-9\.]/gi;
    return (pPrice != null ? pPrice.toString().replace(pattern, "") : null);
}
/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pageID, categoryID, searchString, searchResults){
	pageID=psCleanPageId(pageID);
	categoryID=psCleanCatId(categoryID);
	if (searchResults != null)
        searchResults += "";
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreatePageviewTag(" + pageID + ", " + categoryID + ", " + searchString + ", " + searchResults + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreatePageviewTag(pageID, categoryID, searchString, searchResults);
}

function psCreateProductviewTag(productID, productName, categoryID) {
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateProductviewTag(" + productID + ", " + productName + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateProductviewTag(productID, productName, categoryID);
}

function psCreateShopAction5Tag(productID, productName, productQuantity, productPrice, categoryID){
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction5Tag(" + productID + ", " + productName + ", " + productQuantity + ", " + productPrice + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction5Tag(productID, productName, productQuantity, productPrice, categoryID);
    
}

function psCreateShopAction9Tag(productID, productName, productQuantity, productPrice, customerID, orderID, orderTotal, categoryID){
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction9Tag(" + productID + ", " + productName + ", " + productQuantity + ", " + productPrice + ", " + customerID + ", " + orderID + ", " + orderTotal + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction9Tag(productID, productName, productQuantity, productPrice, customerID, orderID, orderTotal, categoryID);
}

function psCreateOrderTag(orderID, orderTotal, orderShipping, customerID, customerCity, customerState, customerZIP){
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateOrderTag(" + orderID + ", " + orderTotal + ", " + orderShipping + ", " + customerID + ", " + customerCity + ", " + customerState + ", " + customerZIP + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateOrderTag(orderID, orderTotal, orderShipping, customerID, customerCity, customerState, customerZIP);
}

function psCreateConversionEventTag(eventID, actionType, categoryID, points){
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateConversionEventTag(" + eventID + ", " + actionType + ", " + categoryID + ", " + points + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateConversionEventTag(eventID, actionType, categoryID, points);
}

function psCreateRegistrationTag(customerID, customerEmail, customerCity,customerState, customerZIP, customerCountry, customerInterest, customerAge, customerReferral){
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateRegistrationTag(" + customerID + ", " + customerEmail + ", " + customerCity + ", " + customerState + ", " + customerZIP + ", " + customerCountry + ", " + customerInterest + ", " + customerAge + ", " +customerReferral + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)        
		cmCreateRegistrationTag(customerID, customerEmail, customerCity,customerState, customerZIP, customerCountry, customerInterest, customerAge, customerReferral) 
}

function psCreateErrorTag(pageID, categoryID) {
	pageID=psCleanPageId(pageID);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateErrorTag(" + pageID + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateErrorTag(pageID, categoryID);
}

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 ==================*/

/*===========================WEBSITE UTILITY FUNCTION ======================*/
/*===========================END WEBSITE UTILITY FUNCTION ==================*/
//-->
