var _uflash=1;			// set flash version detect option (1=on|0=off)
var _utcp="/";			// the cookie path for tracking

//-- UTM Campaign Tracking Settings
/*
var _uctm=1;				// set campaign tracking module (1=on|0=off)
var _ucto="15768000";		// set timeout in seconds (6 month default)
var _uccn="utm_campaign";	// name
var _ucmd="utm_medium";		// medium (cpc|cpm|link|email|organic)
var _ucsr="utm_source";		// source
var _uctr="utm_term";		// term/keyword
var _ucct="utm_content";	// content
var _ucid="utm_id";			// id number
var _ucno="utm_nooverride";	// don't override
*/
//-- Auto/Organic Sources and Keywords
var _uOsr=new Array();
var _uOkw=new Array();
_uOsr[0]="google";			_uOkw[0]="q";
_uOsr[1]="yahoo";			_uOkw[1]="p";
_uOsr[2]="msn";				_uOkw[2]="q";
_uOsr[3]="aol";				_uOkw[3]="query";
_uOsr[4]="aol";				_uOkw[4]="encquery";
_uOsr[5]="lycos";			_uOkw[5]="query";
_uOsr[6]="ask";				_uOkw[6]="q";
_uOsr[7]="altavista";		_uOkw[7]="q";
_uOsr[8]="netscape";		_uOkw[8]="query";
_uOsr[9]="cnn";				_uOkw[9]="query";
_uOsr[10]="looksmart";		_uOkw[10]="qt";
_uOsr[11]="about";			_uOkw[11]="terms";
_uOsr[12]="mamma";			_uOkw[12]="query";
_uOsr[13]="alltheweb";		_uOkw[13]="q";
_uOsr[14]="gigablast";		_uOkw[14]="q";
_uOsr[15]="voila";			_uOkw[15]="rdata";
_uOsr[16]="virgilio";		_uOkw[16]="qs";
_uOsr[17]="live";			_uOkw[17]="q";
_uOsr[18]="baidu";			_uOkw[18]="wd";
_uOsr[19]="alice";			_uOkw[19]="qs";
_uOsr[20]="yandex";			_uOkw[20]="text";
_uOsr[21]="najdi";			_uOkw[21]="q";
_uOsr[22]="aol";			_uOkw[22]="q";
_uOsr[23]="club-internet"; 	_uOkw[23]="q";
_uOsr[24]="mama";			_uOkw[24]="query";
_uOsr[25]="seznam";			_uOkw[25]="q";
_uOsr[26]="search";			_uOkw[26]="q";
_uOsr[27]="szukaj";			_uOkw[27]="szukaj";
_uOsr[28]="szukaj";			_uOkw[28]="qt";
_uOsr[29]="netsprint";		_uOkw[29]="q";
_uOsr[30]="google.interia";	_uOkw[30]="q";
_uOsr[31]="szukacz";		_uOkw[31]="q";
_uOsr[32]="yam";			_uOkw[32]="k";
_uOsr[33]="pchome";			_uOkw[33]="q";

function fpTracker() {
	// alert( beaconpath );
	// fpl // lifetime cookie // domainhash.sessionid.firstvisit.lastvisit.thisvisit.sessioncount
	// fpd // day cookie
	// fps // session cookie
	// fpc // campaign cookie
	// ---------------------------------------------------------------------------------------
	// check for lifetime cookie
	// ---------------------------------------------------------------------------------------
	if(getcookie ( 'fpl' )){
	// if the lifetime cookie is set, update it
	// ----------------------------------------
	// get current cookie values
		fpl = getcookie('fpl');
		fpl = fpl.split(".");
		d = fpl[0];s = fpl[1];f = fpl[2];l = fpl[3];t = fpl[4];c = fpl[5];
	// check session
		if(!getcookie ( 'fps' ))
			c++;
	// get current time for new visit
		fpd=new Date()
		fpd=Math.round(fpd.getTime()/1000);
	// rebuild the fpl cookie value
		fpl = d+"."+s+"."+f+"."+t+"."+fpd+"."+c;
	// refresh the expiration date
		var fpex = new Date();
		fpex.setTime(fpex.getTime()+1000*60*60*24*365*2)	
	// update the fpl cookie
		document.cookie = "fpl="+fpl+"; expires="+fpex+"; path=/; domain="+document.domain;
	} else {
	// if there is no lifetime cookie, set it
	// --------------------------------------
		var fpd = new Date();
		fpd = Math.round(fpd.getTime()/1000);
		var fpex = new Date();
		fpex.setTime(fpex.getTime()+1000*60*60*24*365*2)
		d = getdomain();
		s = Math.round(Math.random()*2147483647);
		f = fpd;
		l = fpd;
		t = fpd;
		c = 1;
		fpl = d+"."+s+"."+f+"."+l+"."+t+"."+c;
	// set the new lifetime cookie
		document.cookie = "fpl="+fpl+"; expires="+fpex+"; path=/; domain="+document.domain;
	}
	// ---------------------------------------------------------------------------------------
	// check for session cookie
	// ---------------------------------------------------------------------------------------
	if(!getcookie ( 'fps' )){
		document.cookie = "fps="+getdomain()+"; path=/; domain="+document.domain;
	}
	
	// ---------------------------------------------------------------------------------------
	// Check for campaign cookie (direct | referral | organic | campaign)
	// ---------------------------------------------------------------------------------------
	// if no referral is set, its direct
	// if referal is set, campare to list of search engines to detirmine organic
	// if campaign tag is set on referral, it is campaign
	// else its just a referall
	// referral trumps direct
	// organic trumps referral
	// camaign trumps organic
	
	if(!getcookie ( 'fpc' )){
		
		
		
		
		
		// lifespan = 6 months
		var source;
		// if no cookie set, set source based on referral
		if(!document.referrer) {
			source = "(direct)";
			// build cookie value for direct
			
		} else {
			if(document.referrer)
				source = "(not direct)";
			
			// build function to build referrer cookie value
			
			// build funciton to build organic cookie value
			
			// build funciton to build camaign cookie value
			
		}
		/*
		
		// fpc organic format
		// domainhash.updatedon.fplsessioncount.updatecount.fpccn=(source)|fpsrc=search engine|fptrm=search term
		c = 1;
		u = 1;
		if(!document.referrer) {
			var source = "(direct)";
		} else {
			// ignore local referrals
			
			// check for campaign tag
			
			// if no tag, compare referrer against search engines
			
			// if no search enging, its a plain ol' referral
				
		}
		alert(source);
		*/
		//fpc = getdomain()+"."+fpd+"."+c+"."+u+".fpccn="+ +""
		//document.cookie = "fpc="+getdomain()+"; path=/; domain="+document.domain;
	} else {
		// update campaign cookie only if trumped by referrer
		c++;
		if(document.referrer)
		alert('there is a referrer, trump direct source');
	
	}

	
	
	
	
	// define client side vars
	var p 	= document.location;
	var ref	= document.referrer;
	var r 	= ref.replace(/&/g,"|");
	var appname		= navigator.appName;
	var appcode		= navigator.appCodeName;
	var appvers		= navigator.appVersion;
	
	
	userinfo = userinfo();
	
	// send the data to the server
	
	var i=new Image(1,1);
	i.src=beaconpath+"?fpl="+fpl+"&p="+p+"&r="+r+userinfo+"&appname="+appname+"&appcode="+appcode+"&appvers="+appvers;
	i.onload=function() {_uVoid();}
}

function _uVoid() { return; }







// get a cookie
function getcookie( cookie_name ) {
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
  if ( results )
    return ( results[1] );
  else
    return false;
}

// get domain hash
function getdomain() {
	var d=document.domain;
	if (d.substring(0,4)=="www.") {
		d=d.substring(4,d.length);
	}
	_udn = d;
	_udn = _udn.toLowerCase(); 
	return domainhash(_udn);
}

// domain hash
function domainhash( d ) {
	if (!d || d=="") return 1;
	var h=0,g=0;
	for (var i=d.length-1;i>=0;i--) {
		var c=parseInt(d.charCodeAt(i));
		h=((h << 6) & 0xfffffff) + c + (c << 14);
		if ((g=h & 0xfe00000)!=0) 
			h=(h ^ (g >> 21));
	}
	return h;
}

// user info
function userinfo() {
 var sr="-",sc="-",ul="-",fl="-",cs="-",je=1,ck;
 var n=navigator;
 if (self.screen) {
  sr=screen.width+"x"+screen.height;
  sc=screen.colorDepth+"-bit";
 } else if (self.java) {
  var j=java.awt.Toolkit.getDefaultToolkit();
  var s=j.getScreenSize();
  sr=s.width+"x"+s.height;
 }
 if (n.language) { ul=n.language.toLowerCase(); }
 else if (n.browserLanguage) { ul=n.browserLanguage.toLowerCase(); }
 je=n.javaEnabled()?1:0;
 if (_uflash) fl=_uFlash();
 if (document.characterSet) cs=_uES(document.characterSet);
 else if (document.charset) cs=_uES(document.charset);
 if (!getcookie( 'fps' )) ck=0;
 else ck=1;
 return "&charset="+cs+"&screensize="+sr+"&colordepth="+sc+"&lang="+ul+"&java="+je+"&flash="+fl+"&cookies="+ck;
}

// flash detector
function _uFlash() {
 var f="-",n=navigator;
 if (n.plugins && n.plugins.length) {
  for (var ii=0;ii<n.plugins.length;ii++) {
   if (n.plugins[ii].name.indexOf('Shockwave Flash')!=-1) {
    f=n.plugins[ii].description.split('Shockwave Flash ')[1];
    break;
   }
  }
 } else if (window.ActiveXObject) {
  for (var ii=10;ii>=2;ii--) {
   try {
    var fl=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+ii+"');");
    if (fl) { f=ii + '.0'; break; }
   }
   catch(e) {}
  }
 }
 return f;
}

function _uES(s,u) {
 if (typeof(encodeURIComponent) == 'function') {
  if (u) return encodeURI(s);
  else return encodeURIComponent(s);
 } else {
  return escape(s);
 }
}






















/*
function _uRef() {
 if (_ur=="0" || _ur=="" || _ur=="-") return "";
 var i=0,h,k,n;
 if ((i=_ur.indexOf("://"))<0) return "";
 h=_ur.substring(i+3,_ur.length);
 if (h.indexOf("/") > -1) {
  k=h.substring(h.indexOf("/"),h.length);
  if (k.indexOf("?") > -1) k=k.substring(0,k.indexOf("?"));
  h=h.substring(0,h.indexOf("/"));
 }
 h=h.toLowerCase();
 n=h;
 if ((i=n.indexOf(":")) > -1) n=n.substring(0,i);
 //for (var ii=0;ii<_uRno.length;ii++) {
 // if ((i=n.indexOf(_uRno[ii].toLowerCase())) > -1 && n.length==(i+_uRno[ii].length)) { _ufno=1; break; }
 //}
 if (h.indexOf("www.")==0) h=h.substring(4,h.length);
 return "utmccn=(referral)|utmcsr="+_uEC(h)+"|"+"utmcct="+_uEC(k)+"|utmcmd=referral";
}
*/







