// ===============
// utils.js
// ===============

// ------------------------------------
// For logging a "generic" event to sdc
// ------------------------------------
function sdcTrackGeneric(eventName)
{
   dcsMultiTrack("DCS.dcsuri", eventName + ".exe",
                 "WT.ti",      eventName,
                 "DCS.dcsref", window.location.pathname,
                 "WT.tx_e", "",
                 "WT.tx_id", "",
                 "WT.tx_it", "",
                 "WT.tx_u", "",
                 "WT.pn_sku", "",
                 "WT.pi", "",
                 "WT.tx_s", "",
                 "DCSext.QualityIndex", "");
}


// ----------------------------------------------------------------
// Handles events coming from flash files.  Logs the event in SDC.
// ----------------------------------------------------------------
function logFlashEventToSDC(eventName)
{
   //alert(eventName);
   var _eventName = ("FLASH_" + getPageName() + "_" + eventName).toUpperCase();
    
   dcsMultiTrack("DCS.dcsuri", _eventName + ".exe",
                 "WT.ti",      _eventName,
                 "DCS.dcsref", window.location.pathname,
                 "WT.tx_e", "",
                 "WT.tx_id", "",
                 "WT.tx_it", "",
                 "WT.tx_u", "",
                 "WT.pn_sku", "",
                 "WT.pi", "",
                 "WT.tx_s", "",
                 "DCSext.QualityIndex", "");
}
 
// Returns the name of the page as the filename minus the file extension 
function getPageName ()
{
   var pathName = window.location.pathname;

   if (pathName == "/" || pathName == "/index.html") 
      return "home";

   pathName = pathName.replace(/\/index\.html/, "");
   pathName = pathName.replace(/\//, "");
   return pathName;
}

/* For HCP verification */
/* Cookie functions are in /assets/scripts/jquery/global.js */
var HCPCookieName = "HCPVERIFIED";
function setHCPVerified()
{
   createCookie(HCPCookieName, HCPCookieName);
}
function isHCPVerified()
{
   return (readCookie(HCPCookieName) == HCPCookieName);  
}

// Load a page
function load(file,target) 
{
   if (target != null)
      target.window.location.href = file;
   else
      window.location.href = file;
}


