function nt_isTestServer() { return false; }

var esd_events = {};

var esd_config = { 'awn_session_start': {
	id           : 'awn_session_start',
	info         : null,
	project      : 'D000261',
	type         : 'script',
	url          : 'http://D000261.s7.navtracks.com/run/ndh_event.gif'
} };

function _nt_ndh_getIFrameDocument(frm) {
  // Mozilla, IE, Safari, Opera
  var doc = frm.contentWindow || frm.contentDocument;
  if ( null != doc.document ) {
    doc = doc.document;
  }
  if ( null == doc ) alert('no doc = '+doc);
  return doc;
}
function _nt_ndhRequest2(url,params) {
  var method = 'post';
  if ( null == method || !method.match(/^get$/i) ) method = 'post';

  if ( null == _nt_ndhRequest2.list ) {
    _nt_ndhRequest2.list = {};
    _nt_ndhRequest2.cnt  = 0;
    _nt_ndhRequest2.loadedWrapper = function (cnt,frm) {
      if ('complete' != frm.readyState ) return; 
      frm.onreadystatechange = null;
      _nt_ndhRequest2.loaded(cnt,_nt_ndh_getIFrameDocument(frm));
    };
    _nt_ndhRequest2.loaded = function (cnt,doc) {
      var body = doc.getElementsByTagName('body')[0];

      var method = 'post';
      if ( null == method || !method.match(/^get$/i) ) method = 'post';
      var form = doc.createElement('form');

      var args   = _nt_ndhRequest2.list[cnt]; _nt_ndhRequest2.list[cnt] = null;
      var url    = args[0];
      var params = args[1];

      form.setAttribute('action',url);
      form.setAttribute('method',method);
      form.setAttribute('enctype','multipart/form-data');
      for ( var name in params ) {
        var node = doc.createElement('input');
        node.setAttribute('type','text');
        node.setAttribute('name',name);
        node.setAttribute('value',params[name]);
        form.appendChild(node);
      }

      body.appendChild(form);
      form.submit();
      //frm.style.display = 'none';   };
    };
    _nt_ndhRequest2.createFrame = function (cnt,t) {
      var bodyNode = document.getElementsByTagName('body')[0];
      if ( null == bodyNode ) {
        if ( nt_isTestServer() && t ) alert('could not determine body tag '+t);
        window.setTimeout('_nt_ndhRequest2.createFrame('+cnt+','+(t+1)+')',200);
        return;
      }

      var frm = document.createElement('iframe');
      frm.style.border = '0';
      frm.style.width  = '1px';
      frm.style.height = '1px';

      bodyNode.appendChild(frm);
      frm.setAttribute('name','ndhRequest'+cnt);
      if ( null != frm.readyState ) {
        frm.onreadystatechange = function () { if ('complete' != frm.readyState ) return; _nt_ndhRequest2.loadedWrapper(cnt,frm); };
        frm.setAttribute('src','about:blank');
      } else {
        var doc = _nt_ndh_getIFrameDocument(frm);
        doc.open();
        doc.write('<html><head><title></title></head><body onload="parent._nt_ndhRequest2.loaded('+cnt+',document)"></body></html>');
        doc.close();
      }
    };
  }

  var cnt = _nt_ndhRequest2.cnt++;
  _nt_ndhRequest2.list[cnt] = [ url, params ];
  _nt_ndhRequest2.createFrame(cnt,0);
}

function _nt_ndhRequest(conf,data,a,info) {
  var url = conf.url;
  var params = { esd_i: conf.id, esd_a: a, esd_r: document.referrer };
  if ( !a && null != info ) params.esd_d = info;
  for ( var name in data ) { params[name] = data[name]; }
  _nt_ndhRequest2(url,params);
}
function nt_ndhEvent(id,ev) {
  this.__id = id;
  this.__ev = ev;
}
nt_ndhEvent.prototype.toString = function () {
  var ev = this.__ev;
  var str = 'id: '+this.__id;
  if ( ev._t != null ) str += ', time: '+ev._t;
  if ( ev._d != null ) str += ', info: '+ev._d;
  if ( ev._u != null ) str += ', url: '+ev._u;
  if ( ev._r != null ) str += ', referer: '+ev._r;
  for ( n in ev ) {
    if ( n.match(/^d(.*)$/) ) {
      str += ', '+RegExp.$1+': '+ev[n];
    }
  }
  return str;
};
nt_ndhEvent.prototype.getID      = function() { return this.__id;    };
nt_ndhEvent.prototype.getTime    = function() { return this.__ev._t; };
nt_ndhEvent.prototype.getURL     = function() { return this.__ev._u; };
nt_ndhEvent.prototype.getReferer = function() { return this.__ev._r; };
nt_ndhEvent.prototype.getData    = function(k){ return this.__ev['d'+k]; };
nt_ndhEvent.prototype.getDataKeys= function() {
  var keys = [];
  for ( n in ev ) {
    if ( n.match(/^d(.*)$/) ) {
      keys.push(RegExp.$1);
    }
  }
  return keys; 
};


function nt_ndhEventIds() {
  var ids = [];
  for ( var i in esd_events ) {
    ids.push(i);
  }
  return ids;
}
function nt_ndhGetEvent(id) {
  if ( null == nt_ndhGetEvent.cache ) nt_ndhGetEvent.cache = {};
  var ev = nt_ndhGetEvent.cache[id];
  if ( null != ev ) return ev;

  ev = esd_events[id];
  if ( null == ev ) return null;
  return nt_ndhGetEvent.cache[id] = new nt_ndhEvent(id,ev);
}
function nt_ndhHandleEvents(handler,data) {
  var ids = nt_ndhEventIds();
  for ( var i = 0; i < ids.length; i++ ) { handler(nt_ndhGetEvent(ids[i]),data); }
}
function nt_ndhWriteEvent(conf,data,info) {
  _nt_ndhRequest(conf,data,0,info);
}
function nt_ndhWriteData(conf,data) {
  _nt_ndhRequest(conf,data,1);
}
function nt_ndhHandle(event,now) {
  if ( null == now || now != 1109 ) {
    window.setTimeout('nt_ndhHandle(\''+event+'\',1109)',0);
    return;
  }
  var conf = esd_config[event];
  var handler = conf.handler;
  if ( null != handler ) {
    try {
      handler(conf);
    } catch ( e ) {
      if ( nt_isTestServer() ) throw e;
    }
  }
};

esd_config['awn_session_start'].handler = function (config) {
/*
<!-- NAVTRACKS(r) DATA v1.0.0, 2010-05-11 15:01:34 CODE BEGIN -->
<script type="text/javascript" src="http://www.awn-direct.de/run/ndh_code.js?esd_i=awn_session_start"></script>
<script type="text/javascript">nt_ndhHandle('awn_session_start')</script>
<!-- NAVTRACKS(r) DATA CODE END -->
*/


/*
* WIRD IM SKRIPT-FENSTER UNTER "EXTERN SITE DATA" EINGEBUNDEN
* PROJEKT:	D261
* TYPE:			event script
* ID:				awn_session_start
*/

/*
* AUSLESEN DES CGI-PARAMETER (WCODE) AUS URL
*/
var url = document.URL;
var idx = url.indexOf('WCODE');

if ( -1 == idx ) return;  // 	REST DES SKRIPTS WIRD NICHT MEHR AUSGEFÜHRT!


var info = url.substring(idx+6);
var data = { WCODE: info };

/*
* SCHREIBEN DER WERTE IN SESSION-COOKIE
*/
try{
  nt_ndhWriteEvent(config,data,info);
}catch(e){
}

};



