var dattracker = {
  
  getlist : "",
  
  numberOfCalls : 0,
  dat_track_url : "",
  dat_track_alt : "",
  dat_cvid : 0,
  
  
  get_GET_value:function ( get_param_name ) {
    if (!window) { return ''; }
    if (!window.location) { return ''; }
    if (!window.location.search) { return ''; }
    var search=window.location.search.substr(1);
    var assignments=search.split('&');
    for( var i=0; i<assignments.length; i++ ) {
      var assignment_splitted=assignments[i].split('=');
      var param_name=assignment_splitted[0];
      var param_value=assignment_splitted[1];
      if (param_name == get_param_name) {
        return param_value;
      }
    }
    return '';
  },
  
  add_to_list : function( key, value) {
    dattracker.getlist += '&' + key + '=' + escape(value);
  },
  
  //Get protocol, returns protocol string
  getProto : function () {
	var proto = 'http:';
    if ( typeof (document.location) != 'undefined') {
      if ( typeof (document.location.protocol) != 'undefined') {
        if ( document.location.protocol != 'file:') {
          proto = document.location.protocol;
        }
      }
    }
	return proto;
  },
  
  count_URL : function (getlist) {
    
    proto = dattracker.getProto();
    //var WMCT_URL=proto+'//goldneu.dat.de/dattracker/dattracker.php?'+getlist;
    var WMCT_URL='../dattracker/dattracker.php?'+getlist;
    //alert(WMCT_URL);
	
	//Check if it is the first time the pixel is called (numberOfCalls==0) 
	//if it is the first then write pixel, this is required to show the webcounter on the website
	if ( dattracker.numberOfCalls > 0 ) {
		var CT_container=new Image();
        CT_container.src=WMCT_URL;
	} else {
		document.write('<div><a target="_blank" href="'+dattracker.dat_track_url+'"><img src="'+WMCT_URL+'" alt="'+dattracker.dat_track_alt+'" border="0" width="1" heigth="1"/></a></div>');
	}
	dattracker.numberOfCalls++;
  },
  
  countpix : function (pixcode) {
    dat_pixelcode = pixcode;
    dattracker.count();
  },
  
  
  internalCount : function (ext) {
	myDate = new Date();
    //dattracker.getlist="t="+myDate.getTime(); // Clear/Initialize the get list.
											  // NOTE: Clearing the getlist is a must!
											  //       Otherwise subsequent calls to count
											  //       (e.g. by using onClick="") would
											  //       append their values to the old get list.

    //----------------------------------------------------
	// Mandatory parameters
    //----------------------------------------------------
    
    
    //----------------------------------------------------
    // Application Name
    //----------------------------------------------------
    if ( typeof(app_name) != 'undefined') {
      dattracker.add_to_list('app_name',app_name);
    } else {
      return; // no app_name, do nothing
    }
    
    
    //----------------------------------------------------
    // Modul Name
    //----------------------------------------------------
    if ( typeof(mod_name) == 'undefined' ) {
      return; // no mod_name, do nothing
    } else {
      mod_name_value = mod_name;
    }
    dattracker.add_to_list('mod_name',mod_name_value);
    
    //----------------------------------------------------
    // Action Name
    //----------------------------------------------------
    if ( typeof(act_name) == 'undefined') {
      return; // no act_name, do nothing
    }
    dattracker.add_to_list('act_name',act_name);
    
    
    // Then the optional parameters
    // Note: The optional parameters first get collected and added
    //       afterwards to the getlist to better control their order.
    var dat_version = "1.0";
    var dat_resolution = screen.width + "x" + screen.height;
    var dat_color_depth = navigator.appName != 'Netscape' ? screen.colorDepth : screen.pixelDepth;
    
    var dat_plugin_list = "";
    for( var i=0; i<navigator.plugins.length; i++ ) {
      dat_plugin_list += navigator.plugins[i].name + ';';
    }
    
    var dat_jv = 0;
    if (navigator.javaEnabled()) { dat_jv=1; };
    
    var dat_js_value = 1;
    if ((typeof dat_js) != 'undefined') { dat_js_value=dat_js; }
    
    
  
	//END Call Center
    if (dattracker.numberOfCalls == 0) {
		//Only request webcounter if it is the first call (performance issues)
		if ( typeof (dat_wc) != 'undefined')          { dattracker.add_to_list('wc',dat_wc); }
	}

	
    dattracker.count_URL(dattracker.getlist);
  },
  
  
  //This function is called by the counting code and sets the default parameter for dat_track_url and dat_track_alt
  count : function ( ext ) {
	  if (typeof (dat_track_url) != 'undefined') {
		  dattracker.dat_track_url = dat_track_url;
	  } 
	  
	  dattracker.internalCount( ext );
  },
  
  //This function is called by the counting code and sets the default parameter for dat_track_url and dat_track_alt
  counter : function ( ext ) {
	  if (typeof (dat_track_url) != 'undefined') {
		  dattracker.dat_track_url = dat_track_url;
	  } 
	  
	  dattracker.internalCount( ext );
  }
  

};
