// Create variable is_input to see if there is a ? in the url
var is_input = document.URL.indexOf('?');
var url_str = "";
var end_str = "";
var set_final_cookie = "1";

function SetCookie(cookieName,cookieValue,nDays) 
{
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}


// Check the position of the ? in the url
if (is_input != -1)
{ 
// Create variable from ? in the url to the end of the string
addr_str = document.URL.substring(is_input+1, document.URL.length);
url_str = "<img src='http://www.ultimateaffiliate.net/entry2.cfm?";
end_str = "' border=0 height=1 width=1>";

var mytool_array=addr_str.split("&");
for (count = 0; count < mytool_array.length; count++)
{
	var mytool_array_1 = mytool_array[count].split("=");	
	if(mytool_array_1[0] == "afid")
	{
		//document.cookie = 'afid=mytool_array_1[1];'
		SetCookie("afid",mytool_array_1[1],111);
		set_final_cookie = "0";
	}	
}
if(set_final_cookie == "1")
{
	SetCookie("afid","",111);
}

// Loop through the url and write out values found
// or a line break to seperate values by the &
for (count = 0; count < addr_str.length; count++) 
{

if (addr_str.charAt(count) == "&") 
// Write a line break for each & found
{url_str = url_str + "&";}

else 
// Write the part of the url 
{url_str = url_str + (addr_str.charAt(count));}

}}
// If there is no ? in the url state no values found
else
{	
	//If there is no ? in the url state no values found
}
document.write(url_str);document.write(end_str);

