/************************************************************************************/
/* $Revision: $
 * $Id: $
 *
 * Author: Coremetrics/PSD 
 * Coremetrics  v1.2, 2010/05/26
 * 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();
/*===========================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_PS_ARR_DOMAIN = new Array("bonati.com");//value must be one array of domains or null

// 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 = 432000; // 5*24*60*60 = 5 days
// cookie name
var G_PS_COOKIE_CATID = "PS_CATID";
var G_PS_COOKIE_PROD_CATID = "PS_PROD_CATID";
var G_PS_COOKIE_PROD_NAME = "PS_PROD_NAME";
var G_PS_COOKIE_PROFILE = "PS_PROFILE";
var G_PS_COOKIE_REGISTER_ATTRIBUTES = "PS_REG_ATTRIBUTES";
var G_PS_COOKIE_FLAG = "PS_FLAG";		// used as a "session" variable to handle events between pages
// current category ID while browsing/searching/refining, etc
var G_PS_CUR_CATID = null;
/*========================= END GLOBAL VARIABLES =============================*/

/*=========================== BEGIN NAVIGATION ===============================*/
// Navigation logic should go here!
if(G_PS_PATHNAME == "/" || G_PS_PATHNAME == "/default.asp")
{
	psCreatePageviewTag("Home","Home",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.indexOf("mode=register&sid=")>-1)
{
	psCreatePageviewTag(psGetTitle() + " Disclaimer Rules","Disclaimer");
}
else if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.indexOf("mode=register")>-1)
{
	psCreatePageviewTag(psGetH2Value(),"Register");	
}
else if(psIsEqual(G_PS_PATHNAME,"/uf/faq.php"))
{
	psCreatePageviewTag("Bonati Forum - FAQ","Forum FAQ");
}
else if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.indexOf("mode=login")>-1)
{
	psCreatePageviewTag(psGetH2Value(),"Login");	
}
else if(G_PS_PATHNAME == "/uf/search.php" && G_PS_QUERYSTRING =="")
{
	psCreatePageviewTag("Search","Search",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/discussion/"))
{
	psCreatePageviewTag("Discussion","Contact Us",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/about/physicians/Bonati/video1.html"))
{
	psCreatePageviewTag("Origins of the Bonati Procedures","Bonati Origins",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/about/physicians/Bonati/video2.html"))
{
	psCreatePageviewTag("Early Results","Early Results",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/about/physicians/Bonati/video3.html"))
{
	psCreatePageviewTag("Instruments and techniques","Instruments and techniques",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/about/physicians/Bonati/video4.html"))
{
	psCreatePageviewTag("Conditions treated by The Bonati Procedures","Conditions Treated",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/about/physicians/Bonati/video5.html"))
{
	psCreatePageviewTag("Applications of The Bonati Procedures","Procedure Applications",null,null);
}
else if(psIsEqual(G_PS_PATHNAME,"/_videos/Moffatt_Seminar.html"))
{
	psCreatePageviewTag("Moffatt Seminar","Video Library",null,null);
}
else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING == "")
{
	psCreatePageviewTag(psGetTitle(),"User Control Panel",null,null);
}
else
{
	var catId = psGetCatId();
	var pageId = psHtmlDecode(psGetPageId());
	psCreatePageviewTag(pageId,catId,null,null);
}

psHijackRegistration();

/*============================ END NAVIGATION ================================*/

function psGetH2Value(){
	var h2Tags = document.getElementsByTagName("h2");
	if(psCheckArrayExist(h2Tags)){
		return psTrim(psHtmlDecode(unescape(psGetInnerText(h2Tags[0]))));
	}
	return null;
}

function psHijackForumLogin(){
	var loginBtn = psGetElementByName("input","login");
	if(psCheckElementExist(loginBtn) == false) 
		return;	
	loginBtn.OldFunction = loginBtn.onclick;
	loginBtn.onclick = function (){
		var pUserName = psGetElementValueById("username");
		if(pUserName != null && pUserName != ""){
			var uP = new psProfile();
			uP.cusId = pUserName;
			uP.writeProfile();			
			psSetCookie(G_PS_COOKIE_FLAG,"forum_register");			
		}
		if(this.OldFunction != null) 
			return this.OldFunction();
	}

}

function psHijackForumRegister(){
	var submitBtn = document.getElementById("submit");
	if(psCheckElementExist(submitBtn) == false) 
		return;	
	submitBtn.OldFunction = submitBtn.onclick;
	submitBtn.onclick = function (){
		var pEmail = psGetElementValueById("email");
		if(psCheckEmail(pEmail)){
			var uP = new psProfile();
			uP.email = pEmail;
			uP.cusId = psGetElementValueById("username");
			if(uP.cusId == null || uP.cusId == "")
				uP.cusId = uP.email;			
			uP.writeProfile();			
			psSetCookie(G_PS_COOKIE_FLAG,"forum_register");
		}
		if(this.OldFunction != null) 
			return this.OldFunction();
	}

}

function psHijackRegistration(){
	if(G_PS_PATHNAME.indexOf("/reviewmri/") >= 0)
	{		
		psHijackRegisterMRI();
	}
	else if(G_PS_PATHNAME.indexOf("/events/seminar.asp") >= 0)
	{
		psHijackRegisterSeminar();
	}
	else if(G_PS_PATHNAME.indexOf("/referrals/information") >= 0)
	{
		psHijackRegisterReferrals();
	}
	else if(G_PS_PATHNAME.indexOf("/uf/index.php") >= 0 || G_PS_PATHNAME.indexOf("/uf/ucp.php") >= 0)
	{	
		psHijackForumLogin();
	}
	else if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.indexOf("mode=register")>-1)
	{
		psHijackForumRegister();
	}
	
	else if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.indexOf("mode=login")>-1)
	{	
		psHijackForumLogin();
	}
	
	// Post registration	
	if(G_PS_URL_PATH.search(/\/thankyou\/MRIRequest\.asp\?WT\.si_cs\=ContactFormSubmit/i) >= 0 ||
	   G_PS_PATHNAME.search(/\/thankyou\/PhysicianReferral\.asp/i) >= 0 ||
	   G_PS_PATHNAME.search(/\/thankyou\/EventRegistration\.asp/i) >= 0){
		if(psGetCookie(G_PS_COOKIE_FLAG) == "register"){
			var uP = new psProfile();
			uP.readProfile();
			var pAttributes = psGetCookie(G_PS_COOKIE_REGISTER_ATTRIBUTES);
			psCreateRegistrationTag(uP.cusId, uP.email, uP.city, uP.state, uP.zipcode, null, pAttributes); // country = null
			psSetCookie(G_PS_COOKIE_FLAG,"","delete");
		}
	}
	
	if(psIsEqual(G_PS_PATHNAME,"/uf/ucp.php") && G_PS_QUERYSTRING.search(/mode\=(register|login)/i)>-1)
	{
		var divMsg = document.getElementById("message");
		if(psCheckElementExist(divMsg)){
			var pTemp = psGetInnerText(divMsg);
			if(pTemp != null && pTemp.search(/(Your\s+account\s+has\s+been\s+created|You\s+have\s+been\s+successfully\s+logged\s+in)/i) >= 0){
				if(psGetCookie(G_PS_COOKIE_FLAG) == "forum_register"){
					var uP = new psProfile();
					uP.readProfile();				
					psCreateRegistrationTag(uP.cusId, uP.email, uP.city, uP.state, uP.zipcode);
					psSetCookie(G_PS_COOKIE_FLAG,"","delete");
				}	
			}
		}
	}
	
}

function psHijackRegisterReferrals(){
	var submitBtn = document.getElementById("Submit_Form");		
	if(psCheckElementExist(submitBtn)){		
		submitBtn.OldFunction = submitBtn.onclick;
		submitBtn.onclick = function (){
			var pEmail = psGetElementValueById("PhysicianEmail");
			if(psCheckEmail(pEmail)){
				var uP = new psProfile();
				uP.email = pEmail;
				uP.cusId = uP.email;
				uP.writeProfile();
			}
			var sep = "-_-";
			var a1 = "Physician"; // Contact Type
			var a2 = ""; // Specialty
			var a3 = ""; // Physician e-mail
			var a4 = ""; // Patient email
			var a5 = ""; // Type of Insurance
			var a6 = ""; // Lead Source
			var a7 = ""; // Requests Contact
			var a8 = ""; // eMagazine Signup
			var a9 = ""; // Insurance Verification
			var a10 = ""; // Primary Insurance
			var a11 = ""; // Primary Insurance State
			var a12 = ""; // Secondary Insurance
			var a13 = ""; // Secondary Insurance State
			var a14 = ""; // Previous Surgery
			var a15 = ""; // Not Attending  Seminar
			
			a2 = psGetElementValueById("PhysicianSpecialty");
			a3 = uP.email;
			if(a3 == null) a3 = "";
			/*
			a4 = psGetElementValueById("PatientEmail");
			if(a4 == null) a4 = "";
			*/
			var rYes = psGetElementByName("input","Yes");
			if(psCheckElementExist(rYes) && rYes.checked){				
				a14 = "Previous Surgery : Yes";
			}
			
			var rNo = psGetElementByName("input","No");
			if(psCheckElementExist(rNo) && rNo.checked){
				a14 = "Previous Surgery : No";
			}
		
			var attributeStr = a1 + sep + a2 + sep + a3 + sep + a4 + sep + a5 + sep + a6 + sep + a7 + sep + a8 + sep + a9 + sep + a10 + sep + a11 + sep + a12 + sep + a13 + sep + a14 + sep + a15;
			psSetCookie(G_PS_COOKIE_REGISTER_ATTRIBUTES,attributeStr);
			psSetCookie(G_PS_COOKIE_FLAG,"register");
			
			if(this.OldFunction != null) 
				return this.OldFunction();
		}
	}
}

function psHijackRegisterSeminar(){
	var submitBtn = document.getElementById("btnSubmit");
	if(psCheckElementExist(submitBtn) == false)
		return;	
	
	submitBtn.OldFunction = submitBtn.onclick;
	submitBtn.onclick = function (){
		var uP = new psProfile();
		var pEmail = psGetElementValueById("txtEmail");
		if(psCheckEmail(pEmail)){			
			uP.email = pEmail;
			uP.cusId = uP.email;
		}else{
			uP.cusId = psGetElementValueById("txtFirstName");
		}
		uP.city = psGetElementValueById("txtCity");
		var pState = psGetElementByName("select","ddlState");
		if(psCheckElementExist(pState)){
			uP.state = psGetElementValue(pState,false);
		}
		if(uP.state == null) uP.state = "";
		if(uP.state.search(/Choose\.\.\./i) >= 0)
			uP.state = "";
		uP.zipcode = psGetElementValueById("txtZip");
		uP.writeProfile();
		
		var attributeStr = "";
		var sep = "-_-";
		var a1 = ""; // Contact Type
		var a2 = ""; // Specialty
		var a3 = ""; // Physician e-mail
		var a4 = ""; // Patient email
		var a5 = ""; // Type of Insurance
		var a6 = ""; // Lead Source
		var a7 = ""; // Requests Contact
		var a8 = ""; // eMagazine Signup
		var a9 = ""; // Insurance Verification
		var a10 = ""; // Primary Insurance
		var a11 = ""; // Primary Insurance State
		var a12 = ""; // Secondary Insurance
		var a13 = ""; // Secondary Insurance State
		var a14 = ""; // Previous Surgery
		var a15 = ""; // Not Attending  Seminar
		a4 = uP.email;
		a5 = psGetElementValueById("cmbInsurance");
		if(a5 == null) a5 = "";
		if(a5.search(/Choose\.\.\./i) >= 0)
			a5 = "";
		
		a6 = psGetElementValueById("cmbFound");
		if(a6 == null) a6 = "";
		if(a6.search(/Choose\.\.\./i) >= 0)
			a6 = "";				
		
		var eMagElement = document.getElementById("eMagSubscription");
		if(psCheckElementExist(eMagElement)){
			//a8 = eMagElement.checked;
			if(eMagElement.checked)
				a8 = "eMagazine selected";
		
		a15 = psGetElementValueById("txtAttending");
		if(a15 == null) a15 = "";				
		var attributeStr = a1 + sep + a2 + sep + a3 + sep + a4 + sep + a5 + sep + a6 + sep + a7 + sep + a8 + sep + a9 + sep + a10 + sep + a11 + sep + a12 + sep + a13 + sep + a14 + sep + a15;
		psSetCookie(G_PS_COOKIE_REGISTER_ATTRIBUTES,attributeStr);
		psSetCookie(G_PS_COOKIE_FLAG,"register");
		
		if(this.OldFunction != null)
			return this.OldFunction();
		}		
	}
}

function psHijackRegisterMRI(){
	var submitBtn = document.getElementById("Submit_Form");
	if(psCheckElementExist(submitBtn) == false)
		return;	
	submitBtn.OldFunction = submitBtn.onclick;
	submitBtn.onclick = function (){
		var uP = new psProfile();
		uP.city = psGetElementValueById("City",false);
		uP.state = psGetElementValueById("stateSelect",false);
		if(uP.state != null && uP.state.search(/Select\s+State/i) >= 0)
			uP.state = "";
		uP.zipcode = psGetElementValueById("Zip",false);
		uP.email = psGetElementValueById("Email",false);
		if(psCheckEmail(uP.email)){
			uP.cusId = uP.email;
			uP.writeProfile();
		}		
		var sep = "-_-";
		var a1 = ""; // Contact Type
		var a2 = ""; // Specialty
		var a3 = ""; // Physician e-mail
		var a4 = ""; // Patient email
		var a5 = ""; // Type of Insurance
		var a6 = ""; // Lead Source
		var a7 = ""; // Requests Contact
		var a8 = ""; // eMagazine Signup
		var a9 = "Do not verify"; // Insurance Verification
		var a10 = ""; // Primary Insurance
		var a11 = ""; // Primary Insurance State
		var a12 = ""; // Secondary Insurance
		var a13 = ""; // Secondary Insurance State
		var a14 = ""; // Previous Surgery
		var a15 = ""; // Not Attending  Seminar
		if(psCheckEmail(uP.email))
			a4 = uP.email;
		var insuranceType = psGetElementValueById("Type_Insurance",false);
		if(insuranceType != null && insuranceType != "")
			a5 = insuranceType;
		if(a5.search(/Choose\.\.\./i) >= 0)
			a5 = "";
		var heardFrom = psGetElementValueById("How_Did_You_Hear_About");
		if(heardFrom != null && heardFrom != "")
			a6 = heardFrom;
		if(a6.search(/Choose\.\.\./i) >= 0)
			a6 = "";			
		var MagSubscribe = document.getElementById("eMagSubscription");
		if(psCheckElementExist(MagSubscribe)){
			//a8 = MagSubscribe.checked;
			if(MagSubscribe.checked)
				a8 = "eMagazine selected";
		}
		
		var pVerify = psGetElementByName("input","hdnVerifyInsurance");
		if(psCheckElementExist(pVerify)){
			if(psTrim(pVerify.value) == "true"){
				a9 = "Please verify";
				a10 = psGetElementValueById("PrimaryInsuranceCompany",false);
				if(a10 == null) a10 = "";
				if(a10 != "") a10 = "Primary Ins: " + a10;
				var priState = psGetElementByName("select","PrimaryInsuranceState");
				if(psCheckElementExist(priState)){					
					a11 = psGetElementValue(priState,false);					
				}
				
				if(a11 == null) a11 = "";
				if(a11.search(/Choose\.\.\./i) >= 0) a11 = "";
				if(a11 != "") a11 = "Primary Ins: " + a11;
				
				a12 = psGetElementValueById("SecondaryInsuranceCompany",false);
				if(a12 == null) a12 = "";				
				if(a12 != "") a12 = "Secondary Ins: " + a12;
				var secondState = psGetElementByName("select","SecondaryInsuranceState");
				if(psCheckElementExist(secondState)){
					a13 = psGetElementValue(secondState,false);
				}
				if(a13 == null) a13 = "";
				if(a13.search(/Choose\.\.\./i) >= 0) a13 = "";
				if(a13 != "") a13 = "Secondary Ins: " + a13;				
			}
		}
		
		var attributeStr = a1 + sep + a2 + sep + a3 + sep + a4 + sep + a5 + sep + a6 + sep + a7 + sep + a8 + sep + a9 + sep + a10 + sep + a11 + sep + a12 + sep + a13 + sep + a14 + sep + a15;
		psSetCookie(G_PS_COOKIE_REGISTER_ATTRIBUTES,attributeStr);
		psSetCookie(G_PS_COOKIE_FLAG,"register");
		if(this.OldFunction != null)
			return this.OldFunction();
	}
}

function psGetElementByName(tagName,elementName){	
	// return the first element
	var tags = document.getElementsByTagName(tagName);
	if(psCheckArrayExist(tags)){
		for(var i=0; i<tags.length; i++){
			if(tags[i].name != null && tags[i].name.toLowerCase() == elementName.toLowerCase()){
				return tags[i];
			}
		}
	}
	return null;
}

/*===================== BEGIN TAGGING BUSSINESS LOGIC ========================*/
function psGetTitle()
{
	var titleValue = G_PS_PATHNAME;
	var titleItem = document.getElementsByTagName("title");
	if(psCheckArrayExist(titleItem))
	{
		titleValue = psGetElementValue(titleItem[0],true);
	}
	return titleValue;
}

function psGetLastFolder()
{
	var lastFolder = G_PS_PATHNAME;
	var se = /\/([^\/]*)\/(default\.asp|video\.html){0,1}$/gi;
	if(lastFolder.search(se)>-1)
	{
		lastFolder = RegExp.$1;
		lastFolder = psHtmlDecode(lastFolder);
	}
	else
	{
		se = /\/([^\/]*)\.(asp|html)$/gi;
		if(lastFolder.search(se)>-1)
		{
			lastFolder = RegExp.$1;
			lastFolder = psHtmlDecode(lastFolder);
		}
	}
	return lastFolder;
}

function psGetPageId()
{
	var pageId = psGetTitle();
	
	var se = /\s*([^\<]*)\s*\<br\/*\>/gi;
	var se_1 = /bonati.com\/about\/physicians\/([^\/]*)\/video\.html/gi;
	var se_2 = /bonati.com\/_videos\/([^\.\/]*)\.html/gi;
	var se_3 = /bonati.com\/uf\/viewtopic\.php\?f\=[^\&]+\&t\=\d*/gi;
	var se_4= /bonati\.com\/uf\/ucp\.php\?mode\=/gi;
	
	if(G_PS_URL_PATH.indexOf("bonati.com/news/default.asp?id=")>-1)
	{
		var h2List = document.getElementsByTagName("h2");
		if(psCheckArrayExist(h2List))
		{
			pageId = h2List[0].innerHTML;
		}
	}
	else if(G_PS_URL_PATH.search(se_1)>-1)
	{
		pageId = psGetLastFolder() + " video";
	}
	else if(G_PS_URL_PATH.search(se_2)>-1)
	{
		pageId = psGetLastFolder() + " video";
	}
	else if(G_PS_URL_PATH.search(se_3)>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_URL_PATH.search(se_4)>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME=="/uf/" || G_PS_PATHNAME=="/uf/index.php")
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=groups&mode=")>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=zebra&mode=")>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && (G_PS_QUERYSTRING.indexOf("?i=pm&mode=")>-1 || G_PS_QUERYSTRING.indexOf("?i=pm&folder=")>-1))
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=")>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("sid=")>-1)
	{
		pageId = psGetTitle();
	}	
	else if(G_PS_PATHNAME == "/uf/search.php" && G_PS_QUERYSTRING.indexOf("?search_id=")>-1)
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/uf/memberlist.php")
	{
		pageId = psGetTitle();
	}
	else if(G_PS_PATHNAME == "/events/seminar.asp")
	{
		var h1List = document.getElementsByTagName("h1");
		if(psCheckArrayExist(h1List))
		{
			var id = psGetValueFromUrl(G_PS_QUERYSTRING,"id");
			pageId = psGetElementValue(h1List[0],true) + ((id!=null)? ("-" + id):"");
		}
	}
	
	else
	{
		var divItem = document.getElementById("NavList");
		if(psCheckElementExist(divItem))
		{
			var aList = divItem.getElementsByTagName("a");
			for(var i =0; i<aList.length; i++)
			{
				if(aList[i].href!=null && psIsEqual(aList[i].href,G_PS_URL_PATH))
				{
					pageId = (aList[i].innerHTML.search(se)>-1)? RegExp.$1:pageId;
					return pageId;
				}
			}
		}

		var h2Item = document.getElementsByTagName("h2");
		if(psCheckArrayExist(h2Item))
		{
			h2Item = h2Item[0];
			if(h2Item.innerHTML.search(se)>-1)
			{
				return RegExp.$1;
			}
		}
		
		var h1List = document.getElementsByTagName("h1");
		if(psCheckArrayExist(h1List))
		{
			return h1List[0].innerHTML;
		}
	}

	return  pageId;
}

function psGetCatId()
{
	var catId = "ADD URL";
	var se = /\/conditions\/([^\/]+)\/([^\/]+)\//gi;
	var se_1 = /bonati.com\/about\/physicians\/([^\/]*)\/video\.html/gi;
	var se_2 = /bonati.com\/_videos\/([^\.\/]*)\.html/gi;
	var se_3 = /bonati.com\/uf\/viewtopic\.php\?f\=[^\&]+\&t\=\d*/gi;
	var se_4= /bonati\.com\/uf\/ucp\.php\?mode\=/gi;
	if(G_PS_PATHNAME.search(se)>-1)
	{
		catId = RegExp.$1 + ":" + RegExp.$2;
	}
	else if(G_PS_URL_PATH.indexOf("bonati.com/news/default.asp?id=")>-1)
	{
		catId = "Archive";
	}
	else if(G_PS_URL_PATH.search(se_1)>-1)
	{
		catId = "Physician Videos";
	}
	else if(G_PS_URL_PATH.search(se_2)>-1)
	{
		catId = "Patient Stories";
	}
	else if(G_PS_URL_PATH.search(se_3)>-1)
	{
		catId = "View Topic";
	}
	else if(G_PS_URL_PATH.search(se_4)>-1)
	{
		catId = psGetValueFromUrl(G_PS_QUERYSTRING,"mode");
	}
	else if(G_PS_PATHNAME=="/uf/" || G_PS_PATHNAME=="/uf/index.php")
	{
		catId = "Forum";
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=groups&mode=")>-1)
	{
		catId = psGetValueFromUrl(G_PS_QUERYSTRING,"mode");
		var divItem = document.getElementById("navigation");
		if(psCheckElementExist(divItem))
		{
			var aList = divItem.getElementsByTagName("a");
			for(var i =0; i<aList.length; i++)
			{
				var aItem = aList[i];
				if(aItem.href != null && psIsEqual(aItem.href,G_PS_URL_PATH))
				{
					catId = psGetElementValue(aItem,true);
					var se = /\<span\>([^\<]*)\<\/span\>/gi;
					catId = (catId.search(se)>-1)? RegExp.$1:catId;
					break;
				}
			}
		}
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=zebra&mode=")>-1)
	{
		catId = psGetValueFromUrl(G_PS_QUERYSTRING,"mode");
		var divItem = document.getElementById("cp-main");
		if(psCheckElementExist(divItem))
		{
			var h2List = divItem.getElementsByTagName("h2");
			if(psCheckArrayExist(h2List))
			{
				catId = psGetElementValue(h2List[0],true);
			}
		}
	}
	else if(G_PS_PATHNAME == "/uf/ucp.php" && (G_PS_QUERYSTRING.indexOf("?i=pm&mode=")>-1 || G_PS_QUERYSTRING.indexOf("?i=pm&folder=")>-1))
	{
		catId = psGetValueFromUrl(G_PS_QUERYSTRING,"mode");
		if(catId == null || catId =="")
		{
			catId = psGetValueFromUrl(G_PS_QUERYSTRING,"folder");
		}
	}
	//else if(G_PS_PATHNAME == "/uf/ucp.php" && G_PS_QUERYSTRING.indexOf("?i=")>-1)
	else if(G_PS_PATHNAME == "/uf/ucp.php" && (G_PS_QUERYSTRING.indexOf("?i=")>-1 || G_PS_QUERYSTRING.indexOf("sid=")>-1))
	{
		catId = "User Control Panel";
		var liList = psGetElementsByClassName(document,"li","activetab");
		if(psCheckArrayExist(liList))
		{
			var aList = liList[0].getElementsByTagName("a");
			if(psCheckArrayExist(aList))
			{
				catId = psGetElementValue(aList[0],true);
				var se = /\<span\>([^\<]*)\<\/span\>/gi;
				catId = (catId.search(se)>-1)? RegExp.$1:catId;
			}
		}
	}
	else if(G_PS_PATHNAME == "/uf/search.php" && G_PS_QUERYSTRING.indexOf("?search_id=")>-1)
	{
		catId = "Search";
		var divItem = document.getElementById("page-body");
		if(psCheckElementExist(divItem))
		{
			var h2List = divItem.getElementsByTagName("h2");
			if(psCheckArrayExist(h2List))
			{
				catId = psGetElementValue(h2List[0],true);
				catId = catId.replace(/View/gi,"");
				catId = psTrim(catId);
			}
		}
	}
	else if(G_PS_PATHNAME == "/uf/memberlist.php")
	{
		var divItem = document.getElementById("page-body");
		if(psCheckElementExist(divItem))
		{
			var h2List = divItem.getElementsByTagName("h2");
			if(psCheckArrayExist(h2List))
			{
				catId = psGetElementValue(h2List[0],true);
				catId = catId.replace(/\s*Viewing\s*profile\s*-\s*/gi,"");
			}
		}
	}
	else if(G_PS_PATHNAME == "/events/seminar.asp")
	{
		catId = "Events";
	}
	else if(G_PS_PATHNAME == "/thankyou/mrirequest.asp")
	{
		catId = "MRI Request Received";
	}
	else if(G_PS_PATHNAME == "/referrals/information/")
	{
		catId = "Referrals";
	}
	else
	{
		catId = psGetLastFolder();
	}
	return  catId;
}

/*====================== END TAGGING BUSSINESS LOGIC =========================*/


/*======================= GENERAL UTILITY FUNCTION ===========================*/
/* PURPOSE: constructor for profile
 * Note: you can add more methods to psProfile in its prototype
 * RETURN: none
 */
function psProfile()
{
	this.cusId = null;
    this.email = null;
    this.city = null;
    this.state = null;
    this.zipcode = null;
	this.newsletter = null;
	this.subscribe = null;
	/*
	 * Get user profile from cookie
	 */
	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];
					// when NULL is written to cookie, it becomes string, not literal constant
					buf[i] = (tempVal=="null" ? null : tempVal); 
				}
				this.cusId = buf[0];
				if (!this.cusId)
					this.cusId = psGenerateRandomValue();
				this.email = buf[1];
				this.city = buf[2];
				this.state = buf[3];
				this.zipcode = buf[4];
				this.newsletter = buf[5];
				this.subscribe = buf[6];
			}
			return true;
		}
		catch (ex) { return false; }
	}
	/*
	 * Set user profile to cookie
	 */
	this.writeProfile = function()
	{
		try
		{
			if (this.cusId == null)
				return;
			// make sure that the data contains 4 parts separated by 3 '|'
			var data = this.cusId + "|" + this.email + '|' + this.city + '|' + this.state + '|' 
				+ this.zipcode + "|" + this.newsletter + '|' + this.subscribe;
			// store on cookie
			psSetCookie(G_PS_COOKIE_PROFILE, data);
			//
			// NOTE: To persist profile as persistent cookie, pass G_PS_COOKIE_LIFETIME as the third param instead of null
			// psSetCookie(G_PS_COOKIE_PROFILE, data, G_PS_COOKIE_LIFETIME);
			//
			return true;
		}
		catch (ex) { return false; }
	}
}

/* PURPOSE: Compare case-insensitive strings
 * RETURN: true: strings are not null and the same
 *         false: any of the string is null or not the same
 */
function psIsEqual()
{
	for (var i=0; i<arguments.length; i++)
	{
		if(arguments[0] == null || arguments[i] == null)
		{
			return false;
		}
		else if(arguments[0].toUpperCase() != arguments[i].toUpperCase())
		{
			return false;
		}
	}
	return true;
}

/* 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 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; 
}

/* 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 != null) ? 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;
}

/* 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: extract main domain from the URL
 * RETURN: main domain
 */
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;
	
}

/* PURPOSE: extract domain part in the URL
 * RETURN: domain
 */
function psGetDomain(pUrl){
    var se = /^https*\:\/\/([^\/\:]+)/gi;
    return (pUrl.search(se) > -1) ? RegExp.$1 : null;
}

/* PURPOSE: remove unnecessary characters (dollar sign, comma, quote, minus, etc) 
 * from price to make it work properly with parseFloat/parseInt
 * RETURN: well-formed price
 */
function psCleanPrice(pPrice)
{
	var pattern = /[^0-9\.]/gi;
    return (pPrice != null ? pPrice.toString().replace(pattern, "") : null);
}

/* 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;
}

function psCookieBase(pCookieName, pCookieValue, pLifeTime)
{
	var pDomain = psGetMainDomain(G_PS_URL_PATH);
	CC(pCookieName, pDomain);//delete cookie by calling coremetrics's cookie function
	if(pLifeTime == "delete") 
	{         
		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);
}

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;
}

/* 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)
{
	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);
}

/* 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)
{
	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) // Store before -> remove the old value
	{
		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;   
	//Check existed ?
	while (totalsize > 3500)
	{
		var l1 = encodeHtml(catCookie).length;//length before pop
		cookieArray = catCookie.split("#");
		cookieArray.pop();
		catCookie = cookieArray.join("#");
		var l2 = encodeHtml(catCookie).length;//length after pop                                                        
		totalsize -=  (l1-l2);
	}   
	if(catCookie == null || catCookie == "")
	{
		catCookie = oldCatCookie;
	}
	// Save to cookie              
	psCookieBase(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;
}

/*
 * Generate a random number
 */
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;
}

/*
 * Check an element exist or not
*/
function psCheckElementExist(pElement)
{
    if(typeof(pElement) == "undefined" || pElement == null)
    {
        return false;
    }

    return true;
}

/*
 * Check if array is exist or not
 */
function psCheckArrayExist(pArrElement)
{
    if(typeof(pArrElement) == "undefined" || pArrElement == null || pArrElement.length <= 0)
    {
        return false;
    }

    return true;
}

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.toLowerCase())
        {
            arrResult[index ++ ] = arrInputs[i];
        }
    }
    return arrResult;
}

/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pId, pCatId, pSrchTerm, pSrchResult) 
{
	pId = psCleanPageId(pId);
	pId = psShorttenPageID(pId);
	pCatId = psCleanCatId(pCatId);
    if (pSrchResult != null)
        pSrchResult += "";
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreatePageviewTag(" + pId + ", " + pCatId + ", " + pSrchTerm + ", " + pSrchResult + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreatePageviewTag(pId, pCatId, pSrchTerm, pSrchResult);
}

function psCreateProductviewTag(pId, pName, pCatId) 
{
	pName = psCleanProductName(pName);
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateProductviewTag(" + pId + ", " + pName + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateProductviewTag(pId, pName, pCatId);
}

function psCreateShopAction5Tag(pId, pName, pQuantity, pPrice, pCatId) 
{
	pName = psCleanProductName(pName);
	pCatId = 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 + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction5Tag(pId, pName, pQuantity, pPrice, pCatId);    
}

function psCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId) 
{
	pName = psCleanProductName(pName);
	pCatId = psCleanCatId(pCatId);
	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 + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction9Tag(pId, pName, pQuantity, pPrice, pCusID, pOrderID, pOrderTotal, pCatId);
}

function psCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip) 
{
	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 + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateOrderTag(pId, pOrderTotal, pOrderShipping, pCusID, pCusCity, pCusState, pCusZip);
}

function psCreateConversionEventTag(pId, pActionType, pCatID, pPoints) 
{
	pCatID = psCleanCatId(pCatID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateConversionEventTag(" + pId + ", " + pActionType + ", " + pCatID + ", " + pPoints + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateConversionEventTag(pId, pActionType, pCatID, pPoints);
}

function psCreateRegistrationTag(pCusID, pCustEmail, pCusCity, pCusState, pCusZip, pNewsletter, pSubscribe) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateRegistrationTag(" + pCusID + ", " + pCustEmail + ", " + pCusCity + ", " + pCusState + ", " + pCusZip + ", " + pNewsletter + ", " + pSubscribe + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateRegistrationTag(pCusID, pCustEmail, pCusCity, pCusState, pCusZip, pNewsletter, pSubscribe);
}

function psCreateErrorTag(pPageID, pCatId) 
{
	pPageID = psCleanPageId(pPageID);
	pCatId = psCleanCatId(pCatId);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateErrorTag(" + pPageID + ", " + pCatId + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateErrorTag(pPageID, pCatId);
}

function psDisplayShop5s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop5s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop5s();
}

function psDisplayShop9s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop9s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop9s();
}
/*===========================END GENERAL UTILITY FUNCTION ==================*/