//********************************************************************
//
//              Copyright (c) 2008 MindLab GmbH
//                     All rights reserved.
//
//====================================================================
//
// Project    : netmind
// Filename   : nm_tr_config.js
//
//====================================================================
//
/**
 * @file
 * This script can be used to integrate Microsites, which are not on
 * on a 7ed website, in a tracking environment. 
 *
 * @author   $Alexander Schreiber$
 * @version  $Name: V2_8_0 $
 * @date     $Date: 2009-11-02 06:58:16 $
 * 
 * @todo     further testing:   long parameters 
 *                              interaction with other cookies 
 * @listofchanges asc outsourcing of all config-parameters into seperate file 2007/12/13
 * $Log: nm_tr_combined.js,v $
 * Revision 1.11  2009-11-02 06:58:16  pohl
 * Added flag to switch off auto-initialization
 *
 * Revision 1.11  2009-10-08 07:31:41  pohl
 * *** empty log message ***
 *
 * Revision 1.10  2009-10-08 07:20:45  pohl
 * Added configuration value for random unique request parameter
 *
 * Revision 1.9  2009-09-07 14:31:06  pohl
 * Added configuration and method to extract and transmit a specified set of cookies
 *
 * Revision 1.8  2009-05-15 13:27:24  pohl
 * Fixed DOM issue with IE and POST requests
 *
 * Revision 1.7  2009-04-27 13:53:01  pohl
 * Added HTTP POST functionallity
 * Added JSON encoding
 *
 * Revision 1.6  2009-01-21 12:33:18  pohl
 * Added techinfo parameters nm_javascript and changed parameter nm_cookies to nm_cookie.
 * Added functionallity to test/debug pixel tracking by logging configuration and request values to separate window.
 *
 * Revision 1.5  2008-12-02 14:18:41  pohl
 *
 * Added configuration options to enable/disable individual tech plugin detection
 *
 * Revision 1.4  2008/09/03 14:10:53  pohl
 * Added config values for netmind SID CGI parameter
 *
 */
//
//********************************************************************

//********************************************************************
//config Object
//********************************************************************
function cConfigPixel()
{
    //-----------------------------------------------------
    // members
    //-----------------------------------------------------
    //true = Tracker uses Cookies
    //false= tracker uses Session IDs in Urls
    this.m_bCookieTracking = true;

    // true =  Use content side tracking. 
    //         The nm_track.js script needs to be available on the 
    //         tracked web server and the m_strPixelJSPath value needs 
    //         to be set accordingly.
    // false = Use tracker side tracking.
    //         The scripts nm_tr_config, nm_tr_remote.js and the image 
    //         nm_track.gif need to be available on the tracked web server
    //         and the m_strPixelPath value needs to be set accordingly.
    this.m_bContentSideTracking = false;

    // Session timeout for tracker side tracking without tracker cookies.
    // we will treat a session as timed out if more than this amount
    // of seconds has passed between two clicks
    this.m_nNetMindSessionTimeout = 1800;

    //set to true, if you want to get the params automatically
    this.m_bAutoparams = true;
    //set to true, if you want to send the pixel automatically
    this.m_bAutosend = true;
    //set to true, if you want to initialize the pixel automatically
    this.m_bAutoinit = true;

    //The protocol to use for getting the pixel, could be either http
    //or https
    this.m_strPixelProtocol         = location.href.substr(0, location.href.indexOf(":"));

    //the servername to get the pixel from (no protocol here, and
    //no path here), you can append a port or prepend an authendication
    //like: user:passwort@myserver.mydomain.com:12345
    //where "user:password@" is the authentication
    //      "myserver.mydomain.com" is the fully qualified servername
    //      ":12345" is a port-Number

    this.m_strPixelServer           = "bunuel.opus5.de:1080";
    //the path to request from the given server, this path could of
    //course include CGI-Parameters
    //example: "/mywebbug?thisismyparameter=value"

    this.m_strPixelJSPath           = "/tracking/nm_track.js?addparam=value";
    this.m_strPixelPath             = "/tracking/nm_track.gif";

    // this value defines CGI parameter to inject the SID from outside.
    this.m_strSIDParam           = "nmsid";

    // this flag allows to explicitly disable SID injection via CGI parameters
    this.m_bSIDParamDisabled     = false;
    
    //Send Url by default
    this.m_bSendUrl              = true;
    //Send Referrer by default
    this.m_bSendReferrer         = true;
    //Send MetaTags by default
    this.m_bSendMetaTags         = true;
    //Send Browser Setting, Screen Infos etc.
    this.m_bSendTech             = true;
    //Send Browser Setting, Screen Infos etc.
    this.m_bSendUrlHash          = false;
    //Send CGI Params of the current location as Parameters of the Pixel
    this.m_bSendCGIParams        = true;
    
    //Indicates whether an HTTP POST request (using the XMLHttpRequest class)
    //should be used
    this.m_bUseHttpPost          = false;

    //Indicates whether object parameters should be converted to a
    //JSON-repesentation before sending it
    this.m_bConvertToJSON        = false;
    
    //Send the cookie values as defined in the object.
    //The cookies to be send are stored in an associative array; the key is
    //the cookie is the cookie name, the value is the CGI parameter name 
    //used to transmit the cookie value e.g.:
    //this.m_oSendCookies = new Object();
    //this.m_oSendCookies['NETMIND_PERMSID'] = 'nm_ext_permsid';
    //this.m_oSendCookies['NETMIND_SID'] = 'nm_ext_sid';
    this.m_oSendCookies          = false;
    
    
    //to workaround problems with IE and unclosed DOM objects (body),
    //the ID of an existing dummy HTML element to receive the
    //temporary DOM objects can be specified here.
    this.m_strPostParentId       = false;
    
    
    //If specified, the request will contain a unique ID to prevent
    //image caching. The specified value will be used as parameter name.
    //The unique value is calculated using a random number and the 
    //current timestamp.
    //E.g.:
    //this.m_strUniqueReqIdParam = "nm_rndreq_id";
    this.m_strUniqueReqIdParam   = false;
    
    //--------------------------------------------------------
    // metatags to be parsed
    //--------------------------------------------------------
    this.m_aMetatag = new Array(
        "meta.bsp1",
        "meta.bsp2"
    );
    //--------------------------------------------------------
    // Hashed parameter to be parsed
    //--------------------------------------------------------
    this.m_aHashParameter = new Array(
        "test",
        "key"
    );

    this.m_oTechPlugins = new Object();
    this.m_oTechPlugins['Director'] = false;
    this.m_oTechPlugins['MediaPlayer'] = false;
    this.m_oTechPlugins['Flash'] = false;
    this.m_oTechPlugins['RealPlayer'] = false;
    this.m_oTechPlugins['AcroRead'] = false;
        
        // flag to enable debugging.
        // if enabled, a window is opened, displaying the pixel configuration and the
        // pixel request for each request.
        this.m_bDebug = false;
} // end class cConfigPixel

//==========================================================
// getAutoParams
//==========================================================
function config_getSendUrlHash () {
    return this.m_bSendUrlHash;
}
//==========================================================
// getAutoParams
//==========================================================
function config_getAutoParams () {
    return this.m_bAutoparams;
}
//==========================================================
// getAutoSend
//==========================================================
function config_getAutoSend () {
    return this.m_bAutosend;
}

//==========================================================
// getAutoInit
//==========================================================
function config_getAutoInit() {
    return this.m_bAutoinit;
}
//==========================================================
// getSendUrl
//==========================================================
function config_getSendUrl () {
    return this.m_bSendUrl;
}
//==========================================================
// getSendReferrer
//==========================================================
function config_getSendReferrer () {
    return this.m_bSendReferrer;
}
//==========================================================
// getSendMetatags
//==========================================================
function config_getSendMetatags () {
    return this.m_bSendMetaTags;
}
//==========================================================
// getSendTech
//==========================================================
function config_getSendTech () {
    return this.m_bSendTech;
}

//==========================================================
// getSendTechPlugin
// strPlugin = 'Director', 'MediaPlayer', 'Flash', 
//             'RealPlayer', 'AcroRead'
//==========================================================
function config_getSendTechPlugin( strPlugin )
{
    if ( this.m_oTechPlugins )
    {
        return this.m_oTechPlugins[strPlugin];
    }
    return false;
}

//==========================================================
// getSendCGIParams
//==========================================================
function config_getSendCGIParams () {
    return this.m_bSendCGIParams;
}

//==========================================================
// getPixelUrl
//
// return the URL to the tracking pixel or script.
//==========================================================
function config_getPixelUrl () {
    return this.m_strPixelProtocol+"://"+this.m_strPixelServer + this.getPixelPath();
}
//==========================================================
// getProtocol
//==========================================================
function config_getProtocol () {
    return this.m_strPixelProtocol;
}
//==========================================================
// getPixelServer
//==========================================================
function config_getPixelServer () {
    return this.m_strPixelServer;
}
//==========================================================
// getPixelPath
//==========================================================
function config_getPixelPath () {
    if (this.m_bContentSideTracking) 
    {
        return this.m_strPixelJSPath;
    }
    else
    {
        return this.m_strPixelPath;
    }
}

//==========================================================
// getSIDParam
//==========================================================
function config_getSIDParam () {
    return this.m_strSIDParam;
}

//==========================================================
// getSIDParamDisabled
//==========================================================
function config_getSIDParamDisabled () {
  return this.m_bSIDParamDisabled;
}

//==========================================================
// isCookieTracking
//==========================================================
function config_isCookieTracking () {
  return this.m_bCookieTracking;
}
//==========================================================
// isContentSideTracking
//==========================================================
function config_isContentSideTracking () {
  return this.m_bContentSideTracking;
}
//==========================================================
// getSessionTimeout
//==========================================================
function config_getSessionTimeout () {
  return this.m_nNetMindSessionTimeout;
}

//==========================================================
// getSendCookies
// Return the cookies to be send
//==========================================================
function config_getSendCookies()
{
    return this.m_oSendCookies;
}

//==========================================================
// getUniqueRequestIdParam
// Return the name of the parameter to receive the unique
// request ID. Returns false if no such parameter is to 
// be transmitted.
//==========================================================
function config_getUniqueRequestIdParam()
{
    return this.m_strUniqueReqIdParam;
}

//==========================================================
// isHttpPostEnabled
//==========================================================
function config_isHttpPostEnabled()
{
  return this.m_bUseHttpPost;
}


//==========================================================
// isJSONEnabled
// returns whether to use JSON encoding for object
// values.
// Returns only true, if m_bConvertToJSON is set AND
// the JSON object is available.
//==========================================================
function config_isJSONEnabled()
{
  return ( typeof(JSON) == 'object'
           && this.m_bConvertToJSON );
}




//==========================================================
//Definition of Prototypes
//==========================================================
//methoden zur Klasse hinzufuegen
cConfigPixel.prototype.isCookieTracking         = config_isCookieTracking;
cConfigPixel.prototype.isContentSideTracking    = config_isContentSideTracking;
cConfigPixel.prototype.getPixelUrl              = config_getPixelUrl;
cConfigPixel.prototype.getProtocol              = config_getProtocol;
cConfigPixel.prototype.getPixelServer           = config_getPixelServer;
cConfigPixel.prototype.getPixelPath             = config_getPixelPath;
cConfigPixel.prototype.getSIDParam              = config_getSIDParam;
cConfigPixel.prototype.getSIDParamDisabled      = config_getSIDParamDisabled;
cConfigPixel.prototype.getAutoParams            = config_getAutoParams;
cConfigPixel.prototype.getAutoSend              = config_getAutoSend;
cConfigPixel.prototype.getAutoInit              = config_getAutoInit;
cConfigPixel.prototype.getSendUrl               = config_getSendUrl;
cConfigPixel.prototype.getSendUrlHash           = config_getSendUrlHash;
cConfigPixel.prototype.getSendReferrer          = config_getSendReferrer;
cConfigPixel.prototype.getSendMetatags          = config_getSendMetatags;
cConfigPixel.prototype.getSendTech              = config_getSendTech;
cConfigPixel.prototype.getSendTechPlugin        = config_getSendTechPlugin;
cConfigPixel.prototype.getSendCGIParams         = config_getSendCGIParams;
cConfigPixel.prototype.getSessionTimeout        = config_getSessionTimeout;
cConfigPixel.prototype.getSendCookies           = config_getSendCookies;
cConfigPixel.prototype.isHttpPostEnabled        = config_isHttpPostEnabled
cConfigPixel.prototype.isJSONEnabled            = config_isJSONEnabled;
cConfigPixel.prototype.getUniqueRequestIdParam  = config_getUniqueRequestIdParam;


//********************************************************************
//Session-Management
//********************************************************************
//********************************************************************
//Session-Object 
//********************************************************************

//==========================================================
//Constructor for Session-Object
//==========================================================
function cRemoteSession( oConfig )
{
  //-----------------------------------------------------
  // members
  //-----------------------------------------------------
  //this is the SessionID returned at the end
  this.m_strNetMindSID = "";
  this.m_oConfig = oConfig;
  // flag indicating whether to use the injected SID from the CGI parameter
  // or whether to use the more recent SID provided by the tracker
  // via cookie or URI replacement
  this.m_bCgiSIDHandled = false;

  // remember pixel time initialization 
  // needed to adjust timestamp for subsequent JS pixel requests 
  // when using injected SID.
  this.nPixelTime = new Date().getTime() / 1000;
}//end function cRemoteSession()
 
//==========================================================
//method for object Session: returns the Session ID 
//==========================================================
function remotesession_getSessionID()
{

  var strNetMindSID = "";

  // get cookie string
  var strCookie = document.cookie
  //split into cookies
  var arCookies = strCookie.split("; ");
  //loop through cookies and get NetMind-Cookie
  var nLoopCount       = 0;
  var strActCookieName = "";        
   
    if ( strNetMindSID == "" )
    {    
    while (nLoopCount < arCookies.length) {
      var strActCookie = arCookies[nLoopCount];
      var arActCookie = strActCookie.split("=");
      var strActCookieName = arActCookie[0];        
      if (strActCookieName == "NETMIND_SID") {
      strNetMindSID = arActCookie[1];
      }
      nLoopCount++;
    }//end while ((strActCookieName != "NETMIND_SID") && (nLoopCount < arCookies.length))

    if (!oNMConfig.isContentSideTracking() && !oNMConfig.isCookieTracking())
    {
      //
      //  tracker-side tracking with URL rewriting.
      //  SID should be set in the following variable:
      //
      var strSID_trackerside="/";
      var strNewSID = "";
      var nNewTS  = 0;
      if (strSID_trackerside != "/") {
        strNewSID = strSID_trackerside.substr (6, 54);
        nNewTS = parseInt(
              String(parseInt( strNewSID.substring(44) ) 
              + (new Date().getTime() / 1000 - this.nPixelTime)));
      }    

      //  check whether session from cookie is still valid:
      if (strNetMindSID != "" && strNewSID != "" )
      {
        var nOldTS = parseInt( strNetMindSID.substr(44) );
        
        if ( nOldTS <= nNewTS )
        {
          // cookie session did not exceed timeout,
          // use cookie and update timestamp of SID
          if ( this.m_bCgiSIDHandled )
          {
            // use netmind SID from cookie, set via CGI param
            strNetMindSID = strNetMindSID.substr(0,43) + "-" + nNewTS;                                
          }
          else
          {
            // use netmind SID provided by the tracker
            strNetMindSID = strNewSID.substr(0,43) + "-" + nNewTS;
          }
        } 
        else
        {
          strNetMindSID = strNewSID;
        }
      } else {
        // no SID from cookie, use new SID if available
        strNetMindSID = strNewSID;
      }

      if ( strNetMindSID != "")
      {
        document.cookie = "NETMIND_SID="+strNetMindSID+"; path=/";        
      }
    }
    }
    
    strCgiSID = this.getCGISessionID();  
  
  if ( strCgiSID != null )
    {
    strNetMindSID = strCgiSID;
    document.cookie = "NETMIND_SID="+strNetMindSID+"; path=/";
    }

  this.m_strNetMindSID = strNetMindSID;
  
  return this.m_strNetMindSID;
}//end function session_getSessionID()


//==========================================================
// getCGISessionID()
// extract the session ID injected via CGI parameter.
// returns null if no such parameter, or disabled, or if
// already handled, i.e. the injected SID is available
// as cookie.
//==========================================================
function remotesession_getCGISessionID()    
{
    if ( this.m_bCgiSIDHandled )
    {
        // remote CGI SID already extracted. Must be available in the cookies.
        return null;
    }
    if ( !this.m_oConfig.getSIDParamDisabled || !this.m_oConfig.getSIDParamDisabled() )
  {
    var strSIDParam = "nmsid";

    if ( this.m_oConfig.getSIDParam )
    {
      strSIDParam = this.m_oConfig.getSIDParam();
    }
    if ( strSIDParam )
        {
      this.m_bCgiSIDHandled = true;
      var strCgiSID = remotepixel_extractCGIParam( strSIDParam );
      if ( strCgiSID == "" )
            {
        return null;
            }
      return strCgiSID;
        }
    }
    return null;

} // end function remotesession_getCGISessionID

//==========================================================
//add methods to class cSession 
//==========================================================
cRemoteSession.prototype.getSessionID = remotesession_getSessionID;
cRemoteSession.prototype.getCGISessionID = remotesession_getCGISessionID;



//********************************************************************
//Pixel-Object
//********************************************************************
//Contstructor for Pixel-Object
function cRemotePixel(oConfig)
{
    //-----------------------------------------------------
    // members
    //-----------------------------------------------------
    //pixel object constructor
    this.m_arParameterList = new Array();
    this.m_nParameterCount = 0;
    
    //Configuration
    this.m_oConfig = oConfig;
    
    this.m_strPixelURL         = oConfig.getPixelUrl();
    this.m_strPixelURLPrefix       = oConfig.getProtocol()+"://"+oConfig.getPixelServer() + "/";
    this.m_strPixelURLSuffix     = "";
    
    var strPixelpath = oConfig.getPixelPath();
    
    if (strPixelpath.charAt(0) == "/")
    {
      this.m_strPixelURLSuffix = strPixelpath.substr(1);
    } else {
      this.m_strPixelURLSuffix = strPixelpath; 
    }//end else (PixelPath.charAt(0) == "/")
  
    if ( oConfig.m_bDebug ) 
    {
      this.m_oDbgWin = window.open( "", "PixelDebug", "height=550,dependent=yes,scrollbars=yes,resizable=yes" );
      if ( !this.m_oDbgWin.document.getElementById('_log_config') ) 
      {
        this.m_oDbgWin.document.write( "<html><head><title>PixelDebug</title></head><body><b>Config values:</b><br><p><div style=\"height:200px;overflow:auto\" id=\"_log_config\"></div></p><b>Tracked values:</b><br><p><div style=\"height:200px;overflow:auto\" id=\"_log_values\"></div></p></body></html>" );
        this.writeConfig( true );
      }
      else
      {
        this.writeConfig( false );
      }
    }
    
    this.m_oIFrame = null;
    this.m_oBody = null;
    
}//end function cRemotePixel()


function remotepixel_writeConfig( bAppend )
{
  var oConfig = this.m_oConfig;
  
  this.writeDebug( document.URL, "_log_config", bAppend, true );
  
  if ( oConfig.m_bDebug )
  {
    if ( oConfig.isCookieTracking() )
    {
      this.writeDebug( "Cookie Tracking enabled", "_log_config", true );
    } 
    else 
    {
      this.writeDebug( "URL rewriting enabled<br>", "_log_config", true );
    }
    if ( oConfig.isContentSideTracking() )
    {
      this.writeDebug( "Contentside Tracking enabled", "_log_config", true );
    } 
    else 
    {
      this.writeDebug( "Trackerside Tracking enabled", "_log_config", true );
    }
    
    if ( oConfig.isHttpPostEnabled() )
    {
      this.writeDebug( "HTTP POST enabled", "_log_config", true );
    }
    else
    {
      this.writeDebug( "HTTP GET enabled", "_log_config", true );
    }
    this.writeDebug( "Netmind Session Timeout: " + oConfig.m_nNetMindSessionTimeout, "_log_config", true );
    this.writeDebug( "Autoparams: " + oConfig.m_bAutoparams, "_log_config", true );
    this.writeDebug( "Autosend: " + oConfig.m_bAutosend, "_log_config", true );
    this.writeDebug( "Send URL: " + oConfig.m_bSendUrl, "_log_config", true );
    this.writeDebug( "Send Referrer: " + oConfig.m_bSendReferrer, "_log_config", true );
    this.writeDebug( "Send MetaTags: " + oConfig.m_bSendMetaTags, "_log_config", true );
    this.writeDebug( "Send TechInfo: " + oConfig.m_bSendTech, "_log_config", true );
    this.writeDebug( "Send Url Hash: " + oConfig.m_bSendUrlHash, "_log_config", true );
    this.writeDebug( "Send CGI-Params: " + oConfig.m_bSendCGIParams, "_log_config", true );
    this.writeDebug( "Plugins to check:", "_log_config", true );
    this.writeDebug( "- Director: " + oConfig.m_oTechPlugins['Director'], "_log_config", true );
    this.writeDebug( "- MediaPlayer: " + oConfig.m_oTechPlugins['MediaPlayer'], "_log_config", true );
    this.writeDebug( "- Flash: " + oConfig.m_oTechPlugins['Flash'], "_log_config", true );
    this.writeDebug( "- RealPlayer: " + oConfig.m_oTechPlugins['RealPlayer'], "_log_config", true );
    this.writeDebug( "- AcroRead: " + oConfig.m_oTechPlugins['AcroRead'], "_log_config", true );
  }
}
      

//==========================================================
// Wenn der Debugging-Mode aktiviert wurde 
// (cConfigPixel.m_bDebug), wird der angegebene String im
// Debug-Fenster ausgegeben.
//==========================================================
function remotepixel_writeDebug( strDebug, strElementId, bAppend, bBold )
{
  var oElem = null;
  if ( this.m_oDbgWin )
  {
    
    if ( strElementId )
    {
      oElem = this.m_oDbgWin.document.getElementById( strElementId );
    }
    if ( !oElem )
    {
      oElem = this.m_oDbgWin.document.getElementsByTagName( "body" )[0];
    }
    
    if ( oElem )
    {
      if ( !bAppend )
      {
        oElem.nodeValue = "";
      }
      
      if ( bBold )
      {
        var oBold = this.m_oDbgWin.document.createElement("b");
        oElem.appendChild( oBold );
        oElem = oBold;
      }
      var oTextNode = this.m_oDbgWin.document.createTextNode( strDebug );
      oElem.appendChild( oTextNode );
      oElem.appendChild( this.m_oDbgWin.document.createElement("br") );
    }
  }
}


//==========================================================
// Method to convert the given value to a valid 
// representation. 
// Normally this method just returns the given value except:
// * the value is of type object
// * the JSON object is available
// * and JSON is enabled in the config
//==========================================================
function remotepixel_convertValue(value)
{
  if ( oNMConfig.isJSONEnabled()
       && typeof(value) == 'object' )
  {
    return JSON.stringify(value);
  }
  return value;
}

//==========================================================
//methode fuer Objekt Pixel: Fuegt einen Parameter hinzu
//==========================================================
function remotepixel_addParameter(key, value)
{
  arPair = new Array(key, this.convertValue( value) );
  this.m_arParameterList[this.m_nParameterCount] = arPair;
  this.m_nParameterCount++;
}//end function pixel_add_parameter()


//==========================================================
// methode fuer Objekt Pixel: setzt einen Parameter.
// wurde der Parameter bereits gesetzt, so wird er mit dem
// neuen Wert ersetzt.
//==========================================================
function remotepixel_setParameter(key, value)
{
  var arPair = new Array( key, this.convertValue( value ) );
  var arExist;
  var nIdx;
  var bFound = false;
  for ( nIdx = 0; nIdx < this.m_nParameterCount; nIdx ++ )
  {
    arExist = this.m_arParameterList[nIdx];
    if ( arExist[0] == arPair[0] )
    {
      // parameter already set, replace with new value
      bFound = true;
      this.m_arParameterList[nIdx] = arPair;
      break;
    }
  }
  if ( !bFound )
  {
    // add new parameter:
    this.m_arParameterList[this.m_nParameterCount] = arPair;
    this.m_nParameterCount++;
  }
}


//==========================================================
//method for object Pixel: add affiliate
//==========================================================
function remotepixel_addAffiliate(name)
{
  this.addParameter("affiliate", name);
  this.writeDebug( "affiliate = '" + affiliate + "'", "_log_values", true );  
}//end function remotepixel_addAffiliate(name)

//==========================================================
//method for object Pixel: add url
//
//
// Customization
// cha - 25.06.2008 - Cgi Paramter des aktuellen URI werden automatisiert als Paramter angehängt.
//
//==========================================================
function remotepixel_addUrl()
{
  var strUrlParam = document.URL;
  
  this.addParameter("url", strUrlParam);
  this.writeDebug( "url = '" + strUrlParam + "'", "_log_values", true );
  
}//end function remotepixel_addAffiliate(name)

//==========================================================
//method for object Pixel: add referrer
//==========================================================
function remotepixel_addReferrer()
{
  this.addParameter("referrer", document.referrer);
  this.writeDebug( "referer = '" + document.referrer + "'", "_log_values", true );
}//end function remotepixel_addAffiliate(name)

//==========================================================
//method for object Pixel: add parameter to URL
//==========================================================
function remotepixel_addParamToUrl(strUrl, arParameterList)
{
  if (strUrl.indexOf ("?") == -1)
    {
    strUrl = strUrl + "?";
    }
    else
    {
    strUrl = strUrl + "&";
    }
      
  for(var i=0; i<arParameterList.length; i++)
  {
    if (i>0) strUrl += "&";
    strUrl += escape(arParameterList[i][0])+"="+escape(arParameterList[i][1]);
  }//end for(i=0; i<this.m_arParameterList.length; i++) 
  //now set URL on Pixel
  
  return strUrl;
}//end function remotepixel_addAffiliate(name)

//==========================================================
//remotepixel_addCookies
//Add the cookies as configured in cConfigPixel
//==========================================================
function remotepixel_addCookies()
{
  var oCookies = this.m_oConfig.getSendCookies();
  var strCookies = document.cookie;
  if ( oCookies && strCookies )
  {
    var arCookies = strCookies.split("; ");
    // check all cookies
    for ( var i = 0; i < arCookies.length; i ++ )
    {
      arCookie = arCookies[i].split("=");
      
      if ( oCookies[arCookie[0]] )
      {
        // we are interested in this cookie
        this.addParameter( oCookies[arCookie[0]], arCookie[1] );
      }
    }
  }
}

//==========================================================
// getHiddenForm
// Return a hidden form to POST data.
// In addition, a hidden IFrame is created. This IFrame is
// then used as target for the form POST.
//==========================================================
function remotepixel_getHiddenForm( strTargetUrl )
{
  var oIFrame;
  var oDiv = document.createElement("div");
  var oForm;
 
   
  if ( !this.m_oBody )
  {
    if ( this.m_oConfig.m_strPostParentId )
    {
      // try to use an existing dummy object as owner
      this.m_oBody = document.getElementById( this.m_oConfig.m_strPostParentId );
    }
      
    if ( !this.m_oBody )
    {
      // use body (either no parent specified, or parent does not exist)
      this.m_oBody = document.getElementsByTagName("body")[0];
      this.writeDebug( "using body as form owner", "_log_values", true );
    }
    else
    {
      this.writeDebug( "using dummy owner  = '" 
        + this.m_oConfig.m_strPostParentId + "'", "_log_values", true );
    }
  }
  
  if ( !this.m_oIFrame )
  {
    try
    {
      // IE workaround
      this.m_oIFrame = document.createElement( '<iframe name="nm_postframe">' );
    }
    catch (e)
    {
      this.m_oIFrame = document.createElement( "iframe" );
    }
    this.m_oIFrame.style.display = "none";
    this.m_oIFrame.name = "nm_postframe";
    this.m_oBody.appendChild( this.m_oIFrame );
  }
  if ( this.m_oPostDiv )
  {
    delete this.m_oPostDiv;
  }
  oDiv.style.display = "none";
  this.m_oBody.appendChild( oDiv );
  oForm = document.createElement("form");
  oForm.action = strTargetUrl;
  oForm.method = 'post';
  oForm.target = 'nm_postframe';
  oDiv.appendChild( oForm );
  this.m_oPostDiv = oDiv;
  return oForm;
}

//==========================================================
// Generate an XML HTTP instance (if supported).
// If not supported, null is returned. 
//==========================================================
function remotepixel_getXmlHttpInstance()
{
  var oXmlHttp = null;
  
  if ( typeof XMLHttpRequest != 'undefined' )
  {
    oXmlHttp = new XMLHttpRequest();
  }
  if ( !oXmlHttp )
  {
    try
    {
      oXmlHttp = new ActiveXObject( 'Msxml2.XMLHTTP' );
    } 
    catch(e) 
    {
      try 
      {
        oXmlHttp  = new ActiveXObject( 'Microsoft.XMLHTTP' );
      } 
      catch(e) 
      {
        oXmlHttp  = null;
      }
    }
  }
  return oXmlHttp;
}

//==========================================================
// Send the pixel data via as XML HTTP request via HTTP post
//==========================================================
function remotepixel_postData(oRemoteSession)
{
  var bCookieTracking      = this.m_oConfig.isCookieTracking();
  var bContentSideTracking = this.m_oConfig.isContentSideTracking();

  var strSID = oRemoteSession.getSessionID();
  var strCgiSID = oRemoteSession.getCGISessionID();
  var strUrl;
  var nParam;
  var oForm;
  
  if ( strCgiSID )
  {
    strSID = strCgiSID;
  }

  if (bCookieTracking) {
    //-----------------------------------------------------
    // Cookie Tracking Variante
    // no difference between content side and tracker side
    //-----------------------------------------------------  

    strUrl = this.m_strPixelURL;
    
  } else {
    if (strSID != "" ) {
      strSID = "-snm-" + strSID + "-enm-";
    }

    strUrl = this.m_strPixelURLPrefix+strSID+this.m_strPixelURLSuffix;
  } // end else if (bCookieTracking)
  
  this.writeDebug( "postData: sending request to " + strUrl, "_log_values", 
                   true, false );
  
if ( 0 ) {
  try
  {
    // async POST request
    // but we will not handle any errors, so we won't register a 
    // state-change callback
    oHttpRequest.open('POST', strUrl, true );
    oHttpRequest.setRequestHeader( "Content-Type", 
                                   "application/x-www-form-urlencoded" );
  
    // construct POST body
    var strPostBody = "";
    var strAmp = "";
    for ( nParam = 0; nParam < this.m_arParameterList.length; nParam ++ )
    {
      strPostBody += strAmp + escape( this.m_arParameterList[nParam][0] )
                  + "=" + escape( this.m_arParameterList[nParam][1] );
      strAmp = "&";
    }
  
    // and send and forget:
    oHttpRequest.send( strPostBody );
  }
  catch( e )
  {
    this.writeDebug( 'Could not send POST request: ' + e, '_log_values', 
                     true, true );
    if ( oNMConfig.isGetFallbackEnabled() )
    {
        this.sendData( oRemoteSession );
    }
  }
} else {

  oForm = this.getHiddenForm( strUrl );
  this.populateForm( oForm );
  oForm.submit();
}

}

//==========================================================
// populateForm
// Populate the hidden POST form with the values from the
// pixel instance.
//==========================================================
function remotepixel_populateForm( oForm )
{
  var strSID = oNMRemoteSession.getSessionID();
  var strCgiSID = oNMRemoteSession.getCGISessionID();
  var bCookieTracking      = this.m_oConfig.isCookieTracking();
  var bContentSideTracking = this.m_oConfig.isContentSideTracking();
  var nParam;
  
  var oField;
  for ( nParam = 0; nParam < this.m_arParameterList.length; nParam ++ )
  {
    oField          = document.createElement( 'input' );
    oField.type     = 'hidden';
    oField.name     = this.m_arParameterList[nParam][0];
    oField.value    = this.m_arParameterList[nParam][1];
    oForm.appendChild( oField );
  }
}

//==========================================================
//methode fuer Objekt Pixel: senden des Pixels
//==========================================================
function remotepixel_sendData(oRemoteSession)
{
  if ( this.m_oConfig.isHttpPostEnabled() )
  {
    // POST enabled, use the appropriate method
    this.postData( oRemoteSession );
    return;
  }
  var bCookieTracking      = this.m_oConfig.isCookieTracking();
  var bContentSideTracking = this.m_oConfig.isContentSideTracking();

  if ( this.m_oConfig.getUniqueRequestIdParam() )
  {
    // we should transmit a unique request ID, so add it now
    var nRandom = Math.round( ( Math.random() * 1000000 ) );
    var strId = nRandom.toString() + "-"
        + ( new Date().getTime() ).toString(); 
    this.setParameter ( 
        this.m_oConfig.getUniqueRequestIdParam(), strId ); 
  }

  if (bCookieTracking) {
    //-----------------------------------------------------
    // Cookie Tracking Variante
    // no difference between content side and tracker side
    //-----------------------------------------------------   

    var strCgiSID = oRemoteSession.getCGISessionID();

    if ( strCgiSID )
    {
      // need to set cookie
      var strPixelServer = this.m_oConfig.getPixelServer();
      var strHost = strPixelServer.split(':')[0];
      // set the cookie specifically for the pixel server

      var strInjectedCookie = 'NETMIND_SID='+strCgiSID+'; path=/; domain='+strHost;
      document.cookie = strInjectedCookie;
    }

    var strUrl = this.m_strPixelURL;
    strUrl = remotepixel_addParamToUrl(strUrl,this.m_arParameterList);
    
    this.writeDebug( "Sending Image-Request: '" + strUrl + "'", "_log_values", true );
    
    var oTrackingImg = new Image();
    oTrackingImg.src = strUrl;
    
  } else {
    var strSID = oRemoteSession.getSessionID();
    
    if (strSID != "" ) {
      strSID = "-snm-" + strSID + "-enm-";
    }

    var strUrl = this.m_strPixelURLPrefix+strSID+this.m_strPixelURLSuffix;

    strUrl = remotepixel_addParamToUrl(strUrl,this.m_arParameterList);


    if ( bContentSideTracking )
    {
      var oHead = document.getElementsByTagName("head")[0];
      var aSidScript = document.getElementById ('sidscript');
      if (aSidScript) { // Already exists
        for (var j = 0; j < aSidScript.length; j++) {
          oHead.removeChild(aSidScript[j]);
        }//end for (var j = 0; j < aMetatag.length; j++)   
      }

      // need a script element to load the JS
      oScript = document.createElement('script');
      oScript.id = 'sidscript';
      oScript.type = 'text/javascript';
      oScript.src = strUrl;

      //-----------------------------------------------------
      // Set an Evant Handler to Set the Valid Variable and
      // the SessionID
      //-----------------------------------------------------
      //oScript.addEventListener('load',remotepixel_setCookie,false);
      oHead.appendChild(oScript);
    }
    else
    {
        // just use an image tag. SID has already been set when loading this script.
        var oTrackingImg = new Image();
        
        try
        {
            // fixes an IE error @see mantis #499
            oTrackingImg.onload = function(){};
        }
        catch ( e )
        {
        }
 
        oTrackingImg.src = strUrl;
    }
  } // end else if (bCookieTracking)
}//end function remotepixel_sendData()

//==========================================================
//method setSidReady 
//==========================================================
function remotepixel_setCookie()
{
  //alert ("remotepixel_setCookie");
  //-----------------------------------------------------
  // this function is used as an event Handler
  // for the loading of the SID containing Javascript
  // the function does nothing but checking the
  // Javascript Variable containing the 
  //-----------------------------------------------------
}//end function remotesession_waitSidReady()

//==========================================================
//methode fuer Objekt Pixel: auslesen der techdaten
//==========================================================
function remotepixel_getTechData () {
  
  //--------------------------------------------------------
  // variables for general settings
  //--------------------------------------------------------
  var javaOK    = "unknown";
  var cookiesOK = "unknown";
  var browsLang = "unknown";
  var availheight = screen.availHeight;
  var availwidth  = screen.availWidth;
  var colordepth  = screen.colorDepth + " bit";
  var height      = screen.height;
  var width       = screen.width;
  var title       = document.title;
  
  //--------------------------------------------------------
  // variables for plugins
  //--------------------------------------------------------
  var flashPlugin     = "-";
  var flashVersion    = "0";
  var directorPlugin  = "-";
  var wmplayerPlugin  = "-";
  var realplayerPlugin= "-";
  var quicktimePlugin = "-";
  var adobe_svgPlugin = "-";
  var adobe_pdfPlugin = "-";
  
  this.writeDebug( "TechInfo:", "_log_values", true, true );
  var agt = navigator.userAgent.toLowerCase();
  var ie  = (agt.indexOf("msie") != -1);
  var ie7 = false;
  //accept only higher than MSIE 4
  //otherwise the detectIE() function would not work
  if(ie) {
    ie  = (agt.indexOf("msie 4") == -1) && (agt.indexOf("msie 3") == -1);
    ie7 = (agt.indexOf("msie 7") > -1);
  }//end if(ie)
  
  var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
    
  //--------------------------------------------------------
  // Java and Cookies
  //--------------------------------------------------------
  if (navigator.javaEnabled()==true){javaOK="yes"}else{javaOK="no"}
  this.writeDebug( "java = " + javaOK, "_log_values", true );
  //--------------------------------------------------------
  //-- cookieEnabled only works in MSIE.
  //--------------------------------------------------------
  if ((navigator.cookieEnabled) && (navigator.cookieEnabled==true)) {cookiesOK="yes"} else {cookiesOK="no"}
  this.writeDebug( "cookies = " + cookiesOK, "_log_values", true );
  
  //--------------------------------------------------------
  // language
  //--------------------------------------------------------
  if (navigator.language)
    browsLang = navigator.language;
  this.writeDebug( "language = " + browsLang, "_log_values", true );
  //--------------------------------------------------------
  // Plugins
  // 
  // SVG and Quicktime are not certified Plugins and cause a warning
  // in MSIE 7. Because of this fact those two plugins are not detected.
  //--------------------------------------------------------
  if (ie && win) {   
    if ( this.m_oConfig.getSendTechPlugin('Director') )
    {
      directorPlugin = detectIE("SWCtl.SWCtl.1");
    }
    if ( this.m_oConfig.getSendTechPlugin('Flash') ) 
    {
      flashPlugin = detectIE("ShockwaveFlash.ShockwaveFlash.1");
    }
    if ( this.m_oConfig.getSendTechPlugin('RealPlayer') )
    {
      realplayerPlugin = detectIE("rmocx.RealPlayer G2 Control.1");
    }

    if (!ie7 && this.m_oConfig.getSendTechPlugin('MediaPlayer') )
    {
        // hmmmm.... IE7 also thinks that M$ MediaPlayer is unsecure...
        // maybe he is right?!
        // do not try to detect MediaPlayer with IE7
        wmplayerPlugin = detectIE("MediaPlayer.MediaPlayer.1"); 
    }
    if ( this.m_oConfig.getSendTechPlugin('AcroRead') ) 
    {
      adobe_pdfPlugin = detectIEAcrobat("Acrobat Reader");
    }
  }//end if (ie && win) 

  else {
    var nse = ""; 
    for (var i=0;i<navigator.mimeTypes.length;i++) 
    nse += navigator.mimeTypes[i].type.toLowerCase();
  if ( this.m_oConfig.getSendTechPlugin('Director') )
    {
      directorPlugin = detectNS(nse, "application/x-director");
  }
  if ( this.m_oConfig.getSendTechPlugin('Flash') )
  {
      flashPlugin = detectNS(nse, "application/x-shockwave-flash");
  }
  if ( this.m_oConfig.getSendTechPlugin('RealPlayer') )
  {
      realplayerPlugin = detectNS(nse, "audio/x-pn-realaudio-plugin");
  }
  if ( this.m_oConfig.getSendTechPlugin('MediaPlayer') )
  {
      wmplayerPlugin = detectNS(nse, "application/x-mplayer2");     
  }
  if ( this.m_oConfig.getSendTechPlugin('AcroRead') )
  {
    adobe_pdfPlugin = detectNS(nse, "application/pdf");  
  }
  }

  this.writeDebug( "screen = " + width + "x" + height, "_log_values", true );  
  this.writeDebug( "colordepth = " + colordepth, "_log_values", true );
  this.writeDebug( "title = " + title, "_log_values", true );
  this.writeDebug( "javascript = yes", "_log_values", true );
  this.writeDebug( "Plugins:", "_log_values", true );
  this.writeDebug( "- Flash = " + flashPlugin, "_log_values", true );
  this.writeDebug( "- Director = " + directorPlugin, "_log_values", true );
  this.writeDebug( "- MediaPlayer = " + wmplayerPlugin, "_log_values", true );
  this.writeDebug( "- RealPlayer = " + realplayerPlugin, "_log_values", true );
  this.writeDebug( "- AcroRead = " + adobe_pdfPlugin, "_log_values", true );
  //save paramters into pixel
  this.addParameter("nm_java", javaOK);
  this.addParameter("nm_cookie", cookiesOK);
  this.addParameter("nm_screen", width + "x" + height);
  this.addParameter("nm_colordepth", colordepth);
  this.addParameter("nm_plugin_flash", flashPlugin);
  this.addParameter("nm_plugin_director", directorPlugin);
  this.addParameter("nm_plugin_wmplayer", wmplayerPlugin);
  this.addParameter("nm_plugin_realplayer", realplayerPlugin);
  this.addParameter("nm_plugin_acroread", adobe_pdfPlugin);
  this.addParameter("nm_title", title);
  this.addParameter("nm_javascript", "yes" );
  

}//end function pixel_getTechData ()

//==========================================================
//methode zum Auslesen der metatags
//==========================================================
// setzen eines leeren Metatags auf "-"
function remotepixel_getMetaTags () {
  

  var aMetatag = this.m_oConfig.m_aMetatag;
  
  //Save metatags to track into pixel-parameter-list. validation with regexp match
  var strMetaTags = "";
  for (var i = 0; i < document.getElementsByTagName('meta').length; i++) {
    for (var j = 0; j < aMetatag.length; j++) {
      var re = new RegExp(WildToReg(aMetatag[j]));
      if (document.getElementsByTagName('meta')[i].getAttribute('name')) {
        if ( document.getElementsByTagName('meta')[i].getAttribute('name').match(re) ) {
          if (document.getElementsByTagName('meta')[i].getAttribute('content'))
            this.addParameter(document.getElementsByTagName('meta')[i].getAttribute('name'), document.getElementsByTagName('meta')[i].getAttribute('content'));
          else
            this.addParameter(document.getElementsByTagName('meta')[i].getAttribute('name'), "-");
        } // end if document.getElementsByTagName('meta')[i].getAttribute('name').match(re
      } // end if (document.getElementsByTagName('meta')[i].getAttribute('name'))
    }//end for (var j = 0; j < aMetatag.length; j++)
  }//end for (var i = 0; i < document.getElementsByTagName('meta').length; i++)
}// end method remotepixel_getMetaTag

//==========================================================
//methode zum Auslesen der per Hash angehängten Parameter
//==========================================================
// setzen eines leeren Hashparameter auf "-"
function remotepixel_getHashParameter () {

  var aParamList = this.m_oConfig.m_aHashParameter;
  
  var strLoc=(document.location+""); 
  var nPos=strLoc.indexOf("#");
  if (nPos != -1) {
    var strHashQs=strLoc.substring(nPos+1, strLoc.length);
    aParams =  remotepixel_SplitParams(strHashQs);
    //Save metatags to track into pixel-parameter-list. validation with regexp match
    var strHashParam = "";
    for (var j = 0; j < aParamList.length; j++) {
      if ( aParams[aParamList[j]] ) {
        this.addParameter(aParamList[j],aParams[aParamList[j]]);          
      } // end if( aParams[aParamList[j]] )
    }//end for (var j = 0; j < aMetatag.length; j++)
  } // end if nPos != -1)
}// end method remotepixel_getHashParameter


//==========================================================
//methode zum Auslesen der GET CGI Paramter
//==========================================================
// setzen eines leeren Hashparameter auf "-"
function remotepixel_getCGIParameter () {


   if (window.location.search != ""){
    
      //teile den String an allen & Separatoren und schneide zuvor das ? weg     
      var strParamters = window.location.search.split("?")[1];
      var liste = strParamters.split("&");

      //gehe durch die key=value Strings und Teile wiederum am =
      //jedes key und value wird kurzeitig in einer Liste temp gehalten
      for (var i=0;i<=liste.length-1;i++) {
        if(liste[i].length > 0)
        {
					var temp = liste[i].split("=");
	        //bearbeitung des keys
	        var strValue = temp[1];
	        strValue = strValue.replace(/\+/g," ");
	        strValue = unescape(strValue);
	        if(strValue == "")
	           strValue = "-";
	          
	        this.addParameter( temp[0], strValue);
				} 

       } //next 
       
    }
    
}// end method remotepixel_getCGIParameter


//==========================================================
//remotepixel_SplitParams
//==========================================================
function remotepixel_SplitParams(params) {
  var result=[];
  var pairs=params.split("&");
  for (var i=0; i < pairs.length; i++) {
    var kv=pairs[i].split("=");
    if (kv[1] && kv[1] != "")
      result[kv[0]]=kv[1];
    else 
      result[kv[0]]="-";      
  }
  return result;
}

//==========================================================
// remotepixel_extractCGIParam
//==========================================================
function remotepixel_extractCGIParam( strParam )
{
    if (window.location.search != '')
    {
        // parameters available
        var strParams = window.location.search.split('?')[1];
        var aParams = remotepixel_SplitParams( strParams );

        if ( aParams[ strParam ] && aParams[ strParam ] != '-')
        {
             return aParams[ strParam ];
        }    
    }
    return "";
}


//==========================================================
//Definition of Prototypes
//==========================================================

//methoden zur Klasse hinzufuegen
cRemotePixel.prototype.convertValue         = remotepixel_convertValue;
cRemotePixel.prototype.addParameter         = remotepixel_addParameter;
cRemotePixel.prototype.setParameter         = remotepixel_setParameter;
cRemotePixel.prototype.addAffiliate         = remotepixel_addAffiliate;
cRemotePixel.prototype.addUrl               = remotepixel_addUrl;
cRemotePixel.prototype.addReferrer          = remotepixel_addReferrer;
cRemotePixel.prototype.addCookies           = remotepixel_addCookies;
cRemotePixel.prototype.getHiddenForm        = remotepixel_getHiddenForm;
cRemotePixel.prototype.getXmlHttpInstance   = remotepixel_getXmlHttpInstance;
cRemotePixel.prototype.populateForm         = remotepixel_populateForm;
cRemotePixel.prototype.postData             = remotepixel_postData;
cRemotePixel.prototype.sendData             = remotepixel_sendData;
cRemotePixel.prototype.getTechData          = remotepixel_getTechData;
cRemotePixel.prototype.getMetaTags          = remotepixel_getMetaTags;
cRemotePixel.prototype.getHashParameter     = remotepixel_getHashParameter;
cRemotePixel.prototype.getCGIParameter      = remotepixel_getCGIParameter;
cRemotePixel.prototype.extractCGIParam      = remotepixel_extractCGIParam;
cRemotePixel.prototype.writeDebug           = remotepixel_writeDebug;
cRemotePixel.prototype.writeConfig          = remotepixel_writeConfig;

//==========================================================
// Acrobat
//==========================================================
function detectIEAcrobat(name) {

  var acrobat=new Object();
  if (window.ActiveXObject) {
    for (x=2; x<10; x++) {
      try {
        var oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
        if (oAcro) {
          return 'yes';
        }
      }
      catch(e) {}
    } 

    try {
      var oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
      if (oAcro4) {
        return 'yes';
      }
    }
    catch(e) {}

    try {
      var oAcro7=new ActiveXObject('AcroPDF.PDF.1');
      if (oAcro7) {
        return 'yes';
      }
    }
    catch(e) {}
  }  return 'no';    
}//end function detectIEAcrobat(name)

//==========================================================
// IE Plugins
//==========================================================

function detectIE(ClassID) { 

  try {
    new ActiveXObject(ClassID);
    return 'yes'; 
  }
  
  catch(e) {
    return 'no';
  }   
}//end function detectIE(ClassID)

//==========================================================
// Netscape and Firefox Plugins
//==========================================================
function detectNS(strMimetypes, ClassID) { 
  if (strMimetypes.indexOf(ClassID) != -1) 
    if (navigator.mimeTypes[ClassID].enabledPlugin != null) 
      return 'yes'; 
  return 'no';

}//end function detectNS(strMimetypes, ClassID)


//==========================================================
// Convert Wildcard to RegEx
//==========================================================
function WildToReg(str) {

  var s = "";
  var i;
  var c;
  for (i = 0; i < str.length; i++) {
    c = str.charAt(i);
    switch(c) {
      case '*':
        s = s + ".*";
        break;
      case '?':
        s = s + ".";
        break;
                
      case '(': case ')': case '[': case ']': case '$':
      case '^': case '.': case '{': case '}': case '|':
      case '\\':
        s = s + "\\";
        s = s + c;
        break;
        
      default:
        s = s + c;
        break;
      }//end switch(c)
    }//end for (i = 0; i < str.length; i++)
    s =  "^" + s + "$";
   return s;
}//end function WildToReg(str)  

//==========================================================
//function Pixel-Instanz anlegen
//==========================================================
function doPixelInstance(oEvent) {
  oNMRemotePixel.writeDebug( "Prepare pixel for " + document.URL, "_log_values", true, true );
  //Send PartnerName as parameter?
  if (oNMConfig.getAutoParams()) {
    //Send Url as parameter?
    if (oNMConfig.getSendUrl()) {
      oNMRemotePixel.addUrl();
    }//end if (SendUrl)
    //Send Hash Parameter as parameter?
    if (oNMConfig.getSendUrlHash()) {
      oNMRemotePixel.getHashParameter();
    }//end if (SendUrlHash)
    //Send referrer as parameter?
    if (oNMConfig.getSendReferrer()) {
      oNMRemotePixel.addReferrer();
    }//end if (SendReferrer)
    if(oNMConfig.getSendMetatags()) {
      oNMRemotePixel.getMetaTags();
    }
    if(oNMConfig.getSendTech()) {
      oNMRemotePixel.getTechData();
    }
    if(oNMConfig.getSendCGIParams()) {
      oNMRemotePixel.getCGIParameter();
    }
    if(oNMConfig.getSendCookies()) {
      oNMRemotePixel.addCookies();
    }
  } // end autoparams


  if(oNMConfig.getAutoSend()) {
    oNMRemotePixel.sendData(oNMRemoteSession);
  }
} // end function doPixelInstance


//======================================================================================
// Load Time Execution
//======================================================================================

var oNMConfig        = new cConfigPixel();
var oNMRemoteSession = new cRemoteSession(oNMConfig);
var oNMRemotePixel   = new cRemotePixel(oNMConfig);

// RPO 2009-11-02
// initialize the pixel depending on the auto init flag
if ( oNMConfig.getAutoInit() )
{
    
    if( window.addEventListener ) {
      //alert ("window.addEventListener");  
      window.addEventListener('load',doPixelInstance,false);
    } else if( document.addEventListener ) {
      //alert ("document.addEventListener");
      document.addEventListener('load',doPixelInstance,false);
    } else if (window.attachEvent) {
      //alert ("window.attachEvent");
      window.attachEvent('onload', doPixelInstance);
    } else if (document.attachEvent) {
      //alert ("document.attachEvent");
      document.attachEvent('onload', doPixelInstance);
    } else {
      doPixelInstance("");
    }
}

//oNMRemotePixel.sendData(oNMRemoteSession);