function getParameter(paramName) 
{
	var currentUrl = window.location.search;
	var strBegin = currentUrl.indexOf(paramName);
	if (strBegin == -1)
	{
	    return "";
	}
	strBegin += paramName.length+1;
	var strEnd = currentUrl.indexOf("&", strBegin);
	if (strEnd == -1)
	{
		strEnd = currentUrl.length
    }
    
	return currentUrl.substring(strBegin,strEnd);
}
function putPixel(sref) 
{
    var r = Math.round(Math.random() * 1000000000000);
    var af = getParameter("aref");
    var imageURL = '<img src="http://www.resafrica.com/survey/activity/sref=' + sref;
    imageURL += ';rn=' + r;
    if (af != '')
    {
        imageURL += ';aref=' + af;
    }
    if ((document.referer != null) && (document.referer != ''))
    {
        imageURL += ';rref=' + encode(document.referer);
    }
    var lref = 'http://' + document.location.hostname + document.location.pathname;
    lref = encode(lref);
    imageURL += ';lref=' + lref;
    document.write(imageURL + '" width="1" height="1" border="0">');
}
function encode(text)
{
    var encoded = escape(text);
    var index = encoded.indexOf("%2F");
    while (index > 0)
    {
        encoded = encoded.substring(0, index) + "/" + encoded.substring(index+3);
        index = encoded.indexOf("%2F");
    }
    return encoded;
}

