/************************************************************************************/
/* $Revision: 96416 $
 * $Id: cmtaggingservices.js 96416 2008-08-27 11:50:26Z croberts $
 *
 * Author: Coremetrics/PSD 
 * Coremetrics  v1.0, 08/21/2008
 * COPYRIGHT 1999-2008 COREMETRICS, INC. 
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 * Disclaimer: Coremetrics is not responsible for hosting or maintenance or this file
 *
 */
/************************************************************************************/




/*===========================GLOBAL VARIABLES ===============================*/
// current page url
var G_PS_URL_PATH = "" + document.location;
var G_PS_PATHNAME = document.location.pathname.toLowerCase();
var G_PS_QUERYSTRING = document.location.search.toLowerCase();
var G_PS_URL_REFERRER = document.referrer.toLowerCase();
var G_PS_COOKIE_LIFETIME = 432000; // 5*24*60*60 = 5 days
// cookie name
//reduce the use of these 
var G_PS_COOKIE_CATID = "PS_CATID";
var G_PS_COOKIE_PROFILE = "PS_PROFILE";
var G_PS_COOKIE_FLAG = "PS_FLAG";		// used as a "session" variable to handle events between pages
//not necessary
var G_PS_COOKIE_PROD_CATID = "PS_PROD_CATID";
var G_PS_COOKIE_PROD_NAME = "PS_PROD_NAME";

// current category ID while browsing/searching/refining, etc
var G_PS_CUR_CATID = null;

// 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 =============================*/
//Production data warehouse flag
try{
  
    if( IS_WEBANALYTICS_ON && IS_WEBANALYTICS_ON != null && IS_WEBANALYTICS_ON != NaN && IS_WEBANALYTICS_ON == true) {
      if(IS_WEBANALYTICS_PRODUCTION && IS_WEBANALYTICS_PRODUCTION!=null && IS_WEBANALYTICS_PRODUCTION != NaN && IS_WEBANALYTICS_PRODUCTION == true)  {
         cmSetProduction();
         //alert("Coremetrics Production on");
      }    
      //Make Call to do Tagging
      DoWebAnalytics();
    }// END IS_WEBANALYTICS_ON
    else{
      //alert("IS_WEBANALYTICS_ON: " + IS_WEBANALYTICS_ON);
    }
  }
  catch(e)
  {
  //suppress error
  } 

/*=========================== BEGIN NAVIGATION ===============================*/
function DoWebAnalytics()
{

var pCatId=null;
pCatId = psGetCategoryName();
var pPageId=null;
//alert("IS_WEBANALYTICS_ON: " + IS_WEBANALYTICS_ON +"\r\nG_PS_PATHNAME: " + G_PS_PATHNAME);
if (G_PS_PATHNAME=="/cgi-bin/myfico.cfg/php/enduser/std_alp.php"){
	pPageId="FAQ page1";pCatId="Support Center";
	var p_faqid=psGetValueFromUrl(G_PS_URL_PATH,"p_faqid");
	if (p_faqid!=null){
		var tagTD = psGetElementsByClassName(document,"TD","title");
		if (psCheckArrayExist(tagTD[1])==true){
			pPageId =psCleanPageId(psRemoveCopyRight(psGetInnerText(tagTD[1])));
		}
	}	
	psCreatePageviewTag(pPageId,pCatId,null,null);
}
else if (G_PS_PATHNAME=="/cgi-bin/myfico.cfg/php/enduser/std_adp.php" || G_PS_PATHNAME=="/cgi-bin/myfico.cfg/php/enduser/popup_adp.php"){
	pPageId="FAQ page1";pCatId="Support Center";
	var p_faqid=psGetValueFromUrl(G_PS_URL_PATH,"p_faqid");
	if (p_faqid!=null){
		var tagTD = psGetElementsByClassName(document,"TD","title");
		if (psCheckArrayExist(tagTD[1])==true){
			pPageId =psCleanPageId(psRemoveCopyRight(psGetInnerText(tagTD[1])));
		}
	}	
	psCreatePageviewTag(pPageId,pCatId,null,null);
}
else if(document.location.host.indexOf("ficoforums.myfico.com")>-1){
	pPageId="Forums";pCatId="Forums";
	psCreatePageviewTag(pPageId, pCatId, null, null);
}
else if(document.location.host.indexOf("search.myfico.com")>-1){	
	if (G_PS_PATHNAME.indexOf("/promosearch.cgi")>-1){				
		var pResultString=document.getElementById("sresultcount");		
		if (psCheckElementExist(pResultString)==true){
			psSetValueToCookie(G_PS_COOKIE_PROD_CATID,"products","SEARCH");
			var pResult = psTrim(pResultString.innerHTML.substring(pResultString.innerHTML.indexOf("of")+2,pResultString.innerHTML.indexOf("for")));
			var pTextSearch =  psTrim(pResultString.innerHTML.substring(pResultString.innerHTML.indexOf("for")+3,pResultString.innerHTML.length));
			pTextSearch = psGetInnerText(pTextSearch);
			var pPageNo = psGetValueFromUrl(G_PS_URL_PATH,"sp_n")
			if (pPageNo==null)
				psCreatePageviewTag("SEARCH SUCCESSFUL","SEARCH",pTextSearch,pResult);
			else
				psCreatePageviewTag("SEARCH SUCCESSFUL PAGE["+pPageNo+"]","SEARCH",pTextSearch,pResult);
		}
		else
		{
			var pNoResult = document.getElementsByTagName("H2")[0];
			if (psCheckElementExist(pNoResult)==true){
				pTextSearch = psGetInnerText(pNoResult.innerHTML.substring(pNoResult.innerHTML.indexOf(":")+1,pNoResult.innerHTML.length));
			}
			psCreatePageviewTag("SEARCH UNSUCCESSFUL","SEARCH",pTextSearch,null);
		}			
	}	
}
else if(G_PS_PATHNAME == "/"){
	psCreatePageviewTag("Home", pCatId, null, null);
}
else if (G_PS_PATHNAME.indexOf("/loancenter/results.aspx")>-1){
  psCreatePageviewTag(pPageId, pCatId, null, null);
  var tid = psGetValueFromUrl(G_PS_URL_PATH,"tid")
  var cusId = psGetCookie(G_PS_COOKIE_PROFILE);
		if (cusId != null)
			cusId = cusId.split('|')[0]; 
  psCreateShopAction9Tag("Loan Center", "Loan Center", "1", "0", cusId, tid, "0", GetProductCategoryId("LoanCenter"));				
  // Make sure to have actual postings
  psDisplayShop9s();
  // Post order tag finally
  psCreateOrderTag(tid, "0", "0", cusId);
}
else if (G_PS_PATHNAME.indexOf("/crediteducation/")>-1){
  
  if (G_PS_PATHNAME.indexOf("/crediteducation/emailsignup.aspx")>-1){
	  var pEventType ="1";var pPoint="10";var pPointText="myFICO Privileges Program";
	  var tagH1 = document.getElementById("emailsignup");
	  if (psCheckElementExist(tagH1)==true){
		  pPointText  =psTrim(psGetInnerText(tagH1)); 
		  if (pPointText.toLowerCase()=="welcome!"){
			  pEventType = "2"; pPoint = "15";	
		  }
		  else{
			  pEventType = "1"; pPoint = "10";
		  }		
	  }	
	  psCreateConversionEventTag("CreditEducation",pEventType,pPointText,pPoint);	
   }
   psCreatePageviewTag(pPageId, pCatId, null, null);
  
}
else if(G_PS_PATHNAME.indexOf("products/scorewatch/description.aspx")>-1 || G_PS_PATHNAME.indexOf("products/scorewatch/freetrial.aspx")>-1){
  psCreateProductviewTag("Score Watch","Score Watch",pCatId);	
}
else if(G_PS_PATHNAME.indexOf("products/ficokit/description.aspx")>-1){
  psCreateProductviewTag("Suze Ormans FICO Kit Platinum","Suze Ormans FICO Kit Platinum",pCatId);	
}
else if(G_PS_PATHNAME.indexOf("products/ficothree/description.aspx")>-1){ 
  psCreateProductviewTag("FICO Credit Complete","FICO Credit Complete",pCatId);	
}
else if(G_PS_PATHNAME.indexOf("products/ficoone/description.aspx")>-1){
  psCreateProductviewTag("FICO Standard","FICO Standard",pCatId);	
}
else if(G_PS_PATHNAME.indexOf("products/idf/description.aspx")>-1){
  psCreateProductviewTag("FICO Quarterly Monitoring","FICO Quarterly Monitoring",pCatId);	
}
else if (G_PS_PATHNAME.indexOf("store/")>-1){	
  psCreatePageviewTag(pPageId,pCatId, null, null);
  //alert(G_PS_PATHNAME +"\r\n"+G_PS_URL_REFERRER);
	if (G_PS_PATHNAME.indexOf("/store/recommends.aspx") >-1 ){
		if (G_PS_URL_REFERRER.indexOf("store/order.asp")>-1 || G_PS_URL_REFERRER.indexOf("/store/multicart/order.asp")>-1 || G_PS_URL_REFERRER.indexOf("/systemaccess/createprofile.aspx")>-1  ){
			psPostRegistrationView();
		}
	}
	else if (G_PS_PATHNAME.indexOf("/store/order.asp") >-1 || G_PS_PATHNAME.indexOf("/store/multicart/order.asp") >-1){
		psSubscribeProfilePages();
	}	
	else if (G_PS_PATHNAME.indexOf("/store/payment.aspx") >-1){
		psPostCartView();
	}
	else if (G_PS_PATHNAME.indexOf("/store/receipt.aspx") >-1){	
		psPostOrderView();
	}

}
else if (G_PS_PATHNAME.indexOf("systemaccess/")>-1){
  psCreatePageviewTag(pPageId, pCatId, null, null);
	if (G_PS_PATHNAME.indexOf("/systemaccess/login.aspx")>-1){
		psSubscribeProfilePages();
	}
	else if (G_PS_PATHNAME.indexOf("/systemaccess/logout.aspx")>-1){
		psSubscribeProfilePages();
	}
	else if (G_PS_PATHNAME.indexOf("/systemaccess/createprofile.aspx")>-1){
		psSubscribeProfilePages();
	}
	
}
else if (G_PS_PATHNAME.indexOf("suzekitagreement.aspx")>-1 || G_PS_PATHNAME.indexOf("/ccc/correctionoverview.aspx")>-1 || G_PS_PATHNAME.indexOf("/forum/welcome.aspx")>-1){
  psPostRegistrationView();
}
else if (G_PS_PATHNAME.indexOf("membercenter/")>-1){
	if ((G_PS_PATHNAME=="/membercenter/") || ( G_PS_PATHNAME.indexOf("/membercenter/default.aspx")>-1 )){
		psCreatePageviewTag("Member Home", pCatId, null, null);	
		//We are capturing data here on existing customers
	  if ((G_PS_URL_REFERRER.indexOf("/systemaccess/logout.aspx") >-1 )|| (G_PS_URL_REFERRER.indexOf("/systemaccess/login.aspx") >-1))
		  psPostRegistrationView();
	}
	else if (G_PS_PATHNAME.indexOf("/membercenter/changememberinfo.asp") >-1)
	{	
	  psCreatePageviewTag(pPageId,pCatId);
		psSubscribeProfilePages();
	}
	else if (G_PS_PATHNAME.indexOf("/membercenter/changeusername.asp") >-1){
		psSubscribeProfilePages();
		psCreatePageviewTag(pPageId, pCatId, null, null);
	}
	else if (G_PS_PATHNAME.indexOf("/membercenter/errorpage.asp") >-1){
		psCreateErrorTag(pPageId,pCatId);	
	}	
	else if(G_PS_PATHNAME.indexOf("/membercenter/changeuserinfoconfirm.asp") >-1){
			psCreatePageviewTag(pPageId, pCatId, null, null);
			psPostRegistrationView();	
	}	
	else
	{
	  psCreatePageviewTag(pPageId,pCatId);
	}
}
else{
  
	psCreatePageviewTag(pPageId,pCatId);
}
/*============================ END NAVIGATION ================================*/
}//End DoWebAnalytics

function psGetCategoryName()
{
  /* page category */
  var myCat = "Miscellaneous";
  if (G_PS_PATHNAME == "/" || G_PS_PATHNAME=="/default.aspx" )
	  myCat = "Home";
	else if (G_PS_PATHNAME.indexOf("/customerrors/") > -1 || G_PS_PATHNAME == "/membercenter/errorpage.asp")
	  myCat = "Errors";  
  
   /******* Product Merchandizing Start *******/
  else if (G_PS_PATHNAME.indexOf("/products/idf/sample/") > -1)
	  myCat = "FICO Quarterly Monitoring Samples";
  else if (G_PS_PATHNAME.indexOf("/products/ficoone/sample") > -1)
	  myCat = "FICO Score Report Samples";
  else if (G_PS_PATHNAME.indexOf("/products/scorewatch/sample/") > -1)
	  myCat = "Score Watch Samples";
  else if (G_PS_PATHNAME == "/products/products.aspx" || G_PS_PATHNAME == "/products/products2.aspx")
	  myCat = "Products";
  else if (G_PS_PATHNAME == "/products/ficokit/description.aspx")
	  myCat = "Suze Orman FICO Kit Product Information";
  else if (G_PS_PATHNAME == "/products/ficoone/description.aspx")
	  myCat = "FICO Standard Product Information";
  else if (G_PS_PATHNAME == "/products/ficothree/description.aspx")
	  myCat = "FICO Credit Complete Product Information";
  else if (G_PS_PATHNAME == "/products/idf/description.aspx")
	  myCat = "FICO Quarterly Monitoring Product Information";
  else if (G_PS_PATHNAME == "/products/scorewatch/description.aspx" || G_PS_PATHNAME == "/products/scorewatch/freetrial.aspx")
	  myCat = "Score Watch Product Information";
  /******* Product Merchandizing End *******/
  /****** Member Area Start ************/
  
  else if (G_PS_PATHNAME.indexOf("/ccc/") > -1 || G_PS_PATHNAME.indexOf("/dispute/") > -1)
	  myCat = "Error Correction";
  else if (G_PS_PATHNAME.indexOf("/cpp/") > -1)
	  myCat = "FICO Quarterly Monitoring";
  else if (G_PS_PATHNAME.indexOf("/membercenter/simulator/") > -1)
	  myCat = "FICO Score Simulator";
  else if (G_PS_PATHNAME == "/membercenter/default.aspx" || G_PS_PATHNAME == "/membercenter/")
	  myCat = "Member";
  else if (G_PS_PATHNAME.indexOf("/suze/") > -1 || G_PS_PATHNAME.indexOf("/ficokit/") > -1 || 
	  G_PS_PATHNAME.indexOf("/infovault/") > -1 || G_PS_PATHNAME.indexOf("/Unsubscribe/billreminder/") > -1)
	  myCat = "Suze Orman FICO Kit";
  else if (G_PS_PATHNAME.indexOf("/scorewatch/") > -1)
	  myCat = "Score Watch";
  else if (G_PS_PATHNAME.indexOf("/report/") > -1)
	  myCat = "FICO Score Report";
  else if (G_PS_PATHNAME.indexOf("/propertyreport/") > -1)
	  myCat = "Property Report";
  else if (G_PS_PATHNAME.indexOf("/membercenter/") > -1)
	  myCat = "Change Member Info";
  /****** Member Area End *************/

 
  /******* Business Operations Start *******/
  else if (G_PS_PATHNAME.indexOf("/affiliates/") > -1)
	  myCat = "Affiliate Program";
  else if (G_PS_PATHNAME == "/myfico/partnerprograms.asp" || G_PS_PATHNAME.indexOf("/business/") > -1 || 
	  G_PS_PATHNAME.indexOf("/company/") > -1)
	  myCat = "Business";
  else if (G_PS_PATHNAME.indexOf("/reports/") > -1)
	  myCat = "Customer Care";
  else if (G_PS_PATHNAME == "/crediteducation/emailsignup.aspx" || G_PS_PATHNAME == "/unsubscribe/default.aspx" || 
	  G_PS_PATHNAME == "/unsubscribe/" || G_PS_PATHNAME == "/myfico/emailafriend.asp")
	  myCat = "Email";
  else if (G_PS_PATHNAME.indexOf("/help/") > -1 || document.location.host.indexOf("custhelp.myfico.com") > -1)
	  myCat = "Support Center";
  else if (G_PS_PATHNAME.indexOf("/policy/") > -1)
	  myCat = "Legal";
  else if (G_PS_PATHNAME == "/site-map.aspx")
	  myCat = "Site Map";
  /******* Business Operations End *******/
/****** Credit Education Start ******/
  else if (G_PS_PATHNAME.indexOf("/crediteducation/articles/") > -1)
	  myCat = "Articles";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/calculators/") > -1 || G_PS_PATHNAME.indexOf("/loancenter/refinance/calculators/") > -1 || 		G_PS_PATHNAME == "/myfico/creditcentral/loanrates.asp" || G_PS_PATHNAME.indexOf("/loancenter/mortgage/calculators/") > -1 || 			G_PS_PATHNAME.indexOf("/loancenter/homeequity/calculators/") > -1 || G_PS_PATHNAME.indexOf("/loancenter/calculators/") > -1)
	  myCat = "Calculators";
  else if (G_PS_PATHNAME == "/crediteducation/default.aspx" || G_PS_PATHNAME == "/crediteducation/")
	  myCat = "Credit Education";
  else if (G_PS_PATHNAME == "/crediteducation/downloads.aspx" || G_PS_PATHNAME == "/crediteducation/brochures.aspx")
	  myCat = "Downloads";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/feature/") > -1)
	  myCat = "Features";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/questions/") > -1)
	  myCat = "Questions";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/news/") > -1)
	  myCat = "News";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/videos/") > -1)
	  myCat = "Videos";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/espanol/") > -1)
	  myCat = "Spanish";
  else if (G_PS_PATHNAME.indexOf("/crediteducation/") > -1 || 
    G_PS_PATHNAME.indexOf("/loancenter/refinance/step") > -1 ||  
    G_PS_PATHNAME.indexOf("/loancenter/mortgage/step") > -1 || 
    G_PS_PATHNAME.indexOf("/loancenter/homeequity/step") > -1 || 
	  G_PS_PATHNAME.indexOf("/couples/") > -1 || 
	  G_PS_PATHNAME.indexOf("/myfico/creditcentral/") > -1 )
	  myCat = "Basics";
	  
  /****** Credit Education End ******/
  else if (document.location.host.indexOf("ficoforums.myfico.com") > -1 || G_PS_PATHNAME.indexOf("/forum/") > -1)
	  myCat = "FICO Forums";
  else if (G_PS_PATHNAME.indexOf("/systemaccess/") > -1)		
	  myCat = "Access";
  else if (G_PS_PATHNAME.indexOf("/ficocreditscoreestimator/") > -1)
	  myCat = "FICO Score Estimator";
  else if (G_PS_PATHNAME.indexOf("/lp/") > -1 || G_PS_PATHNAME.indexOf("/payless/") > -1 || G_PS_PATHNAME.indexOf("/tv/") > -1)
	  myCat = "Landing Pages";
  else if (G_PS_PATHNAME.indexOf("/12/") > -1 || G_PS_PATHNAME == "/home.asp")
	  myCat = "Partners";
  else if (G_PS_PATHNAME.indexOf("/store/") > -1 || G_PS_PATHNAME.indexOf("/voucher/") > -1)
	  myCat = "Order Process";
  else if (document.location.host.indexOf("search.myFICO.com") > -1)
	  myCat = "Site Search";
  else if (G_PS_PATHNAME.indexOf("/loancenter/") > -1)
	  myCat = "Loan Center";
  else
	  myCat = "Miscellaneous";

  return myCat;
  
}

/*===================== BEGIN TAGGING BUSSINESS LOGIC ========================*/
function psPostRegistrationView()
{
	if ((psGetCookie(G_PS_COOKIE_FLAG) == "SignIn") || (psGetCookie(G_PS_COOKIE_FLAG) =="ChangeUserName") || (psGetCookie(G_PS_COOKIE_FLAG) == "Login"))
	{
		var uP = new psProfile();
		uP.readProfile(); // get user profile from cookie
		// post registration tag for login page
		
		psCreateRegistrationTag(uP.customerId);
		psSetCookie(G_PS_COOKIE_FLAG, "", "delete"); // turn off flag
	}
	else if ((psGetCookie(G_PS_COOKIE_FLAG) == "Updated") || (psGetCookie(G_PS_COOKIE_FLAG) == "Created")){
		var uP = new psProfile();		
		uP.readProfile(); // get user profile from cookie
		// post registration tag for login page
		psCreateRegistrationTag(uP.customerId,uP.email,uP.city,uP.state,uP.zipcode);
		psSetCookie(G_PS_COOKIE_FLAG, "", "delete"); // turn off flag
		
	}
}
function psSubscribeProfilePages()
{
	if ((G_PS_PATHNAME == "/systemaccess/login.aspx") || (G_PS_PATHNAME=="/systemaccess/logout.aspx")){
		var btnSignIn = document.getElementById("baseTemplate_oLoginControl_Button1");
		if (psCheckElementExist(btnSignIn)==true){
			var oldCMFunc = btnSignIn.onclick
			btnSignIn.onclick = function(){				
				var uP = new psProfile();
				uP.customerId = document.getElementById("baseTemplate_oLoginControl_LoginID").value;				
				uP.writeProfile();				
				psSetCookie(G_PS_COOKIE_FLAG, "SignIn");
				return oldCMFunc;
			}
		}	
	}
	else if (G_PS_PATHNAME=="/membercenter/changememberinfo.asp")
	{		
		var btnMakeChanges = document.getElementsByName("Submit1");		
		if (psCheckArrayExist(btnMakeChanges[1])==true){
			var oldCMFunc = btnMakeChanges[1].onclick
			btnMakeChanges[1].onclick = function(){				
				var uP = new psProfile();
				var stringProfile = psGetCookie(G_PS_COOKIE_PROFILE);				
				if (stringProfile != null)
				{
					var buf = stringProfile.split('|');
					for (var i=0; i<buf.length; i++)
					{
						var tempVal = buf[i];						
						buf[i] = (tempVal=="null" ? null : tempVal); 
					}				
					uP.customerId = buf[0];				
					uP.email = document.getElementsByName("EmailAddress")[0].value;				
					uP.city = document.getElementsByName("City")[0].value;				
					uP.zipcode = document.getElementsByName("ZipCode")[0].value;				
					uP.state = psGetElementValue(document.getElementsByName("State")[0],true)
					uP.writeProfile();					
					psSetCookie(G_PS_COOKIE_FLAG, "Updated");
					return oldCMFunc;
				}				
			}						
		}
	}
	else if (G_PS_PATHNAME=="/membercenter/changeusername.asp"){
		var btnChangeUserName = psGetElementsByClassName(document,"INPUT","button accent");		
		if (psCheckElementExist(btnChangeUserName[0])==true){
			var oldCMFunc = btnChangeUserName[0].onclick
			btnChangeUserName[0].onclick = function(){				
				var uP = new psProfile();
				uP.customerId = document.getElementsByName("NewUserName")[0].value;								
				uP.writeProfile();				
				psSetCookie(G_PS_COOKIE_FLAG, "ChangeUserName");
				return oldCMFunc;
			}
		}	
	}
	else if (G_PS_PATHNAME=="/systemaccess/createprofile.aspx"){
		var btnMakeCreate = document.getElementById("baseTemplate_btnSubmit");		
		if (psCheckArrayExist(btnMakeCreate)==true){
			var oldCMFunc = btnMakeCreate.onclick
			btnMakeCreate.onclick = function(){				
				var uP = new psProfile();				
				uP.customerId = document.getElementById("baseTemplate_txtLoginID").value;				
				uP.email = document.getElementById("baseTemplate_txtEmail").value;				
				uP.city = document.getElementById("baseTemplate_txtCity").value;				
				uP.zipcode = document.getElementById("baseTemplate_txtZip").value;				
				uP.state = psGetElementValue(document.getElementById("baseTemplate_ddlState"),true)
				uP.writeProfile();					
				psSetCookie(G_PS_COOKIE_FLAG, "Created");
				return oldCMFunc;	
			}						
		}
	}
	else if (G_PS_PATHNAME=="/store/order.asp"){
		var btnLogin = document.getElementById("Submit1");
		if (psCheckElementExist(btnLogin)==true){
			var oldCMFunc = btnLogin.onclick
			btnLogin.onclick = function(){				
				var uP = new psProfile();
				uP.customerId = document.getElementById("LoginID").value;				
				uP.writeProfile();				
				psSetCookie(G_PS_COOKIE_FLAG, "SignIn");
				return oldCMFunc;
			}
		}	
	}
}
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 productview tag for the item in product detail
 */
function psPostProductView()
{
	var prd = new psProduct();
	prd.getProduct();
	// Post product view tag	
	psCreateProductviewTag(prd.id, prd.name);
}

/*
 * Process to post shop5tags for items in shopping cart
 */
function psPostCartView()
{

	var prd = new psProduct();		
	var cartTbl = document.getElementsByTagName("table");	
	if (psCheckArrayExist(cartTbl)==true)
	{
	  //psGetSubCookie(psGetCookie("MYFICO"),"pp");
		for(var i=0;i<cartTbl.length;i++)
		{
			if (cartTbl[i].className=="SmallBlack")
			{
				var rows = cartTbl[i].rows;
				break;
			}			
		}		
		for (var r = 1; r < rows.length-1; r++) 
		{				
			if (rows[r].id!="baseTemplate_ctrlLineItems_trDeluxeHdr"  && rows[r].id!="baseTemplate_ctrlLineItems_trPaymentHdr" && rows[r].id!="baseTemplate_ctrlLineItems_trTotalPrice")
			{
				prd.getItem5(rows[r]);
				// Post shop5tag
				psCreateShopAction5Tag(prd.id, prd.name, prd.quantity, prd.price, prd.catId);				
			}
		}
		// Make sure to have actual postings
		psDisplayShop5s();
	}	
}

/*
 * Process to post shop9tags for items purchased
 */
function psPostOrderView()
{

  var isPrintableVersion = "no";
  isPrintableVersion = psGetValueFromUrl(G_PS_URL_PATH,"print")
  //alert("isPrintableVersion="+isPrintableVersion)
  if(isPrintableVersion == null || isPrintableVersion!="yes"){
	  var cartTbl = null;
	  /*
	  * Codes for locating the table containing items (each row for an item)
	  */
	  
	  var ord = new psOrder();	
	  var prd = new psProduct();
	  
	  ord.getOrder(); // Get order info from source code
	  // Post Pageviewtag as cartview
  	
	  var cartTbl = document.getElementsByTagName("table");	
  	
	  if (psCheckArrayExist(cartTbl)==true)
	  {
	  
		  for(var i=0;i<cartTbl.length;i++)
		  {
			  if (cartTbl[i].className=="SmallBlack")
			  {
				  var rows = cartTbl[i].rows;
				  break;
			  }			
		  }		
		  var isFCC = false;
		  for (var r = 0; r < rows.length; r++) // item for each row
		  {
		    if (rows[r].id=="baseTemplate_ctrlLineItems_trDeluxeHdr")
		    {
	        isFCC = true;
		    }
			  if (rows[r].id!="baseTemplate_ctrlLineItems_trReceiptHdr"  && rows[r].id!="baseTemplate_ctrlLineItems_trTotalPrice" && rows[r].id!="baseTemplate_ctrlLineItems_trDeluxeHdr")
			  { 
				  prd.getItem9(rows[r]);		
				  if(isFCC == true)
				   prd.catId = "FICO Credit Complete";
				   
				  // Post shop9tag
				  psCreateShopAction9Tag(prd.id, prd.name, prd.quantity, prd.price, ord.cusId, ord.id, ord.subtotal, prd.catId);				
			  }
		  }
		  // Make sure to have actual postings
		  psDisplayShop9s();
		  // Post order tag finally
		  psCreateOrderTag(ord.id, ord.subtotal, ord.shipping, ord.cusId, ord.city, ord.state, ord.zipCode);
	  }
	}
}

/*====================== END TAGGING BUSSINESS LOGIC =========================*/



/*======================= GENERAL UTILITY FUNCTION ===========================*/
/* PURPOSE: constructor for product
 * Note: you can add more methods to psProduct in its prototype
 * RETURN: none
 */
function psProduct(pId, pName, pCatId, pPrice, pQuantity)
{
    this.id = pId;
    this.name = pName;
    this.catId = pCatId;
    this.price = pPrice;
    this.quantity = pQuantity;
	/*
	 * Extracting product info from source code for posting productview tag
	 */
	this.getProduct = function()
	{
	  //product can be lower case  ??
	  ///This gets info if we want a specifice product view based on product querystring
		this.id = psGetValueFromUrl(G_PS_URL_PATH,"product")
		this.name =psTrim(psCleanCatId(psCleanCopyRight(document.getElementById("prodtopur").innerHTML)));
		this.catId = GetProductCategoryId(this.id);
	}
	/*
	 * Extracting product info from source code specified by the "current" row
	 * of items table in the shopping cart
	 * This is very similar if not exactly like getItem9 (see below) and we may be able to combine them.
	 */
	this.getItem5 = function(itemRow)
	{				  
		this.id = psTrim(psRemoveCopyRight(psGetInnerText(itemRow.cells[3])));
		//this.name = psTrim(psRemoveCopyRight(psGetInnerText(itemRow.cells[0])));
		this.name = GetProductNameFromID(this.id);
		var pStringPrice=psTrim(psGetInnerText(itemRow.cells[2].innerHTML));
		if (pStringPrice.indexOf("FREE")>-1)
		{
			if (this.id=="16" && pStringPrice.indexOf("FREE 30-day trial")>-1 ) 
		  {
		    //Not sure if Paul want Free Trial appended to name at this point
		    //this.name += " Free Trial";
			  this.price = 31.48;
		  }
		  else 
		  {
				this.price = 0;
			}				
		}
		else
		{	
			var posFlash = pStringPrice.indexOf("/");
			if (posFlash==-1)
				posFlash = pStringPrice.length;
			

			this.price = pStringPrice.substring(pStringPrice.indexOf("$")+1,posFlash);
			//If this is a monthly subscription product the price indicates and multiply by 12
			if(  pStringPrice.indexOf("/month") >-1 )
			{
				this.price = parseFloat(this.price)*12;
			  if(!isNaN(this.price))
			  {
			    //make sure to return a price after multiplying by 12
			    var result=Math.round(this.price*100)/100 
			    this.price = result;
			  }
			}
		}
		this.quantity = 1;	
			
		this.catId = GetProductCategoryId(this.id);	  	  
	}
	/*
	 * Extracting product info from source code specified by the "current" row
	 * of items table in the receipt page
	 * This is very similar if not exactly like getItem5 (see above) and we may be able to combine them.
	 */
	this.getItem9 = function(itemRow)
	{
		this.id = psTrim(psRemoveCopyRight(psGetInnerText(itemRow.cells[3])));
		//this.name = psTrim(psCleanPageId(psRemoveCopyRight(psGetInnerText(itemRow.cells[0]))));
		this.name = GetProductNameFromID(this.id);
		var pStringPrice=psTrim(psGetInnerText(itemRow.cells[2].innerHTML));
	
		if (pStringPrice.indexOf("FREE")>-1)
		{
			if (this.id=="16" && pStringPrice.indexOf("FREE 30-day trial")>-1 ) 
		  {
			  this.price = 31.48;
		  }
		  else 
		  {
				this.price = 0;
			}			
		}
		else
		{	
			var posFlash = pStringPrice.indexOf("/");
			if (posFlash==-1)
			posFlash = pStringPrice.length;
			this.price = pStringPrice.substring(pStringPrice.indexOf("$")+1,posFlash);
			//If this is a monthly subscription product the price indicates and multiply by 12
			if(  pStringPrice.indexOf("/month") >-1 )
			{
				this.price = parseFloat(this.price)*12;
			  if(!isNaN(this.price))
			  {
			    //make sure to return a price after multiplying by 12
			    var result=Math.round(this.price*100)/100 
			    this.price = result;
			  }
			}			
		}
		this.quantity = 1;	
		
				  	  
		this.catId = GetProductCategoryId(this.id);
	}
}
function GetProductNameFromID(prodID)
{
  var productName = "";
  switch(prodID)
  {
    case "1":
    case "3001":
      productName = "FICO Standard &#150; Equifax (Score Power)";
      break;
    case "10001":
    case "13001":
      productName = "FICO Standard &#150; TransUnion";
      break;
    case "20001":
    case "23001":
      productName = "FICO Standard &#150; Experian";
      break;
    case "17": // EQ FCC Annual Renewal
      productName = "FICO Standard &#150; Equifax (Score Power) Annual Renewal";
      break;
    case "18": // TU FCC Annual Renewal
      productName = "FICO Standard &#150; TransUnion Annual Renewal";
      break;
    case "19": // XPN FCC Annual Renewal
      productName = "FICO Standard &#150; Experian Annual Renewal";
      break;
    case "9999": //Suze Kit II (Platinum)
      productName = "Suze Ormans FICO Kit Platinum";
      break;
    case "16": //Free Trial
      productName ="Score Watch";
      if ( psGetValueFromUrl(G_PS_URL_PATH,"trialdays")!=null && psGetValueFromUrl(G_PS_URL_PATH,"trialdays")=="16d30")
		  {
		    productName = " Free Trial";
		  }
      break;
    case "2016": //Monthly Subscription
      productName ="Score Watch";
      break;
    case "12007": //monthly Subscription
      productName = "FICO Quarterly Monitoring Monthly";
      break;
    case "10007": //Annual Renewal
      productName = "FICO Quarterly Monitoring Annual Renewal";
      break;
    case "501":
      productName = "Property Reports &#150; Single Report";
       break;
    case "503":
      productName = "myFICO Property Reports &#150; 3-Report Package";
       break;
    case "505":
      productName = "myFICO Property Reports &#150; 5-Report Package";
       break;
    case "LoanCenter":
      productName  = "Leads";
      break;
  }
  return productName;
}
function GetProductCategoryId(productID)
{
  var isDeluxe = psGetValueFromUrl(G_PS_URL_PATH,"isdeluxe");
  var categoryID = "Miscellaneous";
  switch(productID)
  {
    case "1":
    case "10001":
    case "20001":
      if(isDeluxe=="yes"){
        categoryID = "FICO Credit Complete";
      }
      else{
        categoryID = "FICO Standard";
      }
      break;
    case "3001":
    case "13001": 
    case "23001":
      categoryID = "FICO Credit Complete";
    break;
    case "17": // EQ FCC Annual Renewal
    case "18": // TU FCC Annual Renewal
    case "19": // XPN FCC Annual Renewal
      categoryID = "FICO Credit Complete Annual";
      break;
    case "9999": //Suze Kit II (Platinum)
      categoryID = "Suze Ormans FICO Kit Platinum";
      break;
    case "16": //Free Trial
    case "2016": //Monthly Subscription
      categoryID ="Score Watch";
      break;
    case "12007": //monthly Subscription
    case "10007": //Annual Renewal
      categoryID = "FICO Quarterly Monitoring";
      break;
    case "501":
    case "503":
    case "505":
      categoryID = "Property Reports";
      break;
    case "LoanCenter":
      categoryID  = "Leads";
      break;
  }
  return categoryID;
}

/* PURPOSE: constructor for profile
 * Note: you can add more methods to psProfile in its prototype
 * RETURN: none
 */
function psProfile()
{
	this.customerId = null;
    this.email = null;
    this.city = null;
    this.state = null;
    this.zipcode = null;
	this.newsletterName = null;    
	/*
	 * Get user profile from cookie
	 */
	this.readProfile = function()
	{
		this.customerId = psGetCookie(G_PS_COOKIE_PROFILE);
		if (this.customerId != null)
		{
			var buf = this.customerId.split('|');
			for (var i=0; i<buf.length; i++)
			{
				var tempVal = buf[i];
                // when NULL is written to cookie, it becomes string, not literal constant
				buf[i] = (tempVal=="null" ? null : tempVal); 
			}
			this.customerId = buf[0];
			this.email = buf[1];
			this.city = buf[2];
			this.state = buf[3];
			this.zipcode = buf[4];
			this.newsletterName = buf[5];			
		}
	}
	/*
	 * Set user profile to cookie
	 */
	this.writeProfile = function()
	{
		// make sure that the data contains 4 parts separated by 3 '|'
		var data = this.customerId + "|" + this.email + '|' + this.city + '|' + this.state + 
			'|' + this.zipcode + '|' + this.newsletterName ;
		// store on cookie
		psSetCookie(G_PS_COOKIE_PROFILE, data);		
	}
}

/*
 * 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)
{
	this.id = pOrderId;
	this.subtotal = pSubtotal;
	this.shipping = pShipping;
	this.cusId = pCusId;
	/*
	 * get order info from source code
	 */
	this.getOrder = function()
	{
		var pTagTD= document.getElementById("baseTemplate_tdReceiptDetails");
		
	    if (psCheckElementExist(pTagTD)==true){
	   
			var tableTag = pTagTD.getElementsByTagName("table");
			if (psCheckElementExist(tableTag[0])==true){		
	      this.subtotal=psGetInnerText(tableTag[0].rows[0].cells[1]);	
				if(this.subtotal == "FREE")
				{
				  this.id = psGetInnerText(tableTag[0].rows[2].cells[1]);
				}
				else
				  this.id = psGetInnerText(tableTag[0].rows[3].cells[1]);
				

				this.shipping=0;
			}
		}
		this.cusId = psGetCookie(G_PS_COOKIE_PROFILE);
		if (this.cusId != null)
			this.cusId = this.cusId.split('|')[0]; 
	}
}
function psRemoveCopyRight(pString)
{
	var pPageId="";
	var arrSpecialWords=["Watch", "Monitoring","FICO","myFICO","Power"];
	var pArr = psTrim(pString).split(" ");
	for(var i=0;i<pArr.length;i++){
		var xxx =psTrim(pArr[i]);		
		for(var index=0;index<arrSpecialWords.length; index++)
		{			
			if(xxx.indexOf(arrSpecialWords[index])==0)
			{				
				xxx=arrSpecialWords[index];
				if (xxx=="Power"){
					if (psTrim(pArr[i]).indexOf(")")>=0){
						xxx="Power)";
					}
				}
				pArr[i]=xxx;
				break;
			}
		}
	}		
	for(var i=0;i<pArr.length;i++)
	{
		xxx=pArr[i];
		pPageId+=xxx+" ";
	}
	return psTrim(pPageId);
}
function psGetInnerText(pTagOjb)
{
	if (pTagOjb != null)
	{
		if (typeof(pTagOjb) == "object")
			return pTagOjb.innerHTML.replace(/\<+.+?\>+/g, "");
		else
			return pTagOjb.replace(/\<+.+?\>+/g, "");
	}
	return null;
}

/* PURPOSE: Remove all unaccepted characters in categoryid, including
 * [, ', ", :, comma,]
 * RETURN: string
 */
function psCleanCatId(pCatId){
    return (pCatId != null) ? pCatId.replace(/[\'\":©®,]/g, "") : null;
}
function psCleanPageId(pPageId){
	return (pPageId != null) ? pPageId.replace(/[\n\t\v\r’\'\"]/gi, "") : null; 	
}
function psTrim(pStr){
	if (pStr == null || typeof(pStr) != "string")
		return pStr;

	return (pStr) ? pStr.replace(/&nbsp;/gi, ' ').replace(/^\s+|\s+$/g, '') : null;
}
String.prototype.trim = psTrim;

/* PURPOSE: extract value from the URL
 * in format of http://xxx.com/page.ext?key1=value1&key2=value2
 * RETURN: string value of the parameter
 */
function psGetValueFromUrl(pUrl, pKey)
{
    var key = pKey.toLowerCase();
    var re = new RegExp("[?&]" + key + "=([^&$]*)", "i");
    if (pUrl.search(re) == -1)
		return null;
    return unescape(RegExp.$1);
}

/* PURPOSE: returns the value of an element based on element_id
 * @pValueFlag: TRUE means VALUE  attribute of SELECT object returned, not innerHTML
 * RETURN: 
 *  Normal tag: decoded innerHTML
 *  INPUT tag: value attribute
 *  SELECT tag: decoded label of the selected option
 */
function psGetElementValueById(pTagId, 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 psGetSubCookie(cookieDataValue, subKey)
{
  alert(cookieDataValue +"\r\n"+ subKey);
  var dataFields = cookieDataValue.split("&");
  var returnValue  = null;
  if(dataFields && dataFields.length>0)
  {
    for(x=0;x<=dataFields.length;x++)
    {
      alert("dataFields["+x+"]: "+dataFields[x]);
      if(dataFields[x].indexOf(subKey) > -1)
      {
        var offset = dataFields[x].indexOf("=")+1;
        alert("offset: " + offset); 
        returnValue = unescape(dataFields[x].substring(offset, dataFields[x].length-1));
        alert("returnValue: " + returnValue); 
        break;    
      }
    }
  }
  return returnValue;
}
function psGetCookie(pCookieName)
{
    if (!pCookieName)
		return null;

    var start = document.cookie.indexOf(pCookieName + "=");
    if (start > -1)
    {
        start = start + pCookieName.length + 1; 
		var end = document.cookie.indexOf(";", start);		
        if (end == -1)
            end = document.cookie.length;
        return unescape(document.cookie.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);//delete cookie by calling coremetrics's cookie function
        return true;
    }
    // set cookie by calling coremetrics's cookie function
    var expire = (pLifeTime) ? (new Date((new Date()).getTime() + (1000 * pLifeTime))).toGMTString() : null;
    
    return CB(pCookieName, escape(pCookieValue), expire, pDomain);
}

/* PURPOSE: set value in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 * NOTE: Use null or '' for pValue to remove the pair specified by pKey
 */
function psSetValueToCookie(pCookieName, pKey, pValue)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// 
	var catCookie = psGetCookie(pCookieName);
	if (catCookie == null)
		catCookie = '';

	if (catCookie.indexOf(pKey) >=0) // Store before -> remove the old value
	{
        var reg = new RegExp("#" + pKey + "~([^#]*)", "gi");
        catCookie = catCookie.replace(reg, "");
	}
	// remove the last items (eldest items) until cookie size < 3500	
	if (pValue != null && pValue != '')
	{
		catCookie = "#" + pKey + "~" + pValue + catCookie;
		var cookieArray = null;
		while (catCookie.length > 3500)
		{
			cookieArray = catCookie.split("#");
			cookieArray.pop();
			catCookie = cookieArray.join("#");
		}
	}
	// Save to cookie
	psSetCookie(pCookieName, catCookie, G_PS_COOKIE_LIFETIME);
}

/* PURPOSE: get value stored in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 */
function psGetValueFromCookie(pCookieName, pKey)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// extract catId associated with the specified key (pKey)
    var catCookie = psGetCookie(pCookieName);
    if (catCookie != null)
    {
        var re = new RegExp("#" + pKey + "~([^#$]+)", "i");
		if (catCookie.search(re) == -1)
			return null;

        return RegExp.$1;
    }
    return null;
}

/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pageID, categoryID, searchString, 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) 
{
    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) 
{
    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) 
{
    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) 
{
    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, newsletterName, 
				subscribe) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateRegistrationTag(" + customerID + ", " + customerEmail + ", " + customerCity + ", " + customerState + ", " + customerZIP + ", " + newsletterName + ", " + subscribe + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateRegistrationTag(customerID, customerEmail, customerCity, customerState, customerZIP, newsletterName, subscribe);
}

function psCreateErrorTag(pageID, 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 ==================*/