//ICStats tracker (c) 2002-2008
function icstats(url)
{
	var info = createInfoString(url);
	document.write('<img name=ICStats width=1 height=1 border=0 alt="" src="' + info + '">');
}

function icstatsJS(siteId)
{
    var sPath = window.location.pathname;
	var sPage;
	if(sPath.lastIndexOf('.') == -1)
	{
		sPage = sPath;
	}
    else
	{
		sPage = sPath.substring(0,sPath.lastIndexOf('.'));
		sPage = sPage.replace('index', '');
	}
	sPage = sPage.replace('_', ' ');
	if(sPage == '/')
	{
		sPage = 'Home';
	}
	icstats('http://application.icstats.nl/stats.aspx?siteId=' + siteId + '&page=' + sPage);
}

function createInfoString(url)
{
	var dDate, browser, c, r, res, info, d=document;
	
    dDate=new Date();
	browser=navigator.appName;
    if (browser != 'Netscape') {c=screen.colorDepth;}
    else {c=screen.pixelDepth;}

	try{r=parent==self ? window.document.referrer : top.document.referrer;}
	catch(e){r=window.document.referrer;}
	
	if (!r || r=="") { r="-"; }
	else {
		dm=d.domain;
		p=r.indexOf(dm);
		if ((p>=0) && (p<=8)) { r="0"; }
		if (r.indexOf("[")==0 && r.lastIndexOf("]")==(r.length-1)) { r="-"; }
	}

	res=screen.width + 'x' +screen.height; 
    info=url + '&js=1&c=' + c + '&res=' + res + '&r=' + escape(r) + '&ua=' + escape(navigator.userAgent) + '&time=' + dDate.getTime() + '&his=' + icscc();
	
	return info;	
}

function icscc()
{
	var dDate=new Date(), sid = icsgc('sid'), expire = 'expires=Sat, 18 Aug 2035 00:00:00 GMT;';

	if(sid == "") {
		icssc('sid', Math.round((dDate.getTime() - 819936000000) / 1000) +"" + Math.round(Math.random()*128647), dDate);
	}
	if(sid != icsgc('his').split('.')[0] && icsgc('his') != "") {
		icssc('his',icsgc('sid') + "." + (parseInt(icsgc('his').split('.')[1])+1), expire);
	}
	if(icsgc('his') == ""){
		icssc('his',icsgc('sid') + "." + 1, expire);
	}		
	return icsgc('his');
}

function icsgc(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return '';
    if (start == -1) return '';
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function icssc(name,value, expire) {
    document.cookie = name + "=" +escape(value) + ';' + expire;
}