var slimstatfile = '/slimstat-js/js.stats.php';

function addLoadEvent(func) {
	var sitename = "dewsmeadow";
	var checkcookie = document.cookie;
	startpos=checkcookie.indexOf("SlimStat_admin_cookie") + 22;
	endpos=checkcookie.indexOf(";",startpos);
	if (endpos == -1) endpos=checkcookie.length;
	name=checkcookie.substring(startpos,endpos);
	if (name != sitename) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			};
		}
	}
}

function SlimStat() {
	var ref = escape(document.referrer);
	var res = escape(document.URL);
	
	var img = document.createElement('img');
	img.setAttribute('id','slimstatimg');
	img.setAttribute('width','1');
	img.setAttribute('height','1');
	img.setAttribute('alt','');
	img.setAttribute('src',slimstatfile+'?ref='+ref+'&res='+res);
	if (document.documentElement) {
		document.documentElement.appendChild(img);
	} else {
		document.appendChild(img);
	}
}

addLoadEvent(SlimStat);
