




function beacon() {
	
	var loc, ref;
	//dump("beacon running \n");
	datatag = '';
	//datatag += '&time=" + new Date().getTime();
	//datatag += 'debug=1';
	datatag += '&projectid=2'
	datatag += '&title=' + escape(document.title);
	loc = document.location +'';
	ref = document.referrer + '';
	loc = replaceAll(loc, "&", "|");
	ref = replaceAll(ref, "&", "|");
	datatag += '&addy=' + loc;
	datatag += '&ref=' + ref;
			
	document.write("<img src='http://surfmind.com/analytic/bin/pixel.cfm?" + datatag + "' height='2' width='2'/>");
	//document.write("<iframe src='http://surfmind.com/analytic/bin/pixel.cfm?" + datatag + "&debug=1' height='200' width='500'/>");
}

if(document.all) {
	if(document.title) {
		beacon();
	} else {
		document.onload = beacon;	
	}
} else {
//dump("beacon listening \n");
	if(document.title) {
		beacon();
	} else {
		document.addEventListener("load", beacon, true);
	}
}


function replaceAll(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceAll(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
