/*
  PROGRAM:	Allianz tracking for CMS based content
  VERSION:	1.3
  SOURCE:	ContentTracker.js
  PURPOSE:	Pruefung auf cookies und bedingtes Verzweigen des counter pixels
  DATE:		2002-01-11
  AUTHOR:	Ulf Kister (ulf.kister@allianz.de)
  Christoph Grunwald (cgr@cephei.com)
*/

// misc variables

var protocol = document.URL.split("//")[0];
var host     = "counter.allianz.de";
var prefix	 = protocol + "//" + host + "/counter/";
var rand	 = Math.random();
var browserVersion = navigator.appVersion.split(" ")[0];

dr = document.referrer;
wo = window.opener;
if (dr != null && dr != "")      { referrer = dr; }
else if (wo != null && wo != "") { referrer = "" + wo.location + ""; } 
else                             { referrer = "empty_referrer"; }
if (referrer == "")              { referrer = "empty_referrer"; }

path = "nocookies";
enterpath = "none";

// Testen, ob Cookies aktiviert sind
if (navigator.cookieEnabled == true) { path = "usecookies/"; }
else { path = "nocookies/"; }

// Testen, ob es Netscape 4.7* ist
if (browserVersion > 4.7 && browserVersion < 4.9) { path = "nocookies/"; }

function CMSTracker(cmsPath,virtualContentPath) {
  if (cmsPath == "") { return; } // can't replace empty strings 

   trackCMSPath = prefix + path + rand + ".gif?TRACK_MASTER_PAGE=" + escape(window.location.href) + "&TRACK_MASTER_REFERER=" + escape(referrer) +"&TRACK_REPLACE_ME="+cmsPath+"&TRACK_REPLACE_BY="+virtualContentPath;
   document.write("<img src=\"" + trackCMSPath + "\">");	
}

///////////////////////////////////////////////////////////////////////////////////////////

function DownloadTracker(list) {
  target   = "nixda";
  language = "de";

  if (DownloadTracker.arguments.length <= 1) {
	downloadURL = DownloadTracker.arguments[0];
  }
  else if (DownloadTracker.arguments.length <= 2) {
	downloadURL = DownloadTracker.arguments[0];
	language    = DownloadTracker.arguments[1];
   }
  else {
	downloadURL = DownloadTracker.arguments[0];
	language    = DownloadTracker.arguments[1];
	target      = DownloadTracker.arguments[2];
  }

  if (target != "new") { target = "nixda"; }

  var protocol = document.URL.split("//")[0];
  var host     = "counter.allianz.de";
  var prefix   = protocol + "//" + host + "/counter/";
  
  var rand		= Math.random();
  var browserVersion	= navigator.appVersion.split(" ")[0];

  if (document.location == "") { referrer = "unknown"; } 
  else { referrer = document.location; }

  path = "nocookies";
  enterpath = "none";

  // Testen, ob Cookies aktiviert sind
  if (navigator.cookieEnabled == true) { path = "usecookies/"; }
  else { path = "nocookies/"; }

  // Testen, ob es Netscape 4.7* ist
  if (browserVersion > 4.7 && browserVersion < 4.9) { path = "nocookies/"; }

  imageURL = prefix + path + "downloads/" + rand + ".gif?TRACK_DOWNLOAD_URL=" + escape(downloadURL) + "&TRACK_MASTER_REFERER=" + escape(referrer);

  if (target != 'nixda') { downloadPopup=window.open(downloadURL,'Title'); }
  else { document.location = downloadURL; }

  getWebbug(imageURL);

}

function getWebbug (pWebbugUrl) {
	var lWebbug = new Image();
	lWebbug.src = pWebbugUrl;
}
