var siteid = '2288';
var okay = true;
var valid = true;
var CRDebug = (document.URL.indexOf('crtest=1') >= 0);
var CRImage = new Image();
var _ud = 'undefined';
var CRForce = false;	/* Force recording regardless */

function cr_makeurl(siteid,actn,value,extra,value2,extra2){
	var referer = escape(document.location);
	var ref = document.location.search;
	var refb = escape(window.document.referrer) + "";
	var nocache = false;
	ref = ref.substr(1,(ref.length-1));
	ref = ref.replace(/"/gi,'%22');
	ref = ref.replace(/'/gi,"%27");
	var allcookies = document.cookie;
	var cookiename = 'nocache_' + siteid + '_' + actn + '=';
	var cookievalue = escape(document.location);
	var pos = allcookies.indexOf(cookiename);
	if (pos != -1) {
		var start = pos + cookiename.length;
		var end = allcookies.indexOf(';',start);
		if (end == -1) end=allcookies.length;
		nocache= allcookies.substring(start,end);
		if (nocache != cookievalue) pos = -1;
	}
	if (pos == -1 || CRForce) {
		nocache = (Math.round(Math.random()*100000) + 1);
		document.cookie =cookiename + cookievalue;
		var qs = "?nocache=" + nocache + "&actn=" + actn + "&eval=" + value + "&eval2=" + value2 + "&etext=" + escape(extra) + "&etext2=" + escape(extra2) + "&siteid=" + siteid + "&" + ref + "&refb=" + refb;
		if (typeof(affiliate) + '' != _ud)  {qs = qs + "&affiliate=" + affiliate};
		if (typeof(cookieexpire) + '' != _ud)  {qs = qs + "&expire=" + cookieexpire};
		if (typeof(referer) + '' != _ud)  {qs = qs + "&referer=" + referer};
		return "http://www.conversionruler.com/bin/tracker.php" + qs; 
	}
	return false;
}
	
function cr_noop() {}

function cr_track(actn,value,extra,value2,extra2)
{
	var u = cr_makeurl(siteid,actn,value,extra,value2,extra2);
	if (!u) {
		if (CRDebug) {
			alert('ConversionRuler: Already recorded this page');
		}
		return true;
	}
	CRImage.onload = cr_noop;
	CRImage.src = u; 
	if (CRDebug) {
		alert('ConversionRuler: Recording ' + u);
	}
	return true;
}
	
function tlitrack(actn,value,extra,value2,extra2)
{
	cr_track(actn,value,extra,value2,extra2);
}