//********************************************************************
//
//              Copyright (c) 2008 MindLab GmbH
//                     All rights reserved.
//
//====================================================================
//
// Project    : BI Feeder
// Filename   : nm_tr_config.js
//
//====================================================================
//
/**
 * @file
 * This script can be used to integrate Microsites, which are not on
 * on a tracked website, in a tracking environment. 
 *
 * @author   $Alexander Schreiber$
 * @version  $Name: V2_5_1 $
 * @date     $Date: 2009-05-15 13:27:24 $
 * 
 * @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_config.js,v $
 * 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;

	//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           = "pixel-proxy-01.mindlab.de";
	//the path to request from the given server, this path could of
	//course include CGI-Parameters
	//example: "/mywebbug?thisismyparameter=value"

	this.m_strPixelJSPath           = "/track/nm_track.js?addparam=value"; //-- not rquired
	this.m_strPixelPath             = "/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             = false;
	//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;
	
	
	//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;
	
	//--------------------------------------------------------
	// metatags to be parsed
	//--------------------------------------------------------
	this.m_aMetatag = new Array(
		"nm.*" //-- netmind related metatags
	);
	//--------------------------------------------------------
	// 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;
}
//==========================================================
// 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;
}

//==========================================================
// 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.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.isHttpPostEnabled     = config_isHttpPostEnabled
cConfigPixel.prototype.isJSONEnabled         = config_isJSONEnabled;

