//
// +---------------------------------------------------------------------+
// | phpOpenTracker - The Website Traffic and Visitor Analysis Solution  |
// +---------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Sebastian Bergmann. All rights reserved.    |
// +---------------------------------------------------------------------+
// | This source file is subject to the phpOpenTracker Software License, |
// | Version 1.0, that is bundled with this package in the file LICENSE. |
// | If you did not receive a copy of this file, you may either read the |
// | license online at http://phpOpenTracker.de/license/1_0.txt, or send |
// | a note to license@phpOpenTracker.de, so we can mail you a copy.     |
// +---------------------------------------------------------------------+
// | Author: Sebastian Bergmann <sebastian@phpOpenTracker.de>            |
// +---------------------------------------------------------------------+
//
// $Id: webbug.js,v 1.5 2003/02/07 14:21:10 bergmann Exp $
//


// Taken from http://www.jan-winkler.de/hw/artikel/art_j02.htm
function base64_encode(decStr) {
 var base64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
 var bits;
 var dual;
 var i = 0;
 var encOut = '';

 while(decStr.length >= i + 3) {
  bits = (decStr.charCodeAt(i++) & 0xff) <<16 |
         (decStr.charCodeAt(i++) & 0xff) <<8 |
          decStr.charCodeAt(i++) & 0xff;
  encOut += base64s.charAt((bits & 0x00fc0000) >>18) +
            base64s.charAt((bits & 0x0003f000) >>12) +
            base64s.charAt((bits & 0x00000fc0) >> 6) +
            base64s.charAt((bits & 0x0000003f));
 }

 if(decStr.length -i > 0 && decStr.length -i < 3) {
  dual = Boolean(decStr.length -i -1);
  bits = ((decStr.charCodeAt(i++) & 0xff) <<16) |
         (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0);
  encOut += base64s.charAt((bits & 0x00fc0000) >>18) +
            base64s.charAt((bits & 0x0003f000) >>12) +
            (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') +
            '=';
  }

  return(encOut);
}


//    dfdsfsdfsdf

function main(client, doc){
	resolution = window.screen.width      + 'x' +
	             window.screen.height     + 'x' +
	             window.screen.colorDepth + 'bit';
	
	document.write('<img name="counter" id=="counter" src="http://teamintegrator.com/cnt_3/image.php?' +
	               'client_id='              + client    + '&' +
	               'document='               + doc + '&' +
	               'referer='                + base64_encode(document.referrer) + '&' +
	               'add_data[]=resolution::' + resolution   +
	               '" alt="" width="1" height="1" />'
	              );
//	alert(document.referrer);
}

function register_download(client, doc){
	resolution = window.screen.width      + 'x' +
	             window.screen.height     + 'x' +
	             window.screen.colorDepth + 'bit';
	
	document.counter.src='http://teamintegrator.com/cnt_3/image.php?' +
	               'client_id='              + client    + '&' +
	               'document='               + doc + '&' +
	               'referer='                + base64_encode(document.referrer) + '&' +
	               'add_data[]=resolution::' + resolution;
              
};
